Convert NativeFont control to unicode, use hbrBackground as in native.

This commit is contained in:
Dmitry Timoshkov 2004-11-01 21:08:10 +00:00 committed by Alexandre Julliard
parent 5656ca0d6c
commit d3eb0550f5
1 changed files with 25 additions and 31 deletions

View File

@ -28,12 +28,11 @@
*/ */
#include <stdarg.h> #include <stdarg.h>
#include <string.h>
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "winnls.h"
#include "commctrl.h" #include "commctrl.h"
#include "comctl32.h" #include "comctl32.h"
#include "wine/debug.h" #include "wine/debug.h"
@ -42,12 +41,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(nativefont);
typedef struct typedef struct
{ {
DWORD dwDummy; /* just to keep the compiler happy ;-) */ HWND hwndSelf; /* my own handle */
} NATIVEFONT_INFO; } NATIVEFONT_INFO;
#define NATIVEFONT_GetInfoPtr(hwnd) ((NATIVEFONT_INFO *)GetWindowLongPtrW (hwnd, 0)) #define NATIVEFONT_GetInfoPtr(hwnd) ((NATIVEFONT_INFO *)GetWindowLongPtrW (hwnd, 0))
static LRESULT static LRESULT
NATIVEFONT_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) NATIVEFONT_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
{ {
@ -57,45 +55,40 @@ NATIVEFONT_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr = (NATIVEFONT_INFO *)Alloc (sizeof(NATIVEFONT_INFO)); infoPtr = (NATIVEFONT_INFO *)Alloc (sizeof(NATIVEFONT_INFO));
SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
/* initialize info structure */ /* initialize info structure */
infoPtr->hwndSelf = hwnd;
return 0; return 0;
} }
static LRESULT static LRESULT
NATIVEFONT_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) NATIVEFONT_Destroy (NATIVEFONT_INFO *infoPtr)
{ {
NATIVEFONT_INFO *infoPtr = NATIVEFONT_GetInfoPtr (hwnd); /* free control info data */
SetWindowLongPtrW( infoPtr->hwndSelf, 0, 0 );
/* free comboex info data */
Free (infoPtr); Free (infoPtr);
SetWindowLongPtrW( hwnd, 0, 0 );
return 0; return 0;
} }
static LRESULT WINAPI static LRESULT WINAPI
NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
if (!NATIVEFONT_GetInfoPtr(hwnd) && (uMsg != WM_CREATE)) NATIVEFONT_INFO *infoPtr = NATIVEFONT_GetInfoPtr(hwnd);
return DefWindowProcA( hwnd, uMsg, wParam, lParam );
TRACE("hwnd=%p msg=%04x wparam=%08x lparam=%08lx\n",
hwnd, uMsg, wParam, lParam);
if (!infoPtr && (uMsg != WM_CREATE))
return DefWindowProcW( hwnd, uMsg, wParam, lParam );
switch (uMsg) switch (uMsg)
{ {
case WM_CREATE: case WM_CREATE:
return NATIVEFONT_Create (hwnd, wParam, lParam); return NATIVEFONT_Create (hwnd, wParam, lParam);
case WM_DESTROY: case WM_DESTROY:
return NATIVEFONT_Destroy (hwnd, wParam, lParam); return NATIVEFONT_Destroy (infoPtr);
case WM_MOVE: case WM_MOVE:
case WM_SIZE: case WM_SIZE:
@ -105,12 +98,13 @@ NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_SETFONT: case WM_SETFONT:
case WM_GETDLGCODE: case WM_GETDLGCODE:
/* FIXME("message %04x seen but stubbed\n", uMsg); */ /* FIXME("message %04x seen but stubbed\n", uMsg); */
return DefWindowProcA (hwnd, uMsg, wParam, lParam); return DefWindowProcW (hwnd, uMsg, wParam, lParam);
default: default:
ERR("unknown msg %04x wp=%08x lp=%08lx\n", if ((uMsg >= WM_USER) && (uMsg < WM_APP))
ERR("unknown msg %04x wp=%08x lp=%08lx\n",
uMsg, wParam, lParam); uMsg, wParam, lParam);
return DefWindowProcA (hwnd, uMsg, wParam, lParam); return DefWindowProcW (hwnd, uMsg, wParam, lParam);
} }
return 0; return 0;
} }
@ -119,23 +113,23 @@ NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
VOID VOID
NATIVEFONT_Register (void) NATIVEFONT_Register (void)
{ {
WNDCLASSA wndClass; WNDCLASSW wndClass;
ZeroMemory (&wndClass, sizeof(WNDCLASSA)); ZeroMemory (&wndClass, sizeof(WNDCLASSW));
wndClass.style = CS_GLOBALCLASS; wndClass.style = CS_GLOBALCLASS;
wndClass.lpfnWndProc = (WNDPROC)NATIVEFONT_WindowProc; wndClass.lpfnWndProc = (WNDPROC)NATIVEFONT_WindowProc;
wndClass.cbClsExtra = 0; wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = sizeof(NATIVEFONT_INFO *); wndClass.cbWndExtra = sizeof(NATIVEFONT_INFO *);
wndClass.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW); wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wndClass.lpszClassName = WC_NATIVEFONTCTLA; wndClass.lpszClassName = WC_NATIVEFONTCTLW;
RegisterClassA (&wndClass); RegisterClassW (&wndClass);
} }
VOID VOID
NATIVEFONT_Unregister (void) NATIVEFONT_Unregister (void)
{ {
UnregisterClassA (WC_NATIVEFONTCTLA, NULL); UnregisterClassW (WC_NATIVEFONTCTLW, NULL);
} }