NO

Author Topic: "Show Desktop"  (Read 4313 times)

liut

  • Guest
"Show Desktop"
« on: November 05, 2013, 11:18:05 AM »
Hi, does anybody know what exactly happened at the backend after user clicks 'Show Desktop' (or press Win+D)?

Originally I thought Win sent a WM_SIZE/SIZE_MINIMIZED to all windows, and I can capture it in a normal 'Overlapped window' program. But I can't capture it in a 'Popup window', even I can't use ShowWindow() (in a Timer proc) to enforce the window restoring after 'show desktop'.

The purpose is I'm going to write a program with displaying sticking on the desktop. But I don't want to use 'Desktop DC' to output the information, because in this way the main window can't capture the mouse event on it easily.

laurro

  • Guest
Re: "Show Desktop"
« Reply #1 on: November 05, 2013, 02:43:17 PM »
Try to use this, see if it helps.

Code: [Select]
// unicode version
#define UNICODE

#include <windows.h>
#include <wchar.h>
#include <stdio.h>
#include <io.h>

// comment or
// uncomment this
#define TRACE

int RedirectStdOut(HWND);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg = { 0 };
WNDCLASS wc = { 0 };

wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpszClassName = L"windowclassname";
wc.hInstance = hInstance;
wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
wc.lpszMenuName = NULL;
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);

RegisterClass(&wc);

int X = 10;
int Y = 10;
int WIDTH = 500;
int HEIGHT = 500;

HWND hwnd = CreateWindow(wc.lpszClassName, L"title", WS_OVERLAPPEDWINDOW, X, Y, WIDTH, HEIGHT, NULL, NULL, hInstance, NULL);

ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);

while (GetMessage(&msg, NULL, 0, 0))
DispatchMessage(&msg);

return (int)msg.wParam;
}



typedef struct table{
DWORD msg;
wchar_t *desc;
} table;

#define MESSAGE(a) {a,L#a},

