-
Dec 16th, 2014, 11:50 PM
#1
Thread Starter
Addicted Member
SysCommand
I have two forms. Sometimes form2 is set to be the child of form1 using SetParent API
WM_SysCommand triggers (by subclassing) when any Close,Maximize or Minimze is clicked whenever form2 is NOT a child of form1, however when it is a child, WM_SYSCommand does not trigger.
However, using Spy++ I cannot find any messages reporting to the parent (form1) that indicates clicking on form2's Close, max,min buttons. I can see SysCommand msgs from form1 when clicking on its own buttons.
Where are form2's msgs going when its the child of form1?
thanks,
-
Dec 17th, 2014, 06:31 PM
#2
Re: SysCommand
Why should form2 to report to parent (form1) that it is closing? Just because a window has a parent does not mean that it forwards all of its messages to the parent. That form2 is not a child wndow. It does not have the WS_CHILD attribute set and even if it did, no guarantee it would forward messages.
Maybe you are under the impression that subclassing 1 window will get you messages of all attached windows? That isn't how it works. If you want subclassed messages for form2, you will need to also subclass form2.
-
Dec 17th, 2014, 07:01 PM
#3
Thread Starter
Addicted Member
Re: SysCommand
Hi, Thanks for responding LaVolpe,
You misunderstand my original post I suppose... I can get SYSCOMMANDS from form2 when it is NOT a child of form1, however the SYS_COMMANDS disappear (when subclassing form2) when it DOES become a child using the SETPARENT api. BTW, the WS_CHILD style is not set after form2 becomes a child, should this be set?
So where did my SYSCOMMANDS go? I need to be able to intercept them somehow when form2 is a child.
-
Dec 17th, 2014, 07:16 PM
#4
Re: SysCommand
So we are on the same page: In form1: SetParent Form2.hWnd, Form1.hWnd
Using Spy++, I see the the SC_Close, SC_Minimize, SC_Maximize message sent to Form2. You should be able to see them too. Maybe it is something you are doing with your subclassing routine? Of an error within your routine's logic?
-
Dec 17th, 2014, 07:34 PM
#5
Thread Starter
Addicted Member
Re: SysCommand
Originally Posted by LaVolpe
So we are on the same page: In form1: SetParent Form2.hWnd, Form1.hWnd
Using Spy++, I see the the SC_Close, SC_Minimize, SC_Maximize message sent to Form2. You should be able to see them too. Maybe it is something you are doing with your subclassing routine? Of an error within your routine's logic?
We are on the same page SetParent Form2.hWnd, Form1.hWnd
It goes like this, subclassing form2, the buttons on form2 were being intercepted and working properly until I did the SetParent form2.hwnd, form1.hwnd. I got out Spy++ to see what happened and no SYSCOMMANDS were coming through, however SPY++ was showing the SYSCOMMAND when SetParent form2.hwnd, 0
-
Dec 17th, 2014, 07:55 PM
#6
Re: SysCommand
Don't know what to tell you, look closer at your code. It's gotta be there.
I put together a quick sample that subclasses Form2 and all it does is trap wm_syscommand. It worked whether or not I called SetParent, as expected. Spy++ also shows those messages, as expected.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|