FreeRDP/winpr/libwinpr/wnd/test/TestWndCreateWindowEx.c

99 lines
2.1 KiB
C
Raw Normal View History

2014-03-18 05:37:12 +04:00
#include <winpr/crt.h>
#include <winpr/wnd.h>
2014-05-22 21:50:01 +04:00
#include <winpr/tchar.h>
#include <winpr/wtsapi.h>
2014-03-18 22:43:25 +04:00
#include <winpr/library.h>
const char* WM_WTS_STRINGS[] =
2014-03-18 22:43:25 +04:00
{
"",
"WTS_CONSOLE_CONNECT",
"WTS_CONSOLE_DISCONNECT",
"WTS_REMOTE_CONNECT",
"WTS_REMOTE_DISCONNECT",
"WTS_SESSION_LOGON",
"WTS_SESSION_LOGOFF",
"WTS_SESSION_LOCK",
"WTS_SESSION_UNLOCK",
"WTS_SESSION_REMOTE_CONTROL",
"WTS_SESSION_CREATE",
"WTS_SESSION_TERMINATE",
""
};
2014-03-18 22:43:25 +04:00
2014-03-19 02:03:55 +04:00
static LRESULT CALLBACK TestWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
2014-03-18 22:43:25 +04:00
switch (uMsg)
{
case WM_WTSSESSION_CHANGE:
if (wParam && (wParam < 13))
{
PWTSSESSION_NOTIFICATION pNotification = (PWTSSESSION_NOTIFICATION) lParam;
printf("WM_WTSSESSION_CHANGE: %s SessionId: %d\n",
WM_WTS_STRINGS[wParam], (int) pNotification->dwSessionId);
}
2014-03-18 22:43:25 +04:00
break;
default:
printf("TestWndProc: uMsg: 0x%04X\n", uMsg);
2014-03-18 22:43:25 +04:00
return DefWindowProc(hwnd, uMsg, wParam, lParam);
break;
2014-03-18 22:43:25 +04:00
}
return 0;
}
2014-03-18 05:37:12 +04:00
int TestWndCreateWindowEx(int argc, char* argv[])
{
2014-03-18 22:43:25 +04:00
HWND hWnd;
HMODULE hModule;
HINSTANCE hInstance;
WNDCLASSEX wndClassEx;
WTSSESSION_NOTIFICATION wtsSessionNotification;
2014-03-18 22:43:25 +04:00
hModule = GetModuleHandle(NULL);
ZeroMemory(&wndClassEx, sizeof(WNDCLASSEX));
wndClassEx.cbSize = sizeof(WNDCLASSEX);
wndClassEx.style = 0;
wndClassEx.lpfnWndProc = TestWndProc;
wndClassEx.cbClsExtra = 0;
wndClassEx.cbWndExtra = 0;
wndClassEx.hInstance = hModule;
wndClassEx.hIcon = NULL;
wndClassEx.hCursor = NULL;
wndClassEx.hbrBackground = NULL;
wndClassEx.lpszMenuName = _T("TestWndMenu");
wndClassEx.lpszClassName = _T("TestWndClass");
wndClassEx.hIconSm = NULL;
if (!RegisterClassEx(&wndClassEx))
{
printf("RegisterClassEx failure\n");
return -1;
}
hInstance = wndClassEx.hInstance;
hWnd = CreateWindowEx(0, wndClassEx.lpszClassName,
0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hInstance, NULL);
if (!hWnd)
{
printf("CreateWindowEx failure\n");
return -1;
}
wtsSessionNotification.cbSize = sizeof(WTSSESSION_NOTIFICATION);
wtsSessionNotification.dwSessionId = 123;
SendMessage(hWnd, WM_WTSSESSION_CHANGE, WTS_SESSION_LOGON, (LPARAM) &wtsSessionNotification);
DestroyWindow(hWnd);
2014-03-18 22:43:25 +04:00
2014-03-18 05:37:12 +04:00
return 0;
}