mirror of https://github.com/FreeRDP/FreeRDP
libwinpr-wnd: expand window procedure functions
This commit is contained in:
parent
2c7ab4be46
commit
2d4cc74961
|
@ -26,14 +26,6 @@
|
|||
|
||||
#ifndef _WIN32
|
||||
|
||||
#ifndef FAR
|
||||
#define FAR
|
||||
#endif
|
||||
|
||||
#ifndef NEAR
|
||||
#define NEAR
|
||||
#endif
|
||||
|
||||
#define WM_NULL 0x0000
|
||||
#define WM_CREATE 0x0001
|
||||
#define WM_DESTROY 0x0002
|
||||
|
@ -297,6 +289,7 @@ typedef UINT_PTR WPARAM;
|
|||
typedef LONG_PTR LPARAM;
|
||||
typedef LONG_PTR LRESULT;
|
||||
|
||||
typedef FARPROC SENDASYNCPROC;
|
||||
typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
typedef HANDLE HICON;
|
||||
|
@ -400,6 +393,24 @@ typedef struct tagMSG
|
|||
POINT pt;
|
||||
} MSG, *PMSG, NEAR *NPMSG, FAR *LPMSG;
|
||||
|
||||
typedef struct tagWTSSESSION_NOTIFICATION
|
||||
{
|
||||
DWORD cbSize;
|
||||
DWORD dwSessionId;
|
||||
} WTSSESSION_NOTIFICATION, *PWTSSESSION_NOTIFICATION;
|
||||
|
||||
#define WTS_CONSOLE_CONNECT 0x1
|
||||
#define WTS_CONSOLE_DISCONNECT 0x2
|
||||
#define WTS_REMOTE_CONNECT 0x3
|
||||
#define WTS_REMOTE_DISCONNECT 0x4
|
||||
#define WTS_SESSION_LOGON 0x5
|
||||
#define WTS_SESSION_LOGOFF 0x6
|
||||
#define WTS_SESSION_LOCK 0x7
|
||||
#define WTS_SESSION_UNLOCK 0x8
|
||||
#define WTS_SESSION_REMOTE_CONTROL 0x9
|
||||
#define WTS_SESSION_CREATE 0xA
|
||||
#define WTS_SESSION_TERMINATE 0xB
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -448,6 +459,22 @@ WINPR_API HWND WINAPI CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName,
|
|||
WINPR_API BOOL WINAPI GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
|
||||
WINPR_API BOOL WINAPI GetMessageW(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
|
||||
|
||||
WINPR_API LRESULT WINAPI SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
WINPR_API LRESULT WINAPI SendMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
WINPR_API LRESULT WINAPI SendMessageTimeoutA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam,
|
||||
UINT fuFlags, UINT uTimeout, PDWORD_PTR lpdwResult);
|
||||
WINPR_API LRESULT WINAPI SendMessageTimeoutW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam,
|
||||
UINT fuFlags, UINT uTimeout, PDWORD_PTR lpdwResult);
|
||||
|
||||
WINPR_API BOOL WINAPI SendNotifyMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
WINPR_API BOOL WINAPI SendNotifyMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
WINPR_API BOOL WINAPI SendMessageCallbackA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam,
|
||||
SENDASYNCPROC lpResultCallBack, ULONG_PTR dwData);
|
||||
WINPR_API BOOL WINAPI SendMessageCallbackW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam,
|
||||
SENDASYNCPROC lpResultCallBack, ULONG_PTR dwData);
|
||||
|
||||
WINPR_API BOOL WINAPI TranslateMessage(CONST MSG* lpMsg);
|
||||
|
||||
WINPR_API LRESULT WINAPI DispatchMessageA(CONST MSG* lpMsg);
|
||||
|
@ -470,6 +497,10 @@ WINPR_API LRESULT WINAPI DefWindowProcW(HWND hWnd, UINT Msg, WPARAM wParam, LPAR
|
|||
#define CreateWindow CreateWindowW
|
||||
#define CreateWindowEx CreateWindowExW
|
||||
#define GetMessage GetMessageW
|
||||
#define SendMessage SendMessageW
|
||||
#define SendMessageTimeout SendMessageTimeoutW
|
||||
#define SendNotifyMessage SendNotifyMessageW
|
||||
#define SendMessageCallback SendMessageCallbackW
|
||||
#define DispatchMessage DispatchMessageW
|
||||
#define CallWindowProc CallWindowProcW
|
||||
#define DefWindowProc DefWindowProcW
|
||||
|
@ -484,6 +515,10 @@ WINPR_API LRESULT WINAPI DefWindowProcW(HWND hWnd, UINT Msg, WPARAM wParam, LPAR
|
|||
#define CreateWindow CreateWindowA
|
||||
#define CreateWindowEx CreateWindowExA
|
||||
#define GetMessage GetMessageA
|
||||
#define SendMessage SendMessageA
|
||||
#define SendMessageTimeout SendMessageTimeoutA
|
||||
#define SendNotifyMessage SendNotifyMessageA
|
||||
#define SendMessageCallback SendMessageCallbackA
|
||||
#define DispatchMessage DispatchMessageA
|
||||
#define CallWindowProc CallWindowProcA
|
||||
#define DefWindowProc DefWindowProcA
|
||||
|
|
|
@ -41,6 +41,14 @@
|
|||
#define WINAPI
|
||||
#define CDECL
|
||||
|
||||
#ifndef FAR
|
||||
#define FAR
|
||||
#endif
|
||||
|
||||
#ifndef NEAR
|
||||
#define NEAR
|
||||
#endif
|
||||
|
||||
#define __int8 char
|
||||
#define __int16 short
|
||||
#define __int32 int
|
||||
|
@ -135,7 +143,7 @@ typedef unsigned long ULONG, *PULONG;
|
|||
typedef ULONG HRESULT;
|
||||
typedef ULONG SCODE;
|
||||
|
||||
typedef ULONG_PTR DWORD_PTR;
|
||||
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
||||
typedef ULONG_PTR SIZE_T;
|
||||
typedef unsigned int ULONG32;
|
||||
typedef unsigned __int64 ULONG64;
|
||||
|
|
|
@ -19,7 +19,8 @@ set(MODULE_NAME "winpr-wnd")
|
|||
set(MODULE_PREFIX "WINPR_WND")
|
||||
|
||||
set(${MODULE_PREFIX}_SRCS
|
||||
wnd.c)
|
||||
wnd.c
|
||||
wnd.h)
|
||||
|
||||
if(MSVC AND (NOT MONOLITHIC_BUILD))
|
||||
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} module.def)
|
||||
|
|
|
@ -1,24 +1,44 @@
|
|||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/wnd.h>
|
||||
#include <winpr/wtsapi.h>
|
||||
#include <winpr/library.h>
|
||||
|
||||
const char* WM_WTS_STRINGS[] =
|
||||
{
|
||||
"",
|
||||
"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",
|
||||
""
|
||||
};
|
||||
|
||||
LRESULT CALLBACK TestWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
printf("TestWndProc: uMsg: 0x%04X\n", uMsg);
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_CLOSE:
|
||||
DestroyWindow(hwnd);
|
||||
break;
|
||||
case WM_WTSSESSION_CHANGE:
|
||||
if (wParam && (wParam < 13))
|
||||
{
|
||||
PWTSSESSION_NOTIFICATION pNotification = (PWTSSESSION_NOTIFICATION) lParam;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
printf("WM_WTSSESSION_CHANGE: %s SessionId: %d\n",
|
||||
WM_WTS_STRINGS[wParam], (int) pNotification->dwSessionId);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("TestWndProc: uMsg: 0x%04X\n", uMsg);
|
||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -26,11 +46,12 @@ LRESULT CALLBACK TestWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
int TestWndCreateWindowEx(int argc, char* argv[])
|
||||
{
|
||||
MSG msg;
|
||||
//MSG msg;
|
||||
HWND hWnd;
|
||||
HMODULE hModule;
|
||||
HINSTANCE hInstance;
|
||||
WNDCLASSEX wndClassEx;
|
||||
WTSSESSION_NOTIFICATION wtsSessionNotification;
|
||||
|
||||
hModule = GetModuleHandle(NULL);
|
||||
|
||||
|
@ -65,11 +86,12 @@ int TestWndCreateWindowEx(int argc, char* argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
while (GetMessage(&msg, NULL, 0, 0) > 0)
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
wtsSessionNotification.cbSize = sizeof(WTSSESSION_NOTIFICATION);
|
||||
wtsSessionNotification.dwSessionId = 123;
|
||||
|
||||
SendMessage(hWnd, WM_WTSSESSION_CHANGE, WTS_SESSION_LOGON, (LPARAM) &wtsSessionNotification);
|
||||
|
||||
DestroyWindow(hWnd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,10 +21,69 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/collections.h>
|
||||
|
||||
#include <winpr/wnd.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include "wnd.h"
|
||||
|
||||
static wArrayList* g_WindowClasses = NULL;
|
||||
|
||||
void InitializeWindowClasses()
|
||||
{
|
||||
if (g_WindowClasses)
|
||||
return;
|
||||
|
||||
g_WindowClasses = ArrayList_New(TRUE);
|
||||
}
|
||||
|
||||
WNDCLASSEXA* CloneWindowClass(CONST WNDCLASSEXA* lpwcx)
|
||||
{
|
||||
WNDCLASSEXA* _lpwcx = NULL;
|
||||
|
||||
_lpwcx = malloc(sizeof(WNDCLASSEXA));
|
||||
|
||||
if (!_lpwcx)
|
||||
return NULL;
|
||||
|
||||
CopyMemory(_lpwcx, lpwcx, sizeof(WNDCLASSEXA));
|
||||
|
||||
_lpwcx->lpszClassName = _strdup(lpwcx->lpszClassName);
|
||||
_lpwcx->lpszMenuName = _strdup(lpwcx->lpszMenuName);
|
||||
|
||||
return _lpwcx;
|
||||
}
|
||||
|
||||
WNDCLASSEXA* FindWindowClass(LPCSTR lpClassName)
|
||||
{
|
||||
int index;
|
||||
int count;
|
||||
BOOL found = FALSE;
|
||||
WNDCLASSEXA* lpwcx = NULL;
|
||||
|
||||
ArrayList_Lock(g_WindowClasses);
|
||||
|
||||
count = ArrayList_Count(g_WindowClasses);
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
lpwcx = (WNDCLASSEXA*) ArrayList_GetItem(g_WindowClasses, index);
|
||||
|
||||
if (strcmp(lpClassName, lpwcx->lpszClassName) == 0)
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList_Unlock(g_WindowClasses);
|
||||
|
||||
return (found) ? lpwcx : NULL;
|
||||
}
|
||||
|
||||
WORD WINAPI GetWindowWord(HWND hWnd, int nIndex)
|
||||
{
|
||||
return 0;
|
||||
|
@ -77,6 +136,20 @@ LONG_PTR WINAPI SetWindowLongPtrW(HWND hWnd, int nIndex, LONG_PTR dwNewLong)
|
|||
|
||||
BOOL WINAPI DestroyWindow(HWND hWnd)
|
||||
{
|
||||
WINPR_WND* pWnd;
|
||||
|
||||
pWnd = (WINPR_WND*) hWnd;
|
||||
|
||||
if (!pWnd)
|
||||
return FALSE;
|
||||
|
||||
free(pWnd->lpClassName);
|
||||
|
||||
if (pWnd->lpWindowName)
|
||||
free(pWnd->lpWindowName);
|
||||
|
||||
free(pWnd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -87,22 +160,30 @@ VOID WINAPI PostQuitMessage(int nExitCode)
|
|||
|
||||
ATOM WINAPI RegisterClassA(CONST WNDCLASSA* lpWndClass)
|
||||
{
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ATOM WINAPI RegisterClassW(CONST WNDCLASSW* lpWndClass)
|
||||
{
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ATOM WINAPI RegisterClassExA(CONST WNDCLASSEXA* lpwcx)
|
||||
{
|
||||
return 0;
|
||||
WNDCLASSEXA* _lpwcx;
|
||||
|
||||
InitializeWindowClasses();
|
||||
|
||||
_lpwcx = CloneWindowClass(lpwcx);
|
||||
|
||||
ArrayList_Add(g_WindowClasses, (void*) _lpwcx);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
ATOM WINAPI RegisterClassExW(CONST WNDCLASSEXW* lpwcx)
|
||||
{
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL WINAPI UnregisterClassA(LPCSTR lpClassName, HINSTANCE hInstance)
|
||||
|
@ -119,7 +200,43 @@ HWND WINAPI CreateWindowExA(DWORD dwExStyle, LPCSTR lpClassName,
|
|||
LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight,
|
||||
HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)
|
||||
{
|
||||
return NULL;
|
||||
HWND hWnd;
|
||||
WINPR_WND* pWnd;
|
||||
WNDCLASSEXA* lpwcx;
|
||||
|
||||
InitializeWindowClasses();
|
||||
|
||||
if (!lpClassName)
|
||||
return NULL;
|
||||
|
||||
lpwcx = FindWindowClass(lpClassName);
|
||||
|
||||
if (!lpwcx)
|
||||
return NULL;
|
||||
|
||||
pWnd = (WINPR_WND*) calloc(1, sizeof(WINPR_WND));
|
||||
|
||||
if (!pWnd)
|
||||
return NULL;
|
||||
|
||||
hWnd = (HWND) pWnd;
|
||||
|
||||
pWnd->X = X;
|
||||
pWnd->Y = Y;
|
||||
pWnd->nWidth = nWidth;
|
||||
pWnd->nHeight = nHeight;
|
||||
pWnd->lpClassName = _strdup(lpClassName);
|
||||
|
||||
if (lpWindowName)
|
||||
pWnd->lpWindowName = _strdup(lpWindowName);
|
||||
|
||||
pWnd->hWndParent = hWndParent;
|
||||
pWnd->hMenu = hMenu;
|
||||
pWnd->hInstance = hInstance;
|
||||
pWnd->lpParam = lpParam;
|
||||
pWnd->lpwcx = lpwcx;
|
||||
|
||||
return hWnd;
|
||||
}
|
||||
|
||||
HWND WINAPI CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName,
|
||||
|
@ -139,6 +256,66 @@ BOOL WINAPI GetMessageW(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFil
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
LRESULT WINAPI SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT status;
|
||||
WINPR_WND* pWnd;
|
||||
WNDPROC lpfnWndProc;
|
||||
|
||||
pWnd = (WINPR_WND*) hWnd;
|
||||
|
||||
if (!pWnd)
|
||||
return 0;
|
||||
|
||||
lpfnWndProc = pWnd->lpwcx->lpfnWndProc;
|
||||
|
||||
if (!lpfnWndProc)
|
||||
return 0;
|
||||
|
||||
status = lpfnWndProc(hWnd, Msg, wParam, lParam);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
LRESULT WINAPI SendMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WINAPI SendMessageTimeoutA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam,
|
||||
UINT fuFlags, UINT uTimeout, PDWORD_PTR lpdwResult)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WINAPI SendMessageTimeoutW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam,
|
||||
UINT fuFlags, UINT uTimeout, PDWORD_PTR lpdwResult)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL WINAPI SendNotifyMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL WINAPI SendNotifyMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL WINAPI SendMessageCallbackA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam,
|
||||
SENDASYNCPROC lpResultCallBack, ULONG_PTR dwData)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL WINAPI SendMessageCallbackW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam,
|
||||
SENDASYNCPROC lpResultCallBack, ULONG_PTR dwData)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL WINAPI TranslateMessage(CONST MSG* lpMsg)
|
||||
{
|
||||
return TRUE;
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* WinPR: Windows Portable Runtime
|
||||
* Window Notification System
|
||||
*
|
||||
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WINPR_WND_PRIVATE_H
|
||||
#define WINPR_WND_PRIVATE_H
|
||||
|
||||
#include <winpr/wnd.h>
|
||||
|
||||
struct _WINPR_WND
|
||||
{
|
||||
int X;
|
||||
int Y;
|
||||
int nWidth;
|
||||
int nHeight;
|
||||
HMENU hMenu;
|
||||
LPVOID lpParam;
|
||||
HWND hWndParent;
|
||||
LPSTR lpClassName;
|
||||
LPSTR lpWindowName;
|
||||
HINSTANCE hInstance;
|
||||
WNDCLASSEXA* lpwcx;
|
||||
};
|
||||
typedef struct _WINPR_WND WINPR_WND;
|
||||
|
||||
#endif /* WINPR_WND_PRIVATE_H */
|
Loading…
Reference in New Issue