Sign in to follow this  

Win32 Modal Windows and Key Monitoring

This topic is 4662 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

Hello All I have two questions, I hope someone can help me with. 1.) How do I create modal windows? Im using CreateWindowEx() but I dont see a modal style. I am setting the parent window handle, but it still isn't modal. 2.) I need to know how I can get the status of key down events. But not just one key. I am trying to monitor the CTRL key too so I can implement KB shortcuts. Any idea's how I can do this with WM_KEYDOWN ? Thanks ! :D

Share this post


Link to post
Share on other sites
Quote:
Original post by Shock
1.) How do I create modal windows? Im using CreateWindowEx() but I dont see a modal style. I am setting the parent window handle, but it still isn't modal.
You need to spin in an while() loop calling your usual message pump (PeekMessage and/or GetMessage, DispatchMessage, etc). Then when you get a WM_DESTROY, you break out of the loop.

Quote:
Original post by Shock
2.) I need to know how I can get the status of key down events. But not just one key. I am trying to monitor the CTRL key too so I can implement KB shortcuts. Any idea's how I can do this with WM_KEYDOWN?
When you get WM_KEYDOWN, call GetAsyncKeyState(VK_LCONTROL) and GetAsyncKeyState(VK_RCONTROL) and see if the highest bit (0x8000) is set. If it is for either of them, then the control key is down.

Share this post


Link to post
Share on other sites
Quote:
Original post by EliasAE
There is an excellent example at The Old New Thing - Modality, part 1: UI-modality vs code-modality, which obeys the rules for enabling and disabling windows.


That site is the reason I hate forums, I might add, people bickering about stupid coding rules that they don't even need to worry about, all their frustrations of a bug that they themselves probably will code eventually as well.

However the article was a good read, and it helped me think like a windows coder, thanks for the information.

Share this post


Link to post
Share on other sites

This topic is 4662 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this