Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Hedos

MFC Question

This topic is 5461 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently learning MFC.. and there is something I don't understand.. My program doesn't seem to have a 'frame' section where I could put code that would be executed every frame... ( I'm talking about frames, like in 'frames per second', not the 'window frame' ) My program needs to have a loop somewhere, where I could put some code, is there a way to create a different kind of window? ( I'm using dialog window ) I think that because my application is modal, ( it uses the fonction DoModal() ), the program execution just stops after DoModal() is called, and will only return with IDOK or IDCANCEL or maybe IDCLOSE, but i'm not sure about the last one... So this is not what I want, and it has been hard to try googling informations about what I want to do, I can't find the appropriate information Thanks for your help edit: Oh, btw, my program would only need a loop somewhere because it needs to verify if the user has pressed some keys.. I'm using Hot Keys "buttont".. But I haven't seen any built in message to handle the Hot keys.. If someone know a way to handle those hot keys, it would be just perfect Thx again [edited by - Hedos on November 10, 2003 9:33:11 AM]

Share this post


Link to post
Share on other sites
Advertisement
MFC follows an event driven program model. This means code gets run only when an event triggers the code to run. In MFC I think you will have to create a Timer event that will fire as often as possible to create your game loop. I''m no MFC guru, there might be another way, but that is one solution. The other solution is use the pure Win32 API which exposes the message loop.

Share this post


Link to post
Share on other sites
Ok, I don''t want to use pure win32 api...
So, I guess I''m gonna try to find some tutorials about using Hot Keys

Share this post


Link to post
Share on other sites
If you are going to use MFC, then you have to stick with the event based model. To regularly update your display, you need to do what CodeMunkie suggested. That is, create a timer, and whenever your timer fires, invalidate the area of the window you want updated. The other alternative (which accomplishes the same thing), is to create a separate thread which invalidates the window. You may get slightly better perfomance this way (in regards to more regular updates) if you boost the thread priority.

As for key presses, an easy way to do this would be to write a handler for the WM_CHAR message. This message is sent to the window which has the keyboard focus whenever a user hits a key which translates into a non system character. In your handler, just check and see if it corresponds to the hot-key you are looking for. If it does, do you what you need to to. If it doesn''t, let the base class message handler handle the WM_CHAR msg.

Hope this helps a bit.

Mike

Share this post


Link to post
Share on other sites
Ok, I think I''m going to stick with the event based model

But, for my hot keys.. I have to detect if a hotkey is pressed even if my application window don''t have the focus :S

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
check this out
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_idle_loop_processing.asp

and using timer for real time rendering is slower than using idle time processing.

Share this post


Link to post
Share on other sites
Btw, there is always a problem when I send my program to a friend who doesn''t have VC++ installed...

"This application has failed to start because MFC42D.DLL was not found. Re-installing the application may fix this problem"

Is there a way to fix this problem?

Share this post


Link to post
Share on other sites
Ok, thx CodeMunkie..
But, could you explain me how I would link statically to the MFC runtime in MVC++?

Share this post


Link to post
Share on other sites
Sure. Go to Project...Settings and look under the General tab. There is a drop down box with three options:
Not Using MFC
Using MFC in a Static Library
Using MFC in a Shared DLL

I''ll give you three guesses which option to choose

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!