Re: [Win95GUI] Windows Message (drive crazy anyone?)

From: Rob Baumstark (shirak@CONNECT.AB.CA)
Date: 09/04/97


> But Gee! I dont know how to work with windows messages with C++Builder
> and VCL, so I'm at an impass for this... I've had a few people send me
> examples of how I would go about doing it, but it seems that It isn't
> as easy as that...
>
> I think that I might be able to conjure up something, if I knew how to
> get the Message Handler FROM the Application instead of creating my
> own... But I dont know how to do this.
>
> I thought I should try using the VCL already-made events, which would
> be a snap! But I dont know if I need something more then that. Maybe
> if I thought of an algorithm for this procedure, and please correct
> me, and change/add/delete whatever you think is needed and send it
> back to me:
>
> - Start Program    (user does this)
>     - Load Window    (windows does this)
>     - Load Objects    (windows does this)
>     - Set-up Objects
>     - Wait for Message    (windows does this, of course)
>
>     - If Quit, then Clean out, and Destroy Application.
>
>         - If Start Server
>         - Check Parameters (CheckBoxes, and Port settings etc)
>             - If bad params, give error message box.
>         - Change to Library Directory
>         - Initialize Game
>         - Get Boot Settings from What user set in the GUI, and Set
> them.
>         - Initialize Socket
>         - Boot Database
>         - Start Game Loop (YIKES!)
>         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> This is what scares me about all of this, everything up to now, has
> not been a loop, and all of it actually takes about 3-4 seconds to go
> through, other then Booting the Database. This Game Loop is what I'm
> having trouble Implementing (Of course! Its the Heart of the Game!)
>
> Basically what I need, is to have the loop be happening while Idle,
> but have the loop stop when the Server User needs to do something??
> That doesn't make too much sense... Maybe its more like this: I need
> to have the Game Loop when Idle, but when there is an Event from the
> Window, go through the event, and then Go back to the loop!! That's
> IT! Gee, writing to this list makes me think... (you probably thought
> of this like two pages ago) But I dont quite know how to make this
> loop of events. Lets finish this Algorithm:
>
>         - If CircleShutdown is set, Get out of the StartServer Loop.
>
>     - If Settings Change, make sure they are valid, otherwise give
> error.
>
> - Quit Program
>
> Ok, so is this a basic algorithm of what would need to be accomplished
> to get the GUI working?
>
> If you know how I would go about looking at Events and Doing the
> Game_Loop when the Server User is Idle, or any other info/comment/help
> etc.. You know the deal, send me a message...
----------
I don't know about C++ Builder, but I've written MFC programs before, and I
assume that the basic Windows application classes must be close to the
same.
Now ... CircleMUD really runs in an infinite loop, stoping when
circle_shutdown is true.  Windows progs also run in infinite loops, parsing
messages as they come.  The easest way to do it, as I see, would be to make
a few more flags, such as whether the server is running or not, and whether
we have to boot and stuff, then simple write your own version of the
windows loop (I forget what the function is ... i don't usually go this
deep) which will be derived from the default one, and every pass through
this loop, it parses messages, and does what the circle main loop in one
pass (if the server is started), otherwize boots and stuff (thats why all
the extra flags)  Your start server buttons and stuff will simply change
the values of these flags
------------------------------------------------------
     Rob Baumstark:   shirak@connect.ab.ca
                      cst0656@nait.ab.ca

   Forsaken Realms:   telnet://drewl.v-wave.com:4000
------------------------------------------------------


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST