ShowWindow(SW_HIDE) & Active window

In my App, I have a Dialog having a menu-likke behaviour (pops up when click on a button, disappear if click outside this fake menu)

I handle it this way:
void CFakeMenuDlg::OnActivate(UINT nState, CWnd*      pWndOther, BOOL      bMinimized )
{
    CDialog::OnActivate(nState,  pWndOther, bMinimized );

    if (nState == WA_INACTIVE) {
        ShowWindow(SW_HIDE)
    }
}

Simple, isn't it ?
problem is: if I press a control outside my FakeMenuDlg, the FakeMenuDlg disappears (which is good), the window containing pressed control receives Activation, but the control never receives the mouse message, must press it once more... this problem is caused by the ShowWindow(SW_HIDE)

seen in doc about SW_SHOW:
SW_SHOWNA (shows the windows but do not change activation)

and about SW_HIDE: hides the Wnd and give activation to someone else

I need something like ShowWindow(SW_HIDENA) (which does not exist)

how to do that ?

PS: move the window outside visible area of the desktop is not a suitable solution...

Thx in advance

Amby
LVL 1
ambyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:
Hi,

If I understood u correctly, U have a dialog. On that dialog on click of some button, the menu like CFakeMenuDlg pops up(u may be doing DoModal()). Then when it is inactivated u r hiding it.

But if that is the case, then try modifying Ur code of OnActivate as
void CFakeMenuDlg::OnActivate(UINT nState, CWnd* pWndOther,
                                BOOL bMinimized )
                                {
                                    CDialog::OnActivate(nState,  pWndOther, bMinimized );

                                    if (nState == WA_INACTIVE) {
                                        CDialog::OnOK();
                                    }
                                }

That is, I am killing that dialog may OnOK() or OnCancel() or destroy window....


Try it out.
VinExpert
0
ambyAuthor Commented:
I am afraid the result is the same as ShowWindow(SW_HIDE)...

DoModal is not possible here

please not the the dialog must disappear (or hide) when you click outside itself, but the control *outside* the FakeMenuDlg should receive a click message or anything, but nothig is sent to the control.

Thanx anyway, the idea was not so bad
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

I am sorry I am not getting U. pls explain from where that fake menu dialog is created and related things.

Is that FakeMenuDlg is the child of that dialog?. If yes, then
void CFakeMenuDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized )
{
                                                             CDialog::OnActivate(nState,  pWndOther, bMinimized );

if (nState == WA_INACTIVE)
{
GetParent()->SendMessage(WM_LBUTTONDOWN,0,0);
CDialog::OnOK();
}
}

Try it out.
VinExpert
0
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

ambyAuthor Commented:
I am afraid the result is the same as ShowWindow(SW_HIDE)...

DoModal is not possible here

please not the the dialog must disappear (or hide) when you click outside itself, but the control *outside* the FakeMenuDlg should receive a click message or anything, but nothig is sent to the control.

Thanx anyway, the idea was not so bad
0
migelCommented:
Hi!
Try this methods:
1.get mouse pos by GetCursorPos();
2. Determine window under this point by
WindowFromPoint;
3. Convert screen pos to the client coords of the dest. window by ScreenToClient();
3. send message to this window by SendMessage(WM_LBUTTONDOWN, 0,  MAKELPARAM(pos.x, pos.y));
0
ambyAuthor Commented:
I am afraid the result is the same as ShowWindow(SW_HIDE)...

DoModal is not possible here

please not the the dialog must disappear (or hide) when you click outside itself, but the control *outside* the FakeMenuDlg should receive a click message or anything, but nothig is sent to the control.

Thanx anyway, the idea was not so bad
0
ambyAuthor Commented:
I am afraid the result is the same as ShowWindow(SW_HIDE)...

DoModal is not possible here

please not the the dialog must disappear (or hide) when you click outside itself, but the control *outside* the FakeMenuDlg should receive a click message or anything, but nothig is sent to the control.

Thanx anyway, the idea was not so bad
0
cyberfrankCommented:
Hi!

Maybe it's not working, but have you tried to update window just right after the ShowWindow(SW_HIDE)?

CF
0
taryn092997Commented:
First, consider default behaviour: control gets notification, but menu stays up.

You only want to change the state of the menu, not the message chain, so don't interfere! WM_ACTIVATE is sent as part of that message chain so it's not a good idea to do anything to that!

First solution:
Edit the containing dialog code to hide the menu when it gains activation. Should use PostMessage, not SendMessage.

Second solution:
Post a message to the menu from the activate message. Again, use PostMessage here. ShowWindow uses SendMessage internally.

Third solution (maybe):
Use SetWindowPos which accepts the flag SWP_NOACTIVATE (I think that's how it is spelt), see MSDN for acceptable combinations of options. I don't think this would work because it would interrupt the message chain, as before.

0
ambyAuthor Commented:
please remember it is NOT a real menu, it is a dialog having a menu-like behaviour...

damned, nobody understands me (I feel sad and lonely...)
0
taryn092997Commented:
I know what you are saying- I just thought that using the terminology of 'menu' was just simpler to understand. What I said still holds: have you tried it?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.