table mTable[] = {
MESSAGE(WM_NULL)
MESSAGE(WM_CREATE)
MESSAGE(WM_DESTROY)
MESSAGE(WM_MOVE)
MESSAGE(WM_SIZE)
MESSAGE(WM_ACTIVATE)
MESSAGE(WM_SETFOCUS)
MESSAGE(WM_KILLFOCUS)
MESSAGE(WM_ENABLE)
MESSAGE(WM_SETREDRAW)
MESSAGE(WM_SETTEXT)
MESSAGE(WM_GETTEXT)
MESSAGE(WM_GETTEXTLENGTH)
MESSAGE(WM_PAINT)
MESSAGE(WM_CLOSE)
MESSAGE(WM_QUERYENDSESSION)
MESSAGE(WM_QUERYOPEN)
MESSAGE(WM_ENDSESSION)
MESSAGE(WM_QUIT)
MESSAGE(WM_ERASEBKGND)
MESSAGE(WM_SYSCOLORCHANGE)
MESSAGE(WM_SHOWWINDOW)
MESSAGE(WM_WININICHANGE)
MESSAGE(WM_DEVMODECHANGE)
MESSAGE(WM_ACTIVATEAPP)
MESSAGE(WM_FONTCHANGE)
MESSAGE(WM_TIMECHANGE)
MESSAGE(WM_CANCELMODE)
MESSAGE(WM_SETCURSOR)
MESSAGE(WM_MOUSEACTIVATE)
MESSAGE(WM_CHILDACTIVATE)
MESSAGE(WM_QUEUESYNC)
MESSAGE(WM_GETMINMAXINFO)
MESSAGE(WM_PAINTICON)
MESSAGE(WM_ICONERASEBKGND)
MESSAGE(WM_NEXTDLGCTL)
MESSAGE(WM_SPOOLERSTATUS)
MESSAGE(WM_DRAWITEM)
MESSAGE(WM_MEASUREITEM)
MESSAGE(WM_DELETEITEM)
MESSAGE(WM_VKEYTOITEM)
MESSAGE(WM_CHARTOITEM)
MESSAGE(WM_SETFONT)
MESSAGE(WM_GETFONT)
MESSAGE(WM_SETHOTKEY)
MESSAGE(WM_GETHOTKEY)
MESSAGE(WM_QUERYDRAGICON)
MESSAGE(WM_COMPAREITEM)
MESSAGE(WM_GETOBJECT)
MESSAGE(WM_COMPACTING)
MESSAGE(WM_COMMNOTIFY)
MESSAGE(WM_WINDOWPOSCHANGING)
MESSAGE(WM_WINDOWPOSCHANGED)
MESSAGE(WM_POWER)
MESSAGE(WM_COPYDATA)
MESSAGE(WM_CANCELJOURNAL)
MESSAGE(WM_NOTIFY)
MESSAGE(WM_INPUTLANGCHANGEREQUEST)
MESSAGE(WM_INPUTLANGCHANGE)
MESSAGE(WM_TCARD)
MESSAGE(WM_HELP)
MESSAGE(WM_USERCHANGED)
MESSAGE(WM_NOTIFYFORMAT)
MESSAGE(WM_CONTEXTMENU)
MESSAGE(WM_STYLECHANGING)
MESSAGE(WM_STYLECHANGED)
MESSAGE(WM_DISPLAYCHANGE)
MESSAGE(WM_GETICON)
MESSAGE(WM_SETICON)
MESSAGE(WM_NCCREATE)
MESSAGE(WM_NCDESTROY)
MESSAGE(WM_NCCALCSIZE)
MESSAGE(WM_NCHITTEST)
MESSAGE(WM_NCPAINT)
MESSAGE(WM_NCACTIVATE)
MESSAGE(WM_GETDLGCODE)
MESSAGE(WM_SYNCPAINT)
MESSAGE(WM_NCMOUSEMOVE)
MESSAGE(WM_NCLBUTTONDOWN)
MESSAGE(WM_NCLBUTTONUP)
MESSAGE(WM_NCLBUTTONDBLCLK)
MESSAGE(WM_NCRBUTTONDOWN)
MESSAGE(WM_NCRBUTTONUP)
MESSAGE(WM_NCRBUTTONDBLCLK)
MESSAGE(WM_NCMBUTTONDOWN)
MESSAGE(WM_NCMBUTTONUP)
MESSAGE(WM_NCMBUTTONDBLCLK)
MESSAGE(WM_NCXBUTTONDOWN)
MESSAGE(WM_NCXBUTTONUP)
MESSAGE(WM_NCXBUTTONDBLCLK)
MESSAGE(WM_INPUT)
MESSAGE(WM_KEYFIRST)
MESSAGE(WM_KEYDOWN)
MESSAGE(WM_KEYUP)
MESSAGE(WM_CHAR)
MESSAGE(WM_DEADCHAR)
MESSAGE(WM_SYSKEYDOWN)
MESSAGE(WM_SYSKEYUP)
MESSAGE(WM_SYSCHAR)
MESSAGE(WM_SYSDEADCHAR)
MESSAGE(WM_UNICHAR)
MESSAGE(WM_KEYLAST)
MESSAGE(WM_KEYLAST)
MESSAGE(WM_IME_STARTCOMPOSITION)
MESSAGE(WM_IME_ENDCOMPOSITION)
MESSAGE(WM_IME_COMPOSITION)
MESSAGE(WM_IME_KEYLAST)
MESSAGE(WM_INITDIALOG)
MESSAGE(WM_COMMAND)
MESSAGE(WM_SYSCOMMAND)
MESSAGE(WM_TIMER)
MESSAGE(WM_HSCROLL)
MESSAGE(WM_VSCROLL)
MESSAGE(WM_INITMENU)
MESSAGE(WM_INITMENUPOPUP)
MESSAGE(WM_MENUSELECT)
MESSAGE(WM_MENUCHAR)
MESSAGE(WM_ENTERIDLE)
MESSAGE(WM_MENURBUTTONUP)
MESSAGE(WM_MENUDRAG)
MESSAGE(WM_MENUGETOBJECT)
MESSAGE(WM_UNINITMENUPOPUP)
MESSAGE(WM_MENUCOMMAND)
MESSAGE(WM_CHANGEUISTATE)
MESSAGE(WM_UPDATEUISTATE)
MESSAGE(WM_QUERYUISTATE)
MESSAGE(WM_CTLCOLORMSGBOX)
MESSAGE(WM_CTLCOLOREDIT)
MESSAGE(WM_CTLCOLORLISTBOX)
MESSAGE(WM_CTLCOLORBTN)
MESSAGE(WM_CTLCOLORDLG)
MESSAGE(WM_CTLCOLORSCROLLBAR)
MESSAGE(WM_CTLCOLORSTATIC)
MESSAGE(WM_MOUSEMOVE)//WM_MOUSEFIRST
MESSAGE(WM_LBUTTONDOWN)
MESSAGE(WM_LBUTTONUP)
MESSAGE(WM_LBUTTONDBLCLK)
MESSAGE(WM_RBUTTONDOWN)
MESSAGE(WM_RBUTTONUP)
MESSAGE(WM_RBUTTONDBLCLK)
MESSAGE(WM_MBUTTONDOWN)
MESSAGE(WM_MBUTTONUP)
MESSAGE(WM_MBUTTONDBLCLK)
MESSAGE(WM_MOUSEWHEEL)
MESSAGE(WM_XBUTTONDOWN)
MESSAGE(WM_XBUTTONUP)
MESSAGE(WM_XBUTTONDBLCLK)
MESSAGE(WM_MOUSEHWHEEL)
MESSAGE(WM_MOUSELAST)
MESSAGE(WM_PARENTNOTIFY)
MESSAGE(WM_ENTERMENULOOP)
MESSAGE(WM_EXITMENULOOP)
MESSAGE(WM_NEXTMENU)
MESSAGE(WM_SIZING)
MESSAGE(WM_CAPTURECHANGED)
MESSAGE(WM_MOVING)
MESSAGE(WM_POWERBROADCAST)
MESSAGE(WM_DEVICECHANGE)
MESSAGE(WM_MDICREATE)
MESSAGE(WM_MDIDESTROY)
MESSAGE(WM_MDIACTIVATE)
MESSAGE(WM_MDIRESTORE)
MESSAGE(WM_MDINEXT)
MESSAGE(WM_MDIMAXIMIZE)
MESSAGE(WM_MDITILE)
MESSAGE(WM_MDICASCADE)
MESSAGE(WM_MDIICONARRANGE)
MESSAGE(WM_MDIGETACTIVE)
MESSAGE(WM_MDISETMENU)
MESSAGE(WM_ENTERSIZEMOVE)
MESSAGE(WM_EXITSIZEMOVE)
MESSAGE(WM_DROPFILES)
MESSAGE(WM_MDIREFRESHMENU)
MESSAGE(WM_IME_SETCONTEXT)
MESSAGE(WM_IME_NOTIFY)
MESSAGE(WM_IME_CONTROL)
MESSAGE(WM_IME_COMPOSITIONFULL)
MESSAGE(WM_IME_SELECT)
MESSAGE(WM_IME_CHAR)
MESSAGE(WM_IME_REQUEST)
MESSAGE(WM_IME_KEYDOWN)
MESSAGE(WM_IME_KEYUP)
MESSAGE(WM_MOUSEHOVER)
MESSAGE(WM_MOUSELEAVE)
MESSAGE(WM_NCMOUSEHOVER)
MESSAGE(WM_NCMOUSELEAVE)
MESSAGE(WM_WTSSESSION_CHANGE)
MESSAGE(WM_TABLET_FIRST)
MESSAGE(WM_TABLET_LAST)
MESSAGE(WM_CUT)
MESSAGE(WM_COPY)
MESSAGE(WM_PASTE)
MESSAGE(WM_CLEAR)
MESSAGE(WM_UNDO)
MESSAGE(WM_RENDERFORMAT)
MESSAGE(WM_RENDERALLFORMATS)
MESSAGE(WM_DESTROYCLIPBOARD)
MESSAGE(WM_DRAWCLIPBOARD)
MESSAGE(WM_PAINTCLIPBOARD)
MESSAGE(WM_VSCROLLCLIPBOARD)
MESSAGE(WM_SIZECLIPBOARD)
MESSAGE(WM_ASKCBFORMATNAME)
MESSAGE(WM_CHANGECBCHAIN)
MESSAGE(WM_HSCROLLCLIPBOARD)
MESSAGE(WM_QUERYNEWPALETTE)
MESSAGE(WM_PALETTEISCHANGING)
MESSAGE(WM_PALETTECHANGED)
MESSAGE(WM_HOTKEY)
MESSAGE(WM_PRINT)
MESSAGE(WM_PRINTCLIENT)
MESSAGE(WM_APPCOMMAND)
MESSAGE(WM_THEMECHANGED)
MESSAGE(WM_CLIPBOARDUPDATE)
MESSAGE(WM_DWMCOMPOSITIONCHANGED)
MESSAGE(WM_DWMNCRENDERINGCHANGED)
MESSAGE(WM_DWMCOLORIZATIONCOLORCHANGED)
MESSAGE(WM_DWMWINDOWMAXIMIZEDCHANGE)
MESSAGE(WM_GETTITLEBARINFOEX)
MESSAGE(WM_HANDHELDFIRST)
MESSAGE(WM_HANDHELDLAST)
MESSAGE(WM_AFXFIRST)
MESSAGE(WM_AFXLAST)
MESSAGE(WM_PENWINFIRST)
MESSAGE(WM_PENWINLAST)
MESSAGE(WM_APP)
MESSAGE(WM_USER)
};



