开发者

Win32 - Fullscreen popup menu temperamental activation

开发者 https://www.devze.com 2023-01-14 10:20 出处:网络
Using C++ in VS2008, I\'m at the beginnings of a DirectX program which can so far display a token image and flip between fullscreen and windowed mode with no problems.

Using C++ in VS2008, I'm at the beginnings of a DirectX program which can so far display a token image and flip between fullscreen and windowed mode with no problems.

It has a menu bar, which is invisible as expected in fullscreen mode. The ALT key could still activate this menu in fullscreen, but it was very clumsy since its items weren't visible until highlighted, and even then it only responded to about 1 in 5 presses of the ALT key.

开发者_Python百科

So I decided to implement a popup menu instead, that responds to the right mouse button. My problem is that this popup menu is also temperamental in fullscreen mode. It also plays with the custom cursor I am using.

The wrong behaviour is defined as follows:

A right click anywhere will active the popup menu, but also deactive the custom cursor and replace it with the system default.

Once the menu is visible, RIGHT-clicking outside of the menu will deactive it, but this leaves the default cursor on. However, right-clicking again will activate the menu again, and this continues perfectly if not for the missing custom cursor.

Once the menu is visible, LEFT-clicking outside of the menu will deactivate it, and this displays the custom cursor again. Now it gets a bit more messy because now:

3a· If I right-click, it will return to step 1. Menu on + cursor off.

3b· If I left-click a second time (as if I am gaining focus or something), then right-click, will will activate the default cursor but NOT active the menu (as if I half did and half didn't regain focus or something). Menu off + cursor off.

3c· If I move the mouse and then right-click, it will do one of the above. Step 1 or step 3b. Menu on + cursor off, or menu off + cursor off. Frustrating.

Most obvious, if step 3b occurs (menu off + cursor off), the user can flip the custom cursor on and off forever. Left click on, right click off. Not only does the menu never appear, but this is simply not what I want a user to be seeing in my program... the cursor changing for no reason.

I imagine the cursor changing is to do with the menu itself taking focus or something like that. I would like that to be avoided if possible, but the real problem is why is the menu activation temperamental in the first place?

My code for the popup menu is:

case WM_RBUTTONDOWN:
    cout << "Right button in fullscreen" << endl;

    TrackPopupMenu(GetSubMenu(g_menu,0), TPM_LEFTALIGN|TPM_HORPOSANIMATION, 
    30, 30, 0, g_parentWindow, NULL);

    // SetActiveWindow(g_parentWindow);  // Makes no difference.
    // SetForegroundWindow(g_parentWindow);  // Makes no difference.

break;

One more thing. If I use F3 to active the menu instead, absolutely nothing happens.

Problem 1: Can I make the menu activate reliably?

Problem 2: Can I stop the cursor from changing?

Problem 3: Why does a key command not work?

Thanks for the read. Any ideas?


you can use this little function to set the cursor back to your customize cursor SetCursor(CURSOR_ID); you can add this in WM_RBUTTONDOWN

0

精彩评论

暂无评论...
验证码 换一张
取 消