CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Screen change

  1. #1
    Join Date
    Jun 2010
    Posts
    115

    Question Screen change

    How can I detect desktop changes ?

    I capture it with GetDesktopWindow(), while there are, for example, 4 open windows
    Later I close one of them, I'd like to get that change right after I close that window. I mean another HWND should be reported.

    Thank you

  2. #2
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: Screen change

    GetDesktopWindow() won't help you in that. You should probably not use that API at all. To do what you want (if I understood your right) you will need a system-wide hook. Check description of the SetWindowsHookEx API for more info.

  3. #3
    Join Date
    Jun 2010
    Posts
    115

    Re: Screen change

    Thank you but what should I hook ?

  4. #4
    Join Date
    Jun 2010
    Posts
    115

    Re: Screen change

    So someone could tll me which hook ?

  5. #5
    Join Date
    Jun 2010
    Posts
    115

    Re: Screen change

    Is this ignored because it is too easy for you ?

  6. #6
    Join Date
    Jun 2010
    Posts
    72

    Re: Screen change

    Quote Originally Posted by Maejie View Post
    Is this ignored because it is too easy for you ?
    Hooking is not easy at all,
    people ignore because they don't know, or maybe because they are afraid you will ruin thei MVP title , It is a cool commercial ads to spread around

  7. #7
    Join Date
    Jun 2010
    Posts
    115

    Re: Screen change

    Thanks, I will search if there is another way to do instead of hooking
    Until I can get the replies here and on other forums, I will make my skin thicker to asking more and more, I will also test how others mentally think about this too,

    Thanks everyone for your time

  8. #8
    Join Date
    Jun 2010
    Posts
    72

    Re: Screen change

    Quote Originally Posted by Maejie View Post
    Thanks, I will search if there is another way to do instead of hooking
    Until I can get the replies here and on other forums, I will make my skin thicker to asking more and more, I will also test how others mentally think about this too,

    Thanks everyone for your time
    Good!, it's good, but
    Don't make it too thick as a human being,
    Only animals like elephant will have thick skin

  9. #9
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: Screen change

    Sorry, I didn't get an email notification about this one. I would use WH_CALLWNDPROC hook and try to catch WM_CLOSE messages sent to your windows of interest. But like Turingmachine pointed out, Windows hooks aren't a trivial thing. This one, most certainly, will have to be a global hook to monitor messages for processes other than yours, which means you will have to put it into a DLL. I haven't programmed Windows hooks since XP and I'm sure they added new restrictions to them under Vista and Windows 7. Study the link I gave you above. There's an example on how you can place a Windows hook there.

    PS. What exactly are you trying to accomplish? Maybe there's an easier way to do it.

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

Featured