wchar_t *messageToString(UINT message)
{
int index = -1;
int size = sizeof(mTable) / sizeof(table);
for (int i = 0; i < size; i++)
{
if (message == mTable[i].msg)
{
index = i;
break;
}
}
if (index == -1)
return L"NOT FOUND";
else
return mTable[index].desc;
}



BOOL I_m_blind = TRUE;
wchar_t messages_before_WM_CREATE[2048] = { 0 };
wchar_t string[MAX_PATH] = { 0 };




LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
{
{
{
if (I_m_blind)
{
string[0] = L'\0';
swprintf(string, MAX_PATH, L"message 0x%.8x %ls\nwParam 0x%x lParam 0x%x\n\n", msg, messageToString(msg), wParam, lParam);
wcscat(messages_before_WM_CREATE, string);
}

}
}
}


wprintf(L"message 0x%.8x %ls\nwParam 0x%x lParam 0x%x\n\n", msg, messageToString(msg), wParam, lParam);


switch (msg)
{

case WM_CREATE:
{
#ifdef TRACE
int redirect = RedirectStdOut(hwnd);
if (redirect == -1)
return redirect;
wprintf(L"%ls", messages_before_WM_CREATE);
I_m_blind = FALSE;
return redirect;
#else
I_m_blind = FALSE;
return 0;
#endif
}//end WM_CREATE


case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}

}
return DefWindowProc(hwnd, msg, wParam, lParam);
}






