Results 1 to 6 of 6

Thread: SysCommand

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    169

    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,

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    169

    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.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    169

    Re: SysCommand

    Quote Originally Posted by LaVolpe View Post
    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

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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
  •  



Click Here to Expand Forum to Full Width