Using WM_SHOWWINDOW to Show a Window instead of ShowWindow()

10,454

Solution 1

Try these two messages:

SendMessage(h,WM_SYSCOMMAND,SC_MINIMIZE,0);
SendMessage(h,WM_SYSCOMMAND,SC_RESTORE,0);

Or if using 3rd party apps is ok, try cmdow

Solution 2

WM_SHOWWINDOW is a notification, not a command. From MSDN:

The WM_SHOWWINDOW message is sent to a window when the window is about to be hidden or shown.

I don't believe there is any message that you can use to make a window show itself. Actually, the very idea seems a little strange to me. The window manager is the system component responsible for showing and hiding windows. To show a window, you must use one of the window manager APIs.

Share:
10,454
Synetech
Author by

Synetech

“Hobby programmer”, for over 27 years. A few of my favorites languages include assembler ❤️, C++, Pascal, and PHP, but my current go-tos (pun intended) these days tend to be AutoHotkey and JavaScript. I used to be a bit of a compile-snob, but I find scripting languages to be more convenient now. Secondary languages I use include anything and everything (I keep trying to pick up new ones just because, including those crazy esoteric ones, but especially anything that is remotely useful). I mostly do library and utility programming, creating either libraries of functions for use in other programs, or small, specific tools to do something that needs to be done but for which no existing programs already exist. (I can’t count the number of times that I’ve needed a program to do something, and finding no existing tools, had to resort to writing one myself.) I’ve been mired in SE pretty much from its beginnings. Unfortunately I became soured towards the SE network a few years ago because of a user on SU and the mods’ inaction against his behavior, so I have not really been active on the sites since, however I do occasionally follow up when I get a notification of a response to something I have previously posted.

Updated on June 04, 2022

Comments

  • Synetech
    Synetech almost 2 years

    I’m trying to use the SendMessage function of a hotkey utility (or NirCMD, etc.) to get a hidden window to pop up. I can for example get windows to close by sending 0x0010 (WM_CLOSE), but when I try sending 0x0018 (WM_SHOWWINDOW) with a wParam of 1 and an lParam of 0, nothing happens.

    I’ve looked around, and the few places where someone complained that WM_SHOWWINDOW did not work, they happily took the suggestion to use ShowWindow() instead.

    However I don’t have ShowWindow() available; I can only send Windows messages. But ShowWindow() is not magic, surely it works by SendMessage-ing a WM_SHOWWINDOW or something under the covers.

    How can I get a window to display itself by sending it a message?

    Thanks.