HWND console = NULL;

BOOL CALLBACK enumWindows(HWND hwnd, LPARAM lParam)
{
wchar_t Name[MAX_PATH] = { 0 };
GetClassName(hwnd, Name, MAX_PATH);
if (!wcscmp(L"ConsoleWindowClass", Name))
{
Name[0] = L'\0';
GetWindowText(hwnd, Name, MAX_PATH);
if (!wcscmp(Name, (wchar_t *)lParam))
{
console = hwnd;
return 0;
}
}
return 1;
}

// from Pelles C IDE help file
//' Tip about using stdout in GUI programs '
int RedirectStdOut(HWND hwnd)
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (!AllocConsole())
return -1;
if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
{
csbi.dwSize.Y = 1000;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), csbi.dwSize);
}
if (!_wfreopen(L"CONIN$", L"w", stdin))
return -1;
if (!_wfreopen(L"CONOUT$", L"w", stderr))
return -1;
if (!_wfreopen(L"CONOUT$", L"w", stdout))
return -1;
setbuf(stdout, NULL);
wchar_t title[MAX_PATH] = { 0 };
if (!GetConsoleTitle(title, MAX_PATH))
return -1;
wprintf(L"\n title %ls\n", title);
EnumWindows(enumWindows, (LPARAM)title);
if (!console)
return -1;
wprintf(L" hwnd 0x%x\n\n", (int)console);
RECT rc;
if (!SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0))
return -1;
MoveWindow(hwnd, rc.left + (rc.right - rc.left) / 2, rc.top, (rc.right - rc.left) / 2, rc.bottom - rc.top, TRUE);
MoveWindow(console, rc.left, rc.top, (rc.right - rc.left) / 2, rc.bottom - rc.top, TRUE);
return 0;
}


