CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    Feb 2002
    Location
    Ukraine
    Posts
    332

    Question How to prevent task manager from minimizing or maximizing my window?

    How to prevent task manager from minimizing or maximizing my window ???(Win2000/XP)


  2. #2
    Join Date
    Sep 2002
    Location
    St.Louis, MO
    Posts
    27
    Just curious how is task manager minimizing or maximizing your window?
    Thanks
    Tom Wright

  3. #3
    Join Date
    Feb 2002
    Location
    Ukraine
    Posts
    332

    Smile Yes!

    Yes! I DO want to know HOW task manager manipulates windows

  4. #4
    Join Date
    Sep 2002
    Location
    St.Louis, MO
    Posts
    27
    Got it. I never used that feature so I wasn't sure what you meant until I looked at it.

    Basically it's grabbing the title of window and using the findwindow api. Now it has the handle, then it uses the showwindow api and depending on what you choose it mins or maxs the window.

    Hope this helps
    Thanks
    Tom Wright

  5. #5
    Join Date
    Sep 2002
    Location
    St.Louis, MO
    Posts
    27
    Sorry MAV I miss read your question. How to stop this from happening I'm not to sure unless you get the handle of the window and watch every message that comes in and intercept the one that tells that particular window to min or max and discard it.
    Thanks
    Tom Wright

  6. #6
    Join Date
    Feb 2002
    Location
    Ukraine
    Posts
    332

    Question What message?

    What message(s) shall I hook and discard
    I'm sure that these are not WM_SIZE(ING) nor WM_WINDOWPOSCHANGE(ING)

  7. #7
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    somebody posted this here the other day, but the short of it is, if you don't want to do the message processing, then just hide it from task manager

    I haven't tried this code below...but I will be soon

    typedef (WINAPI REGSERVPROC)(DWORD, DWORD);
    typedef REGSERVPROC* LPREGISTERSERVICEPROCESS;
    HINSTANCE hLibrary;
    LPREGISTERSERVICEPROCESS regproc;
    hLibrary = LoadLibrary("kernel32.dll");
    if (hLibrary) regproc = (LPREGISTERSERVICEPROCESS)GetProcAddress(hLibrary,
    "RegisterServiceProcess");


    //call this when you want to hide the process from ctrl+alt+del window
    if (regproc) (regproc) (NULL, 1); //hide
    //call this when you close that app...
    if (regproc) (regproc) (0, 0); //show

    FreeLibrary(hLibrary);

  8. #8
    Join Date
    Feb 2002
    Location
    Ukraine
    Posts
    332

    Unhappy This feature will not work in Win2000/XP

    This feature will not work in Win2000/XP because kerenel32.dll does not have RegisterServiceProcess ...


  9. #9
    Join Date
    Sep 2002
    Location
    DC Metro Area, USA
    Posts
    1,509
    I'm not sure if I'm following the question right: You want to stop your window from being min/max'd byt the task manager?

    First thought is to disable/remove the min/max buttons on the title bar, which may help.

    Second thought is that you may need to "trap" the wm_size message before it gets routed to the OnSize method. To do this you'd probably override the DefWindowProc, check for message == to WM_SIZE, and if the wparam specifies min or max, and return that you handled it; otherwise pass the message along to the appropiate handler.

  10. #10
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Right he can either do that which is probably easier, or he can run as a service which then won't allow anyone to min/max it because it will not be listed in the applications tab, just the procecess tab.

  11. #11
    Join Date
    Feb 2002
    Location
    Ukraine
    Posts
    332

    Question Still a problem

    The WM_SIZE message is sent to a window after its size has changed. (copied from MSDN)

    I think there are several ways how to minimize or maximize the window:
    1) Using ShowWindow(hWnd,SW_SHOWMAXIMIZED)
    2) Using PostMessage(hWnd,WM_SYSCOMMAND,SC_MAXIMIZE,NULL)
    3) Another way, probably used by TaskMan.exe

    What is the way task manager uses and how can I trap and disable it?


  12. #12
    Join Date
    Sep 2002
    Location
    DC Metro Area, USA
    Posts
    1,509
    Hmmm,

    Did you try creating the application/window without the min & max styles?

    I know there are one or more messages that you can respone to before Sizing occurs. You might try the WM_WINDOWPOSCHANGING msg or the CWnd::OnWindowPosChanging method, as it looks like what you want. I'm not sure what task manager does, but I believe that since it has the app info, it just does a ShowWindow (or the WM_* Equivalent) which is generally how things work. Is there some sort of behaviour that the task manager displayes that is different from normal desktop behavior?

  13. #13
    Join Date
    Feb 2002
    Location
    Ukraine
    Posts
    332

    Exclamation The goal...

    I've read in MSDN, that WM_WINDOWPOSCHANGING gives no information about wheter window is being minimized or maximized.

    The program i am writing has to work as following:
    1)Start minimized
    2)When user tries to restore or maximize the window, the message box is displayed.
    3)if user clicks "OK" the window is restored, either stay minimized


    I wrote a handler for WM_SYSCOMMAND message. It compares wParam to SC_RESTORE or SC_MAXIMIZE. This method works ok and fine when user clicks window's button on taskbar. But Task manager has also the ability to manipulate windows (eg. restore and maximize). Since the WM_SYSCOMMAND is not sent in this case my window cannot track and deny it's maximization.

    What handler should I write to display message in any case, or how can I simply disallow taskman.exe from manipulating my window

  14. #14
    Join Date
    Sep 2002
    Location
    DC Metro Area, USA
    Posts
    1,509
    Ok, I'm about to the end of any useful suggestions. The last 2 suggestions I have are: 1. potentially you can work with the WM_GETMINMAXINFO msg, but that may not be quite what you want. 2. you could try to override the MoveWindow, SetWindowPos, and any other sizing methods. Did you creating the window without the min/max styles -- then of course, you'd have to repilcate that functionality manually...

    As a GUI guy, I think what you're trying to do would be highly annoying behaviour... but mine is not to question why. It may be that task manager works around most of the common min/max access methods, in order to handle misbehaving or problem applications, don't know for sure, but it's my best guess.

    Good Luck
    bytz
    --This signature left intentionally blank--

  15. #15
    Join Date
    Sep 2002
    Location
    St.Louis, MO
    Posts
    27

    Re: The goal...

    Originally posted by M A V
    I've read in MSDN, that WM_WINDOWPOSCHANGING gives no information about wheter window is being minimized or maximized.

    The program i am writing has to work as following:
    1)Start minimized
    2)When user tries to restore or maximize the window, the message box is displayed.
    3)if user clicks "OK" the window is restored, either stay minimized

    If this is what you are trying to do. Then why don't you create a seperate thread that monitors the state of your window and if the user maximizes it then you prompt them with your messagebox and minimize it.
    There I fixed it. .......what do I win
    Thanks
    Tom Wright

Page 1 of 2 12 LastLast

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