CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 6 FirstFirst 12345 ... LastLast
Results 16 to 30 of 83
  1. #16
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    so where should i call ShowWindow again in my test program?
    and do you mean like this:
    Code:
    ShowWindow(hWnd, SW_SHOW );

  2. #17
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: running a GUI program in the background

    Where you want to.
    But you must be sure (you have to test it!) that this second call is really executed.
    Victor Nijegorodov

  3. #18
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    ok adding the line ShowWindow(hWnd, SW_SHOW ); to the test program causes the window to be displayed when i run createprocess

  4. #19
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: running a GUI program in the background

    Good! So now you know a possible reason for the external program to be displayd despite of your startup parameter set to SW_HIDE!
    Victor Nijegorodov

  5. #20
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    ok so how do i solve this problem? what code do i need to hide the window?

  6. #21
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: running a GUI program in the background

    Well, the best way would be to change this external program so it will never call ShowWindow with any but SW_SHOWDEFAULT parameter.
    It you cannot change this program then you could try with (WH_CBT) HOOK...
    Victor Nijegorodov

  7. #22
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    i can't change the external program so could you show some code for (WH_CBT) HOOK?

  8. #23
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: running a GUI program in the background

    No, I cannot. But you could make a Google search for something like global hook WH_CBT example
    Victor Nijegorodov

  9. #24
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    ok hook be used in a c++ console application? examples on google only seem to be showing examples in win32

  10. #25
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: running a GUI program in the background

    What "c++ console application" are you talking about? What is a problem with a "console application"?
    Victor Nijegorodov

  11. #26
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    my createprocess program is a console application (the code i put in the first post). can i add hook WH_CBT to this?

  12. #27
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: running a GUI program in the background

    No, you need to create a HOOL dll to hook an external applications!
    Victor Nijegorodov

  13. #28
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    i have never used HOOK before. is there an easier way to hide the window of the external program?

  14. #29
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: running a GUI program in the background

    Well, the one and only one way to hide the window is to call ShowWindow with SW_HIDE for this window (or its parent)
    So if you know the handle of the main window of this external program then you could try to hide it.
    But the question is how often you will have to repeat it! What if this external program tries to maximize or restore its main window every second?
    Victor Nijegorodov

  15. #30
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    i don't know anything about the code of the external program.. so i guess SW_HIDE isn't a good option then

Page 2 of 6 FirstFirst 12345 ... LastLast

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

Featured