The function RedirectStdOut () was written by Pelle not by me, see the help file.

Laur

liut

  • Guest
Re: "Show Desktop"
« Reply #2 on: November 07, 2013, 02:10:30 AM »
Thanks a lot! The code is very useful to help me explore the msg queue. I think everybody can use this core code "messageToString()":
Code: [Select]
typedef struct table{
DWORD msg;
wchar_t *desc;
} table;

#define MESSAGE(a) {a,L#a},

table mTable[] = {
MESSAGE(WM_NULL)
MESSAGE(WM_CREATE)
MESSAGE(WM_DESTROY)
MESSAGE(WM_MOVE)
MESSAGE(WM_SIZE)
MESSAGE(WM_ACTIVATE)
MESSAGE(WM_SETFOCUS)
MESSAGE(WM_KILLFOCUS)
MESSAGE(WM_ENABLE)
MESSAGE(WM_SETREDRAW)
MESSAGE(WM_SETTEXT)
MESSAGE(WM_GETTEXT)
MESSAGE(WM_GETTEXTLENGTH)
MESSAGE(WM_PAINT)
MESSAGE(WM_CLOSE)
MESSAGE(WM_QUERYENDSESSION)
MESSAGE(WM_QUERYOPEN)
MESSAGE(WM_ENDSESSION)
MESSAGE(WM_QUIT)
MESSAGE(WM_ERASEBKGND)
MESSAGE(WM_SYSCOLORCHANGE)
MESSAGE(WM_SHOWWINDOW)
MESSAGE(WM_WININICHANGE)
MESSAGE(WM_DEVMODECHANGE)
MESSAGE(WM_ACTIVATEAPP)
MESSAGE(WM_FONTCHANGE)
MESSAGE(WM_TIMECHANGE)
MESSAGE(WM_CANCELMODE)
MESSAGE(WM_SETCURSOR)
MESSAGE(WM_MOUSEACTIVATE)
MESSAGE(WM_CHILDACTIVATE)
MESSAGE(WM_QUEUESYNC)
MESSAGE(WM_GETMINMAXINFO)
MESSAGE(WM_PAINTICON)
MESSAGE(WM_ICONERASEBKGND)
MESSAGE(WM_NEXTDLGCTL)
MESSAGE(WM_SPOOLERSTATUS)
MESSAGE(WM_DRAWITEM)
MESSAGE(WM_MEASUREITEM)
MESSAGE(WM_DELETEITEM)
MESSAGE(WM_VKEYTOITEM)
MESSAGE(WM_CHARTOITEM)
MESSAGE(WM_SETFONT)
MESSAGE(WM_GETFONT)
MESSAGE(WM_SETHOTKEY)
MESSAGE(WM_GETHOTKEY)
MESSAGE(WM_QUERYDRAGICON)
MESSAGE(WM_COMPAREITEM)
MESSAGE(WM_GETOBJECT)
MESSAGE(WM_COMPACTING)
MESSAGE(WM_COMMNOTIFY)
MESSAGE(WM_WINDOWPOSCHANGING)
MESSAGE(WM_WINDOWPOSCHANGED)
MESSAGE(WM_POWER)
MESSAGE(WM_COPYDATA)
MESSAGE(WM_CANCELJOURNAL)
MESSAGE(WM_NOTIFY)
MESSAGE(WM_INPUTLANGCHANGEREQUEST)
MESSAGE(WM_INPUTLANGCHANGE)
MESSAGE(WM_TCARD)
MESSAGE(WM_HELP)
MESSAGE(WM_USERCHANGED)
MESSAGE(WM_NOTIFYFORMAT)
MESSAGE(WM_CONTEXTMENU)
MESSAGE(WM_STYLECHANGING)
MESSAGE(WM_STYLECHANGED)
MESSAGE(WM_DISPLAYCHANGE)
MESSAGE(WM_GETICON)
MESSAGE(WM_SETICON)
MESSAGE(WM_NCCREATE)
MESSAGE(WM_NCDESTROY)
MESSAGE(WM_NCCALCSIZE)
MESSAGE(WM_NCHITTEST)
MESSAGE(WM_NCPAINT)
MESSAGE(WM_NCACTIVATE)
MESSAGE(WM_GETDLGCODE)
MESSAGE(WM_SYNCPAINT)
MESSAGE(WM_NCMOUSEMOVE)
MESSAGE(WM_NCLBUTTONDOWN)
MESSAGE(WM_NCLBUTTONUP)
MESSAGE(WM_NCLBUTTONDBLCLK)
MESSAGE(WM_NCRBUTTONDOWN)
MESSAGE(WM_NCRBUTTONUP)
MESSAGE(WM_NCRBUTTONDBLCLK)
MESSAGE(WM_NCMBUTTONDOWN)
MESSAGE(WM_NCMBUTTONUP)
MESSAGE(WM_NCMBUTTONDBLCLK)
MESSAGE(WM_NCXBUTTONDOWN)
MESSAGE(WM_NCXBUTTONUP)
MESSAGE(WM_NCXBUTTONDBLCLK)
MESSAGE(WM_INPUT)
MESSAGE(WM_KEYFIRST)
MESSAGE(WM_KEYDOWN)
MESSAGE(WM_KEYUP)
MESSAGE(WM_CHAR)
MESSAGE(WM_DEADCHAR)
MESSAGE(WM_SYSKEYDOWN)
MESSAGE(WM_SYSKEYUP)
MESSAGE(WM_SYSCHAR)
MESSAGE(WM_SYSDEADCHAR)
MESSAGE(WM_UNICHAR)
MESSAGE(WM_KEYLAST)
MESSAGE(WM_KEYLAST)
MESSAGE(WM_IME_STARTCOMPOSITION)
MESSAGE(WM_IME_ENDCOMPOSITION)
MESSAGE(WM_IME_COMPOSITION)
MESSAGE(WM_IME_KEYLAST)
MESSAGE(WM_INITDIALOG)
MESSAGE(WM_COMMAND)
MESSAGE(WM_SYSCOMMAND)
MESSAGE(WM_TIMER)
MESSAGE(WM_HSCROLL)
MESSAGE(WM_VSCROLL)
MESSAGE(WM_INITMENU)
MESSAGE(WM_INITMENUPOPUP)
MESSAGE(WM_MENUSELECT)
MESSAGE(WM_MENUCHAR)
MESSAGE(WM_ENTERIDLE)
MESSAGE(WM_MENURBUTTONUP)
MESSAGE(WM_MENUDRAG)
MESSAGE(WM_MENUGETOBJECT)
MESSAGE(WM_UNINITMENUPOPUP)
MESSAGE(WM_MENUCOMMAND)
MESSAGE(WM_CHANGEUISTATE)
MESSAGE(WM_UPDATEUISTATE)
MESSAGE(WM_QUERYUISTATE)
MESSAGE(WM_CTLCOLORMSGBOX)
MESSAGE(WM_CTLCOLOREDIT)
MESSAGE(WM_CTLCOLORLISTBOX)
MESSAGE(WM_CTLCOLORBTN)
MESSAGE(WM_CTLCOLORDLG)
MESSAGE(WM_CTLCOLORSCROLLBAR)
MESSAGE(WM_CTLCOLORSTATIC)
MESSAGE(WM_MOUSEMOVE)//WM_MOUSEFIRST
MESSAGE(WM_LBUTTONDOWN)
MESSAGE(WM_LBUTTONUP)
MESSAGE(WM_LBUTTONDBLCLK)
MESSAGE(WM_RBUTTONDOWN)
MESSAGE(WM_RBUTTONUP)
MESSAGE(WM_RBUTTONDBLCLK)
MESSAGE(WM_MBUTTONDOWN)
MESSAGE(WM_MBUTTONUP)
MESSAGE(WM_MBUTTONDBLCLK)
MESSAGE(WM_MOUSEWHEEL)
MESSAGE(WM_XBUTTONDOWN)
MESSAGE(WM_XBUTTONUP)
MESSAGE(WM_XBUTTONDBLCLK)
MESSAGE(WM_MOUSEHWHEEL)
MESSAGE(WM_MOUSELAST)
MESSAGE(WM_PARENTNOTIFY)
MESSAGE(WM_ENTERMENULOOP)
MESSAGE(WM_EXITMENULOOP)
MESSAGE(WM_NEXTMENU)
MESSAGE(WM_SIZING)
MESSAGE(WM_CAPTURECHANGED)
MESSAGE(WM_MOVING)
MESSAGE(WM_POWERBROADCAST)
MESSAGE(WM_DEVICECHANGE)
MESSAGE(WM_MDICREATE)
MESSAGE(WM_MDIDESTROY)
MESSAGE(WM_MDIACTIVATE)
MESSAGE(WM_MDIRESTORE)
MESSAGE(WM_MDINEXT)
MESSAGE(WM_MDIMAXIMIZE)
MESSAGE(WM_MDITILE)
MESSAGE(WM_MDICASCADE)
MESSAGE(WM_MDIICONARRANGE)
MESSAGE(WM_MDIGETACTIVE)
MESSAGE(WM_MDISETMENU)
MESSAGE(WM_ENTERSIZEMOVE)
MESSAGE(WM_EXITSIZEMOVE)
MESSAGE(WM_DROPFILES)
MESSAGE(WM_MDIREFRESHMENU)
MESSAGE(WM_IME_SETCONTEXT)
MESSAGE(WM_IME_NOTIFY)
MESSAGE(WM_IME_CONTROL)
MESSAGE(WM_IME_COMPOSITIONFULL)
MESSAGE(WM_IME_SELECT)
MESSAGE(WM_IME_CHAR)
MESSAGE(WM_IME_REQUEST)
MESSAGE(WM_IME_KEYDOWN)
MESSAGE(WM_IME_KEYUP)
MESSAGE(WM_MOUSEHOVER)
MESSAGE(WM_MOUSELEAVE)
MESSAGE(WM_NCMOUSEHOVER)
MESSAGE(WM_NCMOUSELEAVE)
MESSAGE(WM_WTSSESSION_CHANGE)
MESSAGE(WM_TABLET_FIRST)
MESSAGE(WM_TABLET_LAST)
MESSAGE(WM_CUT)
MESSAGE(WM_COPY)
MESSAGE(WM_PASTE)
MESSAGE(WM_CLEAR)
MESSAGE(WM_UNDO)
MESSAGE(WM_RENDERFORMAT)
MESSAGE(WM_RENDERALLFORMATS)
MESSAGE(WM_DESTROYCLIPBOARD)
MESSAGE(WM_DRAWCLIPBOARD)
MESSAGE(WM_PAINTCLIPBOARD)
MESSAGE(WM_VSCROLLCLIPBOARD)
MESSAGE(WM_SIZECLIPBOARD)
MESSAGE(WM_ASKCBFORMATNAME)
MESSAGE(WM_CHANGECBCHAIN)
MESSAGE(WM_HSCROLLCLIPBOARD)
MESSAGE(WM_QUERYNEWPALETTE)
MESSAGE(WM_PALETTEISCHANGING)
MESSAGE(WM_PALETTECHANGED)
MESSAGE(WM_HOTKEY)
MESSAGE(WM_PRINT)
MESSAGE(WM_PRINTCLIENT)
MESSAGE(WM_APPCOMMAND)
MESSAGE(WM_THEMECHANGED)
MESSAGE(WM_CLIPBOARDUPDATE)
MESSAGE(WM_DWMCOMPOSITIONCHANGED)
MESSAGE(WM_DWMNCRENDERINGCHANGED)
MESSAGE(WM_DWMCOLORIZATIONCOLORCHANGED)
MESSAGE(WM_DWMWINDOWMAXIMIZEDCHANGE)
MESSAGE(WM_GETTITLEBARINFOEX)
MESSAGE(WM_HANDHELDFIRST)
MESSAGE(WM_HANDHELDLAST)
MESSAGE(WM_AFXFIRST)
MESSAGE(WM_AFXLAST)
MESSAGE(WM_PENWINFIRST)
MESSAGE(WM_PENWINLAST)
MESSAGE(WM_APP)
MESSAGE(WM_USER)
};

