• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Window message

I have an application with a main window which execute a number of child applications in other windows.
When minimize the main window, I call ::ShowWindow(HWND, SW_HIDE) to hide all the child window (only the main window minimized on task bar).
The problem is some applications are called by a hidden program (proxy). When I call minimize, the proxy programs will hide their sub programs (so this is fine) but when I call restore these hidden programs restore (and restore it's sub program) so on my destop have a pair of window, one is the child application, one is the hidden program which is now visible that show a blank window.

Someone suggest me to make custom message WM_Custom_Wnd with contants WPARAM 0 = Hide, 1 = Restore... so when the proxy program receive "Restore" it will call it's child to restore but not itself.

Can anyone help me with more details about coding ? If you understand what I'm writing please reply and I'll show more about my current code. Thanks
1 Solution
I think you can use RegisterWindowMessage to register a message that is guaranteed to be unique throughout the system.
The syntax for registerwindowmessage is:
UINT RegisterWindowMessage(LPCTSTR msgString)
You can then use SendMessage/PostMessage functions with the WPARAM and LPARAM as you require.
ahTriAuthor Commented:
Humm I still quite unclear, all information I have about the child windows is in registry (so I can have those window title in the menu "window" drop down) and HWND of those windows.
>>which is now visible that show a blank window.
How it can be visible? Why dont you simly hide it?
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

ahTriAuthor Commented:
When I call "restore" the message is sent to every applications. The hidden window need that message to restore it's subwindow and un-expectedly restore itself. Now I want a custom message and change every application so that when a "restore" message is posted:

normal application: restore
hidden application: restore it's sub application but not itself
you have to write some code like this:
in the main APP you must register Windows message by:

UINT uMyShowMsg = ::RegisterWindowMessage("WM_MY_SHOW_MESSAGE");// any string can be here
now you can use uMyShowMsg in the SendMessage() or PostMessage() instead standard msg (such as WM_SHOWWINDOW and etc),
that is to send msg to the child wnd you can use this:
::SendMessage(hwndChild, uMyShowMsg, (WPARAM) TRUE, 0);
/* I assume that wParam will indicate desired child window state. in example we want bring it to the screen.
in the child app you must call RegisterWindowMessage with the same string as one in the main APP.
that is:
UINT uMyShowMsgChildApp = ::RegisterWindowMessage("WM_MY_SHOW_MESSAGE");
and in the APP message map you have to write following:

    //{{AFX_MSG_MAP( CMyApp )
    ON_REGISTERED_MESSAGE(  uMyShowMsgChildApp, OnMyShow )
// here OnMyShow -method of the your child APP and it must be declared as:
must be
const UINT uMyShowMsgChildApp = ...;
ahTriAuthor Commented:
Hi Migel, one more stupid question, where/how can I declair the constant for window status to pass through the WPARAM.
just assume that 1 will show window and 0 will hide it (of cource in main app and child app must be assued same things ;-)
or create common header and include it in the both app`s.
ahTriAuthor Commented:
I was asking about sintax, thanks
what syntax?
you can use windows definitions

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now