wchar_t *messageToString(UINT message)
{
int index = -1;
int size = sizeof(mTable) / sizeof(table);
for (int i = 0; i < size; i++)
{
if (message == mTable[i].msg)
{
index = i;
break;
}
}
if (index == -1)
return L"NOT FOUND";
else
return mTable[index].desc;
}

And I added the time and revised the output to a text file for analysis in the WinProc():
Code: [Select]
char output_text[100];
DWORD wt;

SYSTEMTIME cur_stime;
GetLocalTime(&cur_stime);

wsprintfA(output_text,"%02d:%02d:%02d - message 0x%.8x %ls\r\nwParam 0x%x lParam 0x%x\r\n\r\n",cur_stime.wHour,cur_stime.wMinute,cur_stime.wSecond, uMsg, messageToString(uMsg), wParam, lParam);
if(h_msg) WriteFile(h_msg,(void *)output_text,strlen(output_text),&wt,NULL);

switch(uMsg){
« Last Edit: November 07, 2013, 06:21:25 PM by Stefan Pendl »

liut

  • Guest
Re: "Show Desktop"
« Reply #3 on: November 07, 2013, 02:25:13 AM »
It's time for the result... I captured the message queue for a normal "overlapped" window and a "popup" window for comparison. When I click "show desktop", both windows get messages for "set activate to false", and "overlapped" window gets more message "WM_SIZE/MINIMIZED" and "WM_MOVE", that's all.

However, I still can't recover my window after "show desktop". I think I have tried a million ways :) such as SetActiveWindow(), ShowWindow(), SetWindowPos(), RedrawWindow(), InvalidateRect(), SetForegroundWindow(), and send all kinds of messages to hwnd...

I think there is another higher layer to control this, and maybe it's not opened sdk interface. Use a desktop DC to paint anything directly can avoid the issue, but it's not what I need. So I think I'll give up until anybody can give me more hints...