From de42428f23f38311d97559d7edc19b5051d1bce9 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 10 Aug 2001 22:51:42 +0000 Subject: [PATCH] Removed a number of direct accesses to the WND structure, replacing them by API calls. --- controls/button.c | 552 ++++++++++----------- controls/combo.c | 290 ++++++----- controls/desktop.c | 78 ++- controls/edit.c | 1091 +++++++++++++++++++++--------------------- controls/icontitle.c | 149 +++--- controls/listbox.c | 770 ++++++++++++++--------------- controls/menu.c | 430 +++++++---------- controls/scroll.c | 64 ++- controls/static.c | 289 +++++------ dlls/user/controls.h | 16 +- dlls/x11drv/winpos.c | 18 +- include/nonclient.h | 22 +- include/winpos.h | 17 +- include/x11drv.h | 3 - windows/defwnd.c | 20 +- windows/mdi.c | 6 +- windows/nonclient.c | 113 +++-- windows/win.c | 6 +- windows/winpos.c | 148 +++--- 19 files changed, 1907 insertions(+), 2175 deletions(-) diff --git a/controls/button.c b/controls/button.c index d3fd297a60b..20ac8159626 100644 --- a/controls/button.c +++ b/controls/button.c @@ -6,8 +6,8 @@ */ #include -#include /* for abs() */ -#include "win.h" +#include + #include "winbase.h" #include "windef.h" #include "wingdi.h" @@ -15,16 +15,11 @@ #include "controls.h" #include "user.h" -/* Note: under MS-Windows, state is a BYTE and this structure is - * only 3 bytes long. I don't think there are programs out there - * broken enough to rely on this :-) - */ -typedef struct -{ - WORD state; /* Current state */ - HFONT16 hFont; /* Button font (or 0 for system font) */ - HANDLE hImage; /* Handle to the image or the icon */ -} BUTTONINFO; +/* GetWindowLong offsets for window extra information */ +#define STATE_GWL_OFFSET 0 +#define HFONT_GWL_OFFSET (sizeof(LONG)) +#define HIMAGE_GWL_OFFSET (2*sizeof(LONG)) +#define NB_EXTRA_BYTES (3*sizeof(LONG)) /* Button state values */ #define BUTTON_UNCHECKED 0x00 @@ -38,13 +33,12 @@ typedef struct #define BUTTON_UNKNOWN2 0x20 #define BUTTON_UNKNOWN3 0x10 -static void PB_Paint( WND *wndPtr, HDC hDC, WORD action ); -static void CB_Paint( WND *wndPtr, HDC hDC, WORD action ); -static void GB_Paint( WND *wndPtr, HDC hDC, WORD action ); -static void UB_Paint( WND *wndPtr, HDC hDC, WORD action ); -static void OB_Paint( WND *wndPtr, HDC hDC, WORD action ); -static void BUTTON_CheckAutoRadioButton( WND *wndPtr ); -static void BUTTON_DrawPushButton( WND *wndPtr, HDC hDC, WORD action, BOOL pushedState); +static void PB_Paint( HWND hwnd, HDC hDC, UINT action ); +static void CB_Paint( HWND hwnd, HDC hDC, UINT action ); +static void GB_Paint( HWND hwnd, HDC hDC, UINT action ); +static void UB_Paint( HWND hwnd, HDC hDC, UINT action ); +static void OB_Paint( HWND hwnd, HDC hDC, UINT action ); +static void BUTTON_CheckAutoRadioButton( HWND hwnd ); static LRESULT WINAPI ButtonWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); static LRESULT WINAPI ButtonWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); @@ -66,7 +60,7 @@ static const WORD maxCheckState[MAX_BTN_TYPE] = BUTTON_UNCHECKED /* BS_OWNERDRAW */ }; -typedef void (*pfPaint)( WND *wndPtr, HDC hdc, WORD action ); +typedef void (*pfPaint)( HWND hwnd, HDC hdc, UINT action ); static const pfPaint btnPaintFunc[MAX_BTN_TYPE] = { @@ -84,16 +78,6 @@ static const pfPaint btnPaintFunc[MAX_BTN_TYPE] = OB_Paint /* BS_OWNERDRAW */ }; -#define PAINT_BUTTON(wndPtr,style,action) \ - if (btnPaintFunc[style]) { \ - HDC hdc = GetDC( (wndPtr)->hwndSelf ); \ - (btnPaintFunc[style])(wndPtr,hdc,action); \ - ReleaseDC( (wndPtr)->hwndSelf, hdc ); } - -#define BUTTON_SEND_CTLCOLOR(wndPtr,hdc) \ - SendMessageW( GetParent((wndPtr)->hwndSelf), WM_CTLCOLORBTN, \ - (hdc), (wndPtr)->hwndSelf ) - static HBITMAP hbitmapCheckBoxes = 0; static WORD checkBoxWidth = 0, checkBoxHeight = 0; @@ -107,25 +91,68 @@ const struct builtin_class_descr BUTTON_builtin_class = CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC, /* style */ ButtonWndProcA, /* procA */ ButtonWndProcW, /* procW */ - sizeof(BUTTONINFO), /* extra */ + NB_EXTRA_BYTES, /* extra */ IDC_ARROWA, /* cursor */ 0 /* brush */ }; +inline static LONG get_button_state( HWND hwnd ) +{ + return GetWindowLongA( hwnd, STATE_GWL_OFFSET ); +} + +inline static void set_button_state( HWND hwnd, LONG state ) +{ + SetWindowLongA( hwnd, STATE_GWL_OFFSET, state ); +} + +inline static HFONT get_button_font( HWND hwnd ) +{ + return GetWindowLongA( hwnd, HFONT_GWL_OFFSET ); +} + +inline static void set_button_font( HWND hwnd, HFONT font ) +{ + SetWindowLongA( hwnd, HFONT_GWL_OFFSET, font ); +} + +inline static UINT get_button_type( LONG window_style ) +{ + return (window_style & 0x0f); +} + +/* paint a button of any type */ +inline static void paint_button( HWND hwnd, LONG style, UINT action ) +{ + if (btnPaintFunc[style] && IsWindowVisible(hwnd)) + { + HDC hdc = GetDC( hwnd ); + btnPaintFunc[style]( hwnd, hdc, action ); + ReleaseDC( hwnd, hdc ); + } +} + +/* retrieve the button text; returned buffer must be freed by caller */ +inline static WCHAR *get_button_text( HWND hwnd ) +{ + INT len = GetWindowTextLengthW( hwnd ); + WCHAR *buffer = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ); + if (buffer) GetWindowTextW( hwnd, buffer, len + 1 ); + return buffer; +} + /*********************************************************************** - * ButtonWndProc_locked - * - * Called with window lock held. + * ButtonWndProc_common */ -static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, - WPARAM wParam, LPARAM lParam, BOOL unicode ) +static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, + WPARAM wParam, LPARAM lParam, BOOL unicode ) { RECT rect; - HWND hWnd = wndPtr->hwndSelf; POINT pt; - BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra; - LONG style = wndPtr->dwStyle & 0x0f; + LONG style = GetWindowLongA( hWnd, GWL_STYLE ); + UINT btn_type = get_button_type( style ); + LONG state; HANDLE oldHbitmap; pt.x = LOWORD(lParam); @@ -134,7 +161,7 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, switch (uMsg) { case WM_GETDLGCODE: - switch(style) + switch(btn_type) { case BS_PUSHBUTTON: return DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON; case BS_DEFPUSHBUTTON: return DLGC_BUTTON | DLGC_DEFPUSHBUTTON; @@ -144,7 +171,7 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, } case WM_ENABLE: - PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE ); + paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); break; case WM_CREATE: @@ -156,23 +183,21 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, checkBoxWidth = bmp.bmWidth / 4; checkBoxHeight = bmp.bmHeight / 3; } - if (style < 0L || style >= MAX_BTN_TYPE) + if (btn_type < 0L || btn_type >= MAX_BTN_TYPE) return -1; /* abort */ - infoPtr->state = BUTTON_UNCHECKED; - infoPtr->hFont = 0; - infoPtr->hImage = 0; + set_button_state( hWnd, BUTTON_UNCHECKED ); return 0; case WM_ERASEBKGND: return 1; case WM_PAINT: - if (btnPaintFunc[style]) + if (btnPaintFunc[btn_type]) { PAINTSTRUCT ps; HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps ); int nOldMode = SetBkMode( hdc, OPAQUE ); - (btnPaintFunc[style])( wndPtr, hdc, ODA_DRAWENTIRE ); + (btnPaintFunc[btn_type])( hWnd, hdc, ODA_DRAWENTIRE ); SetBkMode(hdc, nOldMode); /* reset painting mode */ if( !wParam ) EndPaint( hWnd, &ps ); } @@ -182,17 +207,18 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, if (wParam == VK_SPACE) { SendMessageW( hWnd, BM_SETSTATE, TRUE, 0 ); - infoPtr->state |= BUTTON_BTNPRESSED; + set_button_state( hWnd, get_button_state( hWnd ) | BUTTON_BTNPRESSED ); } break; case WM_LBUTTONDBLCLK: - if(wndPtr->dwStyle & BS_NOTIFY || - style==BS_RADIOBUTTON || - style==BS_USERBUTTON || - style==BS_OWNERDRAW) { + if(style & BS_NOTIFY || + btn_type == BS_RADIOBUTTON || + btn_type == BS_USERBUTTON || + btn_type == BS_OWNERDRAW) + { SendMessageW( GetParent(hWnd), WM_COMMAND, - MAKEWPARAM( wndPtr->wIDmenu, BN_DOUBLECLICKED ), hWnd); + MAKEWPARAM( GetWindowLongA(hWnd,GWL_ID), BN_DOUBLECLICKED ), hWnd); break; } /* fall through */ @@ -200,7 +226,7 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, SetCapture( hWnd ); SetFocus( hWnd ); SendMessageW( hWnd, BM_SETSTATE, TRUE, 0 ); - infoPtr->state |= BUTTON_BTNPRESSED; + set_button_state( hWnd, get_button_state( hWnd ) | BUTTON_BTNPRESSED ); break; case WM_KEYUP: @@ -208,9 +234,12 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, break; /* fall through */ case WM_LBUTTONUP: - if (!(infoPtr->state & BUTTON_BTNPRESSED)) break; - infoPtr->state &= BUTTON_NSTATES; - if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) { + state = get_button_state( hWnd ); + if (!(state & BUTTON_BTNPRESSED)) break; + state &= BUTTON_NSTATES; + set_button_state( hWnd, state ); + if (!(state & BUTTON_HIGHLIGHTED)) + { ReleaseCapture(); break; } @@ -219,31 +248,32 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, GetClientRect( hWnd, &rect ); if (uMsg == WM_KEYUP || PtInRect( &rect, pt )) { - switch(style) + state = get_button_state( hWnd ); + switch(btn_type) { case BS_AUTOCHECKBOX: - SendMessageW( hWnd, BM_SETCHECK, - !(infoPtr->state & BUTTON_CHECKED), 0 ); + SendMessageW( hWnd, BM_SETCHECK, !(state & BUTTON_CHECKED), 0 ); break; case BS_AUTORADIOBUTTON: SendMessageW( hWnd, BM_SETCHECK, TRUE, 0 ); break; case BS_AUTO3STATE: SendMessageW( hWnd, BM_SETCHECK, - (infoPtr->state & BUTTON_3STATE) ? 0 : - ((infoPtr->state & 3) + 1), 0 ); + (state & BUTTON_3STATE) ? 0 : ((state & 3) + 1), 0 ); break; } SendMessageW( GetParent(hWnd), WM_COMMAND, - MAKEWPARAM( wndPtr->wIDmenu, BN_CLICKED ), hWnd); + MAKEWPARAM( GetWindowLongA(hWnd,GWL_ID), BN_CLICKED ), hWnd); } break; case WM_CAPTURECHANGED: - if (infoPtr->state & BUTTON_BTNPRESSED) { - infoPtr->state &= BUTTON_NSTATES; - if (infoPtr->state & BUTTON_HIGHLIGHTED) - SendMessageW( hWnd, BM_SETSTATE, FALSE, 0 ); + state = get_button_state( hWnd ); + if (state & BUTTON_BTNPRESSED) + { + state &= BUTTON_NSTATES; + set_button_state( hWnd, state ); + if (state & BUTTON_HIGHLIGHTED) SendMessageW( hWnd, BM_SETSTATE, FALSE, 0 ); } break; @@ -256,39 +286,37 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, break; case WM_SETTEXT: - if (unicode) DEFWND_SetTextW( wndPtr, (LPCWSTR)lParam ); - else DEFWND_SetTextA( wndPtr, (LPCSTR)lParam ); - if( wndPtr->dwStyle & WS_VISIBLE ) - PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE ); + if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam ); + else DefWindowProcA( hWnd, WM_SETTEXT, wParam, lParam ); + paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); return 1; /* success. FIXME: check text length */ case WM_SETFONT: - infoPtr->hFont = (HFONT16)wParam; - if (lParam && (wndPtr->dwStyle & WS_VISIBLE)) - PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE ); + set_button_font( hWnd, wParam ); + if (lParam) paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); break; case WM_GETFONT: - return infoPtr->hFont; + return get_button_font( hWnd ); case WM_SETFOCUS: - if ((style == BS_RADIOBUTTON || style == BS_AUTORADIOBUTTON) && (GetCapture() != hWnd) && + if ((btn_type == BS_RADIOBUTTON || btn_type == BS_AUTORADIOBUTTON) && (GetCapture() != hWnd) && !(SendMessageW(hWnd, BM_GETCHECK, 0, 0) & BST_CHECKED)) { /* The notification is sent when the button (BS_AUTORADIOBUTTON) is unchecked and the focus was not given by a mouse click. */ - if (style == BS_AUTORADIOBUTTON) - SendMessageW( hWnd, BM_SETCHECK, BUTTON_CHECKED, 0 ); - SendMessageW( GetParent(hWnd), WM_COMMAND, - MAKEWPARAM( wndPtr->wIDmenu, BN_CLICKED ), hWnd); + if (btn_type == BS_AUTORADIOBUTTON) + SendMessageW( hWnd, BM_SETCHECK, BUTTON_CHECKED, 0 ); + SendMessageW( GetParent(hWnd), WM_COMMAND, + MAKEWPARAM( GetWindowLongA(hWnd,GWL_ID), BN_CLICKED ), hWnd); } - infoPtr->state |= BUTTON_HASFOCUS; - PAINT_BUTTON( wndPtr, style, ODA_FOCUS ); + set_button_state( hWnd, get_button_state(hWnd) | BUTTON_HASFOCUS ); + paint_button( hWnd, btn_type, ODA_FOCUS ); break; case WM_KILLFOCUS: - infoPtr->state &= ~BUTTON_HASFOCUS; - PAINT_BUTTON( wndPtr, style, ODA_FOCUS ); + set_button_state( hWnd, get_button_state(hWnd) & ~BUTTON_HASFOCUS ); + paint_button( hWnd, btn_type, ODA_FOCUS ); InvalidateRect( hWnd, NULL, TRUE ); break; @@ -299,13 +327,13 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, case BM_SETSTYLE16: case BM_SETSTYLE: if ((wParam & 0x0f) >= MAX_BTN_TYPE) break; - wndPtr->dwStyle = (wndPtr->dwStyle & 0xfffffff0) - | (wParam & 0x0000000f); - style = wndPtr->dwStyle & 0x0000000f; + btn_type = wParam & 0x0f; + style = (style & ~0x0f) | btn_type; + SetWindowLongA( hWnd, GWL_STYLE, style ); /* Only redraw if lParam flag is set.*/ if (lParam) - PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE ); + paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); break; @@ -315,82 +343,70 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, break; case BM_SETIMAGE: - /* Check that image format confirm button style */ - if ((wndPtr->dwStyle & (BS_BITMAP|BS_ICON)) == BS_BITMAP) - { - if (wParam != (WPARAM) IMAGE_BITMAP) - return (HICON)0; - } - else if ((wndPtr->dwStyle & (BS_BITMAP|BS_ICON)) == BS_ICON) - { - if (wParam != (WPARAM) IMAGE_ICON) - return (HICON)0; - } else - return (HICON)0; - - oldHbitmap = infoPtr->hImage; - infoPtr->hImage = (HANDLE) lParam; + /* Check that image format matches button style */ + switch (style & (BS_BITMAP|BS_ICON)) + { + case BS_BITMAP: + if (wParam != IMAGE_BITMAP) return 0; + break; + case BS_ICON: + if (wParam != IMAGE_ICON) return 0; + break; + default: + return 0; + } + oldHbitmap = SetWindowLongA( hWnd, HIMAGE_GWL_OFFSET, lParam ); InvalidateRect( hWnd, NULL, FALSE ); return oldHbitmap; case BM_GETIMAGE: - if ((wndPtr->dwStyle & (BS_BITMAP|BS_ICON)) == BS_BITMAP) - { - if (wParam != (WPARAM) IMAGE_BITMAP) - return (HICON)0; - } - else if ((wndPtr->dwStyle & (BS_BITMAP|BS_ICON)) == BS_ICON) - { - if (wParam != (WPARAM) IMAGE_ICON) - return (HICON)0; - } else - return (HICON)0; - return infoPtr->hImage; + return GetWindowLongA( hWnd, HIMAGE_GWL_OFFSET ); case BM_GETCHECK16: case BM_GETCHECK: - return infoPtr->state & 3; + return get_button_state( hWnd ) & 3; case BM_SETCHECK16: case BM_SETCHECK: - if (wParam > maxCheckState[style]) wParam = maxCheckState[style]; - if ((infoPtr->state & 3) != wParam) + if (wParam > maxCheckState[btn_type]) wParam = maxCheckState[btn_type]; + state = get_button_state( hWnd ); + if ((state & 3) != wParam) { - if ((style == BS_RADIOBUTTON) || (style == BS_AUTORADIOBUTTON)) + if ((btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON)) { - if (wParam) - wndPtr->dwStyle |= WS_TABSTOP; - else - wndPtr->dwStyle &= ~WS_TABSTOP; + if (wParam) style |= WS_TABSTOP; + else style &= ~WS_TABSTOP; + SetWindowLongA( hWnd, GWL_STYLE, style ); } - infoPtr->state = (infoPtr->state & ~3) | wParam; - PAINT_BUTTON( wndPtr, style, ODA_SELECT ); + set_button_state( hWnd, (state & ~3) | wParam ); + paint_button( hWnd, btn_type, ODA_SELECT ); } - if ((style == BS_AUTORADIOBUTTON) && (wParam == BUTTON_CHECKED)) - BUTTON_CheckAutoRadioButton( wndPtr ); + if ((btn_type == BS_AUTORADIOBUTTON) && (wParam == BUTTON_CHECKED) && (style & WS_CHILD)) + BUTTON_CheckAutoRadioButton( hWnd ); break; case BM_GETSTATE16: case BM_GETSTATE: - return infoPtr->state; + return get_button_state( hWnd ); case BM_SETSTATE16: case BM_SETSTATE: + state = get_button_state( hWnd ); if (wParam) { - if (infoPtr->state & BUTTON_HIGHLIGHTED) break; - infoPtr->state |= BUTTON_HIGHLIGHTED; + if (state & BUTTON_HIGHLIGHTED) break; + set_button_state( hWnd, state | BUTTON_HIGHLIGHTED ); } else { - if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break; - infoPtr->state &= ~BUTTON_HIGHLIGHTED; + if (!(state & BUTTON_HIGHLIGHTED)) break; + set_button_state( hWnd, state & ~BUTTON_HIGHLIGHTED ); } - PAINT_BUTTON( wndPtr, style, ODA_SELECT ); + paint_button( hWnd, btn_type, ODA_SELECT ); break; case WM_NCHITTEST: - if(style == BS_GROUPBOX) return HTTRANSPARENT; + if(btn_type == BS_GROUPBOX) return HTTRANSPARENT; /* fall through */ default: return unicode ? DefWindowProcW(hWnd, uMsg, wParam, lParam) : @@ -407,15 +423,8 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, */ static LRESULT WINAPI ButtonWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { - LRESULT res = 0; - WND *wndPtr = WIN_FindWndPtr(hWnd); - - if (wndPtr) - { - res = ButtonWndProc_locked(wndPtr,uMsg,wParam,lParam,TRUE); - WIN_ReleaseWndPtr(wndPtr); - } - return res; + if (!IsWindow( hWnd )) return 0; + return ButtonWndProc_common( hWnd, uMsg, wParam, lParam, TRUE ); } @@ -424,36 +433,11 @@ static LRESULT WINAPI ButtonWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARA */ static LRESULT WINAPI ButtonWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { - LRESULT res = 0; - WND *wndPtr = WIN_FindWndPtr(hWnd); - - if (wndPtr) - { - res = ButtonWndProc_locked(wndPtr,uMsg,wParam,lParam,FALSE); - WIN_ReleaseWndPtr(wndPtr); - } - return res; + if (!IsWindow( hWnd )) return 0; + return ButtonWndProc_common( hWnd, uMsg, wParam, lParam, FALSE ); } -/********************************************************************** - * Push Button Functions - */ -static void PB_Paint( WND *wndPtr, HDC hDC, WORD action ) -{ - BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra; - BOOL bHighLighted = (infoPtr->state & BUTTON_HIGHLIGHTED); - - /* - * Delegate this to the more generic pushbutton painting - * method. - */ - BUTTON_DrawPushButton(wndPtr, - hDC, - action, - bHighLighted); -} - /********************************************************************** * Convert button styles to flags used by DrawText. * TODO: handle WS_EX_RIGHT extended style. @@ -478,15 +462,14 @@ static UINT BUTTON_BStoDT(DWORD style) case BS_CENTER: dtStyle |= DT_CENTER; break; default: /* Pushbutton's text is centered by default */ - if ((style & 0x0F) <= BS_DEFPUSHBUTTON) - dtStyle |= DT_CENTER; + if (get_button_type(style) <= BS_DEFPUSHBUTTON) dtStyle |= DT_CENTER; /* all other flavours have left aligned text */ } /* DrawText ignores vertical alignment for multiline text, * but we use these flags to align label manualy. */ - if ((style & 0x0F) != BS_GROUPBOX) + if (get_button_type(style) != BS_GROUPBOX) { switch (style & BS_VCENTER) { @@ -513,27 +496,32 @@ static UINT BUTTON_BStoDT(DWORD style) * (pushed, etc.). If there is nothing to draw (no text/image) output * rectangle is empty, and return value is (UINT)-1. */ -static UINT BUTTON_CalcLabelRect(WND *wndPtr, HDC hdc, RECT *rc) +static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc) { - BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra; + LONG style = GetWindowLongA( hwnd, GWL_STYLE ); + WCHAR *text; ICONINFO iconInfo; BITMAP bm; - UINT dtStyle = BUTTON_BStoDT(wndPtr->dwStyle); + UINT dtStyle = BUTTON_BStoDT(style); RECT r = *rc; INT n; /* Calculate label rectangle according to label type */ - switch (wndPtr->dwStyle & (BS_ICON|BS_BITMAP)) + switch (style & (BS_ICON|BS_BITMAP)) { case BS_TEXT: - if (wndPtr->text && wndPtr->text[0]) - DrawTextW(hdc, wndPtr->text, -1, &r, dtStyle | DT_CALCRECT); - else - goto empty_rect; - break; + if (!(text = get_button_text( hwnd ))) goto empty_rect; + if (!text[0]) + { + HeapFree( GetProcessHeap(), 0, text ); + goto empty_rect; + } + DrawTextW(hdc, text, -1, &r, dtStyle | DT_CALCRECT); + HeapFree( GetProcessHeap(), 0, text ); + break; case BS_ICON: - if (!GetIconInfo((HICON)infoPtr->hImage, &iconInfo)) + if (!GetIconInfo((HICON)GetWindowLongA( hwnd, HIMAGE_GWL_OFFSET ), &iconInfo)) goto empty_rect; GetObjectW (iconInfo.hbmColor, sizeof(BITMAP), &bm); @@ -546,7 +534,7 @@ static UINT BUTTON_CalcLabelRect(WND *wndPtr, HDC hdc, RECT *rc) break; case BS_BITMAP: - if (!GetObjectW (infoPtr->hImage, sizeof(BITMAP), &bm)) + if (!GetObjectW( (HANDLE)GetWindowLongA( hwnd, HIMAGE_GWL_OFFSET ), sizeof(BITMAP), &bm)) goto empty_rect; r.right = r.left + bm.bmWidth; @@ -617,43 +605,46 @@ static BOOL CALLBACK BUTTON_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int * * Common function for drawing button label. */ -static void BUTTON_DrawLabel(WND *wndPtr, HDC hdc, UINT dtFlags, RECT *rc) +static void BUTTON_DrawLabel(HWND hwnd, HDC hdc, UINT dtFlags, RECT *rc) { - BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra; DRAWSTATEPROC lpOutputProc = NULL; LPARAM lp; WPARAM wp = 0; HBRUSH hbr = 0; - UINT flags = IsWindowEnabled(wndPtr->hwndSelf) ? DSS_NORMAL : DSS_DISABLED; + UINT flags = IsWindowEnabled(hwnd) ? DSS_NORMAL : DSS_DISABLED; + LONG state = get_button_state( hwnd ); + LONG style = GetWindowLongA( hwnd, GWL_STYLE ); + WCHAR *text = NULL; /* Fixme: To draw disabled label in Win31 look-and-feel, we probably * must use DSS_MONO flag and COLOR_GRAYTEXT brush (or maybe DSS_UNION). * I don't have Win31 on hand to verify that, so I leave it as is. */ - if ((wndPtr->dwStyle & BS_PUSHLIKE) && (infoPtr->state & BUTTON_3STATE)) + if ((style & BS_PUSHLIKE) && (state & BUTTON_3STATE)) { hbr = GetSysColorBrush(COLOR_GRAYTEXT); flags |= DSS_MONO; } - switch (wndPtr->dwStyle & (BS_ICON|BS_BITMAP)) + switch (style & (BS_ICON|BS_BITMAP)) { case BS_TEXT: /* DST_COMPLEX -- is 0 */ lpOutputProc = BUTTON_DrawTextCallback; - lp = (LPARAM)wndPtr->text; + if (!(text = get_button_text( hwnd ))) return; + lp = (LPARAM)text; wp = (WPARAM)dtFlags; break; case BS_ICON: flags |= DST_ICON; - lp = (LPARAM)infoPtr->hImage; + lp = GetWindowLongA( hwnd, HIMAGE_GWL_OFFSET ); break; case BS_BITMAP: flags |= DST_BITMAP; - lp = (LPARAM)infoPtr->hImage; + lp = GetWindowLongA( hwnd, HIMAGE_GWL_OFFSET ); break; default: @@ -662,19 +653,14 @@ static void BUTTON_DrawLabel(WND *wndPtr, HDC hdc, UINT dtFlags, RECT *rc) DrawStateW(hdc, hbr, lpOutputProc, lp, wp, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, flags); + if (text) HeapFree( GetProcessHeap(), 0, text ); } /********************************************************************** - * This method will actually do the drawing of the pushbutton - * depending on it's state and the pushedState parameter. + * Push Button Functions */ -static void BUTTON_DrawPushButton( - WND* wndPtr, - HDC hDC, - WORD action, - BOOL pushedState ) +static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) { - BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra; RECT rc, focus_rect, r; UINT dtFlags; HRGN hRgn; @@ -682,12 +668,16 @@ static void BUTTON_DrawPushButton( HBRUSH hOldBrush; INT oldBkMode; COLORREF oldTxtColor; + HFONT hFont; + LONG state = get_button_state( hwnd ); + LONG style = GetWindowLongA( hwnd, GWL_STYLE ); + BOOL pushedState = (state & BUTTON_HIGHLIGHTED); - GetClientRect( wndPtr->hwndSelf, &rc ); + GetClientRect( hwnd, &rc ); /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */ - if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont ); - BUTTON_SEND_CTLCOLOR( wndPtr, hDC ); + if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); + SendMessageW( GetParent(hwnd), WM_CTLCOLORBTN, hDC, hwnd ); hOldPen = (HPEN)SelectObject(hDC, GetSysColorPen(COLOR_WINDOWFRAME)); hOldBrush =(HBRUSH)SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE)); oldBkMode = SetBkMode(hDC, TRANSPARENT); @@ -704,7 +694,7 @@ static void BUTTON_DrawPushButton( InflateRect( &rc, -1, -1 ); } - if ((wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON) + if (get_button_type(style) == BS_DEFPUSHBUTTON) { Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); InflateRect( &rc, -1, -1 ); @@ -728,17 +718,17 @@ static void BUTTON_DrawPushButton( { UINT uState = DFCS_BUTTONPUSH | DFCS_ADJUSTRECT; - if (wndPtr->dwStyle & BS_FLAT) + if (style & BS_FLAT) uState |= DFCS_MONO; else if (pushedState) { - if ( (wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON ) + if (get_button_type(style) == BS_DEFPUSHBUTTON ) uState |= DFCS_FLAT; else uState |= DFCS_PUSHED; } - if (infoPtr->state & (BUTTON_CHECKED | BUTTON_3STATE)) + if (state & (BUTTON_CHECKED | BUTTON_3STATE)) uState |= DFCS_CHECKED; DrawFrameControl( hDC, &rc, DFC_BUTTON, uState ); @@ -748,7 +738,7 @@ static void BUTTON_DrawPushButton( /* draw button label */ r = rc; - dtFlags = BUTTON_CalcLabelRect(wndPtr, hDC, &r); + dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &r); if (dtFlags == (UINT)-1L) goto cleanup; @@ -767,13 +757,13 @@ static void BUTTON_DrawPushButton( oldTxtColor = SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) ); - BUTTON_DrawLabel(wndPtr, hDC, dtFlags, &r); + BUTTON_DrawLabel(hwnd, hDC, dtFlags, &r); SetTextColor( hDC, oldTxtColor ); SelectClipRgn(hDC, 0); DeleteObject(hRgn); - if (infoPtr->state & BUTTON_HASFOCUS) + if (state & BUTTON_HASFOCUS) { InflateRect( &focus_rect, -1, -1 ); IntersectRect(&focus_rect, &focus_rect, &rc); @@ -790,37 +780,34 @@ static void BUTTON_DrawPushButton( * Check Box & Radio Button Functions */ -static void CB_Paint( WND *wndPtr, HDC hDC, WORD action ) +static void CB_Paint( HWND hwnd, HDC hDC, UINT action ) { RECT rbox, rtext, client; HBRUSH hBrush; int delta; - BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra; UINT dtFlags; HRGN hRgn; + HFONT hFont; + LONG state = get_button_state( hwnd ); + LONG style = GetWindowLongA( hwnd, GWL_STYLE ); - if (wndPtr->dwStyle & BS_PUSHLIKE) + if (style & BS_PUSHLIKE) { - BOOL bHighLighted = (infoPtr->state & BUTTON_HIGHLIGHTED); - - BUTTON_DrawPushButton(wndPtr, - hDC, - action, - bHighLighted); + PB_Paint( hwnd, hDC, action ); return; } - GetClientRect(wndPtr->hwndSelf, &client); + GetClientRect(hwnd, &client); rbox = rtext = client; - if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont ); + if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); /* GetControlBrush16 sends WM_CTLCOLORBTN, plus it returns default brush * if parent didn't return valid one. So we kill two hares at once */ - hBrush = GetControlBrush16( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN ); + hBrush = GetControlBrush16( hwnd, hDC, CTLCOLOR_BTN ); - if (wndPtr->dwStyle & BS_LEFTTEXT) + if (style & BS_LEFTTEXT) { /* magic +4 is what CTL3D expects */ @@ -849,16 +836,16 @@ static void CB_Paint( WND *wndPtr, HDC hDC, WORD action ) /* Check in case the client area is smaller than the checkbox bitmap */ if (delta < 0) delta = 0; - if (infoPtr->state & BUTTON_HIGHLIGHTED) x += 2 * checkBoxWidth; - if (infoPtr->state & (BUTTON_CHECKED | BUTTON_3STATE)) x += checkBoxWidth; - if (((wndPtr->dwStyle & 0x0f) == BS_RADIOBUTTON) || - ((wndPtr->dwStyle & 0x0f) == BS_AUTORADIOBUTTON)) y += checkBoxHeight; - else if (infoPtr->state & BUTTON_3STATE) y += 2 * checkBoxHeight; + if (state & BUTTON_HIGHLIGHTED) x += 2 * checkBoxWidth; + if (state & (BUTTON_CHECKED | BUTTON_3STATE)) x += checkBoxWidth; + if ((get_button_type(style) == BS_RADIOBUTTON) || + (get_button_type(style) == BS_AUTORADIOBUTTON)) y += checkBoxHeight; + else if (state & BUTTON_3STATE) y += 2 * checkBoxHeight; /* The bitmap for the radio button is not aligned with the * left of the window, it is 1 pixel off. */ - if (((wndPtr->dwStyle & 0x0f) == BS_RADIOBUTTON) || - ((wndPtr->dwStyle & 0x0f) == BS_AUTORADIOBUTTON)) + if ((get_button_type(style) == BS_RADIOBUTTON) || + (get_button_type(style) == BS_AUTORADIOBUTTON)) rbox.left += 1; SelectObject( hMemDC, hbitmapCheckBoxes ); @@ -868,18 +855,17 @@ static void CB_Paint( WND *wndPtr, HDC hDC, WORD action ) } else { - UINT state; + UINT flags; - if (((wndPtr->dwStyle & 0x0f) == BS_RADIOBUTTON) || - ((wndPtr->dwStyle & 0x0f) == BS_AUTORADIOBUTTON)) state = DFCS_BUTTONRADIO; - else if (infoPtr->state & BUTTON_3STATE) state = DFCS_BUTTON3STATE; - else state = DFCS_BUTTONCHECK; + if ((get_button_type(style) == BS_RADIOBUTTON) || + (get_button_type(style) == BS_AUTORADIOBUTTON)) flags = DFCS_BUTTONRADIO; + else if (state & BUTTON_3STATE) flags = DFCS_BUTTON3STATE; + else flags = DFCS_BUTTONCHECK; - if (infoPtr->state & (BUTTON_CHECKED | BUTTON_3STATE)) state |= DFCS_CHECKED; - - if (infoPtr->state & BUTTON_HIGHLIGHTED) state |= DFCS_PUSHED; + if (state & (BUTTON_CHECKED | BUTTON_3STATE)) flags |= DFCS_CHECKED; + if (state & BUTTON_HIGHLIGHTED) flags |= DFCS_PUSHED; - if (wndPtr->dwStyle & WS_DISABLED) state |= DFCS_INACTIVE; + if (style & WS_DISABLED) flags |= DFCS_INACTIVE; /* rbox must have the correct height */ delta = rbox.bottom - rbox.top - checkBoxHeight; @@ -896,13 +882,13 @@ static void CB_Paint( WND *wndPtr, HDC hDC, WORD action ) rbox.bottom = rbox.top + checkBoxHeight; } - DrawFrameControl( hDC, &rbox, DFC_BUTTON, state ); + DrawFrameControl( hDC, &rbox, DFC_BUTTON, flags ); } } /* Draw label */ client = rtext; - dtFlags = BUTTON_CalcLabelRect(wndPtr, hDC, &rtext); + dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rtext); if (dtFlags == (UINT)-1L) /* Noting to draw */ return; @@ -911,11 +897,11 @@ static void CB_Paint( WND *wndPtr, HDC hDC, WORD action ) DeleteObject(hRgn); if (action == ODA_DRAWENTIRE) - BUTTON_DrawLabel(wndPtr, hDC, dtFlags, &rtext); + BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rtext); /* ... and focus */ if ((action == ODA_FOCUS) || - ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS))) + ((action == ODA_DRAWENTIRE) && (state & BUTTON_HASFOCUS))) { rtext.left--; rtext.right++; @@ -929,25 +915,22 @@ static void CB_Paint( WND *wndPtr, HDC hDC, WORD action ) /********************************************************************** * BUTTON_CheckAutoRadioButton * - * wndPtr is checked, uncheck every other auto radio button in group + * hwnd is checked, uncheck every other auto radio button in group */ -static void BUTTON_CheckAutoRadioButton( WND *wndPtr ) +static void BUTTON_CheckAutoRadioButton( HWND hwnd ) { HWND parent, sibling, start; - if (!(wndPtr->dwStyle & WS_CHILD)) return; - parent = wndPtr->parent->hwndSelf; - /* assure that starting control is not disabled or invisible */ - start = sibling = GetNextDlgGroupItem( parent, wndPtr->hwndSelf, TRUE ); + + parent = GetParent(hwnd); + /* make sure that starting control is not disabled or invisible */ + start = sibling = GetNextDlgGroupItem( parent, hwnd, TRUE ); do { - WND *tmpWnd; if (!sibling) break; - tmpWnd = WIN_FindWndPtr(sibling); - if ((wndPtr->hwndSelf != sibling) && - ((tmpWnd->dwStyle & 0x0f) == BS_AUTORADIOBUTTON)) + if ((hwnd != sibling) && + ((GetWindowLongA( sibling, GWL_STYLE) & 0x0f) == BS_AUTORADIOBUTTON)) SendMessageW( sibling, BM_SETCHECK, BUTTON_UNCHECKED, 0 ); sibling = GetNextDlgGroupItem( parent, sibling, FALSE ); - WIN_ReleaseWndPtr(tmpWnd); } while (sibling != start); } @@ -956,22 +939,21 @@ static void BUTTON_CheckAutoRadioButton( WND *wndPtr ) * Group Box Functions */ -static void GB_Paint( WND *wndPtr, HDC hDC, WORD action ) +static void GB_Paint( HWND hwnd, HDC hDC, UINT action ) { RECT rc, rcFrame; - BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra; HBRUSH hbr; + HFONT hFont; UINT dtFlags; + LONG style = GetWindowLongA( hwnd, GWL_STYLE ); if (action != ODA_DRAWENTIRE) return; - if (infoPtr->hFont) - SelectObject (hDC, infoPtr->hFont); + if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); /* GroupBox acts like static control, so it sends CTLCOLORSTATIC */ - hbr = GetControlBrush16( wndPtr->hwndSelf, hDC, CTLCOLOR_STATIC ); + hbr = GetControlBrush16( hwnd, hDC, CTLCOLOR_STATIC ); - - GetClientRect( wndPtr->hwndSelf, &rc); + GetClientRect( hwnd, &rc); if (TWEAK_WineLook == WIN31_LOOK) { HPEN hPrevPen = SelectObject( hDC, GetSysColorPen(COLOR_WINDOWFRAME)); @@ -987,12 +969,11 @@ static void GB_Paint( WND *wndPtr, HDC hDC, WORD action ) GetTextMetricsW (hDC, &tm); rcFrame.top += (tm.tmHeight / 2) - 1; - DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT | - ((wndPtr->dwStyle & BS_FLAT) ? BF_FLAT : 0)); + DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT | ((style & BS_FLAT) ? BF_FLAT : 0)); } InflateRect(&rc, -7, 1); - dtFlags = BUTTON_CalcLabelRect(wndPtr, hDC, &rc); + dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rc); if (dtFlags == (UINT)-1L) return; @@ -1007,7 +988,7 @@ static void GB_Paint( WND *wndPtr, HDC hDC, WORD action ) FillRect(hDC, &rc, hbr); rc.left++; rc.right--; rc.bottom--; - BUTTON_DrawLabel(wndPtr, hDC, dtFlags, &rc); + BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rc); } @@ -1015,22 +996,23 @@ static void GB_Paint( WND *wndPtr, HDC hDC, WORD action ) * User Button Functions */ -static void UB_Paint( WND *wndPtr, HDC hDC, WORD action ) +static void UB_Paint( HWND hwnd, HDC hDC, UINT action ) { RECT rc; HBRUSH hBrush; - BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra; + HFONT hFont; + LONG state = get_button_state( hwnd ); if (action == ODA_SELECT) return; - GetClientRect( wndPtr->hwndSelf, &rc); + GetClientRect( hwnd, &rc); - if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont ); - hBrush = GetControlBrush16( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN ); + if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); + hBrush = GetControlBrush16( hwnd, hDC, CTLCOLOR_BTN ); FillRect( hDC, &rc, hBrush ); if ((action == ODA_FOCUS) || - ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS))) + ((action == ODA_DRAWENTIRE) && (state & BUTTON_HASFOCUS))) DrawFocusRect( hDC, &rc ); } @@ -1039,40 +1021,38 @@ static void UB_Paint( WND *wndPtr, HDC hDC, WORD action ) * Ownerdrawn Button Functions */ -static void OB_Paint( WND *wndPtr, HDC hDC, WORD action ) +static void OB_Paint( HWND hwnd, HDC hDC, UINT action ) { - BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra; + LONG state = get_button_state( hwnd ); DRAWITEMSTRUCT dis; HRGN clipRegion; RECT clipRect; + UINT id = GetWindowLongA( hwnd, GWL_ID ); dis.CtlType = ODT_BUTTON; - dis.CtlID = wndPtr->wIDmenu; + dis.CtlID = id; dis.itemID = 0; dis.itemAction = action; - dis.itemState = ((infoPtr->state & BUTTON_HASFOCUS) ? ODS_FOCUS : 0) | - ((infoPtr->state & BUTTON_HIGHLIGHTED) ? ODS_SELECTED : 0) | - (IsWindowEnabled(wndPtr->hwndSelf) ? 0: ODS_DISABLED); - dis.hwndItem = wndPtr->hwndSelf; + dis.itemState = ((state & BUTTON_HASFOCUS) ? ODS_FOCUS : 0) | + ((state & BUTTON_HIGHLIGHTED) ? ODS_SELECTED : 0) | + (IsWindowEnabled(hwnd) ? 0: ODS_DISABLED); + dis.hwndItem = hwnd; dis.hDC = hDC; dis.itemData = 0; - GetClientRect( wndPtr->hwndSelf, &dis.rcItem ); + GetClientRect( hwnd, &dis.rcItem ); - clipRegion = CreateRectRgnIndirect(&dis.rcItem); + clipRegion = CreateRectRgnIndirect(&dis.rcItem); if (GetClipRgn(hDC, clipRegion) != 1) { DeleteObject(clipRegion); clipRegion=(HRGN)NULL; } clipRect = dis.rcItem; - DPtoLP(hDC, (LPPOINT) &clipRect, 2); + DPtoLP(hDC, (LPPOINT) &clipRect, 2); IntersectClipRect(hDC, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom); SetBkColor( hDC, GetSysColor( COLOR_BTNFACE ) ); - - SendMessageW( GetParent(wndPtr->hwndSelf), WM_DRAWITEM, - wndPtr->wIDmenu, (LPARAM)&dis ); - - SelectClipRgn(hDC, clipRegion); + SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis ); + SelectClipRgn(hDC, clipRegion); } diff --git a/controls/combo.c b/controls/combo.c index d7a6118d5f8..95ccd63e6a1 100644 --- a/controls/combo.c +++ b/controls/combo.c @@ -14,7 +14,6 @@ #include "winuser.h" #include "wine/winuser16.h" #include "wine/unicode.h" -#include "win.h" #include "spy.h" #include "user.h" #include "controls.h" @@ -30,12 +29,14 @@ DEFAULT_DEBUG_CHANNEL(combo); * Additional combo box definitions */ -#define CB_GETPTR( wnd ) (*(LPHEADCOMBO*)((wnd)->wExtra)) #define CB_NOTIFY( lphc, code ) \ (SendMessageW((lphc)->owner, WM_COMMAND, \ - MAKEWPARAM((lphc)->self->wIDmenu, (code)), (lphc)->self->hwndSelf)) -#define CB_GETEDITTEXTLENGTH( lphc ) \ - (SendMessageW((lphc)->hWndEdit, WM_GETTEXTLENGTH, 0, 0 )) + MAKEWPARAM(GetWindowLongA((lphc)->self,GWL_ID), (code)), (lphc)->self)) + +#define CB_DISABLED( lphc ) (!IsWindowEnabled((lphc)->self)) +#define CB_OWNERDRAWN( lphc ) ((lphc)->dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) +#define CB_HASSTRINGS( lphc ) ((lphc)->dwStyle & CBS_HASSTRINGS) +#define CB_HWND( lphc ) ((lphc)->self) #define ISWIN31 (LOWORD(GetVersion()) == 0x0a03) @@ -113,38 +114,36 @@ static BOOL COMBO_Init() /*********************************************************************** * COMBO_NCCreate */ -static LRESULT COMBO_NCCreate(WND* wnd, LONG style) +static LRESULT COMBO_NCCreate(HWND hwnd, LONG style) { - LPHEADCOMBO lphc; + LPHEADCOMBO lphc; - if ( wnd && COMBO_Init() && - (lphc = HeapAlloc(GetProcessHeap(), 0, sizeof(HEADCOMBO))) ) - { - memset( lphc, 0, sizeof(HEADCOMBO) ); - *(LPHEADCOMBO*)wnd->wExtra = lphc; + if (COMBO_Init() && (lphc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HEADCOMBO))) ) + { + lphc->self = hwnd; + SetWindowLongA( hwnd, 0, (LONG)lphc ); /* some braindead apps do try to use scrollbar/border flags */ lphc->dwStyle = style & ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL); - wnd->dwStyle &= ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL); + SetWindowLongA( hwnd, GWL_STYLE, style & ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL) ); /* * We also have to remove the client edge style to make sure * we don't end-up with a non client area. */ - wnd->dwExStyle &= ~(WS_EX_CLIENTEDGE); + SetWindowLongA( hwnd, GWL_EXSTYLE, + GetWindowLongA( hwnd, GWL_EXSTYLE ) & ~WS_EX_CLIENTEDGE ); if( !(style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) ) lphc->dwStyle |= CBS_HASSTRINGS; - if( !(wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) ) + if( !(GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_NOPARENTNOTIFY) ) lphc->wState |= CBF_NOTIFY; - TRACE("[0x%08x], style = %08x\n", - (UINT)lphc, lphc->dwStyle ); - - return (LRESULT)(UINT)wnd->hwndSelf; + TRACE("[0x%p], style = %08x\n", lphc, lphc->dwStyle ); + return TRUE; } - return (LRESULT)FALSE; + return FALSE; } /*********************************************************************** @@ -155,15 +154,13 @@ static LRESULT COMBO_NCDestroy( LPHEADCOMBO lphc ) if( lphc ) { - WND* wnd = lphc->self; - - TRACE("[%04x]: freeing storage\n", CB_HWND(lphc)); + TRACE("[%04x]: freeing storage\n", lphc->self); if( (CB_GETTYPE(lphc) != CBS_SIMPLE) && lphc->hWndLBox ) DestroyWindow( lphc->hWndLBox ); + SetWindowLongA( lphc->self, 0, 0 ); HeapFree( GetProcessHeap(), 0, lphc ); - wnd->wExtra[0] = 0; } return 0; } @@ -228,7 +225,8 @@ static INT CBGetTextAreaHeight( MEASUREITEMSTRUCT measureItem; RECT clientRect; INT originalItemHeight = iTextItemHeight; - + UINT id = GetWindowLongA( lphc->self, GWL_ID ); + /* * We use the client rect for the width of the item. */ @@ -240,13 +238,12 @@ static INT CBGetTextAreaHeight( * Send a first one to measure the size of the text area */ measureItem.CtlType = ODT_COMBOBOX; - measureItem.CtlID = lphc->self->wIDmenu; + measureItem.CtlID = id; measureItem.itemID = -1; measureItem.itemWidth = clientRect.right; measureItem.itemHeight = iTextItemHeight - 6; /* ownerdrawn cb is taller */ measureItem.itemData = 0; - SendMessageW(lphc->owner, WM_MEASUREITEM, - (WPARAM)measureItem.CtlID, (LPARAM)&measureItem); + SendMessageW(lphc->owner, WM_MEASUREITEM, id, (LPARAM)&measureItem); iTextItemHeight = 6 + measureItem.itemHeight; /* @@ -256,13 +253,12 @@ static INT CBGetTextAreaHeight( if (lphc->dwStyle & CBS_OWNERDRAWFIXED) { measureItem.CtlType = ODT_COMBOBOX; - measureItem.CtlID = lphc->self->wIDmenu; + measureItem.CtlID = id; measureItem.itemID = 0; measureItem.itemWidth = clientRect.right; measureItem.itemHeight = originalItemHeight; measureItem.itemData = 0; - SendMessageW(lphc->owner, WM_MEASUREITEM, - (WPARAM)measureItem.CtlID, (LPARAM)&measureItem); + SendMessageW(lphc->owner, WM_MEASUREITEM, id, (LPARAM)&measureItem); lphc->fixedOwnerDrawHeight = measureItem.itemHeight; } @@ -288,9 +284,9 @@ static void CBForceDummyResize( RECT windowRect; int newComboHeight; - newComboHeight = CBGetTextAreaHeight(CB_HWND(lphc),lphc) + 2*COMBO_YBORDERSIZE(); + newComboHeight = CBGetTextAreaHeight(lphc->self,lphc) + 2*COMBO_YBORDERSIZE(); - GetWindowRect(CB_HWND(lphc), &windowRect); + GetWindowRect(lphc->self, &windowRect); /* * We have to be careful, resizing a combobox also has the meaning that the @@ -300,7 +296,7 @@ static void CBForceDummyResize( * this will cancel-out in the processing of the WM_WINDOWPOSCHANGING * message. */ - SetWindowPos( CB_HWND(lphc), + SetWindowPos( lphc->self, (HWND)NULL, 0, 0, windowRect.right - windowRect.left, @@ -427,7 +423,7 @@ static void CBGetDroppedControlRect( LPHEADCOMBO lphc, LPRECT lpRect) /* In windows, CB_GETDROPPEDCONTROLRECT returns the upper left corner of the combo box and the lower right corner of the listbox */ - GetWindowRect(lphc->self->hwndSelf, lpRect); + GetWindowRect(lphc->self, lpRect); lpRect->right = lpRect->left + lphc->droppedRect.right - lphc->droppedRect.left; lpRect->bottom = lpRect->top + lphc->droppedRect.bottom - lphc->droppedRect.top; @@ -481,15 +477,14 @@ static LRESULT COMBO_WindowPosChanging( /*********************************************************************** * COMBO_Create */ -static LRESULT COMBO_Create( LPHEADCOMBO lphc, WND* wnd, HWND hwndParent, LONG style ) +static LRESULT COMBO_Create( HWND hwnd, LPHEADCOMBO lphc, HWND hwndParent, LONG style ) { static const WCHAR clbName[] = {'C','o','m','b','o','L','B','o','x',0}; static const WCHAR editName[] = {'E','d','i','t',0}; if( !CB_GETTYPE(lphc) ) lphc->dwStyle |= CBS_SIMPLE; if( CB_GETTYPE(lphc) != CBS_DROPDOWNLIST ) lphc->wState |= CBF_EDIT; - - lphc->self = wnd; + lphc->owner = hwndParent; /* @@ -515,13 +510,8 @@ static LRESULT COMBO_Create( LPHEADCOMBO lphc, WND* wnd, HWND hwndParent, LONG s * control and then, force all the areas of the combobox to be * recalculated. */ - GetClientRect( wnd->hwndSelf, &lphc->droppedRect ); - - CBCalcPlacement(wnd->hwndSelf, - lphc, - &lphc->textRect, - &lphc->buttonRect, - &lphc->droppedRect ); + GetClientRect( hwnd, &lphc->droppedRect ); + CBCalcPlacement(hwnd, lphc, &lphc->textRect, &lphc->buttonRect, &lphc->droppedRect ); /* * Adjust the position of the popup listbox if it's necessary @@ -536,8 +526,8 @@ static LRESULT COMBO_Create( LPHEADCOMBO lphc, WND* wnd, HWND hwndParent, LONG s if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) lphc->droppedRect.left += COMBO_EDITBUTTONSPACE(); - ClientToScreen(wnd->hwndSelf, (LPPOINT)&lphc->droppedRect); - ClientToScreen(wnd->hwndSelf, (LPPOINT)&lphc->droppedRect.right); + ClientToScreen(hwnd, (LPPOINT)&lphc->droppedRect); + ClientToScreen(hwnd, (LPPOINT)&lphc->droppedRect.right); } /* create listbox popup */ @@ -577,10 +567,8 @@ static LRESULT COMBO_Create( LPHEADCOMBO lphc, WND* wnd, HWND hwndParent, LONG s lphc->droppedRect.top, lphc->droppedRect.right - lphc->droppedRect.left, lphc->droppedRect.bottom - lphc->droppedRect.top, - lphc->self->hwndSelf, - (HMENU)ID_CB_LISTBOX, - lphc->self->hInstance, - (LPVOID)lphc ); + hwnd, (HMENU)ID_CB_LISTBOX, + GetWindowLongA( hwnd, GWL_HINSTANCE ), lphc ); if( lphc->hWndLBox ) { @@ -605,7 +593,7 @@ static LRESULT COMBO_Create( LPHEADCOMBO lphc, WND* wnd, HWND hwndParent, LONG s else if( lphc->dwStyle & CBS_UPPERCASE ) lbeStyle |= ES_UPPERCASE; - if (wnd->dwStyle & WS_DISABLED) lbeStyle |= WS_DISABLED; + if (!IsWindowEnabled(hwnd)) lbeStyle |= WS_DISABLED; lphc->hWndEdit = CreateWindowExW(0, editName, @@ -614,10 +602,8 @@ static LRESULT COMBO_Create( LPHEADCOMBO lphc, WND* wnd, HWND hwndParent, LONG s lphc->textRect.left, lphc->textRect.top, lphc->textRect.right - lphc->textRect.left, lphc->textRect.bottom - lphc->textRect.top, - lphc->self->hwndSelf, - (HMENU)ID_CB_EDIT, - lphc->self->hInstance, - NULL ); + hwnd, (HMENU)ID_CB_EDIT, + GetWindowLongA( hwnd, GWL_HINSTANCE ), NULL ); if( !lphc->hWndEdit ) bEdit = FALSE; @@ -639,7 +625,7 @@ static LRESULT COMBO_Create( LPHEADCOMBO lphc, WND* wnd, HWND hwndParent, LONG s } TRACE("init done\n"); - return wnd->hwndSelf; + return hwnd; } ERR("edit control failure.\n"); } else ERR("listbox failure.\n"); @@ -789,7 +775,8 @@ static void CBPaintText( { DRAWITEMSTRUCT dis; HRGN clipRegion; - + UINT ctlid = GetWindowLongA( lphc->self, GWL_ID ); + /* setup state for DRAWITEM message. Owner will highlight */ if ( (lphc->wState & CBF_FOCUSED) && !(lphc->wState & CBF_DROPPED) ) @@ -807,13 +794,12 @@ static void CBPaintText( DeleteObject(clipRegion); clipRegion=(HRGN)NULL; } - - if ( lphc->self->dwStyle & WS_DISABLED ) - itemState |= ODS_DISABLED; - + + if (!IsWindowEnabled(lphc->self) & WS_DISABLED) itemState |= ODS_DISABLED; + dis.CtlType = ODT_COMBOBOX; - dis.CtlID = lphc->self->wIDmenu; - dis.hwndItem = lphc->self->hwndSelf; + dis.CtlID = ctlid; + dis.hwndItem = lphc->self; dis.itemAction = ODA_DRAWENTIRE; dis.itemID = id; dis.itemState = itemState; @@ -828,10 +814,9 @@ static void CBPaintText( IntersectClipRect(hdc, rectEdit.left, rectEdit.top, rectEdit.right, rectEdit.bottom); - - SendMessageW(lphc->owner, WM_DRAWITEM, - lphc->self->wIDmenu, (LPARAM)&dis ); - + + SendMessageW(lphc->owner, WM_DRAWITEM, ctlid, (LPARAM)&dis ); + /* * Reset the clipping region. */ @@ -912,9 +897,8 @@ static HBRUSH COMBO_PrepareColors( */ if (CB_DISABLED(lphc)) { - hBkgBrush = SendMessageW(lphc->owner, WM_CTLCOLORSTATIC, - hDC, lphc->self->hwndSelf ); - + hBkgBrush = SendMessageW(lphc->owner, WM_CTLCOLORSTATIC, hDC, lphc->self ); + /* * We have to change the text color since WM_CTLCOLORSTATIC will * set it to the "enabled" color. This is the same behavior as the @@ -926,13 +910,11 @@ static HBRUSH COMBO_PrepareColors( { if (lphc->wState & CBF_EDIT) { - hBkgBrush = SendMessageW(lphc->owner, WM_CTLCOLOREDIT, - hDC, lphc->self->hwndSelf ); + hBkgBrush = SendMessageW(lphc->owner, WM_CTLCOLOREDIT, hDC, lphc->self ); } else { - hBkgBrush = SendMessageW(lphc->owner, WM_CTLCOLORLISTBOX, - hDC, lphc->self->hwndSelf ); + hBkgBrush = SendMessageW(lphc->owner, WM_CTLCOLORLISTBOX, hDC, lphc->self ); } } @@ -983,7 +965,7 @@ static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC hParamDC) HDC hDC; hDC = (hParamDC) ? hParamDC - : BeginPaint( lphc->self->hwndSelf, &ps); + : BeginPaint( lphc->self, &ps); TRACE("hdc=%04x\n", hDC); @@ -1004,7 +986,7 @@ static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC hParamDC) */ if (TWEAK_WineLook != WIN31_LOOK) { - CBPaintBorder(CB_HWND(lphc), lphc, hDC); + CBPaintBorder(lphc->self, lphc, hDC); } if( !IsRectEmpty(&lphc->buttonRect) ) @@ -1046,7 +1028,7 @@ static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC hParamDC) } if( !hParamDC ) - EndPaint(lphc->self->hwndSelf, &ps); + EndPaint(lphc->self, &ps); return 0; } @@ -1062,8 +1044,8 @@ static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect ) LPWSTR pText = NULL; idx = LB_ERR; - length = CB_GETEDITTEXTLENGTH( lphc ); - + length = SendMessageW( lphc->hWndEdit, WM_GETTEXTLENGTH, 0, 0 ); + if( length > 0 ) pText = HeapAlloc( GetProcessHeap(), 0, (length + 1) * sizeof(WCHAR)); @@ -1135,7 +1117,7 @@ static void CBDropDown( LPHEADCOMBO lphc ) int nItems = 0; int nDroppedHeight; - TRACE("[%04x]: drop down\n", CB_HWND(lphc)); + TRACE("[%04x]: drop down\n", lphc->self); CB_NOTIFY( lphc, CBN_DROPDOWN ); @@ -1160,7 +1142,7 @@ static void CBDropDown( LPHEADCOMBO lphc ) } /* now set popup position */ - GetWindowRect( lphc->self->hwndSelf, &rect ); + GetWindowRect( lphc->self, &rect ); /* * If it's a dropdown, the listbox is offset @@ -1202,11 +1184,11 @@ static void CBDropDown( LPHEADCOMBO lphc ) if( !(lphc->wState & CBF_NOREDRAW) ) - RedrawWindow( lphc->self->hwndSelf, NULL, 0, RDW_INVALIDATE | + RedrawWindow( lphc->self, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN ); EnableWindow( lphc->hWndLBox, TRUE ); - if (GetCapture() != lphc->self->hwndSelf) + if (GetCapture() != lphc->self) SetCapture(lphc->hWndLBox); } @@ -1217,10 +1199,10 @@ static void CBDropDown( LPHEADCOMBO lphc ) */ static void CBRollUp( LPHEADCOMBO lphc, BOOL ok, BOOL bButton ) { - HWND hWnd = lphc->self->hwndSelf; + HWND hWnd = lphc->self; TRACE("[%04x]: sel ok? [%i] dropped? [%i]\n", - CB_HWND(lphc), (INT)ok, (INT)(lphc->wState & CBF_DROPPED)); + lphc->self, (INT)ok, (INT)(lphc->wState & CBF_DROPPED)); CB_NOTIFY( lphc, (ok) ? CBN_SELENDOK : CBN_SELENDCANCEL ); @@ -1287,8 +1269,8 @@ BOOL COMBO_FlipListbox( LPHEADCOMBO lphc, BOOL ok, BOOL bRedrawButton ) */ static void CBRepaintButton( LPHEADCOMBO lphc ) { - InvalidateRect(CB_HWND(lphc), &lphc->buttonRect, TRUE); - UpdateWindow(CB_HWND(lphc)); + InvalidateRect(lphc->self, &lphc->buttonRect, TRUE); + UpdateWindow(lphc->self); } /*********************************************************************** @@ -1306,7 +1288,7 @@ static void COMBO_SetFocus( LPHEADCOMBO lphc ) /* lphc->wState |= CBF_FOCUSED; */ if( !(lphc->wState & CBF_EDIT) ) - InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE); + InvalidateRect(lphc->self, &lphc->textRect, TRUE); CB_NOTIFY( lphc, CBN_SETFOCUS ); lphc->wState |= CBF_FOCUSED; @@ -1318,7 +1300,7 @@ static void COMBO_SetFocus( LPHEADCOMBO lphc ) */ static void COMBO_KillFocus( LPHEADCOMBO lphc ) { - HWND hWnd = lphc->self->hwndSelf; + HWND hWnd = lphc->self; if( lphc->wState & CBF_FOCUSED ) { @@ -1332,7 +1314,7 @@ static void COMBO_KillFocus( LPHEADCOMBO lphc ) /* redraw text */ if( !(lphc->wState & CBF_EDIT) ) - InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE); + InvalidateRect(lphc->self, &lphc->textRect, TRUE); CB_NOTIFY( lphc, CBN_KILLFOCUS ); } @@ -1353,7 +1335,7 @@ static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd ) case (EN_SETFOCUS >> 8): TRACE("[%04x]: edit [%04x] got focus\n", - CB_HWND(lphc), lphc->hWndEdit ); + lphc->self, lphc->hWndEdit ); COMBO_SetFocus( lphc ); break; @@ -1361,7 +1343,7 @@ static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd ) case (EN_KILLFOCUS >> 8): TRACE("[%04x]: edit [%04x] lost focus\n", - CB_HWND(lphc), lphc->hWndEdit ); + lphc->self, lphc->hWndEdit ); /* NOTE: it seems that Windows' edit control sends an * undocumented message WM_USER + 0x1B instead of this @@ -1419,7 +1401,7 @@ static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd ) case LBN_SELCANCEL: TRACE("[%04x]: lbox selection change [%04x]\n", - CB_HWND(lphc), lphc->wState ); + lphc->self, lphc->wState ); if( HIWORD(wParam) == LBN_SELCHANGE) { @@ -1432,7 +1414,7 @@ static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd ) SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1)); } else - InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE); + InvalidateRect(lphc->self, &lphc->textRect, TRUE); } /* do not roll up if selection is being tracked @@ -1464,35 +1446,46 @@ static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd ) */ static LRESULT COMBO_ItemOp( LPHEADCOMBO lphc, UINT msg, LPARAM lParam ) { - HWND hWnd = lphc->self->hwndSelf; + HWND hWnd = lphc->self; + UINT id = GetWindowLongA( hWnd, GWL_ID ); - TRACE("[%04x]: ownerdraw op %04x\n", CB_HWND(lphc), msg ); + TRACE("[%04x]: ownerdraw op %04x\n", lphc->self, msg ); -#define lpIS ((LPDELETEITEMSTRUCT)lParam) - - /* two first items are the same in all 4 structs */ - lpIS->CtlType = ODT_COMBOBOX; - lpIS->CtlID = lphc->self->wIDmenu; - - switch( msg ) /* patch window handle */ + switch( msg ) { - case WM_DELETEITEM: - lpIS->hwndItem = hWnd; -#undef lpIS - break; - case WM_DRAWITEM: -#define lpIS ((LPDRAWITEMSTRUCT)lParam) - lpIS->hwndItem = hWnd; -#undef lpIS - break; - case WM_COMPAREITEM: -#define lpIS ((LPCOMPAREITEMSTRUCT)lParam) - lpIS->hwndItem = hWnd; -#undef lpIS - break; + case WM_DELETEITEM: + { + DELETEITEMSTRUCT *lpIS = (DELETEITEMSTRUCT *)lParam; + lpIS->CtlType = ODT_COMBOBOX; + lpIS->CtlID = id; + lpIS->hwndItem = hWnd; + break; + } + case WM_DRAWITEM: + { + DRAWITEMSTRUCT *lpIS = (DRAWITEMSTRUCT *)lParam; + lpIS->CtlType = ODT_COMBOBOX; + lpIS->CtlID = id; + lpIS->hwndItem = hWnd; + break; + } + case WM_COMPAREITEM: + { + COMPAREITEMSTRUCT *lpIS = (COMPAREITEMSTRUCT *)lParam; + lpIS->CtlType = ODT_COMBOBOX; + lpIS->CtlID = id; + lpIS->hwndItem = hWnd; + break; + } + case WM_MEASUREITEM: + { + MEASUREITEMSTRUCT *lpIS = (MEASUREITEMSTRUCT *)lParam; + lpIS->CtlType = ODT_COMBOBOX; + lpIS->CtlID = id; + break; + } } - - return SendMessageW(lphc->owner, msg, lphc->self->wIDmenu, lParam); + return SendMessageW(lphc->owner, msg, id, lParam); } /*********************************************************************** @@ -1622,7 +1615,7 @@ static void CBResetPos( } if( bRedraw && !(lphc->wState & CBF_NOREDRAW) ) - RedrawWindow( lphc->self->hwndSelf, NULL, 0, + RedrawWindow( lphc->self, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW ); } } @@ -1633,7 +1626,7 @@ static void CBResetPos( */ static void COMBO_Size( LPHEADCOMBO lphc ) { - CBCalcPlacement(lphc->self->hwndSelf, + CBCalcPlacement(lphc->self, lphc, &lphc->textRect, &lphc->buttonRect, @@ -1665,7 +1658,7 @@ static void COMBO_Font( LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw ) */ if ( CB_GETTYPE(lphc) == CBS_SIMPLE) { - CBCalcPlacement(lphc->self->hwndSelf, + CBCalcPlacement(lphc->self, lphc, &lphc->textRect, &lphc->buttonRect, @@ -1698,7 +1691,7 @@ static LRESULT COMBO_SetItemHeight( LPHEADCOMBO lphc, INT index, INT height ) */ if ( CB_GETTYPE(lphc) == CBS_SIMPLE) { - CBCalcPlacement(lphc->self->hwndSelf, + CBCalcPlacement(lphc->self, lphc, &lphc->textRect, &lphc->buttonRect, @@ -1733,7 +1726,7 @@ static LRESULT COMBO_SelectString( LPHEADCOMBO lphc, INT start, LPARAM pText, BO CBUpdateEdit( lphc, index ); else { - InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE); + InvalidateRect(lphc->self, &lphc->textRect, TRUE); } } return (LRESULT)index; @@ -1746,7 +1739,7 @@ static void COMBO_LButtonDown( LPHEADCOMBO lphc, LPARAM lParam ) { POINT pt; BOOL bButton; - HWND hWnd = lphc->self->hwndSelf; + HWND hWnd = lphc->self; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); @@ -1842,7 +1835,7 @@ static void COMBO_MouseMove( LPHEADCOMBO lphc, WPARAM wParam, LPARAM lParam ) } GetClientRect( lphc->hWndLBox, &lbRect ); - MapWindowPoints( lphc->self->hwndSelf, lphc->hWndLBox, &pt, 1 ); + MapWindowPoints( lphc->self, lphc->hWndLBox, &pt, 1 ); if( PtInRect(&lbRect, pt) ) { lphc->wState &= ~CBF_CAPTURE; @@ -1856,18 +1849,17 @@ static void COMBO_MouseMove( LPHEADCOMBO lphc, WPARAM wParam, LPARAM lParam ) /*********************************************************************** - * ComboWndProc_locked + * ComboWndProc_common * * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/ctrl/src/combobox_15.htm */ -static LRESULT ComboWndProc_locked( WND* pWnd, UINT message, +static LRESULT ComboWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, BOOL unicode ) { - LPHEADCOMBO lphc = CB_GETPTR(pWnd); - HWND hwnd = pWnd->hwndSelf; + LPHEADCOMBO lphc = (LPHEADCOMBO)GetWindowLongA( hwnd, 0 ); TRACE("[%04x]: msg %s wp %08x lp %08lx\n", - pWnd->hwndSelf, SPY_GetMsgName(message), wParam, lParam ); + hwnd, SPY_GetMsgName(message), wParam, lParam ); if( lphc || message == WM_NCCREATE ) switch(message) @@ -1879,7 +1871,7 @@ static LRESULT ComboWndProc_locked( WND* pWnd, UINT message, { LONG style = unicode ? ((LPCREATESTRUCTW)lParam)->style : ((LPCREATESTRUCTA)lParam)->style; - return COMBO_NCCreate(pWnd, style); + return COMBO_NCCreate(hwnd, style); } case WM_NCDESTROY: COMBO_NCDestroy(lphc); @@ -1899,7 +1891,7 @@ static LRESULT ComboWndProc_locked( WND* pWnd, UINT message, hwndParent = ((LPCREATESTRUCTA)lParam)->hwndParent; style = ((LPCREATESTRUCTA)lParam)->style; } - return COMBO_Create(lphc, pWnd, hwndParent, style); + return COMBO_Create(hwnd, lphc, hwndParent, style); } case WM_PRINTCLIENT: @@ -1999,7 +1991,7 @@ static LRESULT ComboWndProc_locked( WND* pWnd, UINT message, EnableWindow( lphc->hWndLBox, (BOOL)wParam ); /* Force the control to repaint when the enabled state changes. */ - InvalidateRect(CB_HWND(lphc), NULL, TRUE); + InvalidateRect(lphc->self, NULL, TRUE); return TRUE; case WM_SETREDRAW: if( wParam ) @@ -2038,7 +2030,7 @@ static LRESULT ComboWndProc_locked( WND* pWnd, UINT message, SendMessageA(hwndTarget, message, wParam, lParam); } case WM_LBUTTONDOWN: - if( !(lphc->wState & CBF_FOCUSED) ) SetFocus( lphc->self->hwndSelf ); + if( !(lphc->wState & CBF_FOCUSED) ) SetFocus( lphc->self ); if( lphc->wState & CBF_FOCUSED ) COMBO_LButtonDown( lphc, lParam ); return TRUE; case WM_LBUTTONUP: @@ -2117,7 +2109,7 @@ static LRESULT ComboWndProc_locked( WND* pWnd, UINT message, SendMessageW(lphc->hWndEdit, WM_SETTEXT, 0, (LPARAM)empty_stringW); } else - InvalidateRect(CB_HWND(lphc), NULL, TRUE); + InvalidateRect(lphc->self, NULL, TRUE); return TRUE; case CB_INITSTORAGE: return SendMessageW(lphc->hWndLBox, LB_INITSTORAGE, wParam, lParam); @@ -2195,7 +2187,7 @@ static LRESULT ComboWndProc_locked( WND* pWnd, UINT message, if( lphc->wState & CBF_EDIT ) CBUpdateEdit( lphc, (INT)wParam ); else - InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE); + InvalidateRect(lphc->self, &lphc->textRect, TRUE); lphc->wState &= ~CBF_SELCHANGE; return lParam; case CB_GETLBTEXT16: @@ -2264,15 +2256,8 @@ static LRESULT ComboWndProc_locked( WND* pWnd, UINT message, */ static LRESULT WINAPI ComboWndProcA( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) { - LRESULT retvalue = 0; - WND* pWnd = WIN_FindWndPtr(hwnd); - - if (pWnd) - { - retvalue = ComboWndProc_locked(pWnd, message, wParam, lParam, FALSE); - WIN_ReleaseWndPtr(pWnd); - } - return retvalue; + if (!IsWindow(hwnd)) return 0; + return ComboWndProc_common( hwnd, message, wParam, lParam, FALSE ); } /*********************************************************************** @@ -2280,13 +2265,6 @@ static LRESULT WINAPI ComboWndProcA( HWND hwnd, UINT message, WPARAM wParam, LPA */ static LRESULT WINAPI ComboWndProcW( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) { - LRESULT retvalue = 0; - WND* pWnd = WIN_FindWndPtr(hwnd); - - if (pWnd) - { - retvalue = ComboWndProc_locked(pWnd, message, wParam, lParam, TRUE); - WIN_ReleaseWndPtr(pWnd); - } - return retvalue; + if (!IsWindow(hwnd)) return 0; + return ComboWndProc_common( hwnd, message, wParam, lParam, TRUE ); } diff --git a/controls/desktop.c b/controls/desktop.c index 3400ddebab6..fbed461995b 100644 --- a/controls/desktop.c +++ b/controls/desktop.c @@ -11,17 +11,13 @@ #include "windef.h" #include "wingdi.h" #include "user.h" -#include "win.h" #include "controls.h" #include "wine/winuser16.h" -typedef struct -{ - HBRUSH hbrushPattern; - HBITMAP hbitmapWallPaper; - SIZE bitmapSize; - BOOL fTileWallPaper; -} DESKTOP; +static HBRUSH hbrushPattern; +static HBITMAP hbitmapWallPaper; +static SIZE bitmapSize; +static BOOL fTileWallPaper; static LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ); @@ -35,7 +31,7 @@ const struct builtin_class_descr DESKTOP_builtin_class = CS_GLOBALCLASS, /* style */ NULL, /* procA (winproc is Unicode only) */ DesktopWndProc, /* procW */ - sizeof(DESKTOP), /* extra */ + 0, /* extra */ IDC_ARROWA, /* cursor */ COLOR_BACKGROUND+1 /* brush */ }; @@ -103,20 +99,16 @@ static HBITMAP DESKTOP_LoadBitmap( HDC hdc, const char *filename ) static LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) { LRESULT retvalue = 0; - WND *wndPtr = WIN_FindWndPtr( hwnd ); - DESKTOP *desktopPtr = (DESKTOP *)wndPtr->wExtra; if (message == WM_NCCREATE) { - desktopPtr->hbrushPattern = 0; - desktopPtr->hbitmapWallPaper = 0; + hbrushPattern = 0; + hbitmapWallPaper = 0; SetDeskPattern(); SetDeskWallPaper( (LPSTR)-1 ); retvalue = 1; } /* all other messages are ignored */ - - WIN_ReleaseWndPtr(wndPtr); return retvalue; } @@ -127,11 +119,9 @@ static LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message, WPARAM wParam, LP BOOL WINAPI PaintDesktop(HDC hdc) { HWND hwnd = GetDesktopWindow(); - WND *wndPtr = WIN_FindWndPtr( hwnd ); - DESKTOP *desktopPtr = (DESKTOP *)wndPtr->wExtra; - /* check for a queue; otherwise don't paint anything (non-desktop mode) */ - if (wndPtr->hmemTaskQ) + /* check for an owning thread; otherwise don't paint anything (non-desktop mode) */ + if (GetWindowThreadProcessId( hwnd, NULL )) { RECT rect; @@ -139,11 +129,10 @@ BOOL WINAPI PaintDesktop(HDC hdc) /* Paint desktop pattern (only if wall paper does not cover everything) */ - if (!desktopPtr->hbitmapWallPaper || - (!desktopPtr->fTileWallPaper && ((desktopPtr->bitmapSize.cx < rect.right) || - (desktopPtr->bitmapSize.cy < rect.bottom)))) + if (!hbitmapWallPaper || + (!fTileWallPaper && ((bitmapSize.cx < rect.right) || (bitmapSize.cy < rect.bottom)))) { - HBRUSH brush = desktopPtr->hbrushPattern; + HBRUSH brush = hbrushPattern; if (!brush) brush = GetClassLongA( hwnd, GCL_HBRBACKGROUND ); /* Set colors in case pattern is a monochrome bitmap */ SetBkColor( hdc, RGB(0,0,0) ); @@ -153,33 +142,30 @@ BOOL WINAPI PaintDesktop(HDC hdc) /* Paint wall paper */ - if (desktopPtr->hbitmapWallPaper) + if (hbitmapWallPaper) { INT x, y; HDC hMemDC = CreateCompatibleDC( hdc ); - SelectObject( hMemDC, desktopPtr->hbitmapWallPaper ); + SelectObject( hMemDC, hbitmapWallPaper ); - if (desktopPtr->fTileWallPaper) + if (fTileWallPaper) { - for (y = 0; y < rect.bottom; y += desktopPtr->bitmapSize.cy) - for (x = 0; x < rect.right; x += desktopPtr->bitmapSize.cx) - BitBlt( hdc, x, y, desktopPtr->bitmapSize.cx, - desktopPtr->bitmapSize.cy, hMemDC, 0, 0, SRCCOPY ); + for (y = 0; y < rect.bottom; y += bitmapSize.cy) + for (x = 0; x < rect.right; x += bitmapSize.cx) + BitBlt( hdc, x, y, bitmapSize.cx, bitmapSize.cy, hMemDC, 0, 0, SRCCOPY ); } else { - x = (rect.left + rect.right - desktopPtr->bitmapSize.cx) / 2; - y = (rect.top + rect.bottom - desktopPtr->bitmapSize.cy) / 2; + x = (rect.left + rect.right - bitmapSize.cx) / 2; + y = (rect.top + rect.bottom - bitmapSize.cy) / 2; if (x < 0) x = 0; if (y < 0) y = 0; - BitBlt( hdc, x, y, desktopPtr->bitmapSize.cx, - desktopPtr->bitmapSize.cy, hMemDC, 0, 0, SRCCOPY ); + BitBlt( hdc, x, y, bitmapSize.cx, bitmapSize.cy, hMemDC, 0, 0, SRCCOPY ); } DeleteDC( hMemDC ); } } - WIN_ReleaseWndPtr(wndPtr); return TRUE; } @@ -213,8 +199,6 @@ BOOL WINAPI SetDeskWallPaper( LPCSTR filename ) HBITMAP hbitmap; HDC hdc; char buffer[256]; - WND *wndPtr = WIN_GetDesktop(); - DESKTOP *desktopPtr = (DESKTOP *)wndPtr->wExtra; if (filename == (LPSTR)-1) { @@ -224,17 +208,16 @@ BOOL WINAPI SetDeskWallPaper( LPCSTR filename ) hdc = GetDC( 0 ); hbitmap = DESKTOP_LoadBitmap( hdc, filename ); ReleaseDC( 0, hdc ); - if (desktopPtr->hbitmapWallPaper) DeleteObject( desktopPtr->hbitmapWallPaper ); - desktopPtr->hbitmapWallPaper = hbitmap; - desktopPtr->fTileWallPaper = GetProfileIntA( "desktop", "TileWallPaper", 0 ); + if (hbitmapWallPaper) DeleteObject( hbitmapWallPaper ); + hbitmapWallPaper = hbitmap; + fTileWallPaper = GetProfileIntA( "desktop", "TileWallPaper", 0 ); if (hbitmap) { BITMAP bmp; GetObjectA( hbitmap, sizeof(bmp), &bmp ); - desktopPtr->bitmapSize.cx = (bmp.bmWidth != 0) ? bmp.bmWidth : 1; - desktopPtr->bitmapSize.cy = (bmp.bmHeight != 0) ? bmp.bmHeight : 1; + bitmapSize.cx = (bmp.bmWidth != 0) ? bmp.bmWidth : 1; + bitmapSize.cy = (bmp.bmHeight != 0) ? bmp.bmHeight : 1; } - WIN_ReleaseDesktop(); return TRUE; } @@ -246,11 +229,9 @@ BOOL WINAPI SetDeskWallPaper( LPCSTR filename ) */ BOOL DESKTOP_SetPattern( LPCSTR pattern ) { - WND *wndPtr = WIN_GetDesktop(); - DESKTOP *desktopPtr = (DESKTOP *)wndPtr->wExtra; int pat[8]; - if (desktopPtr->hbrushPattern) DeleteObject( desktopPtr->hbrushPattern ); + if (hbrushPattern) DeleteObject( hbrushPattern ); memset( pat, 0, sizeof(pat) ); if (pattern && sscanf( pattern, " %d %d %d %d %d %d %d %d", &pat[0], &pat[1], &pat[2], &pat[3], @@ -262,11 +243,10 @@ BOOL DESKTOP_SetPattern( LPCSTR pattern ) for (i = 0; i < 8; i++) pattern[i] = pat[i] & 0xffff; hbitmap = CreateBitmap( 8, 8, 1, 1, (LPSTR)pattern ); - desktopPtr->hbrushPattern = CreatePatternBrush( hbitmap ); + hbrushPattern = CreatePatternBrush( hbitmap ); DeleteObject( hbitmap ); } - else desktopPtr->hbrushPattern = 0; - WIN_ReleaseDesktop(); + else hbrushPattern = 0; return TRUE; } diff --git a/controls/edit.c b/controls/edit.c index 8a8d1f1d2b5..46fe497a0fb 100644 --- a/controls/edit.c +++ b/controls/edit.c @@ -130,29 +130,29 @@ typedef struct (UINT)(hwnd));} while(0) /* used for disabled or read-only edit control */ -#define EDIT_SEND_CTLCOLORSTATIC(wnd,hdc) \ - (SendMessageW((wnd)->parent->hwndSelf, WM_CTLCOLORSTATIC, \ - (WPARAM)(hdc), (LPARAM)(wnd)->hwndSelf)) -#define EDIT_SEND_CTLCOLOR(wnd,hdc) \ - (SendMessageW((wnd)->parent->hwndSelf, WM_CTLCOLOREDIT, \ - (WPARAM)(hdc), (LPARAM)(wnd)->hwndSelf)) -#define EDIT_NOTIFY_PARENT(es, wNotifyCode, str) \ +#define EDIT_SEND_CTLCOLORSTATIC(hwnd,hdc) \ + (SendMessageW(GetParent(hwnd), WM_CTLCOLORSTATIC, \ + (WPARAM)(hdc), (LPARAM)(hwnd))) +#define EDIT_SEND_CTLCOLOR(hwnd,hdc) \ + (SendMessageW(GetParent(hwnd), WM_CTLCOLOREDIT, \ + (WPARAM)(hdc), (LPARAM)(hwnd))) +#define EDIT_NOTIFY_PARENT(hwnd, es, wNotifyCode, str) \ do \ { /* Notify parent which has created this edit control */ \ DPRINTF_EDIT_NOTIFY((es)->hwndParent, str); \ SendMessageW((es)->hwndParent, WM_COMMAND, \ - MAKEWPARAM((wnd)->wIDmenu, wNotifyCode), \ - (LPARAM)(wnd)->hwndSelf); \ + MAKEWPARAM(GetWindowLongA((hwnd),GWL_ID), wNotifyCode), \ + (LPARAM)(hwnd)); \ } while(0) #define DPRINTF_EDIT_MSG16(str) \ TRACE(\ "16 bit : " str ": hwnd=%08x, wParam=%08x, lParam=%08x\n", \ - (UINT)wnd->hwndSelf, (UINT)wParam, (UINT)lParam) + hwnd, (UINT)wParam, (UINT)lParam) #define DPRINTF_EDIT_MSG32(str) \ TRACE(\ "32 bit %c : " str ": hwnd=%08x, wParam=%08x, lParam=%08x\n", \ unicode ? 'W' : 'A', \ - (UINT)wnd->hwndSelf, (UINT)wParam, (UINT)lParam) + hwnd, (UINT)wParam, (UINT)lParam) /********************************************************************* * @@ -167,105 +167,105 @@ typedef struct */ static inline BOOL EDIT_EM_CanUndo(EDITSTATE *es); static inline void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es); -static inline void EDIT_WM_Clear(WND *wnd, EDITSTATE *es); -static inline void EDIT_WM_Cut(WND *wnd, EDITSTATE *es); +static inline void EDIT_WM_Clear(HWND hwnd, EDITSTATE *es); +static inline void EDIT_WM_Cut(HWND hwnd, EDITSTATE *es); /* * Helper functions only valid for one type of control */ -static void EDIT_BuildLineDefs_ML(WND *wnd, EDITSTATE *es, INT iStart, INT iEnd, INT delta, HRGN hrgn); -static void EDIT_CalcLineWidth_SL(WND *wnd, EDITSTATE *es); +static void EDIT_BuildLineDefs_ML(HWND hwnd, EDITSTATE *es, INT iStart, INT iEnd, INT delta, HRGN hrgn); +static void EDIT_CalcLineWidth_SL(HWND hwnd, EDITSTATE *es); static LPWSTR EDIT_GetPasswordPointer_SL(EDITSTATE *es); -static void EDIT_MoveDown_ML(WND *wnd, EDITSTATE *es, BOOL extend); -static void EDIT_MovePageDown_ML(WND *wnd, EDITSTATE *es, BOOL extend); -static void EDIT_MovePageUp_ML(WND *wnd, EDITSTATE *es, BOOL extend); -static void EDIT_MoveUp_ML(WND *wnd, EDITSTATE *es, BOOL extend); +static void EDIT_MoveDown_ML(HWND hwnd, EDITSTATE *es, BOOL extend); +static void EDIT_MovePageDown_ML(HWND hwnd, EDITSTATE *es, BOOL extend); +static void EDIT_MovePageUp_ML(HWND hwnd, EDITSTATE *es, BOOL extend); +static void EDIT_MoveUp_ML(HWND hwnd, EDITSTATE *es, BOOL extend); /* * Helper functions valid for both single line _and_ multi line controls */ static INT EDIT_CallWordBreakProc(EDITSTATE *es, INT start, INT index, INT count, INT action); -static INT EDIT_CharFromPos(WND *wnd, EDITSTATE *es, INT x, INT y, LPBOOL after_wrap); +static INT EDIT_CharFromPos(HWND hwnd, EDITSTATE *es, INT x, INT y, LPBOOL after_wrap); static void EDIT_ConfinePoint(EDITSTATE *es, LPINT x, LPINT y); -static void EDIT_GetLineRect(WND *wnd, EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc); -static void EDIT_InvalidateText(WND *wnd, EDITSTATE *es, INT start, INT end); -static void EDIT_LockBuffer(WND *wnd, EDITSTATE *es); -static BOOL EDIT_MakeFit(WND *wnd, EDITSTATE *es, UINT size); +static void EDIT_GetLineRect(HWND hwnd, EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc); +static void EDIT_InvalidateText(HWND hwnd, EDITSTATE *es, INT start, INT end); +static void EDIT_LockBuffer(HWND hwnd, EDITSTATE *es); +static BOOL EDIT_MakeFit(HWND hwnd, EDITSTATE *es, UINT size); static BOOL EDIT_MakeUndoFit(EDITSTATE *es, UINT size); -static void EDIT_MoveBackward(WND *wnd, EDITSTATE *es, BOOL extend); -static void EDIT_MoveEnd(WND *wnd, EDITSTATE *es, BOOL extend); -static void EDIT_MoveForward(WND *wnd, EDITSTATE *es, BOOL extend); -static void EDIT_MoveHome(WND *wnd, EDITSTATE *es, BOOL extend); -static void EDIT_MoveWordBackward(WND *wnd, EDITSTATE *es, BOOL extend); -static void EDIT_MoveWordForward(WND *wnd, EDITSTATE *es, BOOL extend); -static void EDIT_PaintLine(WND *wnd, EDITSTATE *es, HDC hdc, INT line, BOOL rev); +static void EDIT_MoveBackward(HWND hwnd, EDITSTATE *es, BOOL extend); +static void EDIT_MoveEnd(HWND hwnd, EDITSTATE *es, BOOL extend); +static void EDIT_MoveForward(HWND hwnd, EDITSTATE *es, BOOL extend); +static void EDIT_MoveHome(HWND hwnd, EDITSTATE *es, BOOL extend); +static void EDIT_MoveWordBackward(HWND hwnd, EDITSTATE *es, BOOL extend); +static void EDIT_MoveWordForward(HWND hwnd, EDITSTATE *es, BOOL extend); +static void EDIT_PaintLine(HWND hwnd, EDITSTATE *es, HDC hdc, INT line, BOOL rev); static INT EDIT_PaintText(EDITSTATE *es, HDC hdc, INT x, INT y, INT line, INT col, INT count, BOOL rev); -static void EDIT_SetCaretPos(WND *wnd, EDITSTATE *es, INT pos, BOOL after_wrap); -static void EDIT_SetRectNP(WND *wnd, EDITSTATE *es, LPRECT lprc); -static void EDIT_UnlockBuffer(WND *wnd, EDITSTATE *es, BOOL force); -static void EDIT_UpdateScrollInfo(WND *wnd, EDITSTATE *es); +static void EDIT_SetCaretPos(HWND hwnd, EDITSTATE *es, INT pos, BOOL after_wrap); +static void EDIT_SetRectNP(HWND hwnd, EDITSTATE *es, LPRECT lprc); +static void EDIT_UnlockBuffer(HWND hwnd, EDITSTATE *es, BOOL force); +static void EDIT_UpdateScrollInfo(HWND hwnd, EDITSTATE *es); static INT CALLBACK EDIT_WordBreakProc(LPWSTR s, INT index, INT count, INT action); /* * EM_XXX message handlers */ -static LRESULT EDIT_EM_CharFromPos(WND *wnd, EDITSTATE *es, INT x, INT y); +static LRESULT EDIT_EM_CharFromPos(HWND hwnd, EDITSTATE *es, INT x, INT y); static BOOL EDIT_EM_FmtLines(EDITSTATE *es, BOOL add_eol); static HLOCAL EDIT_EM_GetHandle(EDITSTATE *es); -static HLOCAL16 EDIT_EM_GetHandle16(WND *wnd, EDITSTATE *es); +static HLOCAL16 EDIT_EM_GetHandle16(HWND hwnd, EDITSTATE *es); static INT EDIT_EM_GetLine(EDITSTATE *es, INT line, LPARAM lParam, BOOL unicode); static LRESULT EDIT_EM_GetSel(EDITSTATE *es, LPUINT start, LPUINT end); -static LRESULT EDIT_EM_GetThumb(WND *wnd, EDITSTATE *es); +static LRESULT EDIT_EM_GetThumb(HWND hwnd, EDITSTATE *es); static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index); static INT EDIT_EM_LineIndex(EDITSTATE *es, INT line); static INT EDIT_EM_LineLength(EDITSTATE *es, INT index); -static BOOL EDIT_EM_LineScroll(WND *wnd, EDITSTATE *es, INT dx, INT dy); -static BOOL EDIT_EM_LineScroll_internal(WND *wnd, EDITSTATE *es, INT dx, INT dy); -static LRESULT EDIT_EM_PosFromChar(WND *wnd, EDITSTATE *es, INT index, BOOL after_wrap); -static void EDIT_EM_ReplaceSel(WND *wnd, EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update); -static LRESULT EDIT_EM_Scroll(WND *wnd, EDITSTATE *es, INT action); -static void EDIT_EM_ScrollCaret(WND *wnd, EDITSTATE *es); -static void EDIT_EM_SetHandle(WND *wnd, EDITSTATE *es, HLOCAL hloc); -static void EDIT_EM_SetHandle16(WND *wnd, EDITSTATE *es, HLOCAL16 hloc); +static BOOL EDIT_EM_LineScroll(HWND hwnd, EDITSTATE *es, INT dx, INT dy); +static BOOL EDIT_EM_LineScroll_internal(HWND hwnd, EDITSTATE *es, INT dx, INT dy); +static LRESULT EDIT_EM_PosFromChar(HWND hwnd, EDITSTATE *es, INT index, BOOL after_wrap); +static void EDIT_EM_ReplaceSel(HWND hwnd, EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update); +static LRESULT EDIT_EM_Scroll(HWND hwnd, EDITSTATE *es, INT action); +static void EDIT_EM_ScrollCaret(HWND hwnd, EDITSTATE *es); +static void EDIT_EM_SetHandle(HWND hwnd, EDITSTATE *es, HLOCAL hloc); +static void EDIT_EM_SetHandle16(HWND hwnd, EDITSTATE *es, HLOCAL16 hloc); static void EDIT_EM_SetLimitText(EDITSTATE *es, INT limit); static void EDIT_EM_SetMargins(EDITSTATE *es, INT action, INT left, INT right); -static void EDIT_EM_SetPasswordChar(WND *wnd, EDITSTATE *es, WCHAR c); -static void EDIT_EM_SetSel(WND *wnd, EDITSTATE *es, UINT start, UINT end, BOOL after_wrap); +static void EDIT_EM_SetPasswordChar(HWND hwnd, EDITSTATE *es, WCHAR c); +static void EDIT_EM_SetSel(HWND hwnd, EDITSTATE *es, UINT start, UINT end, BOOL after_wrap); static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, LPINT tabs); static BOOL EDIT_EM_SetTabStops16(EDITSTATE *es, INT count, LPINT16 tabs); -static void EDIT_EM_SetWordBreakProc(WND *wnd, EDITSTATE *es, LPARAM lParam); -static void EDIT_EM_SetWordBreakProc16(WND *wnd, EDITSTATE *es, EDITWORDBREAKPROC16 wbp); -static BOOL EDIT_EM_Undo(WND *wnd, EDITSTATE *es); +static void EDIT_EM_SetWordBreakProc(HWND hwnd, EDITSTATE *es, LPARAM lParam); +static void EDIT_EM_SetWordBreakProc16(HWND hwnd, EDITSTATE *es, EDITWORDBREAKPROC16 wbp); +static BOOL EDIT_EM_Undo(HWND hwnd, EDITSTATE *es); /* * WM_XXX message handlers */ -static void EDIT_WM_Char(WND *wnd, EDITSTATE *es, WCHAR c); -static void EDIT_WM_Command(WND *wnd, EDITSTATE *es, INT code, INT id, HWND conrtol); -static void EDIT_WM_ContextMenu(WND *wnd, EDITSTATE *es, INT x, INT y); -static void EDIT_WM_Copy(WND *wnd, EDITSTATE *es); -static LRESULT EDIT_WM_Create(WND *wnd, EDITSTATE *es, LPCWSTR name); -static void EDIT_WM_Destroy(WND *wnd, EDITSTATE *es); -static LRESULT EDIT_WM_EraseBkGnd(WND *wnd, EDITSTATE *es, HDC dc); +static void EDIT_WM_Char(HWND hwnd, EDITSTATE *es, WCHAR c); +static void EDIT_WM_Command(HWND hwnd, EDITSTATE *es, INT code, INT id, HWND conrtol); +static void EDIT_WM_ContextMenu(HWND hwnd, EDITSTATE *es, INT x, INT y); +static void EDIT_WM_Copy(HWND hwnd, EDITSTATE *es); +static LRESULT EDIT_WM_Create(HWND hwnd, EDITSTATE *es, LPCWSTR name); +static void EDIT_WM_Destroy(HWND hwnd, EDITSTATE *es); +static LRESULT EDIT_WM_EraseBkGnd(HWND hwnd, EDITSTATE *es, HDC dc); static INT EDIT_WM_GetText(EDITSTATE *es, INT count, LPARAM lParam, BOOL unicode); -static LRESULT EDIT_WM_HScroll(WND *wnd, EDITSTATE *es, INT action, INT pos); -static LRESULT EDIT_WM_KeyDown(WND *wnd, EDITSTATE *es, INT key); -static LRESULT EDIT_WM_KillFocus(WND *wnd, EDITSTATE *es); -static LRESULT EDIT_WM_LButtonDblClk(WND *wnd, EDITSTATE *es); -static LRESULT EDIT_WM_LButtonDown(WND *wnd, EDITSTATE *es, DWORD keys, INT x, INT y); +static LRESULT EDIT_WM_HScroll(HWND hwnd, EDITSTATE *es, INT action, INT pos); +static LRESULT EDIT_WM_KeyDown(HWND hwnd, EDITSTATE *es, INT key); +static LRESULT EDIT_WM_KillFocus(HWND hwnd, EDITSTATE *es); +static LRESULT EDIT_WM_LButtonDblClk(HWND hwnd, EDITSTATE *es); +static LRESULT EDIT_WM_LButtonDown(HWND hwnd, EDITSTATE *es, DWORD keys, INT x, INT y); static LRESULT EDIT_WM_LButtonUp(HWND hwndSelf, EDITSTATE *es); -static LRESULT EDIT_WM_MButtonDown(WND *wnd); -static LRESULT EDIT_WM_MouseMove(WND *wnd, EDITSTATE *es, INT x, INT y); -static LRESULT EDIT_WM_NCCreate(WND *wnd, DWORD style, HWND hwndParent, BOOL unicode); -static void EDIT_WM_Paint(WND *wnd, EDITSTATE *es, WPARAM wParam); -static void EDIT_WM_Paste(WND *wnd, EDITSTATE *es); -static void EDIT_WM_SetFocus(WND *wnd, EDITSTATE *es); -static void EDIT_WM_SetFont(WND *wnd, EDITSTATE *es, HFONT font, BOOL redraw); -static void EDIT_WM_SetText(WND *wnd, EDITSTATE *es, LPARAM lParam, BOOL unicode); -static void EDIT_WM_Size(WND *wnd, EDITSTATE *es, UINT action, INT width, INT height); -static LRESULT EDIT_WM_StyleChanged (WND *wnd, EDITSTATE *es, WPARAM which, const STYLESTRUCT *style); -static LRESULT EDIT_WM_SysKeyDown(WND *wnd, EDITSTATE *es, INT key, DWORD key_data); -static void EDIT_WM_Timer(WND *wnd, EDITSTATE *es); -static LRESULT EDIT_WM_VScroll(WND *wnd, EDITSTATE *es, INT action, INT pos); -static void EDIT_UpdateText(WND *wnd, LPRECT rc, BOOL bErase); -static void EDIT_UpdateTextRegion(WND *wnd, HRGN hrgn, BOOL bErase); +static LRESULT EDIT_WM_MButtonDown(HWND hwnd); +static LRESULT EDIT_WM_MouseMove(HWND hwnd, EDITSTATE *es, INT x, INT y); +static LRESULT EDIT_WM_NCCreate(HWND hwnd, DWORD style, HWND hwndParent, BOOL unicode); +static void EDIT_WM_Paint(HWND hwnd, EDITSTATE *es, WPARAM wParam); +static void EDIT_WM_Paste(HWND hwnd, EDITSTATE *es); +static void EDIT_WM_SetFocus(HWND hwnd, EDITSTATE *es); +static void EDIT_WM_SetFont(HWND hwnd, EDITSTATE *es, HFONT font, BOOL redraw); +static void EDIT_WM_SetText(HWND hwnd, EDITSTATE *es, LPARAM lParam, BOOL unicode); +static void EDIT_WM_Size(HWND hwnd, EDITSTATE *es, UINT action, INT width, INT height); +static LRESULT EDIT_WM_StyleChanged (HWND hwnd, EDITSTATE *es, WPARAM which, const STYLESTRUCT *style); +static LRESULT EDIT_WM_SysKeyDown(HWND hwnd, EDITSTATE *es, INT key, DWORD key_data); +static void EDIT_WM_Timer(HWND hwnd, EDITSTATE *es); +static LRESULT EDIT_WM_VScroll(HWND hwnd, EDITSTATE *es, INT action, INT pos); +static void EDIT_UpdateText(HWND hwnd, EDITSTATE *es, LPRECT rc, BOOL bErase); +static void EDIT_UpdateTextRegion(HWND hwnd, EDITSTATE *es, HRGN hrgn, BOOL bErase); LRESULT WINAPI EditWndProcA(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); LRESULT WINAPI EditWndProcW(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); @@ -313,7 +313,7 @@ static inline void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es) * WM_CLEAR * */ -static inline void EDIT_WM_Clear(WND *wnd, EDITSTATE *es) +static inline void EDIT_WM_Clear(HWND hwnd, EDITSTATE *es) { static const WCHAR empty_stringW[] = {0}; @@ -321,7 +321,7 @@ static inline void EDIT_WM_Clear(WND *wnd, EDITSTATE *es) if(es->style & ES_READONLY) return; - EDIT_EM_ReplaceSel(wnd, es, TRUE, empty_stringW, TRUE); + EDIT_EM_ReplaceSel(hwnd, es, TRUE, empty_stringW, TRUE); } @@ -330,10 +330,10 @@ static inline void EDIT_WM_Clear(WND *wnd, EDITSTATE *es) * WM_CUT * */ -static inline void EDIT_WM_Cut(WND *wnd, EDITSTATE *es) +static inline void EDIT_WM_Cut(HWND hwnd, EDITSTATE *es) { - EDIT_WM_Copy(wnd, es); - EDIT_WM_Clear(wnd, es); + EDIT_WM_Copy(hwnd, es); + EDIT_WM_Clear(hwnd, es); } @@ -375,7 +375,7 @@ static DWORD get_app_version(void) /********************************************************************* * - * EditWndProc_locked + * EditWndProc_common * * The messages are in the order of the actual integer values * (which can be found in include/windows.h) @@ -386,16 +386,16 @@ static DWORD get_app_version(void) * names). * */ -static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, +static LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode ) { - EDITSTATE *es = *(EDITSTATE **)((wnd)->wExtra); + EDITSTATE *es = (EDITSTATE *)GetWindowLongA( hwnd, 0 ); LRESULT result = 0; switch (msg) { case WM_DESTROY: DPRINTF_EDIT_MSG32("WM_DESTROY"); - if (es) EDIT_WM_Destroy(wnd, es); + if (es) EDIT_WM_Destroy(hwnd, es); result = 0; goto END; @@ -404,12 +404,12 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, if(unicode) { LPCREATESTRUCTW cs = (LPCREATESTRUCTW)lParam; - result = EDIT_WM_NCCreate(wnd, cs->style, cs->hwndParent, TRUE); + result = EDIT_WM_NCCreate(hwnd, cs->style, cs->hwndParent, TRUE); } else { LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam; - result = EDIT_WM_NCCreate(wnd, cs->style, cs->hwndParent, FALSE); + result = EDIT_WM_NCCreate(hwnd, cs->style, cs->hwndParent, FALSE); } goto END; } @@ -417,14 +417,14 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, if (!es) { if(unicode) - result = DefWindowProcW(wnd->hwndSelf, msg, wParam, lParam); + result = DefWindowProcW(hwnd, msg, wParam, lParam); else - result = DefWindowProcA(wnd->hwndSelf, msg, wParam, lParam); + result = DefWindowProcA(hwnd, msg, wParam, lParam); goto END; } - EDIT_LockBuffer(wnd, es); + EDIT_LockBuffer(hwnd, es); switch (msg) { case EM_GETSEL16: DPRINTF_EDIT_MSG16("EM_GETSEL"); @@ -439,17 +439,17 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, case EM_SETSEL16: DPRINTF_EDIT_MSG16("EM_SETSEL"); if (SLOWORD(lParam) == -1) - EDIT_EM_SetSel(wnd, es, (UINT)-1, 0, FALSE); + EDIT_EM_SetSel(hwnd, es, (UINT)-1, 0, FALSE); else - EDIT_EM_SetSel(wnd, es, LOWORD(lParam), HIWORD(lParam), FALSE); + EDIT_EM_SetSel(hwnd, es, LOWORD(lParam), HIWORD(lParam), FALSE); if (!wParam) - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_ScrollCaret(hwnd, es); result = 1; break; case EM_SETSEL: DPRINTF_EDIT_MSG32("EM_SETSEL"); - EDIT_EM_SetSel(wnd, es, wParam, lParam, FALSE); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, wParam, lParam, FALSE); + EDIT_EM_ScrollCaret(hwnd, es); result = 1; break; @@ -469,15 +469,15 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, if ((es->style & ES_MULTILINE) && lParam) { RECT rc; CONV_RECT16TO32(MapSL(lParam), &rc); - EDIT_SetRectNP(wnd, es, &rc); - EDIT_UpdateText(wnd, NULL, TRUE); + EDIT_SetRectNP(hwnd, es, &rc); + EDIT_UpdateText(hwnd, es, NULL, TRUE); } break; case EM_SETRECT: DPRINTF_EDIT_MSG32("EM_SETRECT"); if ((es->style & ES_MULTILINE) && lParam) { - EDIT_SetRectNP(wnd, es, (LPRECT)lParam); - EDIT_UpdateText(wnd, NULL, TRUE); + EDIT_SetRectNP(hwnd, es, (LPRECT)lParam); + EDIT_UpdateText(hwnd, es, NULL, TRUE); } break; @@ -486,13 +486,13 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, if ((es->style & ES_MULTILINE) && lParam) { RECT rc; CONV_RECT16TO32(MapSL(lParam), &rc); - EDIT_SetRectNP(wnd, es, &rc); + EDIT_SetRectNP(hwnd, es, &rc); } break; case EM_SETRECTNP: DPRINTF_EDIT_MSG32("EM_SETRECTNP"); if ((es->style & ES_MULTILINE) && lParam) - EDIT_SetRectNP(wnd, es, (LPRECT)lParam); + EDIT_SetRectNP(hwnd, es, (LPRECT)lParam); break; case EM_SCROLL16: @@ -500,7 +500,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, /* fall through */ case EM_SCROLL: DPRINTF_EDIT_MSG32("EM_SCROLL"); - result = EDIT_EM_Scroll(wnd, es, (INT)wParam); + result = EDIT_EM_Scroll(hwnd, es, (INT)wParam); break; case EM_LINESCROLL16: @@ -510,7 +510,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, /* fall through */ case EM_LINESCROLL: DPRINTF_EDIT_MSG32("EM_LINESCROLL"); - result = (LRESULT)EDIT_EM_LineScroll(wnd, es, (INT)wParam, (INT)lParam); + result = (LRESULT)EDIT_EM_LineScroll(hwnd, es, (INT)wParam, (INT)lParam); break; case EM_SCROLLCARET16: @@ -518,7 +518,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, /* fall through */ case EM_SCROLLCARET: DPRINTF_EDIT_MSG32("EM_SCROLLCARET"); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_ScrollCaret(hwnd, es); result = 1; break; @@ -561,16 +561,16 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, case EM_SETHANDLE16: DPRINTF_EDIT_MSG16("EM_SETHANDLE"); - EDIT_EM_SetHandle16(wnd, es, (HLOCAL16)wParam); + EDIT_EM_SetHandle16(hwnd, es, (HLOCAL16)wParam); break; case EM_SETHANDLE: DPRINTF_EDIT_MSG32("EM_SETHANDLE"); - EDIT_EM_SetHandle(wnd, es, (HLOCAL)wParam); + EDIT_EM_SetHandle(hwnd, es, (HLOCAL)wParam); break; case EM_GETHANDLE16: DPRINTF_EDIT_MSG16("EM_GETHANDLE"); - result = (LRESULT)EDIT_EM_GetHandle16(wnd, es); + result = (LRESULT)EDIT_EM_GetHandle16(hwnd, es); break; case EM_GETHANDLE: DPRINTF_EDIT_MSG32("EM_GETHANDLE"); @@ -582,7 +582,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, /* fall through */ case EM_GETTHUMB: DPRINTF_EDIT_MSG32("EM_GETTHUMB"); - result = EDIT_EM_GetThumb(wnd, es); + result = EDIT_EM_GetThumb(hwnd, es); break; /* messages 0x00bf and 0x00c0 missing from specs */ @@ -592,10 +592,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, /* fall through */ case 0x00bf: DPRINTF_EDIT_MSG32("undocumented 0x00bf, please report"); - if(unicode) - result = DefWindowProcW(wnd->hwndSelf, msg, wParam, lParam); - else - result = DefWindowProcA(wnd->hwndSelf, msg, wParam, lParam); + result = DefWindowProcW(hwnd, msg, wParam, lParam); break; case WM_USER+16: @@ -603,10 +600,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, /* fall through */ case 0x00c0: DPRINTF_EDIT_MSG32("undocumented 0x00c0, please report"); - if(unicode) - result = DefWindowProcW(wnd->hwndSelf, msg, wParam, lParam); - else - result = DefWindowProcA(wnd->hwndSelf, msg, wParam, lParam); + result = DefWindowProcW(hwnd, msg, wParam, lParam); break; case EM_LINELENGTH16: @@ -637,7 +631,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW); } - EDIT_EM_ReplaceSel(wnd, es, (BOOL)wParam, textW, TRUE); + EDIT_EM_ReplaceSel(hwnd, es, (BOOL)wParam, textW, TRUE); result = 1; if(!unicode) @@ -651,10 +645,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, /* fall through */ case 0x00c3: DPRINTF_EDIT_MSG32("undocumented 0x00c3, please report"); - if(unicode) - result = DefWindowProcW(wnd->hwndSelf, msg, wParam, lParam); - else - result = DefWindowProcA(wnd->hwndSelf, msg, wParam, lParam); + result = DefWindowProcW(hwnd, msg, wParam, lParam); break; case EM_GETLINE16: @@ -690,7 +681,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, /* fall through */ case WM_UNDO: DPRINTF_EDIT_MSG32("EM_UNDO / WM_UNDO"); - result = (LRESULT)EDIT_EM_Undo(wnd, es); + result = (LRESULT)EDIT_EM_Undo(hwnd, es); break; case EM_FMTLINES16: @@ -716,10 +707,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, /* fall through */ case 0x00ca: DPRINTF_EDIT_MSG32("undocumented 0x00ca, please report"); - if(unicode) - result = DefWindowProcW(wnd->hwndSelf, msg, wParam, lParam); - else - result = DefWindowProcA(wnd->hwndSelf, msg, wParam, lParam); + result = DefWindowProcW(hwnd, msg, wParam, lParam); break; case EM_SETTABSTOPS16: @@ -748,7 +736,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, MultiByteToWideChar(CP_ACP, 0, &charA, 1, &charW, 1); } - EDIT_EM_SetPasswordChar(wnd, es, charW); + EDIT_EM_SetPasswordChar(hwnd, es, charW); break; } @@ -775,22 +763,24 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, case EM_SETREADONLY: DPRINTF_EDIT_MSG32("EM_SETREADONLY"); if (wParam) { - wnd->dwStyle |= ES_READONLY; - es->style |= ES_READONLY; + SetWindowLongA( hwnd, GWL_STYLE, + GetWindowLongA( hwnd, GWL_STYLE ) | ES_READONLY ); + es->style |= ES_READONLY; } else { - wnd->dwStyle &= ~ES_READONLY; - es->style &= ~ES_READONLY; + SetWindowLongA( hwnd, GWL_STYLE, + GetWindowLongA( hwnd, GWL_STYLE ) & ~ES_READONLY ); + es->style &= ~ES_READONLY; } result = 1; break; case EM_SETWORDBREAKPROC16: DPRINTF_EDIT_MSG16("EM_SETWORDBREAKPROC"); - EDIT_EM_SetWordBreakProc16(wnd, es, (EDITWORDBREAKPROC16)lParam); + EDIT_EM_SetWordBreakProc16(hwnd, es, (EDITWORDBREAKPROC16)lParam); break; case EM_SETWORDBREAKPROC: DPRINTF_EDIT_MSG32("EM_SETWORDBREAKPROC"); - EDIT_EM_SetWordBreakProc(wnd, es, lParam); + EDIT_EM_SetWordBreakProc(hwnd, es, lParam); break; case EM_GETWORDBREAKPROC16: @@ -841,12 +831,12 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, case EM_POSFROMCHAR: DPRINTF_EDIT_MSG32("EM_POSFROMCHAR"); - result = EDIT_EM_PosFromChar(wnd, es, (INT)wParam, FALSE); + result = EDIT_EM_PosFromChar(hwnd, es, (INT)wParam, FALSE); break; case EM_CHARFROMPOS: DPRINTF_EDIT_MSG32("EM_CHARFROMPOS"); - result = EDIT_EM_CharFromPos(wnd, es, SLOWORD(lParam), SHIWORD(lParam)); + result = EDIT_EM_CharFromPos(hwnd, es, SLOWORD(lParam), SHIWORD(lParam)); break; /* End of the EM_ messages which were in numerical order; what order @@ -861,13 +851,13 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, { int vk = (int)((LPMSG)lParam)->wParam; - if ((wnd->dwStyle & ES_WANTRETURN) && vk == VK_RETURN) + if (vk == VK_RETURN && (GetWindowLongA( hwnd, GWL_STYLE ) & ES_WANTRETURN)) { result |= DLGC_WANTMESSAGE; } else if (es->hwndListBox && (vk == VK_RETURN || vk == VK_ESCAPE)) { - if (SendMessageW(wnd->parent->hwndSelf, CB_GETDROPPEDSTATE, 0, 0)) + if (SendMessageW(GetParent(hwnd), CB_GETDROPPEDSTATE, 0, 0)) result |= DLGC_WANTMESSAGE; } } @@ -888,38 +878,38 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, if ((charW == VK_RETURN || charW == VK_ESCAPE) && es->hwndListBox) { - if (SendMessageW(wnd->parent->hwndSelf, CB_GETDROPPEDSTATE, 0, 0)) - SendMessageW(wnd->parent->hwndSelf, WM_KEYDOWN, charW, 0); + if (SendMessageW(GetParent(hwnd), CB_GETDROPPEDSTATE, 0, 0)) + SendMessageW(GetParent(hwnd), WM_KEYDOWN, charW, 0); break; } - EDIT_WM_Char(wnd, es, charW); + EDIT_WM_Char(hwnd, es, charW); break; } case WM_CLEAR: DPRINTF_EDIT_MSG32("WM_CLEAR"); - EDIT_WM_Clear(wnd, es); + EDIT_WM_Clear(hwnd, es); break; case WM_COMMAND: DPRINTF_EDIT_MSG32("WM_COMMAND"); - EDIT_WM_Command(wnd, es, HIWORD(wParam), LOWORD(wParam), (HWND)lParam); + EDIT_WM_Command(hwnd, es, HIWORD(wParam), LOWORD(wParam), (HWND)lParam); break; case WM_CONTEXTMENU: DPRINTF_EDIT_MSG32("WM_CONTEXTMENU"); - EDIT_WM_ContextMenu(wnd, es, SLOWORD(lParam), SHIWORD(lParam)); + EDIT_WM_ContextMenu(hwnd, es, SLOWORD(lParam), SHIWORD(lParam)); break; case WM_COPY: DPRINTF_EDIT_MSG32("WM_COPY"); - EDIT_WM_Copy(wnd, es); + EDIT_WM_Copy(hwnd, es); break; case WM_CREATE: DPRINTF_EDIT_MSG32("WM_CREATE"); if(unicode) - result = EDIT_WM_Create(wnd, es, ((LPCREATESTRUCTW)lParam)->lpszName); + result = EDIT_WM_Create(hwnd, es, ((LPCREATESTRUCTW)lParam)->lpszName); else { LPCSTR nameA = ((LPCREATESTRUCTA)lParam)->lpszName; @@ -930,7 +920,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, if((nameW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, countW); } - result = EDIT_WM_Create(wnd, es, nameW); + result = EDIT_WM_Create(hwnd, es, nameW); if(nameW) HeapFree(GetProcessHeap(), 0, nameW); } @@ -938,18 +928,18 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, case WM_CUT: DPRINTF_EDIT_MSG32("WM_CUT"); - EDIT_WM_Cut(wnd, es); + EDIT_WM_Cut(hwnd, es); break; case WM_ENABLE: DPRINTF_EDIT_MSG32("WM_ENABLE"); es->bEnableState = (BOOL) wParam; - EDIT_UpdateText(wnd, NULL, TRUE); + EDIT_UpdateText(hwnd, es, NULL, TRUE); break; case WM_ERASEBKGND: DPRINTF_EDIT_MSG32("WM_ERASEBKGND"); - result = EDIT_WM_EraseBkGnd(wnd, es, (HDC)wParam); + result = EDIT_WM_EraseBkGnd(hwnd, es, (HDC)wParam); break; case WM_GETFONT: @@ -969,37 +959,37 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, case WM_HSCROLL: DPRINTF_EDIT_MSG32("WM_HSCROLL"); - result = EDIT_WM_HScroll(wnd, es, LOWORD(wParam), SHIWORD(wParam)); + result = EDIT_WM_HScroll(hwnd, es, LOWORD(wParam), SHIWORD(wParam)); break; case WM_KEYDOWN: DPRINTF_EDIT_MSG32("WM_KEYDOWN"); - result = EDIT_WM_KeyDown(wnd, es, (INT)wParam); + result = EDIT_WM_KeyDown(hwnd, es, (INT)wParam); break; case WM_KILLFOCUS: DPRINTF_EDIT_MSG32("WM_KILLFOCUS"); - result = EDIT_WM_KillFocus(wnd, es); + result = EDIT_WM_KillFocus(hwnd, es); break; case WM_LBUTTONDBLCLK: DPRINTF_EDIT_MSG32("WM_LBUTTONDBLCLK"); - result = EDIT_WM_LButtonDblClk(wnd, es); + result = EDIT_WM_LButtonDblClk(hwnd, es); break; case WM_LBUTTONDOWN: DPRINTF_EDIT_MSG32("WM_LBUTTONDOWN"); - result = EDIT_WM_LButtonDown(wnd, es, (DWORD)wParam, SLOWORD(lParam), SHIWORD(lParam)); + result = EDIT_WM_LButtonDown(hwnd, es, (DWORD)wParam, SLOWORD(lParam), SHIWORD(lParam)); break; case WM_LBUTTONUP: DPRINTF_EDIT_MSG32("WM_LBUTTONUP"); - result = EDIT_WM_LButtonUp(wnd->hwndSelf, es); + result = EDIT_WM_LButtonUp(hwnd, es); break; case WM_MBUTTONDOWN: DPRINTF_EDIT_MSG32("WM_MBUTTONDOWN"); - result = EDIT_WM_MButtonDown(wnd); + result = EDIT_WM_MButtonDown(hwnd); break; case WM_MOUSEACTIVATE: @@ -1010,7 +1000,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, * modeless dialog box ??? */ DPRINTF_EDIT_MSG32("WM_MOUSEACTIVATE"); - SetFocus(wnd->hwndSelf); + SetFocus(hwnd); result = MA_ACTIVATE; break; @@ -1018,27 +1008,27 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, /* * DPRINTF_EDIT_MSG32("WM_MOUSEMOVE"); */ - result = EDIT_WM_MouseMove(wnd, es, SLOWORD(lParam), SHIWORD(lParam)); + result = EDIT_WM_MouseMove(hwnd, es, SLOWORD(lParam), SHIWORD(lParam)); break; case WM_PAINT: DPRINTF_EDIT_MSG32("WM_PAINT"); - EDIT_WM_Paint(wnd, es, wParam); + EDIT_WM_Paint(hwnd, es, wParam); break; case WM_PASTE: DPRINTF_EDIT_MSG32("WM_PASTE"); - EDIT_WM_Paste(wnd, es); + EDIT_WM_Paste(hwnd, es); break; case WM_SETFOCUS: DPRINTF_EDIT_MSG32("WM_SETFOCUS"); - EDIT_WM_SetFocus(wnd, es); + EDIT_WM_SetFocus(hwnd, es); break; case WM_SETFONT: DPRINTF_EDIT_MSG32("WM_SETFONT"); - EDIT_WM_SetFont(wnd, es, (HFONT)wParam, LOWORD(lParam) != 0); + EDIT_WM_SetFont(hwnd, es, (HFONT)wParam, LOWORD(lParam) != 0); break; case WM_SETREDRAW: @@ -1047,18 +1037,18 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, case WM_SETTEXT: DPRINTF_EDIT_MSG32("WM_SETTEXT"); - EDIT_WM_SetText(wnd, es, lParam, unicode); + EDIT_WM_SetText(hwnd, es, lParam, unicode); result = TRUE; break; case WM_SIZE: DPRINTF_EDIT_MSG32("WM_SIZE"); - EDIT_WM_Size(wnd, es, (UINT)wParam, LOWORD(lParam), HIWORD(lParam)); + EDIT_WM_Size(hwnd, es, (UINT)wParam, LOWORD(lParam), HIWORD(lParam)); break; case WM_STYLECHANGED: DPRINTF_EDIT_MSG32("WM_STYLECHANGED"); - result = EDIT_WM_StyleChanged (wnd, es, wParam, (const STYLESTRUCT *)lParam); + result = EDIT_WM_StyleChanged (hwnd, es, wParam, (const STYLESTRUCT *)lParam); break; case WM_STYLECHANGING: @@ -1068,17 +1058,17 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, case WM_SYSKEYDOWN: DPRINTF_EDIT_MSG32("WM_SYSKEYDOWN"); - result = EDIT_WM_SysKeyDown(wnd, es, (INT)wParam, (DWORD)lParam); + result = EDIT_WM_SysKeyDown(hwnd, es, (INT)wParam, (DWORD)lParam); break; case WM_TIMER: DPRINTF_EDIT_MSG32("WM_TIMER"); - EDIT_WM_Timer(wnd, es); + EDIT_WM_Timer(hwnd, es); break; case WM_VSCROLL: DPRINTF_EDIT_MSG32("WM_VSCROLL"); - result = EDIT_WM_VScroll(wnd, es, LOWORD(wParam), SHIWORD(wParam)); + result = EDIT_WM_VScroll(hwnd, es, LOWORD(wParam), SHIWORD(wParam)); break; case WM_MOUSEWHEEL: @@ -1088,10 +1078,7 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0); if (wParam & (MK_SHIFT | MK_CONTROL)) { - if(unicode) - result = DefWindowProcW(wnd->hwndSelf, msg, wParam, lParam); - else - result = DefWindowProcA(wnd->hwndSelf, msg, wParam, lParam); + result = DefWindowProcW(hwnd, msg, wParam, lParam); break; } gcWheelDelta -= SHIWORD(wParam); @@ -1099,18 +1086,18 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, { int cLineScroll= (int) min((UINT) es->line_count, pulScrollLines); cLineScroll *= (gcWheelDelta / WHEEL_DELTA); - result = EDIT_EM_LineScroll(wnd, es, 0, cLineScroll); + result = EDIT_EM_LineScroll(hwnd, es, 0, cLineScroll); } } break; default: if(unicode) - result = DefWindowProcW(wnd->hwndSelf, msg, wParam, lParam); + result = DefWindowProcW(hwnd, msg, wParam, lParam); else - result = DefWindowProcA(wnd->hwndSelf, msg, wParam, lParam); + result = DefWindowProcA(hwnd, msg, wParam, lParam); break; } - EDIT_UnlockBuffer(wnd, es, FALSE); + EDIT_UnlockBuffer(hwnd, es, FALSE); END: return result; } @@ -1121,15 +1108,8 @@ static LRESULT WINAPI EditWndProc_locked( WND *wnd, UINT msg, */ LRESULT WINAPI EditWndProcW(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - LRESULT res = 0; - WND *wndPtr = WIN_FindWndPtr(hWnd); - - if (wndPtr) - { - res = EditWndProc_locked(wndPtr, uMsg, wParam, lParam, TRUE); - WIN_ReleaseWndPtr(wndPtr); - } - return res; + if (!IsWindow( hWnd )) return 0; + return EditWndProc_common(hWnd, uMsg, wParam, lParam, TRUE); } /********************************************************************* @@ -1138,15 +1118,8 @@ LRESULT WINAPI EditWndProcW(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) */ LRESULT WINAPI EditWndProcA(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - LRESULT res = 0; - WND *wndPtr = WIN_FindWndPtr(hWnd); - - if (wndPtr) - { - res = EditWndProc_locked(wndPtr, uMsg, wParam, lParam, FALSE); - WIN_ReleaseWndPtr(wndPtr); - } - return res; + if (!IsWindow( hWnd )) return 0; + return EditWndProc_common(hWnd, uMsg, wParam, lParam, FALSE); } /********************************************************************* @@ -1158,7 +1131,7 @@ LRESULT WINAPI EditWndProcA(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) * a soft return '\r\r\n' or a hard return '\r\n' * */ -static void EDIT_BuildLineDefs_ML(WND *wnd, EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn) +static void EDIT_BuildLineDefs_ML(HWND hwnd, EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn) { HDC dc; HFONT old_font = 0; @@ -1175,7 +1148,7 @@ static void EDIT_BuildLineDefs_ML(WND *wnd, EDITSTATE *es, INT istart, INT iend, if (istart == iend && delta == 0) return; - dc = GetDC(wnd->hwndSelf); + dc = GetDC(hwnd); if (es->font) old_font = SelectObject(dc, es->font); @@ -1402,7 +1375,7 @@ static void EDIT_BuildLineDefs_ML(WND *wnd, EDITSTATE *es, INT istart, INT iend, if (es->font) SelectObject(dc, old_font); - ReleaseDC(wnd->hwndSelf, dc); + ReleaseDC(hwnd, dc); } /********************************************************************* @@ -1410,9 +1383,9 @@ static void EDIT_BuildLineDefs_ML(WND *wnd, EDITSTATE *es, INT istart, INT iend, * EDIT_CalcLineWidth_SL * */ -static void EDIT_CalcLineWidth_SL(WND *wnd, EDITSTATE *es) +static void EDIT_CalcLineWidth_SL(HWND hwnd, EDITSTATE *es) { - es->text_width = SLOWORD(EDIT_EM_PosFromChar(wnd, es, strlenW(es->text), FALSE)); + es->text_width = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, strlenW(es->text), FALSE)); } /********************************************************************* @@ -1496,7 +1469,7 @@ static INT EDIT_CallWordBreakProc(EDITSTATE *es, INT start, INT index, INT count * The return value is only the character index * */ -static INT EDIT_CharFromPos(WND *wnd, EDITSTATE *es, INT x, INT y, LPBOOL after_wrap) +static INT EDIT_CharFromPos(HWND hwnd, EDITSTATE *es, INT x, INT y, LPBOOL after_wrap) { INT index; HDC dc; @@ -1523,7 +1496,7 @@ static INT EDIT_CharFromPos(WND *wnd, EDITSTATE *es, INT x, INT y, LPBOOL after_ *after_wrap = FALSE; return line_index; } - dc = GetDC(wnd->hwndSelf); + dc = GetDC(hwnd); if (es->font) old_font = SelectObject(dc, es->font); low = line_index + 1; @@ -1548,7 +1521,7 @@ static INT EDIT_CharFromPos(WND *wnd, EDITSTATE *es, INT x, INT y, LPBOOL after_ if (!x) return es->x_offset; text = EDIT_GetPasswordPointer_SL(es); - dc = GetDC(wnd->hwndSelf); + dc = GetDC(hwnd); if (es->font) old_font = SelectObject(dc, es->font); if (x < 0) @@ -1584,7 +1557,7 @@ static INT EDIT_CharFromPos(WND *wnd, EDITSTATE *es, INT x, INT y, LPBOOL after_ } if (es->font) SelectObject(dc, old_font); - ReleaseDC(wnd->hwndSelf, dc); + ReleaseDC(hwnd, dc); return index; } @@ -1612,7 +1585,7 @@ static void EDIT_ConfinePoint(EDITSTATE *es, LPINT x, LPINT y) * column to an ending column. * */ -static void EDIT_GetLineRect(WND *wnd, EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc) +static void EDIT_GetLineRect(HWND hwnd, EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc) { INT line_index = EDIT_EM_LineIndex(es, line); @@ -1621,8 +1594,8 @@ static void EDIT_GetLineRect(WND *wnd, EDITSTATE *es, INT line, INT scol, INT ec else rc->top = es->format_rect.top; rc->bottom = rc->top + es->line_height; - rc->left = (scol == 0) ? es->format_rect.left : SLOWORD(EDIT_EM_PosFromChar(wnd, es, line_index + scol, TRUE)); - rc->right = (ecol == -1) ? es->format_rect.right : SLOWORD(EDIT_EM_PosFromChar(wnd, es, line_index + ecol, TRUE)); + rc->left = (scol == 0) ? es->format_rect.left : SLOWORD(EDIT_EM_PosFromChar(hwnd, es, line_index + scol, TRUE)); + rc->right = (ecol == -1) ? es->format_rect.right : SLOWORD(EDIT_EM_PosFromChar(hwnd, es, line_index + ecol, TRUE)); } @@ -1654,8 +1627,9 @@ static LPWSTR EDIT_GetPasswordPointer_SL(EDITSTATE *es) * you can call it whenever you like, without unlocking. * */ -static void EDIT_LockBuffer(WND *wnd, EDITSTATE *es) +static void EDIT_LockBuffer(HWND hwnd, EDITSTATE *es) { + HINSTANCE hInstance = GetWindowLongA( hwnd, GWL_HINSTANCE ); if (!es) { ERR("no EDITSTATE ... please report\n"); return; @@ -1676,7 +1650,7 @@ static void EDIT_LockBuffer(WND *wnd, EDITSTATE *es) else if(es->hloc16) { TRACE("Synchronizing with 16-bit ANSI buffer\n"); - textA = LOCAL_Lock(wnd->hInstance, es->hloc16); + textA = LOCAL_Lock(hInstance, es->hloc16); countA = strlen(textA) + 1; _16bit = TRUE; } @@ -1714,7 +1688,7 @@ static void EDIT_LockBuffer(WND *wnd, EDITSTATE *es) { MultiByteToWideChar(CP_ACP, 0, textA, countA, es->text, es->buffer_size + 1); if(_16bit) - LOCAL_Unlock(wnd->hInstance, es->hloc16); + LOCAL_Unlock(hInstance, es->hloc16); else LocalUnlock(es->hloc32A); } @@ -1731,14 +1705,14 @@ static void EDIT_LockBuffer(WND *wnd, EDITSTATE *es) * Does the job for single-line controls only. * */ -static void EDIT_SL_InvalidateText(WND *wnd, EDITSTATE *es, INT start, INT end) +static void EDIT_SL_InvalidateText(HWND hwnd, EDITSTATE *es, INT start, INT end) { RECT line_rect; RECT rc; - EDIT_GetLineRect(wnd, es, 0, start, end, &line_rect); + EDIT_GetLineRect(hwnd, es, 0, start, end, &line_rect); if (IntersectRect(&rc, &line_rect, &es->format_rect)) - EDIT_UpdateText(wnd, &rc, FALSE); + EDIT_UpdateText(hwnd, es, &rc, FALSE); } @@ -1750,7 +1724,7 @@ static void EDIT_SL_InvalidateText(WND *wnd, EDITSTATE *es, INT start, INT end) * Does the job for multi-line controls only. * */ -static void EDIT_ML_InvalidateText(WND *wnd, EDITSTATE *es, INT start, INT end) +static void EDIT_ML_InvalidateText(HWND hwnd, EDITSTATE *es, INT start, INT end) { INT vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height; INT sl = EDIT_EM_LineFromChar(es, start); @@ -1776,30 +1750,30 @@ static void EDIT_ML_InvalidateText(WND *wnd, EDITSTATE *es, INT start, INT end) el = es->y_offset + vlc; ec = EDIT_EM_LineLength(es, EDIT_EM_LineIndex(es, el)); } - GetClientRect(wnd->hwndSelf, &rc1); + GetClientRect(hwnd, &rc1); IntersectRect(&rcWnd, &rc1, &es->format_rect); if (sl == el) { - EDIT_GetLineRect(wnd, es, sl, sc, ec, &rcLine); + EDIT_GetLineRect(hwnd, es, sl, sc, ec, &rcLine); if (IntersectRect(&rcUpdate, &rcWnd, &rcLine)) - EDIT_UpdateText(wnd, &rcUpdate, FALSE); + EDIT_UpdateText(hwnd, es, &rcUpdate, FALSE); } else { - EDIT_GetLineRect(wnd, es, sl, sc, + EDIT_GetLineRect(hwnd, es, sl, sc, EDIT_EM_LineLength(es, EDIT_EM_LineIndex(es, sl)), &rcLine); if (IntersectRect(&rcUpdate, &rcWnd, &rcLine)) - EDIT_UpdateText(wnd, &rcUpdate, FALSE); + EDIT_UpdateText(hwnd, es, &rcUpdate, FALSE); for (l = sl + 1 ; l < el ; l++) { - EDIT_GetLineRect(wnd, es, l, 0, + EDIT_GetLineRect(hwnd, es, l, 0, EDIT_EM_LineLength(es, EDIT_EM_LineIndex(es, l)), &rcLine); if (IntersectRect(&rcUpdate, &rcWnd, &rcLine)) - EDIT_UpdateText(wnd, &rcUpdate, FALSE); + EDIT_UpdateText(hwnd, es, &rcUpdate, FALSE); } - EDIT_GetLineRect(wnd, es, el, 0, ec, &rcLine); + EDIT_GetLineRect(hwnd, es, el, 0, ec, &rcLine); if (IntersectRect(&rcUpdate, &rcWnd, &rcLine)) - EDIT_UpdateText(wnd, &rcUpdate, FALSE); + EDIT_UpdateText(hwnd, es, &rcUpdate, FALSE); } } @@ -1815,7 +1789,7 @@ static void EDIT_ML_InvalidateText(WND *wnd, EDITSTATE *es, INT start, INT end) * start and end need not be ordered. * */ -static void EDIT_InvalidateText(WND *wnd, EDITSTATE *es, INT start, INT end) +static void EDIT_InvalidateText(HWND hwnd, EDITSTATE *es, INT start, INT end) { if (end == start) return; @@ -1826,9 +1800,9 @@ static void EDIT_InvalidateText(WND *wnd, EDITSTATE *es, INT start, INT end) ORDER_INT(start, end); if (es->style & ES_MULTILINE) - EDIT_ML_InvalidateText(wnd, es, start, end); + EDIT_ML_InvalidateText(hwnd, es, start, end); else - EDIT_SL_InvalidateText(wnd, es, start, end); + EDIT_SL_InvalidateText(hwnd, es, start, end); } @@ -1839,14 +1813,14 @@ static void EDIT_InvalidateText(WND *wnd, EDITSTATE *es, INT start, INT end) * Try to fit size + 1 characters in the buffer. Constrain to limits. * */ -static BOOL EDIT_MakeFit(WND *wnd, EDITSTATE *es, UINT size) +static BOOL EDIT_MakeFit(HWND hwnd, EDITSTATE *es, UINT size) { HLOCAL hNew32W; if (size <= es->buffer_size) return TRUE; if (size > es->buffer_limit) { - EDIT_NOTIFY_PARENT(es, EN_MAXTEXT, "EN_MAXTEXT"); + EDIT_NOTIFY_PARENT(hwnd, es, EN_MAXTEXT, "EN_MAXTEXT"); return FALSE; } if (size > es->buffer_limit) @@ -1855,7 +1829,7 @@ static BOOL EDIT_MakeFit(WND *wnd, EDITSTATE *es, UINT size) TRACE("trying to ReAlloc to %d+1 characters\n", size); /* Force edit to unlock it's buffer. es->text now NULL */ - EDIT_UnlockBuffer(wnd, es, TRUE); + EDIT_UnlockBuffer(hwnd, es, TRUE); if (es->hloc32W) { UINT alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR)); @@ -1866,11 +1840,11 @@ static BOOL EDIT_MakeFit(WND *wnd, EDITSTATE *es, UINT size) } } - EDIT_LockBuffer(wnd, es); + EDIT_LockBuffer(hwnd, es); if (es->buffer_size < size) { WARN("FAILED ! We now have %d+1\n", es->buffer_size); - EDIT_NOTIFY_PARENT(es, EN_ERRSPACE, "EN_ERRSPACE"); + EDIT_NOTIFY_PARENT(hwnd, es, EN_ERRSPACE, "EN_ERRSPACE"); return FALSE; } else { TRACE("We now have %d+1\n", es->buffer_size); @@ -1913,7 +1887,7 @@ static BOOL EDIT_MakeUndoFit(EDITSTATE *es, UINT size) * EDIT_MoveBackward * */ -static void EDIT_MoveBackward(WND *wnd, EDITSTATE *es, BOOL extend) +static void EDIT_MoveBackward(HWND hwnd, EDITSTATE *es, BOOL extend) { INT e = es->selection_end; @@ -1926,8 +1900,8 @@ static void EDIT_MoveBackward(WND *wnd, EDITSTATE *es, BOOL extend) e--; } } - EDIT_EM_SetSel(wnd, es, extend ? es->selection_start : e, e, FALSE); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, extend ? es->selection_start : e, e, FALSE); + EDIT_EM_ScrollCaret(hwnd, es); } @@ -1940,20 +1914,20 @@ static void EDIT_MoveBackward(WND *wnd, EDITSTATE *es, BOOL extend) * x coordinate on the screen (might be a different column). * */ -static void EDIT_MoveDown_ML(WND *wnd, EDITSTATE *es, BOOL extend) +static void EDIT_MoveDown_ML(HWND hwnd, EDITSTATE *es, BOOL extend) { INT s = es->selection_start; INT e = es->selection_end; BOOL after_wrap = (es->flags & EF_AFTER_WRAP); - LRESULT pos = EDIT_EM_PosFromChar(wnd, es, e, after_wrap); + LRESULT pos = EDIT_EM_PosFromChar(hwnd, es, e, after_wrap); INT x = SLOWORD(pos); INT y = SHIWORD(pos); - e = EDIT_CharFromPos(wnd, es, x, y + es->line_height, &after_wrap); + e = EDIT_CharFromPos(hwnd, es, x, y + es->line_height, &after_wrap); if (!extend) s = e; - EDIT_EM_SetSel(wnd, es, s, e, after_wrap); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, s, e, after_wrap); + EDIT_EM_ScrollCaret(hwnd, es); } @@ -1962,19 +1936,19 @@ static void EDIT_MoveDown_ML(WND *wnd, EDITSTATE *es, BOOL extend) * EDIT_MoveEnd * */ -static void EDIT_MoveEnd(WND *wnd, EDITSTATE *es, BOOL extend) +static void EDIT_MoveEnd(HWND hwnd, EDITSTATE *es, BOOL extend) { BOOL after_wrap = FALSE; INT e; /* Pass a high value in x to make sure of receiving the end of the line */ if (es->style & ES_MULTILINE) - e = EDIT_CharFromPos(wnd, es, 0x3fffffff, - HIWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap); + e = EDIT_CharFromPos(hwnd, es, 0x3fffffff, + HIWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap); else e = strlenW(es->text); - EDIT_EM_SetSel(wnd, es, extend ? es->selection_start : e, e, after_wrap); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, extend ? es->selection_start : e, e, after_wrap); + EDIT_EM_ScrollCaret(hwnd, es); } @@ -1983,7 +1957,7 @@ static void EDIT_MoveEnd(WND *wnd, EDITSTATE *es, BOOL extend) * EDIT_MoveForward * */ -static void EDIT_MoveForward(WND *wnd, EDITSTATE *es, BOOL extend) +static void EDIT_MoveForward(HWND hwnd, EDITSTATE *es, BOOL extend) { INT e = es->selection_end; @@ -1996,8 +1970,8 @@ static void EDIT_MoveForward(WND *wnd, EDITSTATE *es, BOOL extend) e += 2; } } - EDIT_EM_SetSel(wnd, es, extend ? es->selection_start : e, e, FALSE); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, extend ? es->selection_start : e, e, FALSE); + EDIT_EM_ScrollCaret(hwnd, es); } @@ -2008,18 +1982,18 @@ static void EDIT_MoveForward(WND *wnd, EDITSTATE *es, BOOL extend) * Home key: move to beginning of line. * */ -static void EDIT_MoveHome(WND *wnd, EDITSTATE *es, BOOL extend) +static void EDIT_MoveHome(HWND hwnd, EDITSTATE *es, BOOL extend) { INT e; /* Pass the x_offset in x to make sure of receiving the first position of the line */ if (es->style & ES_MULTILINE) - e = EDIT_CharFromPos(wnd, es, -es->x_offset, - HIWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)), NULL); + e = EDIT_CharFromPos(hwnd, es, -es->x_offset, + HIWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)), NULL); else e = 0; - EDIT_EM_SetSel(wnd, es, extend ? es->selection_start : e, e, FALSE); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, extend ? es->selection_start : e, e, FALSE); + EDIT_EM_ScrollCaret(hwnd, es); } @@ -2032,22 +2006,22 @@ static void EDIT_MoveHome(WND *wnd, EDITSTATE *es, BOOL extend) * x coordinate on the screen (might be a different column). * */ -static void EDIT_MovePageDown_ML(WND *wnd, EDITSTATE *es, BOOL extend) +static void EDIT_MovePageDown_ML(HWND hwnd, EDITSTATE *es, BOOL extend) { INT s = es->selection_start; INT e = es->selection_end; BOOL after_wrap = (es->flags & EF_AFTER_WRAP); - LRESULT pos = EDIT_EM_PosFromChar(wnd, es, e, after_wrap); + LRESULT pos = EDIT_EM_PosFromChar(hwnd, es, e, after_wrap); INT x = SLOWORD(pos); INT y = SHIWORD(pos); - e = EDIT_CharFromPos(wnd, es, x, + e = EDIT_CharFromPos(hwnd, es, x, y + (es->format_rect.bottom - es->format_rect.top), &after_wrap); if (!extend) s = e; - EDIT_EM_SetSel(wnd, es, s, e, after_wrap); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, s, e, after_wrap); + EDIT_EM_ScrollCaret(hwnd, es); } @@ -2060,22 +2034,22 @@ static void EDIT_MovePageDown_ML(WND *wnd, EDITSTATE *es, BOOL extend) * x coordinate on the screen (might be a different column). * */ -static void EDIT_MovePageUp_ML(WND *wnd, EDITSTATE *es, BOOL extend) +static void EDIT_MovePageUp_ML(HWND hwnd, EDITSTATE *es, BOOL extend) { INT s = es->selection_start; INT e = es->selection_end; BOOL after_wrap = (es->flags & EF_AFTER_WRAP); - LRESULT pos = EDIT_EM_PosFromChar(wnd, es, e, after_wrap); + LRESULT pos = EDIT_EM_PosFromChar(hwnd, es, e, after_wrap); INT x = SLOWORD(pos); INT y = SHIWORD(pos); - e = EDIT_CharFromPos(wnd, es, x, + e = EDIT_CharFromPos(hwnd, es, x, y - (es->format_rect.bottom - es->format_rect.top), &after_wrap); if (!extend) s = e; - EDIT_EM_SetSel(wnd, es, s, e, after_wrap); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, s, e, after_wrap); + EDIT_EM_ScrollCaret(hwnd, es); } @@ -2088,20 +2062,20 @@ static void EDIT_MovePageUp_ML(WND *wnd, EDITSTATE *es, BOOL extend) * x coordinate on the screen (might be a different column). * */ -static void EDIT_MoveUp_ML(WND *wnd, EDITSTATE *es, BOOL extend) +static void EDIT_MoveUp_ML(HWND hwnd, EDITSTATE *es, BOOL extend) { INT s = es->selection_start; INT e = es->selection_end; BOOL after_wrap = (es->flags & EF_AFTER_WRAP); - LRESULT pos = EDIT_EM_PosFromChar(wnd, es, e, after_wrap); + LRESULT pos = EDIT_EM_PosFromChar(hwnd, es, e, after_wrap); INT x = SLOWORD(pos); INT y = SHIWORD(pos); - e = EDIT_CharFromPos(wnd, es, x, y - es->line_height, &after_wrap); + e = EDIT_CharFromPos(hwnd, es, x, y - es->line_height, &after_wrap); if (!extend) s = e; - EDIT_EM_SetSel(wnd, es, s, e, after_wrap); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, s, e, after_wrap); + EDIT_EM_ScrollCaret(hwnd, es); } @@ -2110,7 +2084,7 @@ static void EDIT_MoveUp_ML(WND *wnd, EDITSTATE *es, BOOL extend) * EDIT_MoveWordBackward * */ -static void EDIT_MoveWordBackward(WND *wnd, EDITSTATE *es, BOOL extend) +static void EDIT_MoveWordBackward(HWND hwnd, EDITSTATE *es, BOOL extend) { INT s = es->selection_start; INT e = es->selection_end; @@ -2132,8 +2106,8 @@ static void EDIT_MoveWordBackward(WND *wnd, EDITSTATE *es, BOOL extend) } if (!extend) s = e; - EDIT_EM_SetSel(wnd, es, s, e, FALSE); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, s, e, FALSE); + EDIT_EM_ScrollCaret(hwnd, es); } @@ -2142,7 +2116,7 @@ static void EDIT_MoveWordBackward(WND *wnd, EDITSTATE *es, BOOL extend) * EDIT_MoveWordForward * */ -static void EDIT_MoveWordForward(WND *wnd, EDITSTATE *es, BOOL extend) +static void EDIT_MoveWordForward(HWND hwnd, EDITSTATE *es, BOOL extend) { INT s = es->selection_start; INT e = es->selection_end; @@ -2162,8 +2136,8 @@ static void EDIT_MoveWordForward(WND *wnd, EDITSTATE *es, BOOL extend) } if (!extend) s = e; - EDIT_EM_SetSel(wnd, es, s, e, FALSE); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, s, e, FALSE); + EDIT_EM_ScrollCaret(hwnd, es); } @@ -2172,7 +2146,7 @@ static void EDIT_MoveWordForward(WND *wnd, EDITSTATE *es, BOOL extend) * EDIT_PaintLine * */ -static void EDIT_PaintLine(WND *wnd, EDITSTATE *es, HDC dc, INT line, BOOL rev) +static void EDIT_PaintLine(HWND hwnd, EDITSTATE *es, HDC dc, INT line, BOOL rev) { INT s = es->selection_start; INT e = es->selection_end; @@ -2191,7 +2165,7 @@ static void EDIT_PaintLine(WND *wnd, EDITSTATE *es, HDC dc, INT line, BOOL rev) TRACE("line=%d\n", line); - pos = EDIT_EM_PosFromChar(wnd, es, EDIT_EM_LineIndex(es, line), FALSE); + pos = EDIT_EM_PosFromChar(hwnd, es, EDIT_EM_LineIndex(es, line), FALSE); x = SLOWORD(pos); y = SHIWORD(pos); li = EDIT_EM_LineIndex(es, line); @@ -2261,10 +2235,10 @@ static INT EDIT_PaintText(EDITSTATE *es, HDC dc, INT x, INT y, INT line, INT col * EDIT_SetCaretPos * */ -static void EDIT_SetCaretPos(WND *wnd, EDITSTATE *es, INT pos, +static void EDIT_SetCaretPos(HWND hwnd, EDITSTATE *es, INT pos, BOOL after_wrap) { - LRESULT res = EDIT_EM_PosFromChar(wnd, es, pos, after_wrap); + LRESULT res = EDIT_EM_PosFromChar(hwnd, es, pos, after_wrap); SetCaretPos(SLOWORD(res), SHIWORD(res)); } @@ -2277,7 +2251,7 @@ static void EDIT_SetCaretPos(WND *wnd, EDITSTATE *es, INT pos, * it is also used to set the rect of a single line control * */ -static void EDIT_SetRectNP(WND *wnd, EDITSTATE *es, LPRECT rc) +static void EDIT_SetRectNP(HWND hwnd, EDITSTATE *es, LPRECT rc) { CopyRect(&es->format_rect, rc); if (es->style & WS_BORDER) { @@ -2313,14 +2287,14 @@ static void EDIT_SetRectNP(WND *wnd, EDITSTATE *es, LPRECT rc) es->y_offset = max_y_offset; /* force scroll info update */ - EDIT_UpdateScrollInfo(wnd, es); + EDIT_UpdateScrollInfo(hwnd, es); } else /* Windows doesn't care to fix text placement for SL controls */ es->format_rect.bottom = es->format_rect.top + es->line_height; if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) - EDIT_BuildLineDefs_ML(wnd, es, 0, strlenW(es->text), 0, (HRGN)0); + EDIT_BuildLineDefs_ML(hwnd, es, 0, strlenW(es->text), 0, (HRGN)0); } @@ -2329,12 +2303,14 @@ static void EDIT_SetRectNP(WND *wnd, EDITSTATE *es, LPRECT rc) * EDIT_UnlockBuffer * */ -static void EDIT_UnlockBuffer(WND *wnd, EDITSTATE *es, BOOL force) +static void EDIT_UnlockBuffer(HWND hwnd, EDITSTATE *es, BOOL force) { + HINSTANCE hInstance = GetWindowLongA( hwnd, GWL_HINSTANCE ); + /* Edit window might be already destroyed */ - if(!IsWindow(wnd->hwndSelf)) + if(!IsWindow(hwnd)) { - WARN("edit wnd %04x already destroyed\n", wnd->hwndSelf); + WARN("edit hwnd %04x already destroyed\n", hwnd); return; } @@ -2386,23 +2362,23 @@ static void EDIT_UnlockBuffer(WND *wnd, EDITSTATE *es, BOOL force) UINT countA_new = WideCharToMultiByte(CP_ACP, 0, es->text, countW, NULL, 0, NULL, NULL); TRACE("Synchronizing with 16-bit ANSI buffer\n"); TRACE("%d WCHARs translated to %d bytes\n", countW, countA_new); - countA = LOCAL_Size(wnd->hInstance, es->hloc16); + countA = LOCAL_Size(hInstance, es->hloc16); if(countA_new > countA) { HLOCAL16 hloc16_new; UINT alloc_size = ROUND_TO_GROW(countA_new); TRACE("Resizing 16-bit ANSI buffer from %d to %d bytes\n", countA, alloc_size); - hloc16_new = LOCAL_ReAlloc(wnd->hInstance, es->hloc16, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT); + hloc16_new = LOCAL_ReAlloc(hInstance, es->hloc16, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT); if(hloc16_new) { es->hloc16 = hloc16_new; - countA = LOCAL_Size(wnd->hInstance, hloc16_new); + countA = LOCAL_Size(hInstance, hloc16_new); TRACE("Real new size %d bytes\n", countA); } else WARN("FAILED! Will synchronize partially\n"); } - textA = LOCAL_Lock(wnd->hInstance, es->hloc16); + textA = LOCAL_Lock(hInstance, es->hloc16); _16bit = TRUE; } @@ -2410,7 +2386,7 @@ static void EDIT_UnlockBuffer(WND *wnd, EDITSTATE *es, BOOL force) { WideCharToMultiByte(CP_ACP, 0, es->text, countW, textA, countA, NULL, NULL); if(_16bit) - LOCAL_Unlock(wnd->hInstance, es->hloc16); + LOCAL_Unlock(hInstance, es->hloc16); else LocalUnlock(es->hloc32A); } @@ -2432,7 +2408,7 @@ static void EDIT_UnlockBuffer(WND *wnd, EDITSTATE *es, BOOL force) * EDIT_UpdateScrollInfo * */ -static void EDIT_UpdateScrollInfo(WND *wnd, EDITSTATE *es) +static void EDIT_UpdateScrollInfo(HWND hwnd, EDITSTATE *es) { if ((es->style & WS_VSCROLL) && !(es->flags & EF_VSCROLL_TRACK)) { @@ -2445,7 +2421,7 @@ static void EDIT_UpdateScrollInfo(WND *wnd, EDITSTATE *es) si.nPos = es->y_offset; TRACE("SB_VERT, nMin=%d, nMax=%d, nPage=%d, nPos=%d\n", si.nMin, si.nMax, si.nPage, si.nPos); - SetScrollInfo(wnd->hwndSelf, SB_VERT, &si, TRUE); + SetScrollInfo(hwnd, SB_VERT, &si, TRUE); } if ((es->style & WS_HSCROLL) && !(es->flags & EF_HSCROLL_TRACK)) @@ -2459,7 +2435,7 @@ static void EDIT_UpdateScrollInfo(WND *wnd, EDITSTATE *es) si.nPos = es->x_offset; TRACE("SB_HORZ, nMin=%d, nMax=%d, nPage=%d, nPos=%d\n", si.nMin, si.nMax, si.nPage, si.nPos); - SetScrollInfo(wnd->hwndSelf, SB_HORZ, &si, TRUE); + SetScrollInfo(hwnd, SB_HORZ, &si, TRUE); } } @@ -2541,7 +2517,7 @@ static INT CALLBACK EDIT_WordBreakProc(LPWSTR s, INT index, INT count, INT actio * if outside formatting rectangle ??? * */ -static LRESULT EDIT_EM_CharFromPos(WND *wnd, EDITSTATE *es, INT x, INT y) +static LRESULT EDIT_EM_CharFromPos(HWND hwnd, EDITSTATE *es, INT x, INT y) { POINT pt; RECT rc; @@ -2549,11 +2525,11 @@ static LRESULT EDIT_EM_CharFromPos(WND *wnd, EDITSTATE *es, INT x, INT y) pt.x = x; pt.y = y; - GetClientRect(wnd->hwndSelf, &rc); + GetClientRect(hwnd, &rc); if (!PtInRect(&rc, pt)) return -1; - index = EDIT_CharFromPos(wnd, es, x, y, NULL); + index = EDIT_CharFromPos(hwnd, es, x, y, NULL); return MAKELONG(index, EDIT_EM_LineFromChar(es, index)); } @@ -2636,8 +2612,9 @@ static HLOCAL EDIT_EM_GetHandle(EDITSTATE *es) * * In this function we'll try to switch to local heap. */ -static HLOCAL16 EDIT_EM_GetHandle16(WND *wnd, EDITSTATE *es) +static HLOCAL16 EDIT_EM_GetHandle16(HWND hwnd, EDITSTATE *es) { + HINSTANCE hInstance = GetWindowLongA( hwnd, GWL_HINSTANCE ); CHAR *textA; UINT countA, alloc_size; @@ -2647,9 +2624,9 @@ static HLOCAL16 EDIT_EM_GetHandle16(WND *wnd, EDITSTATE *es) if (es->hloc16) return es->hloc16; - if (!LOCAL_HeapSize(wnd->hInstance)) { - if (!LocalInit16(wnd->hInstance, 0, - GlobalSize16(wnd->hInstance))) { + if (!LOCAL_HeapSize(hInstance)) { + if (!LocalInit16(hInstance, 0, + GlobalSize16(hInstance))) { ERR("could not initialize local heap\n"); return 0; } @@ -2660,22 +2637,22 @@ static HLOCAL16 EDIT_EM_GetHandle16(WND *wnd, EDITSTATE *es) alloc_size = ROUND_TO_GROW(countA); TRACE("Allocating 16-bit ANSI alias buffer\n"); - if (!(es->hloc16 = LOCAL_Alloc(wnd->hInstance, LMEM_MOVEABLE | LMEM_ZEROINIT, alloc_size))) { + if (!(es->hloc16 = LOCAL_Alloc(hInstance, LMEM_MOVEABLE | LMEM_ZEROINIT, alloc_size))) { ERR("could not allocate new 16 bit buffer\n"); return 0; } - if (!(textA = (LPSTR)LOCAL_Lock(wnd->hInstance, es->hloc16))) { + if (!(textA = (LPSTR)LOCAL_Lock(hInstance, es->hloc16))) { ERR("could not lock new 16 bit buffer\n"); - LOCAL_Free(wnd->hInstance, es->hloc16); + LOCAL_Free(hInstance, es->hloc16); es->hloc16 = 0; return 0; } WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, countA, NULL, NULL); - LOCAL_Unlock(wnd->hInstance, es->hloc16); + LOCAL_Unlock(hInstance, es->hloc16); - TRACE("Returning %04X, LocalSize() = %d\n", es->hloc16, LOCAL_Size(wnd->hInstance, es->hloc16)); + TRACE("Returning %04X, LocalSize() = %d\n", es->hloc16, LOCAL_Size(hInstance, es->hloc16)); return es->hloc16; } @@ -2758,10 +2735,10 @@ static LRESULT EDIT_EM_GetSel(EDITSTATE *es, LPUINT start, LPUINT end) * All in all: very poorly documented * */ -static LRESULT EDIT_EM_GetThumb(WND *wnd, EDITSTATE *es) +static LRESULT EDIT_EM_GetThumb(HWND hwnd, EDITSTATE *es) { - return MAKELONG(EDIT_WM_VScroll(wnd, es, EM_GETTHUMB16, 0), - EDIT_WM_HScroll(wnd, es, EM_GETTHUMB16, 0)); + return MAKELONG(EDIT_WM_VScroll(hwnd, es, EM_GETTHUMB16, 0), + EDIT_WM_HScroll(hwnd, es, EM_GETTHUMB16, 0)); } @@ -2871,13 +2848,13 @@ static INT EDIT_EM_LineLength(EDITSTATE *es, INT index) * NOTE: dx is in average character widths, dy - in lines; * */ -static BOOL EDIT_EM_LineScroll(WND *wnd, EDITSTATE *es, INT dx, INT dy) +static BOOL EDIT_EM_LineScroll(HWND hwnd, EDITSTATE *es, INT dx, INT dy) { if (!(es->style & ES_MULTILINE)) return FALSE; dx *= es->char_width; - return EDIT_EM_LineScroll_internal(wnd, es, dx, dy); + return EDIT_EM_LineScroll_internal(hwnd, es, dx, dy); } /********************************************************************* @@ -2889,7 +2866,7 @@ static BOOL EDIT_EM_LineScroll(WND *wnd, EDITSTATE *es, INT dx, INT dy) * dx is in pixels, dy - in lines. * */ -static BOOL EDIT_EM_LineScroll_internal(WND *wnd, EDITSTATE *es, INT dx, INT dy) +static BOOL EDIT_EM_LineScroll_internal(HWND hwnd, EDITSTATE *es, INT dx, INT dy) { INT nyoff; INT x_offset_in_pixels; @@ -2901,7 +2878,7 @@ static BOOL EDIT_EM_LineScroll_internal(WND *wnd, EDITSTATE *es, INT dx, INT dy) else { dy = 0; - x_offset_in_pixels = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->x_offset, FALSE)); + x_offset_in_pixels = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, es->x_offset, FALSE)); } if (-dx > x_offset_in_pixels) @@ -2922,17 +2899,17 @@ static BOOL EDIT_EM_LineScroll_internal(WND *wnd, EDITSTATE *es, INT dx, INT dy) else es->x_offset += dx / es->char_width; - GetClientRect(wnd->hwndSelf, &rc1); + GetClientRect(hwnd, &rc1); IntersectRect(&rc, &rc1, &es->format_rect); - ScrollWindowEx(wnd->hwndSelf, -dx, dy, + ScrollWindowEx(hwnd, -dx, dy, NULL, &rc, (HRGN)NULL, NULL, SW_INVALIDATE); /* force scroll info update */ - EDIT_UpdateScrollInfo(wnd, es); + EDIT_UpdateScrollInfo(hwnd, es); } if (dx && !(es->flags & EF_HSCROLL_TRACK)) - EDIT_NOTIFY_PARENT(es, EN_HSCROLL, "EN_HSCROLL"); + EDIT_NOTIFY_PARENT(hwnd, es, EN_HSCROLL, "EN_HSCROLL"); if (dy && !(es->flags & EF_VSCROLL_TRACK)) - EDIT_NOTIFY_PARENT(es, EN_VSCROLL, "EN_VSCROLL"); + EDIT_NOTIFY_PARENT(hwnd, es, EN_VSCROLL, "EN_VSCROLL"); return TRUE; } @@ -2942,7 +2919,7 @@ static BOOL EDIT_EM_LineScroll_internal(WND *wnd, EDITSTATE *es, INT dx, INT dy) * EM_POSFROMCHAR * */ -static LRESULT EDIT_EM_PosFromChar(WND *wnd, EDITSTATE *es, INT index, BOOL after_wrap) +static LRESULT EDIT_EM_PosFromChar(HWND hwnd, EDITSTATE *es, INT index, BOOL after_wrap) { INT len = strlenW(es->text); INT l; @@ -2954,7 +2931,7 @@ static LRESULT EDIT_EM_PosFromChar(WND *wnd, EDITSTATE *es, INT index, BOOL afte SIZE size; index = min(index, len); - dc = GetDC(wnd->hwndSelf); + dc = GetDC(hwnd); if (es->font) old_font = SelectObject(dc, es->font); if (es->style & ES_MULTILINE) { @@ -2995,7 +2972,7 @@ static LRESULT EDIT_EM_PosFromChar(WND *wnd, EDITSTATE *es, INT index, BOOL afte y += es->format_rect.top; if (es->font) SelectObject(dc, old_font); - ReleaseDC(wnd->hwndSelf, dc); + ReleaseDC(hwnd, dc); return MAKELONG((INT16)x, (INT16)y); } @@ -3007,7 +2984,7 @@ static LRESULT EDIT_EM_PosFromChar(WND *wnd, EDITSTATE *es, INT index, BOOL afte * FIXME: handle ES_NUMBER and ES_OEMCONVERT here * */ -static void EDIT_EM_ReplaceSel(WND *wnd, EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update) +static void EDIT_EM_ReplaceSel(HWND hwnd, EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update) { UINT strl = strlenW(lpsz_replace); UINT tl = strlenW(es->text); @@ -3029,7 +3006,7 @@ static void EDIT_EM_ReplaceSel(WND *wnd, EDITSTATE *es, BOOL can_undo, LPCWSTR l ORDER_UINT(s, e); - if (!EDIT_MakeFit(wnd, es, tl - (e - s) + strl)) + if (!EDIT_MakeFit(hwnd, es, tl - (e - s) + strl)) return; if (e != s) { @@ -3102,32 +3079,32 @@ static void EDIT_EM_ReplaceSel(WND *wnd, EDITSTATE *es, BOOL can_undo, LPCWSTR l INT s = min(es->selection_start, es->selection_end); hrgn = CreateRectRgn(0, 0, 0, 0); - EDIT_BuildLineDefs_ML(wnd, es, s, s + strl, + EDIT_BuildLineDefs_ML(hwnd, es, s, s + strl, strl - abs(es->selection_end - es->selection_start), hrgn); } else - EDIT_CalcLineWidth_SL(wnd, es); + EDIT_CalcLineWidth_SL(hwnd, es); - EDIT_EM_SetSel(wnd, es, s, s, FALSE); + EDIT_EM_SetSel(hwnd, es, s, s, FALSE); es->flags |= EF_MODIFIED; if (send_update) es->flags |= EF_UPDATE; - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_ScrollCaret(hwnd, es); /* force scroll info update */ - EDIT_UpdateScrollInfo(wnd, es); + EDIT_UpdateScrollInfo(hwnd, es); if (hrgn) { - EDIT_UpdateTextRegion(wnd, hrgn, TRUE); + EDIT_UpdateTextRegion(hwnd, es, hrgn, TRUE); DeleteObject(hrgn); } else - EDIT_UpdateText(wnd, NULL, TRUE); + EDIT_UpdateText(hwnd, es, NULL, TRUE); if(es->flags & EF_UPDATE) { es->flags &= ~EF_UPDATE; - EDIT_NOTIFY_PARENT(es, EN_CHANGE, "EN_CHANGE"); + EDIT_NOTIFY_PARENT(hwnd, es, EN_CHANGE, "EN_CHANGE"); } } @@ -3137,7 +3114,7 @@ static void EDIT_EM_ReplaceSel(WND *wnd, EDITSTATE *es, BOOL can_undo, LPCWSTR l * EM_SCROLL * */ -static LRESULT EDIT_EM_Scroll(WND *wnd, EDITSTATE *es, INT action) +static LRESULT EDIT_EM_Scroll(HWND hwnd, EDITSTATE *es, INT action) { INT dy; @@ -3174,7 +3151,7 @@ static LRESULT EDIT_EM_Scroll(WND *wnd, EDITSTATE *es, INT action) /* Notification is done in EDIT_EM_LineScroll */ if(dy) - EDIT_EM_LineScroll(wnd, es, 0, dy); + EDIT_EM_LineScroll(hwnd, es, 0, dy); } return MAKELONG((INT16)dy, (BOOL16)TRUE); } @@ -3185,7 +3162,7 @@ static LRESULT EDIT_EM_Scroll(WND *wnd, EDITSTATE *es, INT action) * EM_SCROLLCARET * */ -static void EDIT_EM_ScrollCaret(WND *wnd, EDITSTATE *es) +static void EDIT_EM_ScrollCaret(HWND hwnd, EDITSTATE *es) { if (es->style & ES_MULTILINE) { INT l; @@ -3199,7 +3176,7 @@ static void EDIT_EM_ScrollCaret(WND *wnd, EDITSTATE *es) l = EDIT_EM_LineFromChar(es, es->selection_end); li = EDIT_EM_LineIndex(es, l); - x = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)); + x = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)); vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height; if (l >= es->y_offset + vlc) dy = l - vlc + 1 - es->y_offset; @@ -3216,7 +3193,7 @@ static void EDIT_EM_ScrollCaret(WND *wnd, EDITSTATE *es) if(es->x_offset + dx + ww > es->text_width) dx = es->text_width - ww - es->x_offset; if(dx || dy) - EDIT_EM_LineScroll_internal(wnd, es, dx, dy); + EDIT_EM_LineScroll_internal(hwnd, es, dx, dy); } } else { INT x; @@ -3226,32 +3203,32 @@ static void EDIT_EM_ScrollCaret(WND *wnd, EDITSTATE *es) if (!(es->style & ES_AUTOHSCROLL)) return; - x = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, FALSE)); + x = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, FALSE)); format_width = es->format_rect.right - es->format_rect.left; if (x < es->format_rect.left) { goal = es->format_rect.left + format_width / HSCROLL_FRACTION; do { es->x_offset--; - x = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, FALSE)); + x = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, FALSE)); } while ((x < goal) && es->x_offset); /* FIXME: use ScrollWindow() somehow to improve performance */ - EDIT_UpdateText(wnd, NULL, TRUE); + EDIT_UpdateText(hwnd, es, NULL, TRUE); } else if (x > es->format_rect.right) { INT x_last; INT len = strlenW(es->text); goal = es->format_rect.right - format_width / HSCROLL_FRACTION; do { es->x_offset++; - x = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, FALSE)); - x_last = SLOWORD(EDIT_EM_PosFromChar(wnd, es, len, FALSE)); + x = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, es->selection_end, FALSE)); + x_last = SLOWORD(EDIT_EM_PosFromChar(hwnd, es, len, FALSE)); } while ((x > goal) && (x_last > es->format_rect.right)); /* FIXME: use ScrollWindow() somehow to improve performance */ - EDIT_UpdateText(wnd, NULL, TRUE); + EDIT_UpdateText(hwnd, es, NULL, TRUE); } } if(es->flags & EF_FOCUSED) - EDIT_SetCaretPos(wnd, es, es->selection_end, es->flags & EF_AFTER_WRAP); + EDIT_SetCaretPos(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP); } @@ -3262,8 +3239,10 @@ static void EDIT_EM_ScrollCaret(WND *wnd, EDITSTATE *es) * FIXME: ES_LOWERCASE, ES_UPPERCASE, ES_OEMCONVERT, ES_NUMBER ??? * */ -static void EDIT_EM_SetHandle(WND *wnd, EDITSTATE *es, HLOCAL hloc) +static void EDIT_EM_SetHandle(HWND hwnd, EDITSTATE *es, HLOCAL hloc) { + HINSTANCE hInstance = GetWindowLongA( hwnd, GWL_HINSTANCE ); + if (!(es->style & ES_MULTILINE)) return; @@ -3272,11 +3251,11 @@ static void EDIT_EM_SetHandle(WND *wnd, EDITSTATE *es, HLOCAL hloc) return; } - EDIT_UnlockBuffer(wnd, es, TRUE); + EDIT_UnlockBuffer(hwnd, es, TRUE); if(es->hloc16) { - LOCAL_Free(wnd->hInstance, es->hloc16); + LOCAL_Free(hInstance, es->hloc16); es->hloc16 = (HLOCAL16)NULL; } @@ -3318,18 +3297,18 @@ static void EDIT_EM_SetHandle(WND *wnd, EDITSTATE *es, HLOCAL hloc) es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1; - EDIT_LockBuffer(wnd, es); + EDIT_LockBuffer(hwnd, es); es->x_offset = es->y_offset = 0; es->selection_start = es->selection_end = 0; EDIT_EM_EmptyUndoBuffer(es); es->flags &= ~EF_MODIFIED; es->flags &= ~EF_UPDATE; - EDIT_BuildLineDefs_ML(wnd, es, 0, strlenW(es->text), 0, (HRGN)0); - EDIT_UpdateText(wnd, NULL, TRUE); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_BuildLineDefs_ML(hwnd, es, 0, strlenW(es->text), 0, (HRGN)0); + EDIT_UpdateText(hwnd, es, NULL, TRUE); + EDIT_EM_ScrollCaret(hwnd, es); /* force scroll info update */ - EDIT_UpdateScrollInfo(wnd, es); + EDIT_UpdateScrollInfo(hwnd, es); } @@ -3340,8 +3319,9 @@ static void EDIT_EM_SetHandle(WND *wnd, EDITSTATE *es, HLOCAL hloc) * FIXME: ES_LOWERCASE, ES_UPPERCASE, ES_OEMCONVERT, ES_NUMBER ??? * */ -static void EDIT_EM_SetHandle16(WND *wnd, EDITSTATE *es, HLOCAL16 hloc) +static void EDIT_EM_SetHandle16(HWND hwnd, EDITSTATE *es, HLOCAL16 hloc) { + HINSTANCE hInstance = GetWindowLongA( hwnd, GWL_HINSTANCE ); INT countW, countA; HLOCAL hloc32W_new; WCHAR *textW; @@ -3355,7 +3335,7 @@ static void EDIT_EM_SetHandle16(WND *wnd, EDITSTATE *es, HLOCAL16 hloc) return; } - EDIT_UnlockBuffer(wnd, es, TRUE); + EDIT_UnlockBuffer(hwnd, es, TRUE); if(es->hloc32A) { @@ -3363,8 +3343,8 @@ static void EDIT_EM_SetHandle16(WND *wnd, EDITSTATE *es, HLOCAL16 hloc) es->hloc32A = (HLOCAL)NULL; } - countA = LOCAL_Size(wnd->hInstance, hloc); - textA = LOCAL_Lock(wnd->hInstance, hloc); + countA = LOCAL_Size(hInstance, hloc); + textA = LOCAL_Lock(hInstance, hloc); countW = MultiByteToWideChar(CP_ACP, 0, textA, countA, NULL, 0); if(!(hloc32W_new = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, countW * sizeof(WCHAR)))) { @@ -3374,7 +3354,7 @@ static void EDIT_EM_SetHandle16(WND *wnd, EDITSTATE *es, HLOCAL16 hloc) textW = LocalLock(hloc32W_new); MultiByteToWideChar(CP_ACP, 0, textA, countA, textW, countW); LocalUnlock(hloc32W_new); - LOCAL_Unlock(wnd->hInstance, hloc); + LOCAL_Unlock(hInstance, hloc); if(es->hloc32W) LocalFree(es->hloc32W); @@ -3384,18 +3364,18 @@ static void EDIT_EM_SetHandle16(WND *wnd, EDITSTATE *es, HLOCAL16 hloc) es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1; - EDIT_LockBuffer(wnd, es); + EDIT_LockBuffer(hwnd, es); es->x_offset = es->y_offset = 0; es->selection_start = es->selection_end = 0; EDIT_EM_EmptyUndoBuffer(es); es->flags &= ~EF_MODIFIED; es->flags &= ~EF_UPDATE; - EDIT_BuildLineDefs_ML(wnd, es, 0, strlenW(es->text), 0, (HRGN)0); - EDIT_UpdateText(wnd, NULL, TRUE); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_BuildLineDefs_ML(hwnd, es, 0, strlenW(es->text), 0, (HRGN)0); + EDIT_UpdateText(hwnd, es, NULL, TRUE); + EDIT_EM_ScrollCaret(hwnd, es); /* force scroll info update */ - EDIT_UpdateScrollInfo(wnd, es); + EDIT_UpdateScrollInfo(hwnd, es); } @@ -3457,23 +3437,26 @@ static void EDIT_EM_SetMargins(EDITSTATE *es, INT action, * EM_SETPASSWORDCHAR * */ -static void EDIT_EM_SetPasswordChar(WND *wnd, EDITSTATE *es, WCHAR c) +static void EDIT_EM_SetPasswordChar(HWND hwnd, EDITSTATE *es, WCHAR c) { + LONG style; + if (es->style & ES_MULTILINE) return; if (es->password_char == c) return; + style = GetWindowLongA( hwnd, GWL_STYLE ); es->password_char = c; if (c) { - wnd->dwStyle |= ES_PASSWORD; - es->style |= ES_PASSWORD; + SetWindowLongA( hwnd, GWL_STYLE, style | ES_PASSWORD ); + es->style |= ES_PASSWORD; } else { - wnd->dwStyle &= ~ES_PASSWORD; - es->style &= ~ES_PASSWORD; + SetWindowLongA( hwnd, GWL_STYLE, style & ~ES_PASSWORD ); + es->style &= ~ES_PASSWORD; } - EDIT_UpdateText(wnd, NULL, TRUE); + EDIT_UpdateText(hwnd, es, NULL, TRUE); } @@ -3486,7 +3469,7 @@ static void EDIT_EM_SetPasswordChar(WND *wnd, EDITSTATE *es, WCHAR c) * In other words: this handler is OK * */ -static void EDIT_EM_SetSel(WND *wnd, EDITSTATE *es, UINT start, UINT end, BOOL after_wrap) +static void EDIT_EM_SetSel(HWND hwnd, EDITSTATE *es, UINT start, UINT end, BOOL after_wrap) { UINT old_start = es->selection_start; UINT old_end = es->selection_end; @@ -3515,22 +3498,22 @@ static void EDIT_EM_SetSel(WND *wnd, EDITSTATE *es, UINT start, UINT end, BOOL a /* * One can also do * ORDER_UINT32(end, old_start); - * EDIT_InvalidateText(wnd, es, start, end); - * EDIT_InvalidateText(wnd, es, old_start, old_end); + * EDIT_InvalidateText(hwnd, es, start, end); + * EDIT_InvalidateText(hwnd, es, old_start, old_end); * in place of the following if statement. */ if (old_start > end ) { - EDIT_InvalidateText(wnd, es, start, end); - EDIT_InvalidateText(wnd, es, old_start, old_end); + EDIT_InvalidateText(hwnd, es, start, end); + EDIT_InvalidateText(hwnd, es, old_start, old_end); } else { - EDIT_InvalidateText(wnd, es, start, old_start); - EDIT_InvalidateText(wnd, es, end, old_end); + EDIT_InvalidateText(hwnd, es, start, old_start); + EDIT_InvalidateText(hwnd, es, end, old_end); } } - else EDIT_InvalidateText(wnd, es, start, old_end); + else EDIT_InvalidateText(hwnd, es, start, old_end); } @@ -3585,7 +3568,7 @@ static BOOL EDIT_EM_SetTabStops16(EDITSTATE *es, INT count, LPINT16 tabs) * EM_SETWORDBREAKPROC * */ -static void EDIT_EM_SetWordBreakProc(WND *wnd, EDITSTATE *es, LPARAM lParam) +static void EDIT_EM_SetWordBreakProc(HWND hwnd, EDITSTATE *es, LPARAM lParam) { if (es->word_break_proc == (void *)lParam) return; @@ -3594,8 +3577,8 @@ static void EDIT_EM_SetWordBreakProc(WND *wnd, EDITSTATE *es, LPARAM lParam) es->word_break_proc16 = NULL; if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) { - EDIT_BuildLineDefs_ML(wnd, es, 0, strlenW(es->text), 0, (HRGN)0); - EDIT_UpdateText(wnd, NULL, TRUE); + EDIT_BuildLineDefs_ML(hwnd, es, 0, strlenW(es->text), 0, (HRGN)0); + EDIT_UpdateText(hwnd, es, NULL, TRUE); } } @@ -3605,7 +3588,7 @@ static void EDIT_EM_SetWordBreakProc(WND *wnd, EDITSTATE *es, LPARAM lParam) * EM_SETWORDBREAKPROC16 * */ -static void EDIT_EM_SetWordBreakProc16(WND *wnd, EDITSTATE *es, EDITWORDBREAKPROC16 wbp) +static void EDIT_EM_SetWordBreakProc16(HWND hwnd, EDITSTATE *es, EDITWORDBREAKPROC16 wbp) { if (es->word_break_proc16 == wbp) return; @@ -3613,8 +3596,8 @@ static void EDIT_EM_SetWordBreakProc16(WND *wnd, EDITSTATE *es, EDITWORDBREAKPRO es->word_break_proc = NULL; es->word_break_proc16 = wbp; if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) { - EDIT_BuildLineDefs_ML(wnd, es, 0, strlenW(es->text), 0, (HRGN)0); - EDIT_UpdateText(wnd, NULL, TRUE); + EDIT_BuildLineDefs_ML(hwnd, es, 0, strlenW(es->text), 0, (HRGN)0); + EDIT_UpdateText(hwnd, es, NULL, TRUE); } } @@ -3624,7 +3607,7 @@ static void EDIT_EM_SetWordBreakProc16(WND *wnd, EDITSTATE *es, EDITWORDBREAKPRO * EM_UNDO / WM_UNDO * */ -static BOOL EDIT_EM_Undo(WND *wnd, EDITSTATE *es) +static BOOL EDIT_EM_Undo(HWND hwnd, EDITSTATE *es) { INT ulength; LPWSTR utext; @@ -3641,13 +3624,13 @@ static BOOL EDIT_EM_Undo(WND *wnd, EDITSTATE *es) TRACE("before UNDO:insertion length = %d, deletion buffer = %s\n", es->undo_insert_count, debugstr_w(utext)); - EDIT_EM_SetSel(wnd, es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE); + EDIT_EM_SetSel(hwnd, es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE); EDIT_EM_EmptyUndoBuffer(es); - EDIT_EM_ReplaceSel(wnd, es, TRUE, utext, FALSE); - EDIT_EM_SetSel(wnd, es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE); + EDIT_EM_ReplaceSel(hwnd, es, TRUE, utext, FALSE); + EDIT_EM_SetSel(hwnd, es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE); /* send the notification after the selection start and end are set */ - EDIT_NOTIFY_PARENT(es, EN_CHANGE, "EN_CHANGE"); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_NOTIFY_PARENT(hwnd, es, EN_CHANGE, "EN_CHANGE"); + EDIT_EM_ScrollCaret(hwnd, es); HeapFree(GetProcessHeap(), 0, utext); TRACE("after UNDO:insertion length = %d, deletion buffer = %s\n", @@ -3661,7 +3644,7 @@ static BOOL EDIT_EM_Undo(WND *wnd, EDITSTATE *es) * WM_CHAR * */ -static void EDIT_WM_Char(WND *wnd, EDITSTATE *es, WCHAR c) +static void EDIT_WM_Char(HWND hwnd, EDITSTATE *es, WCHAR c) { BOOL control; @@ -3679,11 +3662,11 @@ static void EDIT_WM_Char(WND *wnd, EDITSTATE *es, WCHAR c) case '\n': if (es->style & ES_MULTILINE) { if (es->style & ES_READONLY) { - EDIT_MoveHome(wnd, es, FALSE); - EDIT_MoveDown_ML(wnd, es, FALSE); + EDIT_MoveHome(hwnd, es, FALSE); + EDIT_MoveDown_ML(hwnd, es, FALSE); } else { static const WCHAR cr_lfW[] = {'\r','\n',0}; - EDIT_EM_ReplaceSel(wnd, es, TRUE, cr_lfW, TRUE); + EDIT_EM_ReplaceSel(hwnd, es, TRUE, cr_lfW, TRUE); } } break; @@ -3691,29 +3674,29 @@ static void EDIT_WM_Char(WND *wnd, EDITSTATE *es, WCHAR c) if ((es->style & ES_MULTILINE) && !(es->style & ES_READONLY)) { static const WCHAR tabW[] = {'\t',0}; - EDIT_EM_ReplaceSel(wnd, es, TRUE, tabW, TRUE); + EDIT_EM_ReplaceSel(hwnd, es, TRUE, tabW, TRUE); } break; case VK_BACK: if (!(es->style & ES_READONLY) && !control) { if (es->selection_start != es->selection_end) - EDIT_WM_Clear(wnd, es); + EDIT_WM_Clear(hwnd, es); else { /* delete character left of caret */ - EDIT_EM_SetSel(wnd, es, (UINT)-1, 0, FALSE); - EDIT_MoveBackward(wnd, es, TRUE); - EDIT_WM_Clear(wnd, es); + EDIT_EM_SetSel(hwnd, es, (UINT)-1, 0, FALSE); + EDIT_MoveBackward(hwnd, es, TRUE); + EDIT_WM_Clear(hwnd, es); } } break; case 0x03: /* ^C */ - SendMessageW(wnd->hwndSelf, WM_COPY, 0, 0); + SendMessageW(hwnd, WM_COPY, 0, 0); break; case 0x16: /* ^V */ - SendMessageW(wnd->hwndSelf, WM_PASTE, 0, 0); + SendMessageW(hwnd, WM_PASTE, 0, 0); break; case 0x18: /* ^X */ - SendMessageW(wnd->hwndSelf, WM_CUT, 0, 0); + SendMessageW(hwnd, WM_CUT, 0, 0); break; default: @@ -3721,7 +3704,7 @@ static void EDIT_WM_Char(WND *wnd, EDITSTATE *es, WCHAR c) WCHAR str[2]; str[0] = c; str[1] = '\0'; - EDIT_EM_ReplaceSel(wnd, es, TRUE, str, TRUE); + EDIT_EM_ReplaceSel(hwnd, es, TRUE, str, TRUE); } break; } @@ -3733,30 +3716,30 @@ static void EDIT_WM_Char(WND *wnd, EDITSTATE *es, WCHAR c) * WM_COMMAND * */ -static void EDIT_WM_Command(WND *wnd, EDITSTATE *es, INT code, INT id, HWND control) +static void EDIT_WM_Command(HWND hwnd, EDITSTATE *es, INT code, INT id, HWND control) { if (code || control) return; switch (id) { case EM_UNDO: - EDIT_EM_Undo(wnd, es); + EDIT_EM_Undo(hwnd, es); break; case WM_CUT: - EDIT_WM_Cut(wnd, es); + EDIT_WM_Cut(hwnd, es); break; case WM_COPY: - EDIT_WM_Copy(wnd, es); + EDIT_WM_Copy(hwnd, es); break; case WM_PASTE: - EDIT_WM_Paste(wnd, es); + EDIT_WM_Paste(hwnd, es); break; case WM_CLEAR: - EDIT_WM_Clear(wnd, es); + EDIT_WM_Clear(hwnd, es); break; case EM_SETSEL: - EDIT_EM_SetSel(wnd, es, 0, (UINT)-1, FALSE); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, 0, (UINT)-1, FALSE); + EDIT_EM_ScrollCaret(hwnd, es); break; default: ERR("unknown menu item, please report\n"); @@ -3781,7 +3764,7 @@ static void EDIT_WM_Command(WND *wnd, EDITSTATE *es, INT code, INT id, HWND cont * (as we do in EDIT_WM_Command()). * */ -static void EDIT_WM_ContextMenu(WND *wnd, EDITSTATE *es, INT x, INT y) +static void EDIT_WM_ContextMenu(HWND hwnd, EDITSTATE *es, INT x, INT y) { HMENU menu = LoadMenuA(GetModuleHandleA("USER32"), "EDITMENU"); HMENU popup = GetSubMenu(menu, 0); @@ -3803,7 +3786,7 @@ static void EDIT_WM_ContextMenu(WND *wnd, EDITSTATE *es, INT x, INT y) /* select all */ EnableMenuItem(popup, 7, MF_BYPOSITION | (start || (end != strlenW(es->text)) ? MF_ENABLED : MF_GRAYED)); - TrackPopupMenu(popup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, x, y, 0, wnd->hwndSelf, NULL); + TrackPopupMenu(popup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, x, y, 0, hwnd, NULL); DestroyMenu(menu); } @@ -3813,7 +3796,7 @@ static void EDIT_WM_ContextMenu(WND *wnd, EDITSTATE *es, INT x, INT y) * WM_COPY * */ -static void EDIT_WM_Copy(WND *wnd, EDITSTATE *es) +static void EDIT_WM_Copy(HWND hwnd, EDITSTATE *es) { INT s = es->selection_start; INT e = es->selection_end; @@ -3829,7 +3812,7 @@ static void EDIT_WM_Copy(WND *wnd, EDITSTATE *es) dst[e - s] = 0; /* ensure 0 termination */ TRACE("%s\n", debugstr_w(dst)); GlobalUnlock(hdst); - OpenClipboard(wnd->hwndSelf); + OpenClipboard(hwnd); EmptyClipboard(); SetClipboardData(CF_UNICODETEXT, hdst); CloseClipboard(); @@ -3841,7 +3824,7 @@ static void EDIT_WM_Copy(WND *wnd, EDITSTATE *es) * WM_CREATE * */ -static LRESULT EDIT_WM_Create(WND *wnd, EDITSTATE *es, LPCWSTR name) +static LRESULT EDIT_WM_Create(HWND hwnd, EDITSTATE *es, LPCWSTR name) { TRACE("%s\n", debugstr_w(name)); /* @@ -3850,11 +3833,11 @@ static LRESULT EDIT_WM_Create(WND *wnd, EDITSTATE *es, LPCWSTR name) * not fully initialized), we should be very careful which * functions can be called, and in what order. */ - EDIT_WM_SetFont(wnd, es, 0, FALSE); + EDIT_WM_SetFont(hwnd, es, 0, FALSE); EDIT_EM_EmptyUndoBuffer(es); if (name && *name) { - EDIT_EM_ReplaceSel(wnd, es, FALSE, name, FALSE); + EDIT_EM_ReplaceSel(hwnd, es, FALSE, name, FALSE); /* if we insert text to the editline, the text scrolls out * of the window, as the caret is placed after the insert * pos normally; thus we reset es->selection... to 0 and @@ -3862,11 +3845,11 @@ static LRESULT EDIT_WM_Create(WND *wnd, EDITSTATE *es, LPCWSTR name) */ es->selection_start = es->selection_end = 0; /* send the notification after the selection start and end are set */ - EDIT_NOTIFY_PARENT(es, EN_CHANGE, "EN_CHANGE"); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_NOTIFY_PARENT(hwnd, es, EN_CHANGE, "EN_CHANGE"); + EDIT_EM_ScrollCaret(hwnd, es); } /* force scroll info update */ - EDIT_UpdateScrollInfo(wnd, es); + EDIT_UpdateScrollInfo(hwnd, es); return 0; } @@ -3876,8 +3859,9 @@ static LRESULT EDIT_WM_Create(WND *wnd, EDITSTATE *es, LPCWSTR name) * WM_DESTROY * */ -static void EDIT_WM_Destroy(WND *wnd, EDITSTATE *es) +static void EDIT_WM_Destroy(HWND hwnd, EDITSTATE *es) { + HINSTANCE hInstance = GetWindowLongA( hwnd, GWL_HINSTANCE ); LINEDEF *pc, *pp; if (es->hloc32W) { @@ -3889,8 +3873,8 @@ static void EDIT_WM_Destroy(WND *wnd, EDITSTATE *es) LocalFree(es->hloc32A); } if (es->hloc16) { - while (LOCAL_Unlock(wnd->hInstance, es->hloc16)) ; - LOCAL_Free(wnd->hInstance, es->hloc16); + while (LOCAL_Unlock(hInstance, es->hloc16)) ; + LOCAL_Free(hInstance, es->hloc16); } pc = es->first_line_def; @@ -3901,8 +3885,8 @@ static void EDIT_WM_Destroy(WND *wnd, EDITSTATE *es) pc = pp; } + SetWindowLongA( hwnd, 0, 0 ); HeapFree(GetProcessHeap(), 0, es); - *(EDITSTATE **)wnd->wExtra = NULL; } @@ -3911,21 +3895,21 @@ static void EDIT_WM_Destroy(WND *wnd, EDITSTATE *es) * WM_ERASEBKGND * */ -static LRESULT EDIT_WM_EraseBkGnd(WND *wnd, EDITSTATE *es, HDC dc) +static LRESULT EDIT_WM_EraseBkGnd(HWND hwnd, EDITSTATE *es, HDC dc) { HBRUSH brush; RECT rc; if ( get_app_version() >= 0x40000 &&( !es->bEnableState || (es->style & ES_READONLY))) - brush = (HBRUSH)EDIT_SEND_CTLCOLORSTATIC(wnd, dc); + brush = (HBRUSH)EDIT_SEND_CTLCOLORSTATIC(hwnd, dc); else - brush = (HBRUSH)EDIT_SEND_CTLCOLOR(wnd, dc); + brush = (HBRUSH)EDIT_SEND_CTLCOLOR(hwnd, dc); if (!brush) brush = (HBRUSH)GetStockObject(WHITE_BRUSH); - GetClientRect(wnd->hwndSelf, &rc); + GetClientRect(hwnd, &rc); IntersectClipRect(dc, rc.left, rc.top, rc.right, rc.bottom); GetClipBox(dc, &rc); /* @@ -3969,7 +3953,7 @@ static INT EDIT_WM_GetText(EDITSTATE *es, INT count, LPARAM lParam, BOOL unicode * WM_HSCROLL * */ -static LRESULT EDIT_WM_HScroll(WND *wnd, EDITSTATE *es, INT action, INT pos) +static LRESULT EDIT_WM_HScroll(HWND hwnd, EDITSTATE *es, INT action, INT pos) { INT dx; INT fw; @@ -4032,7 +4016,7 @@ static LRESULT EDIT_WM_HScroll(WND *wnd, EDITSTATE *es, INT action, INT pos) case SB_THUMBPOSITION: TRACE("SB_THUMBPOSITION %d\n", pos); es->flags &= ~EF_HSCROLL_TRACK; - if(wnd->dwStyle & WS_HSCROLL) + if(GetWindowLongA( hwnd, GWL_STYLE ) & WS_HSCROLL) dx = pos - es->x_offset; else { @@ -4046,8 +4030,8 @@ static LRESULT EDIT_WM_HScroll(WND *wnd, EDITSTATE *es, INT action, INT pos) } if (!dx) { /* force scroll info update */ - EDIT_UpdateScrollInfo(wnd, es); - EDIT_NOTIFY_PARENT(es, EN_HSCROLL, "EN_HSCROLL"); + EDIT_UpdateScrollInfo(hwnd, es); + EDIT_NOTIFY_PARENT(hwnd, es, EN_HSCROLL, "EN_HSCROLL"); } break; case SB_ENDSCROLL: @@ -4063,8 +4047,8 @@ static LRESULT EDIT_WM_HScroll(WND *wnd, EDITSTATE *es, INT action, INT pos) case EM_GETTHUMB16: { LRESULT ret; - if(wnd->dwStyle & WS_HSCROLL) - ret = GetScrollPos(wnd->hwndSelf, SB_HORZ); + if(GetWindowLongA( hwnd, GWL_STYLE ) & WS_HSCROLL) + ret = GetScrollPos(hwnd, SB_HORZ); else { /* Assume default scroll range 0-100 */ @@ -4091,7 +4075,7 @@ static LRESULT EDIT_WM_HScroll(WND *wnd, EDITSTATE *es, INT action, INT pos) if(es->x_offset + dx + fw > es->text_width) dx = es->text_width - fw - es->x_offset; if(dx) - EDIT_EM_LineScroll_internal(wnd, es, dx, 0); + EDIT_EM_LineScroll_internal(hwnd, es, dx, 0); } return 0; } @@ -4102,7 +4086,7 @@ static LRESULT EDIT_WM_HScroll(WND *wnd, EDITSTATE *es, INT action, INT pos) * EDIT_CheckCombo * */ -static BOOL EDIT_CheckCombo(WND *wnd, EDITSTATE *es, UINT msg, INT key) +static BOOL EDIT_CheckCombo(HWND hwnd, EDITSTATE *es, UINT msg, INT key) { HWND hLBox = es->hwndListBox; HWND hCombo; @@ -4112,12 +4096,12 @@ static BOOL EDIT_CheckCombo(WND *wnd, EDITSTATE *es, UINT msg, INT key) if (!hLBox) return FALSE; - hCombo = wnd->parent->hwndSelf; + hCombo = GetParent(hwnd); bDropped = TRUE; nEUI = 0; TRACE_(combo)("[%04x]: handling msg %04x (%04x)\n", - wnd->hwndSelf, (UINT16)msg, (UINT16)key); + hwnd, (UINT16)msg, (UINT16)key); if (key == VK_UP || key == VK_DOWN) { @@ -4165,7 +4149,7 @@ static BOOL EDIT_CheckCombo(WND *wnd, EDITSTATE *es, UINT msg, INT key) * (i.e. non-printable keys) & Backspace & Delete * */ -static LRESULT EDIT_WM_KeyDown(WND *wnd, EDITSTATE *es, INT key) +static LRESULT EDIT_WM_KeyDown(HWND hwnd, EDITSTATE *es, INT key) { BOOL shift; BOOL control; @@ -4179,72 +4163,72 @@ static LRESULT EDIT_WM_KeyDown(WND *wnd, EDITSTATE *es, INT key) switch (key) { case VK_F4: case VK_UP: - if (EDIT_CheckCombo(wnd, es, WM_KEYDOWN, key) || key == VK_F4) + if (EDIT_CheckCombo(hwnd, es, WM_KEYDOWN, key) || key == VK_F4) break; /* fall through */ case VK_LEFT: if ((es->style & ES_MULTILINE) && (key == VK_UP)) - EDIT_MoveUp_ML(wnd, es, shift); + EDIT_MoveUp_ML(hwnd, es, shift); else if (control) - EDIT_MoveWordBackward(wnd, es, shift); + EDIT_MoveWordBackward(hwnd, es, shift); else - EDIT_MoveBackward(wnd, es, shift); + EDIT_MoveBackward(hwnd, es, shift); break; case VK_DOWN: - if (EDIT_CheckCombo(wnd, es, WM_KEYDOWN, key)) + if (EDIT_CheckCombo(hwnd, es, WM_KEYDOWN, key)) break; /* fall through */ case VK_RIGHT: if ((es->style & ES_MULTILINE) && (key == VK_DOWN)) - EDIT_MoveDown_ML(wnd, es, shift); + EDIT_MoveDown_ML(hwnd, es, shift); else if (control) - EDIT_MoveWordForward(wnd, es, shift); + EDIT_MoveWordForward(hwnd, es, shift); else - EDIT_MoveForward(wnd, es, shift); + EDIT_MoveForward(hwnd, es, shift); break; case VK_HOME: - EDIT_MoveHome(wnd, es, shift); + EDIT_MoveHome(hwnd, es, shift); break; case VK_END: - EDIT_MoveEnd(wnd, es, shift); + EDIT_MoveEnd(hwnd, es, shift); break; case VK_PRIOR: if (es->style & ES_MULTILINE) - EDIT_MovePageUp_ML(wnd, es, shift); + EDIT_MovePageUp_ML(hwnd, es, shift); else - EDIT_CheckCombo(wnd, es, WM_KEYDOWN, key); + EDIT_CheckCombo(hwnd, es, WM_KEYDOWN, key); break; case VK_NEXT: if (es->style & ES_MULTILINE) - EDIT_MovePageDown_ML(wnd, es, shift); + EDIT_MovePageDown_ML(hwnd, es, shift); else - EDIT_CheckCombo(wnd, es, WM_KEYDOWN, key); + EDIT_CheckCombo(hwnd, es, WM_KEYDOWN, key); break; case VK_DELETE: if (!(es->style & ES_READONLY) && !(shift && control)) { if (es->selection_start != es->selection_end) { if (shift) - EDIT_WM_Cut(wnd, es); + EDIT_WM_Cut(hwnd, es); else - EDIT_WM_Clear(wnd, es); + EDIT_WM_Clear(hwnd, es); } else { if (shift) { /* delete character left of caret */ - EDIT_EM_SetSel(wnd, es, (UINT)-1, 0, FALSE); - EDIT_MoveBackward(wnd, es, TRUE); - EDIT_WM_Clear(wnd, es); + EDIT_EM_SetSel(hwnd, es, (UINT)-1, 0, FALSE); + EDIT_MoveBackward(hwnd, es, TRUE); + EDIT_WM_Clear(hwnd, es); } else if (control) { /* delete to end of line */ - EDIT_EM_SetSel(wnd, es, (UINT)-1, 0, FALSE); - EDIT_MoveEnd(wnd, es, TRUE); - EDIT_WM_Clear(wnd, es); + EDIT_EM_SetSel(hwnd, es, (UINT)-1, 0, FALSE); + EDIT_MoveEnd(hwnd, es, TRUE); + EDIT_WM_Clear(hwnd, es); } else { /* delete character right of caret */ - EDIT_EM_SetSel(wnd, es, (UINT)-1, 0, FALSE); - EDIT_MoveForward(wnd, es, TRUE); - EDIT_WM_Clear(wnd, es); + EDIT_EM_SetSel(hwnd, es, (UINT)-1, 0, FALSE); + EDIT_MoveForward(hwnd, es, TRUE); + EDIT_WM_Clear(hwnd, es); } } } @@ -4252,15 +4236,15 @@ static LRESULT EDIT_WM_KeyDown(WND *wnd, EDITSTATE *es, INT key) case VK_INSERT: if (shift) { if (!(es->style & ES_READONLY)) - EDIT_WM_Paste(wnd, es); + EDIT_WM_Paste(hwnd, es); } else if (control) - EDIT_WM_Copy(wnd, es); + EDIT_WM_Copy(hwnd, es); break; case VK_RETURN: /* If the edit doesn't want the return send a message to the default object */ if(!(es->style & ES_WANTRETURN)) { - HWND hwndParent = GetParent(wnd->hwndSelf); + HWND hwndParent = GetParent(hwnd); DWORD dw = SendMessageW( hwndParent, DM_GETDEFID, 0, 0 ); if (HIWORD(dw) == DC_HASDEFID) { @@ -4280,13 +4264,13 @@ static LRESULT EDIT_WM_KeyDown(WND *wnd, EDITSTATE *es, INT key) * WM_KILLFOCUS * */ -static LRESULT EDIT_WM_KillFocus(WND *wnd, EDITSTATE *es) +static LRESULT EDIT_WM_KillFocus(HWND hwnd, EDITSTATE *es) { es->flags &= ~EF_FOCUSED; DestroyCaret(); if(!(es->style & ES_NOHIDESEL)) - EDIT_InvalidateText(wnd, es, es->selection_start, es->selection_end); - EDIT_NOTIFY_PARENT(es, EN_KILLFOCUS, "EN_KILLFOCUS"); + EDIT_InvalidateText(hwnd, es, es->selection_start, es->selection_end); + EDIT_NOTIFY_PARENT(hwnd, es, EN_KILLFOCUS, "EN_KILLFOCUS"); return 0; } @@ -4298,7 +4282,7 @@ static LRESULT EDIT_WM_KillFocus(WND *wnd, EDITSTATE *es) * The caret position has been set on the WM_LBUTTONDOWN message * */ -static LRESULT EDIT_WM_LButtonDblClk(WND *wnd, EDITSTATE *es) +static LRESULT EDIT_WM_LButtonDblClk(HWND hwnd, EDITSTATE *es) { INT s; INT e = es->selection_end; @@ -4314,8 +4298,8 @@ static LRESULT EDIT_WM_LButtonDblClk(WND *wnd, EDITSTATE *es) ll = EDIT_EM_LineLength(es, e); s = li + EDIT_CallWordBreakProc(es, li, e - li, ll, WB_LEFT); e = li + EDIT_CallWordBreakProc(es, li, e - li, ll, WB_RIGHT); - EDIT_EM_SetSel(wnd, es, s, e, FALSE); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_EM_SetSel(hwnd, es, s, e, FALSE); + EDIT_EM_ScrollCaret(hwnd, es); return 0; } @@ -4325,7 +4309,7 @@ static LRESULT EDIT_WM_LButtonDblClk(WND *wnd, EDITSTATE *es) * WM_LBUTTONDOWN * */ -static LRESULT EDIT_WM_LButtonDown(WND *wnd, EDITSTATE *es, DWORD keys, INT x, INT y) +static LRESULT EDIT_WM_LButtonDown(HWND hwnd, EDITSTATE *es, DWORD keys, INT x, INT y) { INT e; BOOL after_wrap; @@ -4334,13 +4318,13 @@ static LRESULT EDIT_WM_LButtonDown(WND *wnd, EDITSTATE *es, DWORD keys, INT x, I return 0; es->bCaptureState = TRUE; - SetCapture(wnd->hwndSelf); + SetCapture(hwnd); EDIT_ConfinePoint(es, &x, &y); - e = EDIT_CharFromPos(wnd, es, x, y, &after_wrap); - EDIT_EM_SetSel(wnd, es, (keys & MK_SHIFT) ? es->selection_start : e, e, after_wrap); - EDIT_EM_ScrollCaret(wnd, es); + e = EDIT_CharFromPos(hwnd, es, x, y, &after_wrap); + EDIT_EM_SetSel(hwnd, es, (keys & MK_SHIFT) ? es->selection_start : e, e, after_wrap); + EDIT_EM_ScrollCaret(hwnd, es); es->region_posx = es->region_posy = 0; - SetTimer(wnd->hwndSelf, 0, 100, NULL); + SetTimer(hwnd, 0, 100, NULL); return 0; } @@ -4366,9 +4350,9 @@ static LRESULT EDIT_WM_LButtonUp(HWND hwndSelf, EDITSTATE *es) * WM_MBUTTONDOWN * */ -static LRESULT EDIT_WM_MButtonDown(WND *wnd) +static LRESULT EDIT_WM_MButtonDown(HWND hwnd) { - SendMessageW(wnd->hwndSelf,WM_PASTE,0,0); + SendMessageW(hwnd,WM_PASTE,0,0); return 0; } @@ -4378,13 +4362,13 @@ static LRESULT EDIT_WM_MButtonDown(WND *wnd) * WM_MOUSEMOVE * */ -static LRESULT EDIT_WM_MouseMove(WND *wnd, EDITSTATE *es, INT x, INT y) +static LRESULT EDIT_WM_MouseMove(HWND hwnd, EDITSTATE *es, INT x, INT y) { INT e; BOOL after_wrap; INT prex, prey; - if (GetCapture() != wnd->hwndSelf) + if (GetCapture() != hwnd) return 0; /* @@ -4395,8 +4379,8 @@ static LRESULT EDIT_WM_MouseMove(WND *wnd, EDITSTATE *es, INT x, INT y) EDIT_ConfinePoint(es, &x, &y); es->region_posx = (prex < x) ? -1 : ((prex > x) ? 1 : 0); es->region_posy = (prey < y) ? -1 : ((prey > y) ? 1 : 0); - e = EDIT_CharFromPos(wnd, es, x, y, &after_wrap); - EDIT_EM_SetSel(wnd, es, es->selection_start, e, after_wrap); + e = EDIT_CharFromPos(hwnd, es, x, y, &after_wrap); + EDIT_EM_SetSel(hwnd, es, es->selection_start, e, after_wrap); return 0; } @@ -4407,17 +4391,17 @@ static LRESULT EDIT_WM_MouseMove(WND *wnd, EDITSTATE *es, INT x, INT y) * * See also EDIT_WM_StyleChanged */ -static LRESULT EDIT_WM_NCCreate(WND *wnd, DWORD style, HWND hwndParent, BOOL unicode) +static LRESULT EDIT_WM_NCCreate(HWND hwnd, DWORD style, HWND hwndParent, BOOL unicode) { EDITSTATE *es; UINT alloc_size; - TRACE("Creating %s edit control, style = %08lx %08lx\n", - unicode ? "Unicode" : "ANSI", style, wnd->dwExStyle); + TRACE("Creating %s edit control, style = %08lx\n", + unicode ? "Unicode" : "ANSI", style); if (!(es = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*es)))) return FALSE; - *(EDITSTATE **)wnd->wExtra = es; + SetWindowLongA( hwnd, 0, (LONG)es ); /* * Note: since the EDITSTATE has not been fully initialized yet, @@ -4446,7 +4430,8 @@ static LRESULT EDIT_WM_NCCreate(WND *wnd, DWORD style, HWND hwndParent, BOOL uni else { if ((es->style & WS_BORDER) && !(es->style & WS_DLGFRAME)) - wnd->dwStyle &= ~WS_BORDER; + SetWindowLongA( hwnd, GWL_STYLE, + GetWindowLongA( hwnd, GWL_STYLE ) & ~WS_BORDER ); } /* Save parent, which will be notified by EN_* messages */ @@ -4524,7 +4509,7 @@ static LRESULT EDIT_WM_NCCreate(WND *wnd, DWORD style, HWND hwndParent, BOOL uni * WM_PAINT * */ -static void EDIT_WM_Paint(WND *wnd, EDITSTATE *es, WPARAM wParam) +static void EDIT_WM_Paint(HWND hwnd, EDITSTATE *es, WPARAM wParam) { PAINTSTRUCT ps; INT i; @@ -4537,11 +4522,11 @@ static void EDIT_WM_Paint(WND *wnd, EDITSTATE *es, WPARAM wParam) ((es->flags & EF_FOCUSED) || (es->style & ES_NOHIDESEL)); if (!wParam) - dc = BeginPaint(wnd->hwndSelf, &ps); + dc = BeginPaint(hwnd, &ps); else dc = (HDC) wParam; if(es->style & WS_BORDER) { - GetClientRect(wnd->hwndSelf, &rc); + GetClientRect(hwnd, &rc); if(es->style & ES_MULTILINE) { if(es->style & WS_HSCROLL) rc.bottom++; if(es->style & WS_VSCROLL) rc.right++; @@ -4553,16 +4538,16 @@ static void EDIT_WM_Paint(WND *wnd, EDITSTATE *es, WPARAM wParam) es->format_rect.right, es->format_rect.bottom); if (es->style & ES_MULTILINE) { - GetClientRect(wnd->hwndSelf, &rc); + GetClientRect(hwnd, &rc); IntersectClipRect(dc, rc.left, rc.top, rc.right, rc.bottom); } if (es->font) old_font = SelectObject(dc, es->font); if ( get_app_version() >= 0x40000 &&( !es->bEnableState || (es->style & ES_READONLY))) - EDIT_SEND_CTLCOLORSTATIC(wnd, dc); + EDIT_SEND_CTLCOLORSTATIC(hwnd, dc); else - EDIT_SEND_CTLCOLOR(wnd, dc); + EDIT_SEND_CTLCOLOR(hwnd, dc); if (!es->bEnableState) SetTextColor(dc, GetSysColor(COLOR_GRAYTEXT)); @@ -4570,20 +4555,20 @@ static void EDIT_WM_Paint(WND *wnd, EDITSTATE *es, WPARAM wParam) if (es->style & ES_MULTILINE) { INT vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height; for (i = es->y_offset ; i <= min(es->y_offset + vlc, es->y_offset + es->line_count - 1) ; i++) { - EDIT_GetLineRect(wnd, es, i, 0, -1, &rcLine); + EDIT_GetLineRect(hwnd, es, i, 0, -1, &rcLine); if (IntersectRect(&rc, &rcRgn, &rcLine)) - EDIT_PaintLine(wnd, es, dc, i, rev); + EDIT_PaintLine(hwnd, es, dc, i, rev); } } else { - EDIT_GetLineRect(wnd, es, 0, 0, -1, &rcLine); + EDIT_GetLineRect(hwnd, es, 0, 0, -1, &rcLine); if (IntersectRect(&rc, &rcRgn, &rcLine)) - EDIT_PaintLine(wnd, es, dc, 0, rev); + EDIT_PaintLine(hwnd, es, dc, 0, rev); } if (es->font) SelectObject(dc, old_font); if (!wParam) - EndPaint(wnd->hwndSelf, &ps); + EndPaint(hwnd, &ps); } @@ -4592,7 +4577,7 @@ static void EDIT_WM_Paint(WND *wnd, EDITSTATE *es, WPARAM wParam) * WM_PASTE * */ -static void EDIT_WM_Paste(WND *wnd, EDITSTATE *es) +static void EDIT_WM_Paste(HWND hwnd, EDITSTATE *es) { HGLOBAL hsrc; LPWSTR src; @@ -4601,10 +4586,10 @@ static void EDIT_WM_Paste(WND *wnd, EDITSTATE *es) if(es->style & ES_READONLY) return; - OpenClipboard(wnd->hwndSelf); + OpenClipboard(hwnd); if ((hsrc = GetClipboardData(CF_UNICODETEXT))) { src = (LPWSTR)GlobalLock(hsrc); - EDIT_EM_ReplaceSel(wnd, es, TRUE, src, TRUE); + EDIT_EM_ReplaceSel(hwnd, es, TRUE, src, TRUE); GlobalUnlock(hsrc); } CloseClipboard(); @@ -4616,16 +4601,16 @@ static void EDIT_WM_Paste(WND *wnd, EDITSTATE *es) * WM_SETFOCUS * */ -static void EDIT_WM_SetFocus(WND *wnd, EDITSTATE *es) +static void EDIT_WM_SetFocus(HWND hwnd, EDITSTATE *es) { es->flags |= EF_FOCUSED; - CreateCaret(wnd->hwndSelf, 0, 2, es->line_height); - EDIT_SetCaretPos(wnd, es, es->selection_end, + CreateCaret(hwnd, 0, 2, es->line_height); + EDIT_SetCaretPos(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP); if(!(es->style & ES_NOHIDESEL)) - EDIT_InvalidateText(wnd, es, es->selection_start, es->selection_end); - ShowCaret(wnd->hwndSelf); - EDIT_NOTIFY_PARENT(es, EN_SETFOCUS, "EN_SETFOCUS"); + EDIT_InvalidateText(hwnd, es, es->selection_start, es->selection_end); + ShowCaret(hwnd); + EDIT_NOTIFY_PARENT(hwnd, es, EN_SETFOCUS, "EN_SETFOCUS"); } @@ -4638,7 +4623,7 @@ static void EDIT_WM_SetFocus(WND *wnd, EDITSTATE *es) * unchanged. * */ -static void EDIT_WM_SetFont(WND *wnd, EDITSTATE *es, HFONT font, BOOL redraw) +static void EDIT_WM_SetFont(HWND hwnd, EDITSTATE *es, HFONT font, BOOL redraw) { TEXTMETRICW tm; HDC dc; @@ -4646,7 +4631,7 @@ static void EDIT_WM_SetFont(WND *wnd, EDITSTATE *es, HFONT font, BOOL redraw) RECT r; es->font = font; - dc = GetDC(wnd->hwndSelf); + dc = GetDC(hwnd); if (font) old_font = SelectObject(dc, font); GetTextMetricsW(dc, &tm); @@ -4654,28 +4639,28 @@ static void EDIT_WM_SetFont(WND *wnd, EDITSTATE *es, HFONT font, BOOL redraw) es->char_width = tm.tmAveCharWidth; if (font) SelectObject(dc, old_font); - ReleaseDC(wnd->hwndSelf, dc); + ReleaseDC(hwnd, dc); if (font && (TWEAK_WineLook > WIN31_LOOK)) EDIT_EM_SetMargins(es, EC_LEFTMARGIN | EC_RIGHTMARGIN, EC_USEFONTINFO, EC_USEFONTINFO); /* Force the recalculation of the format rect for each font change */ - GetClientRect(wnd->hwndSelf, &r); - EDIT_SetRectNP(wnd, es, &r); + GetClientRect(hwnd, &r); + EDIT_SetRectNP(hwnd, es, &r); if (es->style & ES_MULTILINE) - EDIT_BuildLineDefs_ML(wnd, es, 0, strlenW(es->text), 0, (HRGN)0); + EDIT_BuildLineDefs_ML(hwnd, es, 0, strlenW(es->text), 0, (HRGN)0); else - EDIT_CalcLineWidth_SL(wnd, es); + EDIT_CalcLineWidth_SL(hwnd, es); if (redraw) - EDIT_UpdateText(wnd, NULL, TRUE); + EDIT_UpdateText(hwnd, es, NULL, TRUE); if (es->flags & EF_FOCUSED) { DestroyCaret(); - CreateCaret(wnd->hwndSelf, 0, 2, es->line_height); - EDIT_SetCaretPos(wnd, es, es->selection_end, + CreateCaret(hwnd, 0, 2, es->line_height); + EDIT_SetCaretPos(hwnd, es, es->selection_end, es->flags & EF_AFTER_WRAP); - ShowCaret(wnd->hwndSelf); + ShowCaret(hwnd); } } @@ -4692,7 +4677,7 @@ static void EDIT_WM_SetFont(WND *wnd, EDITSTATE *es, HFONT font, BOOL redraw) * The modified flag is reset. EN_UPDATE and EN_CHANGE notifications are sent. * */ -static void EDIT_WM_SetText(WND *wnd, EDITSTATE *es, LPARAM lParam, BOOL unicode) +static void EDIT_WM_SetText(HWND hwnd, EDITSTATE *es, LPARAM lParam, BOOL unicode) { LPWSTR text = NULL; @@ -4706,27 +4691,27 @@ static void EDIT_WM_SetText(WND *wnd, EDITSTATE *es, LPARAM lParam, BOOL unicode MultiByteToWideChar(CP_ACP, 0, textA, -1, text, countW); } - EDIT_EM_SetSel(wnd, es, 0, (UINT)-1, FALSE); + EDIT_EM_SetSel(hwnd, es, 0, (UINT)-1, FALSE); if (text) { TRACE("%s\n", debugstr_w(text)); - EDIT_EM_ReplaceSel(wnd, es, FALSE, text, FALSE); + EDIT_EM_ReplaceSel(hwnd, es, FALSE, text, FALSE); if(!unicode) HeapFree(GetProcessHeap(), 0, text); } else { static const WCHAR empty_stringW[] = {0}; TRACE("\n"); - EDIT_EM_ReplaceSel(wnd, es, FALSE, empty_stringW, FALSE); + EDIT_EM_ReplaceSel(hwnd, es, FALSE, empty_stringW, FALSE); } es->x_offset = 0; es->flags &= ~EF_MODIFIED; - EDIT_EM_SetSel(wnd, es, 0, 0, FALSE); + EDIT_EM_SetSel(hwnd, es, 0, 0, FALSE); /* Send the notification after the selection start and end have been set * edit control doesn't send notification on WM_SETTEXT * if it is multiline, or it is part of combobox */ if( !((es->style & ES_MULTILINE) || es->hwndListBox)) - EDIT_NOTIFY_PARENT(es, EN_CHANGE, "EN_CHANGE"); - EDIT_EM_ScrollCaret(wnd, es); + EDIT_NOTIFY_PARENT(hwnd, es, EN_CHANGE, "EN_CHANGE"); + EDIT_EM_ScrollCaret(hwnd, es); } @@ -4735,14 +4720,14 @@ static void EDIT_WM_SetText(WND *wnd, EDITSTATE *es, LPARAM lParam, BOOL unicode * WM_SIZE * */ -static void EDIT_WM_Size(WND *wnd, EDITSTATE *es, UINT action, INT width, INT height) +static void EDIT_WM_Size(HWND hwnd, EDITSTATE *es, UINT action, INT width, INT height) { if ((action == SIZE_MAXIMIZED) || (action == SIZE_RESTORED)) { RECT rc; TRACE("width = %d, height = %d\n", width, height); SetRect(&rc, 0, 0, width, height); - EDIT_SetRectNP(wnd, es, &rc); - EDIT_UpdateText(wnd, NULL, TRUE); + EDIT_SetRectNP(hwnd, es, &rc); + EDIT_UpdateText(hwnd, es, NULL, TRUE); } } @@ -4769,7 +4754,7 @@ static void EDIT_WM_Size(WND *wnd, EDITSTATE *es, UINT action, INT width, INT he * Windows User Interface -> Edit Controls -> Edit Control Reference -> * Edit Control Styles */ -static LRESULT EDIT_WM_StyleChanged (WND *wnd, +static LRESULT EDIT_WM_StyleChanged (HWND hwnd, EDITSTATE *es, WPARAM which, const STYLESTRUCT *style) @@ -4812,17 +4797,17 @@ static LRESULT EDIT_WM_StyleChanged (WND *wnd, * WM_SYSKEYDOWN * */ -static LRESULT EDIT_WM_SysKeyDown(WND *wnd, EDITSTATE *es, INT key, DWORD key_data) +static LRESULT EDIT_WM_SysKeyDown(HWND hwnd, EDITSTATE *es, INT key, DWORD key_data) { if ((key == VK_BACK) && (key_data & 0x2000)) { if (EDIT_EM_CanUndo(es)) - EDIT_EM_Undo(wnd, es); + EDIT_EM_Undo(hwnd, es); return 0; } else if (key == VK_UP || key == VK_DOWN) { - if (EDIT_CheckCombo(wnd, es, WM_SYSKEYDOWN, key)) + if (EDIT_CheckCombo(hwnd, es, WM_SYSKEYDOWN, key)) return 0; } - return DefWindowProcW(wnd->hwndSelf, WM_SYSKEYDOWN, (WPARAM)key, (LPARAM)key_data); + return DefWindowProcW(hwnd, WM_SYSKEYDOWN, (WPARAM)key, (LPARAM)key_data); } @@ -4831,16 +4816,16 @@ static LRESULT EDIT_WM_SysKeyDown(WND *wnd, EDITSTATE *es, INT key, DWORD key_da * WM_TIMER * */ -static void EDIT_WM_Timer(WND *wnd, EDITSTATE *es) +static void EDIT_WM_Timer(HWND hwnd, EDITSTATE *es) { if (es->region_posx < 0) { - EDIT_MoveBackward(wnd, es, TRUE); + EDIT_MoveBackward(hwnd, es, TRUE); } else if (es->region_posx > 0) { - EDIT_MoveForward(wnd, es, TRUE); + EDIT_MoveForward(hwnd, es, TRUE); } /* * FIXME: gotta do some vertical scrolling here, like - * EDIT_EM_LineScroll(wnd, 0, 1); + * EDIT_EM_LineScroll(hwnd, 0, 1); */ } @@ -4849,7 +4834,7 @@ static void EDIT_WM_Timer(WND *wnd, EDITSTATE *es) * WM_VSCROLL * */ -static LRESULT EDIT_WM_VScroll(WND *wnd, EDITSTATE *es, INT action, INT pos) +static LRESULT EDIT_WM_VScroll(HWND hwnd, EDITSTATE *es, INT action, INT pos) { INT dy; @@ -4866,7 +4851,7 @@ static LRESULT EDIT_WM_VScroll(WND *wnd, EDITSTATE *es, INT action, INT pos) case SB_PAGEUP: case SB_PAGEDOWN: TRACE("action %d\n", action); - EDIT_EM_Scroll(wnd, es, action); + EDIT_EM_Scroll(hwnd, es, action); return 0; case SB_TOP: TRACE("SB_TOP\n"); @@ -4914,8 +4899,8 @@ static LRESULT EDIT_WM_VScroll(WND *wnd, EDITSTATE *es, INT action, INT pos) if (!dy) { /* force scroll info update */ - EDIT_UpdateScrollInfo(wnd, es); - EDIT_NOTIFY_PARENT(es, EN_VSCROLL, "EN_VSCROLL"); + EDIT_UpdateScrollInfo(hwnd, es); + EDIT_NOTIFY_PARENT(hwnd, es, EN_VSCROLL, "EN_VSCROLL"); } break; case SB_ENDSCROLL: @@ -4931,8 +4916,8 @@ static LRESULT EDIT_WM_VScroll(WND *wnd, EDITSTATE *es, INT action, INT pos) case EM_GETTHUMB16: { LRESULT ret; - if(wnd->dwStyle & WS_VSCROLL) - ret = GetScrollPos(wnd->hwndSelf, SB_VERT); + if(GetWindowLongA( hwnd, GWL_STYLE ) & WS_VSCROLL) + ret = GetScrollPos(hwnd, SB_VERT); else { /* Assume default scroll range 0-100 */ @@ -4953,7 +4938,7 @@ static LRESULT EDIT_WM_VScroll(WND *wnd, EDITSTATE *es, INT action, INT pos) return 0; } if (dy) - EDIT_EM_LineScroll(wnd, es, 0, dy); + EDIT_EM_LineScroll(hwnd, es, 0, dy); return 0; } @@ -4962,14 +4947,10 @@ static LRESULT EDIT_WM_VScroll(WND *wnd, EDITSTATE *es, INT action, INT pos) * EDIT_UpdateText * */ -static void EDIT_UpdateTextRegion(WND *wnd, HRGN hrgn, BOOL bErase) +static void EDIT_UpdateTextRegion(HWND hwnd, EDITSTATE *es, HRGN hrgn, BOOL bErase) { - EDITSTATE *es = *(EDITSTATE **)((wnd)->wExtra); - - if (es->flags & EF_UPDATE) - EDIT_NOTIFY_PARENT(es, EN_UPDATE, "EN_UPDATE"); - - InvalidateRgn(wnd->hwndSelf, hrgn, bErase); + if (es->flags & EF_UPDATE) EDIT_NOTIFY_PARENT(hwnd, es, EN_UPDATE, "EN_UPDATE"); + InvalidateRgn(hwnd, hrgn, bErase); } @@ -4978,12 +4959,8 @@ static void EDIT_UpdateTextRegion(WND *wnd, HRGN hrgn, BOOL bErase) * EDIT_UpdateText * */ -static void EDIT_UpdateText(WND *wnd, LPRECT rc, BOOL bErase) +static void EDIT_UpdateText(HWND hwnd, EDITSTATE *es, LPRECT rc, BOOL bErase) { - EDITSTATE *es = *(EDITSTATE **)((wnd)->wExtra); - - if (es->flags & EF_UPDATE) - EDIT_NOTIFY_PARENT(es, EN_UPDATE, "EN_UPDATE"); - - InvalidateRect(wnd->hwndSelf, rc, bErase); + if (es->flags & EF_UPDATE) EDIT_NOTIFY_PARENT(hwnd, es, EN_UPDATE, "EN_UPDATE"); + InvalidateRect(hwnd, rc, bErase); } diff --git a/controls/icontitle.c b/controls/icontitle.c index ea37153435c..6b9dad47307 100644 --- a/controls/icontitle.c +++ b/controls/icontitle.c @@ -41,94 +41,89 @@ const struct builtin_class_descr ICONTITLE_builtin_class = /*********************************************************************** * ICONTITLE_Create */ -HWND ICONTITLE_Create( WND* wnd ) +HWND ICONTITLE_Create( HWND owner ) { WND* wndPtr; HWND hWnd; + HINSTANCE instance = GetWindowLongA( owner, GWL_HINSTANCE ); - if( wnd->dwStyle & WS_CHILD ) + if( GetWindowLongA( owner, GWL_STYLE ) & WS_CHILD ) hWnd = CreateWindowExA( 0, ICONTITLE_CLASS_ATOM, NULL, WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 1, 1, - wnd->parent->hwndSelf, 0, wnd->hInstance, NULL ); + GetParent(owner), 0, instance, NULL ); else hWnd = CreateWindowExA( 0, ICONTITLE_CLASS_ATOM, NULL, WS_CLIPSIBLINGS, 0, 0, 1, 1, - wnd->hwndSelf, 0, wnd->hInstance, NULL ); + owner, 0, instance, NULL ); wndPtr = WIN_FindWndPtr( hWnd ); if( wndPtr ) { + WND *wnd = WIN_FindWndPtr(owner); wndPtr->owner = wnd; /* MDI depends on this */ wndPtr->dwStyle &= ~(WS_CAPTION | WS_BORDER); - if( wnd->dwStyle & WS_DISABLED ) wndPtr->dwStyle |= WS_DISABLED; + if (!IsWindowEnabled(owner)) wndPtr->dwStyle |= WS_DISABLED; WIN_ReleaseWndPtr(wndPtr); + WIN_ReleaseWndPtr(wnd); return hWnd; } return 0; } /*********************************************************************** - * ICONTITLE_GetTitlePos + * ICONTITLE_SetTitlePos */ -static BOOL ICONTITLE_GetTitlePos( WND* wnd, LPRECT lpRect ) +static BOOL ICONTITLE_SetTitlePos( HWND hwnd, HWND owner ) { static WCHAR emptyTitleText[] = {'<','.','.','.','>',0}; - LPWSTR str = NULL; - int length = lstrlenW( wnd->owner->text ); + WCHAR str[80]; + HDC hDC; + HFONT hPrevFont; + RECT rect; + INT cx, cy; + POINT pt; - if( length ) + int length = GetWindowTextW( owner, str, sizeof(str)/sizeof(WCHAR) ); + + while (length && str[length - 1] == ' ') /* remove trailing spaces */ + str[--length] = 0; + + if( !length ) { - str = HeapAlloc( GetProcessHeap(), 0, (length + 1) * sizeof(WCHAR) ); - strcpyW( str, wnd->owner->text ); - while( str[length - 1] == ' ' ) /* remove trailing spaces */ - { - str[--length] = '\0'; - if( !length ) - { - HeapFree( GetProcessHeap(), 0, str ); - break; - } - } - } - if( !length ) - { - str = emptyTitleText; - length = lstrlenW( str ); + strcpyW( str, emptyTitleText ); + length = strlenW( str ); } - if( str ) - { - HDC hDC = GetDC( wnd->hwndSelf ); - if( hDC ) - { - HFONT hPrevFont = SelectObject( hDC, hIconTitleFont ); + if (!(hDC = GetDC( hwnd ))) return FALSE; - SetRect( lpRect, 0, 0, GetSystemMetrics(SM_CXICONSPACING) - - GetSystemMetrics(SM_CXBORDER) * 2, - GetSystemMetrics(SM_CYBORDER) * 2 ); + hPrevFont = SelectObject( hDC, hIconTitleFont ); - DrawTextW( hDC, str, length, lpRect, DT_CALCRECT | - DT_CENTER | DT_NOPREFIX | DT_WORDBREAK | - (( bMultiLineTitle ) ? 0 : DT_SINGLELINE) ); + SetRect( &rect, 0, 0, GetSystemMetrics(SM_CXICONSPACING) - + GetSystemMetrics(SM_CXBORDER) * 2, + GetSystemMetrics(SM_CYBORDER) * 2 ); - SelectObject( hDC, hPrevFont ); - ReleaseDC( wnd->hwndSelf, hDC ); + DrawTextW( hDC, str, length, &rect, DT_CALCRECT | DT_CENTER | DT_NOPREFIX | DT_WORDBREAK | + (( bMultiLineTitle ) ? 0 : DT_SINGLELINE) ); - lpRect->right += 4 * GetSystemMetrics(SM_CXBORDER) - lpRect->left; - lpRect->left = wnd->owner->rectWindow.left + GetSystemMetrics(SM_CXICON) / 2 - - (lpRect->right - lpRect->left) / 2; - lpRect->bottom -= lpRect->top; - lpRect->top = wnd->owner->rectWindow.top + GetSystemMetrics(SM_CYICON); - } - if( str != emptyTitleText ) HeapFree( GetProcessHeap(), 0, str ); - return ( hDC ) ? TRUE : FALSE; - } - return FALSE; + SelectObject( hDC, hPrevFont ); + ReleaseDC( hwnd, hDC ); + + cx = rect.right - rect.left + 4 * GetSystemMetrics(SM_CXBORDER); + cy = rect.bottom - rect.top; + + pt.x = (GetSystemMetrics(SM_CXICON) - cx) / 2; + pt.y = GetSystemMetrics(SM_CYICON); + + /* point is relative to owner, make it relative to parent */ + MapWindowPoints( owner, GetParent(hwnd), &pt, 1 ); + + SetWindowPos( hwnd, owner, pt.x, pt.y, cx, cy, SWP_NOACTIVATE ); + return TRUE; } /*********************************************************************** * ICONTITLE_Paint */ -static BOOL ICONTITLE_Paint( WND* wnd, HDC hDC, BOOL bActive ) +static BOOL ICONTITLE_Paint( HWND hwnd, HWND owner, HDC hDC, BOOL bActive ) { HFONT hPrevFont; HBRUSH hBrush = 0; @@ -141,9 +136,9 @@ static BOOL ICONTITLE_Paint( WND* wnd, HDC hDC, BOOL bActive ) } else { - if( wnd->dwStyle & WS_CHILD ) + if( GetWindowLongA( hwnd, GWL_STYLE ) & WS_CHILD ) { - hBrush = (HBRUSH) GetClassLongA(wnd->hwndSelf, GCL_HBRBACKGROUND); + hBrush = (HBRUSH) GetClassLongA(hwnd, GCL_HBRBACKGROUND); if( hBrush ) { INT level; @@ -165,25 +160,23 @@ static BOOL ICONTITLE_Paint( WND* wnd, HDC hDC, BOOL bActive ) } } - FillWindow16( wnd->parent->hwndSelf, wnd->hwndSelf, hDC, hBrush ); + FillWindow16( GetParent(hwnd), hwnd, hDC, hBrush ); hPrevFont = SelectObject( hDC, hIconTitleFont ); if( hPrevFont ) { RECT rect; INT length; - char buffer[80]; + WCHAR buffer[80]; - rect.left = rect.top = 0; - rect.right = wnd->rectWindow.right - wnd->rectWindow.left; - rect.bottom = wnd->rectWindow.bottom - wnd->rectWindow.top; + GetClientRect( hwnd, &rect ); - length = GetWindowTextA( wnd->owner->hwndSelf, buffer, 80 ); + length = GetWindowTextW( owner, buffer, 80 ); SetTextColor( hDC, textColor ); SetBkMode( hDC, TRANSPARENT ); - - DrawTextA( hDC, buffer, length, &rect, DT_CENTER | DT_NOPREFIX | - DT_WORDBREAK | ((bMultiLineTitle) ? 0 : DT_SINGLELINE) ); + + DrawTextW( hDC, buffer, length, &rect, DT_CENTER | DT_NOPREFIX | + DT_WORDBREAK | ((bMultiLineTitle) ? 0 : DT_SINGLELINE) ); SelectObject( hDC, hPrevFont ); } @@ -197,6 +190,7 @@ LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { LRESULT retvalue; + HWND owner = GetWindow( hWnd, GW_OWNER ); WND *wnd = WIN_FindWndPtr( hWnd ); if( !wnd ) @@ -219,44 +213,27 @@ LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg, goto END; case WM_NCMOUSEMOVE: case WM_NCLBUTTONDBLCLK: - retvalue = SendMessageA( wnd->owner->hwndSelf, msg, wParam, lParam ); + retvalue = SendMessageW( owner, msg, wParam, lParam ); goto END; case WM_ACTIVATE: - if( wParam ) SetActiveWindow( wnd->owner->hwndSelf ); + if( wParam ) SetActiveWindow( owner ); /* fall through */ case WM_CLOSE: retvalue = 0; goto END; case WM_SHOWWINDOW: - if( wnd && wParam ) - { - RECT titleRect; - - ICONTITLE_GetTitlePos( wnd, &titleRect ); - if( wnd->owner->next != wnd ) /* keep icon title behind the owner */ - SetWindowPos( hWnd, wnd->owner->hwndSelf, - titleRect.left, titleRect.top, - titleRect.right, titleRect.bottom, SWP_NOACTIVATE ); - else - SetWindowPos( hWnd, 0, titleRect.left, titleRect.top, - titleRect.right, titleRect.bottom, - SWP_NOACTIVATE | SWP_NOZORDER ); - } + if( wnd && wParam ) ICONTITLE_SetTitlePos( hWnd, owner ); retvalue = 0; goto END; case WM_ERASEBKGND: if( wnd ) { - WND* iconWnd = WIN_LockWndPtr(wnd->owner); - - if( iconWnd->dwStyle & WS_CHILD ) - lParam = SendMessageA( iconWnd->hwndSelf, WM_ISACTIVEICON, 0, 0 ); + if( GetWindowLongA( owner, GWL_STYLE ) & WS_CHILD ) + lParam = SendMessageA( owner, WM_ISACTIVEICON, 0, 0 ); else - lParam = (iconWnd->hwndSelf == GetActiveWindow16()); - - WIN_ReleaseWndPtr(iconWnd); - if( ICONTITLE_Paint( wnd, (HDC)wParam, (BOOL)lParam ) ) + lParam = (owner == GetActiveWindow()); + if( ICONTITLE_Paint( hWnd, owner, (HDC)wParam, (BOOL)lParam ) ) ValidateRect( hWnd, NULL ); retvalue = 1; goto END; diff --git a/controls/listbox.c b/controls/listbox.c index 99e4103927b..ff55edd0394 100644 --- a/controls/listbox.c +++ b/controls/listbox.c @@ -15,7 +15,6 @@ #include "winuser.h" #include "winerror.h" #include "spy.h" -#include "win.h" #include "user.h" #include "controls.h" #include "debugtools.h" @@ -41,7 +40,7 @@ DECLARE_DEBUG_CHANNEL(combo); #define LB_TIMER_ID 2 /* flag listbox changed while setredraw false - internal style */ -#define LBS_DISPLAYCHANGED 0x80000000 +#define LBS_DISPLAYCHANGED 0x80000000 /* Item structure */ typedef struct @@ -91,9 +90,9 @@ typedef struct #define IS_MULTISELECT(descr) \ ((descr)->style & LBS_MULTIPLESEL || ((descr)->style & LBS_EXTENDEDSEL)) -#define SEND_NOTIFICATION(wnd,descr,code) \ +#define SEND_NOTIFICATION(hwnd,descr,code) \ (SendMessageW( (descr)->owner, WM_COMMAND, \ - MAKEWPARAM((wnd)->wIDmenu, (code)), (wnd)->hwndSelf )) + MAKEWPARAM( GetWindowLongA((hwnd),GWL_ID), (code)), (hwnd) )) #define ISWIN31 (LOWORD(GetVersion()) == 0x0a03) @@ -146,18 +145,25 @@ const struct builtin_class_descr COMBOLBOX_builtin_class = }; +/* check whether app is a Win 3.1 app */ +inline static BOOL is_old_app( HWND hwnd ) +{ + return (GetExpWinVer16( GetWindowLongA(hwnd,GWL_HINSTANCE) ) & 0xFF00 ) == 0x0300; +} + + /*********************************************************************** * LISTBOX_Dump */ -void LISTBOX_Dump( WND *wnd ) +void LISTBOX_Dump( HWND hwnd ) { INT i; LB_ITEMDATA *item; - LB_DESCR *descr = *(LB_DESCR **)wnd->wExtra; + LB_DESCR *descr = (LB_DESCR *)GetWindowLongA( hwnd, 0 ); TRACE( "Listbox:\n" ); TRACE( "hwnd=%04x descr=%08x items=%d top=%d\n", - wnd->hwndSelf, (UINT)descr, descr->nb_items, + hwnd, (UINT)descr, descr->nb_items, descr->top_item ); for (i = 0, item = descr->items; i < descr->nb_items; i++, item++) { @@ -222,7 +228,7 @@ static INT LISTBOX_GetMaxTopIndex( LB_DESCR *descr ) * Update the scrollbars. Should be called whenever the content * of the listbox changes. */ -static void LISTBOX_UpdateScroll( WND *wnd, LB_DESCR *descr ) +static void LISTBOX_UpdateScroll( HWND hwnd, LB_DESCR *descr ) { SCROLLINFO info; @@ -231,7 +237,7 @@ static void LISTBOX_UpdateScroll( WND *wnd, LB_DESCR *descr ) no WS_VSCROLL, we end up with an uninitialized, visible horizontal scroll bar when we do not need one. if (!(descr->style & WS_VSCROLL)) return; - */ + */ /* It is important that we check descr->style, and not wnd->dwStyle, for WS_VSCROLL, as the former is exactly the one passed in @@ -255,11 +261,11 @@ static void LISTBOX_UpdateScroll( WND *wnd, LB_DESCR *descr ) if (descr->style & LBS_DISABLENOSCROLL) info.fMask |= SIF_DISABLENOSCROLL; if (descr->style & WS_HSCROLL) - SetScrollInfo( wnd->hwndSelf, SB_HORZ, &info, TRUE ); + SetScrollInfo( hwnd, SB_HORZ, &info, TRUE ); info.nMax = 0; info.fMask = SIF_RANGE; if (descr->style & WS_VSCROLL) - SetScrollInfo( wnd->hwndSelf, SB_VERT, &info, TRUE ); + SetScrollInfo( hwnd, SB_VERT, &info, TRUE ); } else { @@ -271,7 +277,7 @@ static void LISTBOX_UpdateScroll( WND *wnd, LB_DESCR *descr ) if (descr->style & LBS_DISABLENOSCROLL) info.fMask |= SIF_DISABLENOSCROLL; if (descr->style & WS_VSCROLL) - SetScrollInfo( wnd->hwndSelf, SB_VERT, &info, TRUE ); + SetScrollInfo( hwnd, SB_VERT, &info, TRUE ); if (descr->horz_extent) { @@ -283,7 +289,7 @@ static void LISTBOX_UpdateScroll( WND *wnd, LB_DESCR *descr ) if (descr->style & LBS_DISABLENOSCROLL) info.fMask |= SIF_DISABLENOSCROLL; if (descr->style & WS_HSCROLL) - SetScrollInfo( wnd->hwndSelf, SB_HORZ, &info, TRUE ); + SetScrollInfo( hwnd, SB_HORZ, &info, TRUE ); } } } @@ -294,7 +300,7 @@ static void LISTBOX_UpdateScroll( WND *wnd, LB_DESCR *descr ) * * Set the top item of the listbox, scrolling up or down if necessary. */ -static LRESULT LISTBOX_SetTopItem( WND *wnd, LB_DESCR *descr, INT index, +static LRESULT LISTBOX_SetTopItem( HWND hwnd, LB_DESCR *descr, INT index, BOOL scroll ) { INT max = LISTBOX_GetMaxTopIndex( descr ); @@ -306,7 +312,7 @@ static LRESULT LISTBOX_SetTopItem( WND *wnd, LB_DESCR *descr, INT index, { INT diff = (descr->top_item - index) / descr->page_size * descr->column_width; if (scroll && (abs(diff) < descr->width)) - ScrollWindowEx( wnd->hwndSelf, diff, 0, NULL, NULL, 0, NULL, + ScrollWindowEx( hwnd, diff, 0, NULL, NULL, 0, NULL, SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); else @@ -330,18 +336,18 @@ static LRESULT LISTBOX_SetTopItem( WND *wnd, LB_DESCR *descr, INT index, diff += descr->items[i].height; } } - else + else diff = (descr->top_item - index) * descr->item_height; if (abs(diff) < descr->height) - ScrollWindowEx( wnd->hwndSelf, 0, diff, NULL, NULL, 0, NULL, + ScrollWindowEx( hwnd, 0, diff, NULL, NULL, 0, NULL, SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); else scroll = FALSE; } - if (!scroll) InvalidateRect( wnd->hwndSelf, NULL, TRUE ); + if (!scroll) InvalidateRect( hwnd, NULL, TRUE ); descr->top_item = index; - LISTBOX_UpdateScroll( wnd, descr ); + LISTBOX_UpdateScroll( hwnd, descr ); return LB_OKAY; } @@ -352,17 +358,17 @@ static LRESULT LISTBOX_SetTopItem( WND *wnd, LB_DESCR *descr, INT index, * Update the page size. Should be called when the size of * the client area or the item height changes. */ -static void LISTBOX_UpdatePage( WND *wnd, LB_DESCR *descr ) +static void LISTBOX_UpdatePage( HWND hwnd, LB_DESCR *descr ) { INT page_size; - if ((descr->item_height == 0) || (page_size = descr->height / descr->item_height) < 1) + if ((descr->item_height == 0) || (page_size = descr->height / descr->item_height) < 1) page_size = 1; if (page_size == descr->page_size) return; descr->page_size = page_size; if (descr->style & LBS_MULTICOLUMN) - InvalidateRect( wnd->hwndSelf, NULL, TRUE ); - LISTBOX_SetTopItem( wnd, descr, descr->top_item, FALSE ); + InvalidateRect( hwnd, NULL, TRUE ); + LISTBOX_SetTopItem( hwnd, descr, descr->top_item, FALSE ); } @@ -372,50 +378,49 @@ static void LISTBOX_UpdatePage( WND *wnd, LB_DESCR *descr ) * Update the size of the listbox. Should be called when the size of * the client area changes. */ -static void LISTBOX_UpdateSize( WND *wnd, LB_DESCR *descr ) +static void LISTBOX_UpdateSize( HWND hwnd, LB_DESCR *descr ) { RECT rect; - GetClientRect( wnd->hwndSelf, &rect ); + GetClientRect( hwnd, &rect ); descr->width = rect.right - rect.left; descr->height = rect.bottom - rect.top; if (!(descr->style & LBS_NOINTEGRALHEIGHT) && !(descr->style & LBS_OWNERDRAWVARIABLE)) { INT remaining; + RECT rect; + GetWindowRect( hwnd, &rect ); if(descr->item_height != 0) remaining = descr->height % descr->item_height; else remaining = 0; if ((descr->height > descr->item_height) && remaining) { - if (!(wnd->flags & WIN_ISWIN32)) + if (is_old_app(hwnd)) { /* give a margin for error to 16 bits programs - if we need less than the height of the nonclient area, round to the - *next* number of items */ - int ncheight = wnd->rectWindow.bottom - wnd->rectWindow.top - descr->height; + *next* number of items */ + int ncheight = rect.bottom - rect.top - descr->height; if ((descr->item_height - remaining) <= ncheight) remaining = remaining - descr->item_height; } TRACE("[%04x]: changing height %d -> %d\n", - wnd->hwndSelf, descr->height, - descr->height - remaining ); - SetWindowPos( wnd->hwndSelf, 0, 0, 0, - wnd->rectWindow.right - wnd->rectWindow.left, - wnd->rectWindow.bottom - wnd->rectWindow.top - remaining, + hwnd, descr->height, descr->height - remaining ); + SetWindowPos( hwnd, 0, 0, 0, rect.right - rect.left, + rect.bottom - rect.top - remaining, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE ); return; } } - TRACE("[%04x]: new size = %d,%d\n", - wnd->hwndSelf, descr->width, descr->height ); - LISTBOX_UpdatePage( wnd, descr ); - LISTBOX_UpdateScroll( wnd, descr ); + TRACE("[%04x]: new size = %d,%d\n", hwnd, descr->width, descr->height ); + LISTBOX_UpdatePage( hwnd, descr ); + LISTBOX_UpdateScroll( hwnd, descr ); /* Invalidate the focused item so it will be repainted correctly */ if (LISTBOX_GetItemRect( descr, descr->focus_item, &rect ) == 1) { - InvalidateRect( wnd->hwndSelf, &rect, FALSE ); + InvalidateRect( hwnd, &rect, FALSE ); } } @@ -524,7 +529,7 @@ static INT LISTBOX_GetItemFromPoint( LB_DESCR *descr, INT x, INT y ) * * Paint an item. */ -static void LISTBOX_PaintItem( WND *wnd, LB_DESCR *descr, HDC hdc, +static void LISTBOX_PaintItem( HWND hwnd, LB_DESCR *descr, HDC hdc, const RECT *rect, INT index, UINT action, BOOL ignoreFocus ) { LB_ITEMDATA *item = NULL; @@ -535,10 +540,11 @@ static void LISTBOX_PaintItem( WND *wnd, LB_DESCR *descr, HDC hdc, DRAWITEMSTRUCT dis; RECT r; HRGN hrgn; + UINT id = GetWindowLongA( hwnd, GWL_ID ); if (!item) { - if (action == ODA_FOCUS) + if (action == ODA_FOCUS) DrawFocusRect( hdc, rect ); else FIXME("called with an out of bounds index %d(%d) in owner draw, Not good.\n",index,descr->nb_items); @@ -549,14 +555,14 @@ static void LISTBOX_PaintItem( WND *wnd, LB_DESCR *descr, HDC hdc, drawing the item, *and* restore the previous region after they are done, so a region has better to exist else everything ends clipped */ - GetClientRect(wnd->hwndSelf, &r); + GetClientRect(hwnd, &r); hrgn = CreateRectRgnIndirect(&r); SelectClipRgn( hdc, hrgn); DeleteObject( hrgn ); dis.CtlType = ODT_LISTBOX; - dis.CtlID = wnd->wIDmenu; - dis.hwndItem = wnd->hwndSelf; + dis.CtlID = id; + dis.hwndItem = hwnd; dis.itemAction = action; dis.hDC = hdc; dis.itemID = index; @@ -565,15 +571,13 @@ static void LISTBOX_PaintItem( WND *wnd, LB_DESCR *descr, HDC hdc, if (!ignoreFocus && (descr->focus_item == index) && (descr->caret_on) && (descr->in_focus)) dis.itemState |= ODS_FOCUS; - if (wnd->dwStyle & WS_DISABLED) dis.itemState |= ODS_DISABLED; + if (!IsWindowEnabled(hwnd)) dis.itemState |= ODS_DISABLED; dis.itemData = item ? item->data : 0; dis.rcItem = *rect; - TRACE("[%04x]: drawitem %d (%s) action=%02x " - "state=%02x rect=%d,%d-%d,%d\n", - wnd->hwndSelf, index, item ? debugstr_w(item->str) : "", action, - dis.itemState, rect->left, rect->top, - rect->right, rect->bottom ); - SendMessageW(descr->owner, WM_DRAWITEM, wnd->wIDmenu, (LPARAM)&dis); + TRACE("[%04x]: drawitem %d (%s) action=%02x state=%02x rect=%d,%d-%d,%d\n", + hwnd, index, item ? debugstr_w(item->str) : "", action, + dis.itemState, rect->left, rect->top, rect->right, rect->bottom ); + SendMessageW(descr->owner, WM_DRAWITEM, id, (LPARAM)&dis); } else { @@ -590,10 +594,9 @@ static void LISTBOX_PaintItem( WND *wnd, LB_DESCR *descr, HDC hdc, oldText = SetTextColor( hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); } - TRACE("[%04x]: painting %d (%s) action=%02x " - "rect=%d,%d-%d,%d\n", - wnd->hwndSelf, index, item ? debugstr_w(item->str) : "", action, - rect->left, rect->top, rect->right, rect->bottom ); + TRACE("[%04x]: painting %d (%s) action=%02x rect=%d,%d-%d,%d\n", + hwnd, index, item ? debugstr_w(item->str) : "", action, + rect->left, rect->top, rect->right, rect->bottom ); if (!item) ExtTextOutW( hdc, rect->left + 1, rect->top, ETO_OPAQUE | ETO_CLIPPED, rect, NULL, 0, NULL ); @@ -627,7 +630,7 @@ static void LISTBOX_PaintItem( WND *wnd, LB_DESCR *descr, HDC hdc, * * Change the redraw flag. */ -static void LISTBOX_SetRedraw( WND *wnd, LB_DESCR *descr, BOOL on ) +static void LISTBOX_SetRedraw( HWND hwnd, LB_DESCR *descr, BOOL on ) { if (on) { @@ -635,15 +638,15 @@ static void LISTBOX_SetRedraw( WND *wnd, LB_DESCR *descr, BOOL on ) descr->style &= ~LBS_NOREDRAW; if (descr->style & LBS_DISPLAYCHANGED) { /* page was changed while setredraw false, refresh automatically */ - InvalidateRect(wnd->hwndSelf, NULL, TRUE); + InvalidateRect(hwnd, NULL, TRUE); if ((descr->top_item + descr->page_size) > descr->nb_items) - { /* reset top of page if less than number of items/page */ + { /* reset top of page if less than number of items/page */ descr->top_item = descr->nb_items - descr->page_size; if (descr->top_item < 0) descr->top_item = 0; } descr->style &= ~LBS_DISPLAYCHANGED; } - LISTBOX_UpdateScroll( wnd, descr ); + LISTBOX_UpdateScroll( hwnd, descr ); } else descr->style |= LBS_NOREDRAW; } @@ -654,7 +657,7 @@ static void LISTBOX_SetRedraw( WND *wnd, LB_DESCR *descr, BOOL on ) * * Repaint a single item synchronously. */ -static void LISTBOX_RepaintItem( WND *wnd, LB_DESCR *descr, INT index, +static void LISTBOX_RepaintItem( HWND hwnd, LB_DESCR *descr, INT index, UINT action ) { HDC hdc; @@ -663,32 +666,32 @@ static void LISTBOX_RepaintItem( WND *wnd, LB_DESCR *descr, INT index, HBRUSH hbrush, oldBrush = 0; /* Do not repaint the item if the item is not visible */ - if (!IsWindowVisible(wnd->hwndSelf)) return; + if (!IsWindowVisible(hwnd)) return; if (descr->style & LBS_NOREDRAW) { descr->style |= LBS_DISPLAYCHANGED; return; } if (LISTBOX_GetItemRect( descr, index, &rect ) != 1) return; - if (!(hdc = GetDCEx( wnd->hwndSelf, 0, DCX_CACHE ))) return; + if (!(hdc = GetDCEx( hwnd, 0, DCX_CACHE ))) return; if (descr->font) oldFont = SelectObject( hdc, descr->font ); hbrush = SendMessageW( descr->owner, WM_CTLCOLORLISTBOX, - hdc, (LPARAM)wnd->hwndSelf ); + hdc, (LPARAM)hwnd ); if (hbrush) oldBrush = SelectObject( hdc, hbrush ); - if (wnd->dwStyle & WS_DISABLED) + if (!IsWindowEnabled(hwnd)) SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) ); SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL ); - LISTBOX_PaintItem( wnd, descr, hdc, &rect, index, action, FALSE ); + LISTBOX_PaintItem( hwnd, descr, hdc, &rect, index, action, FALSE ); if (oldFont) SelectObject( hdc, oldFont ); if (oldBrush) SelectObject( hdc, oldBrush ); - ReleaseDC( wnd->hwndSelf, hdc ); + ReleaseDC( hwnd, hdc ); } /*********************************************************************** * LISTBOX_InitStorage */ -static LRESULT LISTBOX_InitStorage( WND *wnd, LB_DESCR *descr, INT nb_items ) +static LRESULT LISTBOX_InitStorage( HWND hwnd, LB_DESCR *descr, INT nb_items ) { LB_ITEMDATA *item; @@ -699,7 +702,7 @@ static LRESULT LISTBOX_InitStorage( WND *wnd, LB_DESCR *descr, INT nb_items ) if (!(item = HeapReAlloc( GetProcessHeap(), 0, descr->items, nb_items * sizeof(LB_ITEMDATA) ))) { - SEND_NOTIFICATION( wnd, descr, LBN_ERRSPACE ); + SEND_NOTIFICATION( hwnd, descr, LBN_ERRSPACE ); return LB_ERRSPACE; } descr->items = item; @@ -710,7 +713,7 @@ static LRESULT LISTBOX_InitStorage( WND *wnd, LB_DESCR *descr, INT nb_items ) /*********************************************************************** * LISTBOX_SetTabStops */ -static BOOL LISTBOX_SetTabStops( WND *wnd, LB_DESCR *descr, INT count, +static BOOL LISTBOX_SetTabStops( HWND hwnd, LB_DESCR *descr, INT count, LPINT tabs, BOOL short_ints ) { if (!(descr->style & LBS_USETABSTOPS)) return TRUE; @@ -729,7 +732,7 @@ static BOOL LISTBOX_SetTabStops( WND *wnd, LB_DESCR *descr, INT count, INT i; LPINT16 p = (LPINT16)tabs; - TRACE("[%04x]: settabstops ", wnd->hwndSelf ); + TRACE("[%04x]: settabstops ", hwnd ); for (i = 0; i < descr->nb_tabs; i++) { descr->tabs[i] = *p++<<1; /* FIXME */ if (TRACE_ON(listbox)) DPRINTF("%hd ", descr->tabs[i]); @@ -780,7 +783,7 @@ static LRESULT LISTBOX_GetText( LB_DESCR *descr, INT index, LPARAM lParam, BOOL * Find the nearest string located before a given string in sort order. * If 'exact' is TRUE, return an error if we don't get an exact match. */ -static INT LISTBOX_FindStringPos( WND *wnd, LB_DESCR *descr, LPCWSTR str, +static INT LISTBOX_FindStringPos( HWND hwnd, LB_DESCR *descr, LPCWSTR str, BOOL exact ) { INT index, min, max, res = -1; @@ -796,17 +799,17 @@ static INT LISTBOX_FindStringPos( WND *wnd, LB_DESCR *descr, LPCWSTR str, else { COMPAREITEMSTRUCT cis; + UINT id = GetWindowLongA( hwnd, GWL_ID ); cis.CtlType = ODT_LISTBOX; - cis.CtlID = wnd->wIDmenu; - cis.hwndItem = wnd->hwndSelf; + cis.CtlID = id; + cis.hwndItem = hwnd; cis.itemID1 = index; cis.itemData1 = descr->items[index].data; cis.itemID2 = -1; cis.itemData2 = (DWORD)str; cis.dwLocaleId = descr->locale; - res = SendMessageW( descr->owner, WM_COMPAREITEM, - wnd->wIDmenu, (LPARAM)&cis ); + res = SendMessageW( descr->owner, WM_COMPAREITEM, id, (LPARAM)&cis ); } if (!res) return index; if (res > 0) max = index; @@ -822,12 +825,12 @@ static INT LISTBOX_FindStringPos( WND *wnd, LB_DESCR *descr, LPCWSTR str, * Find the nearest string located before a given string in directory * sort order (i.e. first files, then directories, then drives). */ -static INT LISTBOX_FindFileStrPos( WND *wnd, LB_DESCR *descr, LPCWSTR str ) +static INT LISTBOX_FindFileStrPos( HWND hwnd, LB_DESCR *descr, LPCWSTR str ) { INT min, max, res = -1; if (!HAS_STRINGS(descr)) - return LISTBOX_FindStringPos( wnd, descr, str, FALSE ); + return LISTBOX_FindStringPos( hwnd, descr, str, FALSE ); min = 0; max = descr->nb_items; while (min != max) @@ -866,7 +869,7 @@ static INT LISTBOX_FindFileStrPos( WND *wnd, LB_DESCR *descr, LPCWSTR str ) * * Find the item beginning with a given string. */ -static INT LISTBOX_FindString( WND *wnd, LB_DESCR *descr, INT start, +static INT LISTBOX_FindString( HWND hwnd, LB_DESCR *descr, INT start, LPCWSTR str, BOOL exact ) { INT i; @@ -913,7 +916,7 @@ static INT LISTBOX_FindString( WND *wnd, LB_DESCR *descr, INT start, { if (exact && (descr->style & LBS_SORT)) /* If sorted, use a WM_COMPAREITEM binary search */ - return LISTBOX_FindStringPos( wnd, descr, str, TRUE ); + return LISTBOX_FindStringPos( hwnd, descr, str, TRUE ); /* Otherwise use a linear search */ for (i = start + 1; i < descr->nb_items; i++, item++) @@ -973,7 +976,7 @@ static LRESULT LISTBOX_GetSelItems( LB_DESCR *descr, INT max, LPINT array ) /*********************************************************************** * LISTBOX_Paint */ -static LRESULT LISTBOX_Paint( WND *wnd, LB_DESCR *descr, HDC hdc ) +static LRESULT LISTBOX_Paint( HWND hwnd, LB_DESCR *descr, HDC hdc ) { INT i, col_pos = descr->page_size - 1; RECT rect; @@ -994,17 +997,16 @@ static LRESULT LISTBOX_Paint( WND *wnd, LB_DESCR *descr, HDC hdc ) if (descr->font) oldFont = SelectObject( hdc, descr->font ); hbrush = SendMessageW( descr->owner, WM_CTLCOLORLISTBOX, - hdc, (LPARAM)wnd->hwndSelf ); + hdc, (LPARAM)hwnd ); if (hbrush) oldBrush = SelectObject( hdc, hbrush ); - if (wnd->dwStyle & WS_DISABLED) - SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) ); + if (!IsWindowEnabled(hwnd)) SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) ); if (!descr->nb_items && (descr->focus_item != -1) && descr->caret_on && (descr->in_focus)) { /* Special case for empty listbox: paint focus rect */ rect.bottom = rect.top + descr->item_height; - LISTBOX_PaintItem( wnd, descr, hdc, &rect, descr->focus_item, + LISTBOX_PaintItem( hwnd, descr, hdc, &rect, descr->focus_item, ODA_FOCUS, FALSE ); rect.top = rect.bottom; } @@ -1027,7 +1029,7 @@ static LRESULT LISTBOX_Paint( WND *wnd, LB_DESCR *descr, HDC hdc ) focusRect.top = rect.top; focusRect.bottom = rect.bottom; } - LISTBOX_PaintItem( wnd, descr, hdc, &rect, i, ODA_DRAWENTIRE, TRUE ); + LISTBOX_PaintItem( hwnd, descr, hdc, &rect, i, ODA_DRAWENTIRE, TRUE ); rect.top = rect.bottom; if ((descr->style & LBS_MULTICOLUMN) && !col_pos) @@ -1058,7 +1060,7 @@ static LRESULT LISTBOX_Paint( WND *wnd, LB_DESCR *descr, HDC hdc ) /* Paint the focus item now */ if (focusRect.top != focusRect.bottom && descr->caret_on) - LISTBOX_PaintItem( wnd, descr, hdc, &focusRect, descr->focus_item, ODA_FOCUS, FALSE ); + LISTBOX_PaintItem( hwnd, descr, hdc, &focusRect, descr->focus_item, ODA_FOCUS, FALSE ); if (!IS_OWNERDRAW(descr)) { @@ -1091,7 +1093,7 @@ static LRESULT LISTBOX_Paint( WND *wnd, LB_DESCR *descr, HDC hdc ) * Invalidate all items from a given item. If the specified item is not * visible, nothing happens. */ -static void LISTBOX_InvalidateItems( WND *wnd, LB_DESCR *descr, INT index ) +static void LISTBOX_InvalidateItems( HWND hwnd, LB_DESCR *descr, INT index ) { RECT rect; @@ -1103,14 +1105,14 @@ static void LISTBOX_InvalidateItems( WND *wnd, LB_DESCR *descr, INT index ) return; } rect.bottom = descr->height; - InvalidateRect( wnd->hwndSelf, &rect, TRUE ); + InvalidateRect( hwnd, &rect, TRUE ); if (descr->style & LBS_MULTICOLUMN) { /* Repaint the other columns */ rect.left = rect.right; rect.right = descr->width; rect.top = 0; - InvalidateRect( wnd->hwndSelf, &rect, TRUE ); + InvalidateRect( hwnd, &rect, TRUE ); } } } @@ -1133,7 +1135,7 @@ static LRESULT LISTBOX_GetItemHeight( LB_DESCR *descr, INT index ) /*********************************************************************** * LISTBOX_SetItemHeight */ -static LRESULT LISTBOX_SetItemHeight( WND *wnd, LB_DESCR *descr, INT index, +static LRESULT LISTBOX_SetItemHeight( HWND hwnd, LB_DESCR *descr, INT index, INT height ) { if (!height) height = 1; @@ -1141,20 +1143,18 @@ static LRESULT LISTBOX_SetItemHeight( WND *wnd, LB_DESCR *descr, INT index, if (descr->style & LBS_OWNERDRAWVARIABLE) { if ((index < 0) || (index >= descr->nb_items)) return LB_ERR; - TRACE("[%04x]: item %d height = %d\n", - wnd->hwndSelf, index, height ); + TRACE("[%04x]: item %d height = %d\n", hwnd, index, height ); descr->items[index].height = height; - LISTBOX_UpdateScroll( wnd, descr ); - LISTBOX_InvalidateItems( wnd, descr, index ); + LISTBOX_UpdateScroll( hwnd, descr ); + LISTBOX_InvalidateItems( hwnd, descr, index ); } else if (height != descr->item_height) { - TRACE("[%04x]: new height = %d\n", - wnd->hwndSelf, height ); + TRACE("[%04x]: new height = %d\n", hwnd, height ); descr->item_height = height; - LISTBOX_UpdatePage( wnd, descr ); - LISTBOX_UpdateScroll( wnd, descr ); - InvalidateRect( wnd->hwndSelf, 0, TRUE ); + LISTBOX_UpdatePage( hwnd, descr ); + LISTBOX_UpdateScroll( hwnd, descr ); + InvalidateRect( hwnd, 0, TRUE ); } return LB_OKAY; } @@ -1163,7 +1163,7 @@ static LRESULT LISTBOX_SetItemHeight( WND *wnd, LB_DESCR *descr, INT index, /*********************************************************************** * LISTBOX_SetHorizontalPos */ -static void LISTBOX_SetHorizontalPos( WND *wnd, LB_DESCR *descr, INT pos ) +static void LISTBOX_SetHorizontalPos( HWND hwnd, LB_DESCR *descr, INT pos ) { INT diff; @@ -1171,35 +1171,33 @@ static void LISTBOX_SetHorizontalPos( WND *wnd, LB_DESCR *descr, INT pos ) pos = descr->horz_extent - descr->width; if (pos < 0) pos = 0; if (!(diff = descr->horz_pos - pos)) return; - TRACE("[%04x]: new horz pos = %d\n", - wnd->hwndSelf, pos ); + TRACE("[%04x]: new horz pos = %d\n", hwnd, pos ); descr->horz_pos = pos; - LISTBOX_UpdateScroll( wnd, descr ); + LISTBOX_UpdateScroll( hwnd, descr ); if (abs(diff) < descr->width) - ScrollWindowEx( wnd->hwndSelf, diff, 0, NULL, NULL, 0, NULL, + ScrollWindowEx( hwnd, diff, 0, NULL, NULL, 0, NULL, SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); else - InvalidateRect( wnd->hwndSelf, NULL, TRUE ); + InvalidateRect( hwnd, NULL, TRUE ); } /*********************************************************************** * LISTBOX_SetHorizontalExtent */ -static LRESULT LISTBOX_SetHorizontalExtent( WND *wnd, LB_DESCR *descr, +static LRESULT LISTBOX_SetHorizontalExtent( HWND hwnd, LB_DESCR *descr, INT extent ) { if (!descr->horz_extent || (descr->style & LBS_MULTICOLUMN)) return LB_OKAY; if (extent <= 0) extent = 1; if (extent == descr->horz_extent) return LB_OKAY; - TRACE("[%04x]: new horz extent = %d\n", - wnd->hwndSelf, extent ); + TRACE("[%04x]: new horz extent = %d\n", hwnd, extent ); descr->horz_extent = extent; if (descr->horz_pos > extent - descr->width) - LISTBOX_SetHorizontalPos( wnd, descr, extent - descr->width ); + LISTBOX_SetHorizontalPos( hwnd, descr, extent - descr->width ); else - LISTBOX_UpdateScroll( wnd, descr ); + LISTBOX_UpdateScroll( hwnd, descr ); return LB_OKAY; } @@ -1207,13 +1205,12 @@ static LRESULT LISTBOX_SetHorizontalExtent( WND *wnd, LB_DESCR *descr, /*********************************************************************** * LISTBOX_SetColumnWidth */ -static LRESULT LISTBOX_SetColumnWidth( WND *wnd, LB_DESCR *descr, INT width) +static LRESULT LISTBOX_SetColumnWidth( HWND hwnd, LB_DESCR *descr, INT width) { if (width == descr->column_width) return LB_OKAY; - TRACE("[%04x]: new column width = %d\n", - wnd->hwndSelf, width ); + TRACE("[%04x]: new column width = %d\n", hwnd, width ); descr->column_width = width; - LISTBOX_UpdatePage( wnd, descr ); + LISTBOX_UpdatePage( hwnd, descr ); return LB_OKAY; } @@ -1223,7 +1220,7 @@ static LRESULT LISTBOX_SetColumnWidth( WND *wnd, LB_DESCR *descr, INT width) * * Returns the item height. */ -static INT LISTBOX_SetFont( WND *wnd, LB_DESCR *descr, HFONT font ) +static INT LISTBOX_SetFont( HWND hwnd, LB_DESCR *descr, HFONT font ) { HDC hdc; HFONT oldFont = 0; @@ -1231,7 +1228,7 @@ static INT LISTBOX_SetFont( WND *wnd, LB_DESCR *descr, HFONT font ) descr->font = font; - if (!(hdc = GetDCEx( wnd->hwndSelf, 0, DCX_CACHE ))) + if (!(hdc = GetDCEx( hwnd, 0, DCX_CACHE ))) { ERR("unable to get DC.\n" ); return 16; @@ -1239,9 +1236,9 @@ static INT LISTBOX_SetFont( WND *wnd, LB_DESCR *descr, HFONT font ) if (font) oldFont = SelectObject( hdc, font ); GetTextMetricsW( hdc, &tm ); if (oldFont) SelectObject( hdc, oldFont ); - ReleaseDC( wnd->hwndSelf, hdc ); + ReleaseDC( hwnd, hdc ); if (!IS_OWNERDRAW(descr)) - LISTBOX_SetItemHeight( wnd, descr, 0, tm.tmHeight ); + LISTBOX_SetItemHeight( hwnd, descr, 0, tm.tmHeight ); return tm.tmHeight ; } @@ -1251,7 +1248,7 @@ static INT LISTBOX_SetFont( WND *wnd, LB_DESCR *descr, HFONT font ) * * Make sure that a given item is partially or fully visible. */ -static void LISTBOX_MakeItemVisible( WND *wnd, LB_DESCR *descr, INT index, +static void LISTBOX_MakeItemVisible( HWND hwnd, LB_DESCR *descr, INT index, BOOL fully ) { INT top; @@ -1279,7 +1276,7 @@ static void LISTBOX_MakeItemVisible( WND *wnd, LB_DESCR *descr, INT index, (descr->height > (descr->page_size * descr->item_height))) return; top = index - descr->page_size + 1; } - LISTBOX_SetTopItem( wnd, descr, top, TRUE ); + LISTBOX_SetTopItem( hwnd, descr, top, TRUE ); } /*********************************************************************** @@ -1289,21 +1286,21 @@ static void LISTBOX_MakeItemVisible( WND *wnd, LB_DESCR *descr, INT index, * index must be between 0 and descr->nb_items-1, or LB_ERR is returned. * */ -static LRESULT LISTBOX_SetCaretIndex( WND *wnd, LB_DESCR *descr, INT index, +static LRESULT LISTBOX_SetCaretIndex( HWND hwnd, LB_DESCR *descr, INT index, BOOL fully_visible ) { - INT oldfocus = descr->focus_item; + INT oldfocus = descr->focus_item; if (descr->style & LBS_NOSEL) return LB_ERR; if ((index < 0) || (index >= descr->nb_items)) return LB_ERR; if (index == oldfocus) return LB_OKAY; descr->focus_item = index; if ((oldfocus != -1) && descr->caret_on && (descr->in_focus)) - LISTBOX_RepaintItem( wnd, descr, oldfocus, ODA_FOCUS ); + LISTBOX_RepaintItem( hwnd, descr, oldfocus, ODA_FOCUS ); - LISTBOX_MakeItemVisible( wnd, descr, index, fully_visible ); + LISTBOX_MakeItemVisible( hwnd, descr, index, fully_visible ); if (descr->caret_on && (descr->in_focus)) - LISTBOX_RepaintItem( wnd, descr, index, ODA_FOCUS ); + LISTBOX_RepaintItem( hwnd, descr, index, ODA_FOCUS ); return LB_OKAY; } @@ -1314,7 +1311,7 @@ static LRESULT LISTBOX_SetCaretIndex( WND *wnd, LB_DESCR *descr, INT index, * * Select a range of items. Should only be used on a MULTIPLESEL listbox. */ -static LRESULT LISTBOX_SelectItemRange( WND *wnd, LB_DESCR *descr, INT first, +static LRESULT LISTBOX_SelectItemRange( HWND hwnd, LB_DESCR *descr, INT first, INT last, BOOL on ) { INT i; @@ -1336,9 +1333,9 @@ static LRESULT LISTBOX_SelectItemRange( WND *wnd, LB_DESCR *descr, INT first, { if (descr->items[i].selected) continue; descr->items[i].selected = TRUE; - LISTBOX_RepaintItem( wnd, descr, i, ODA_SELECT ); + LISTBOX_RepaintItem( hwnd, descr, i, ODA_SELECT ); } - LISTBOX_SetCaretIndex( wnd, descr, last, TRUE ); + LISTBOX_SetCaretIndex( hwnd, descr, last, TRUE ); } else /* Turn selection off */ { @@ -1346,7 +1343,7 @@ static LRESULT LISTBOX_SelectItemRange( WND *wnd, LB_DESCR *descr, INT first, { if (!descr->items[i].selected) continue; descr->items[i].selected = FALSE; - LISTBOX_RepaintItem( wnd, descr, i, ODA_SELECT ); + LISTBOX_RepaintItem( hwnd, descr, i, ODA_SELECT ); } } return LB_OKAY; @@ -1355,7 +1352,7 @@ static LRESULT LISTBOX_SelectItemRange( WND *wnd, LB_DESCR *descr, INT first, /*********************************************************************** * LISTBOX_SetSelection */ -static LRESULT LISTBOX_SetSelection( WND *wnd, LB_DESCR *descr, INT index, +static LRESULT LISTBOX_SetSelection( HWND hwnd, LB_DESCR *descr, INT index, BOOL on, BOOL send_notify ) { TRACE( "index=%d notify=%s\n", index, send_notify ? "YES" : "NO" ); @@ -1365,9 +1362,9 @@ static LRESULT LISTBOX_SetSelection( WND *wnd, LB_DESCR *descr, INT index, if (descr->style & LBS_MULTIPLESEL) { if (index == -1) /* Select all items */ - return LISTBOX_SelectItemRange( wnd, descr, 0, -1, on ); + return LISTBOX_SelectItemRange( hwnd, descr, 0, -1, on ); else /* Only one item */ - return LISTBOX_SelectItemRange( wnd, descr, index, index, on ); + return LISTBOX_SelectItemRange( hwnd, descr, index, index, on ); } else { @@ -1376,9 +1373,9 @@ static LRESULT LISTBOX_SetSelection( WND *wnd, LB_DESCR *descr, INT index, if (oldsel != -1) descr->items[oldsel].selected = FALSE; if (index != -1) descr->items[index].selected = TRUE; descr->selected_item = index; - if (oldsel != -1) LISTBOX_RepaintItem( wnd, descr, oldsel, ODA_SELECT ); - if (index != -1) LISTBOX_RepaintItem( wnd, descr, index, ODA_SELECT ); - if (send_notify && descr->nb_items) SEND_NOTIFICATION( wnd, descr, + if (oldsel != -1) LISTBOX_RepaintItem( hwnd, descr, oldsel, ODA_SELECT ); + if (index != -1) LISTBOX_RepaintItem( hwnd, descr, index, ODA_SELECT ); + if (send_notify && descr->nb_items) SEND_NOTIFICATION( hwnd, descr, (index != -1) ? LBN_SELCHANGE : LBN_SELCANCEL ); else if( descr->lphc ) /* set selection change flag for parent combo */ @@ -1393,12 +1390,12 @@ static LRESULT LISTBOX_SetSelection( WND *wnd, LB_DESCR *descr, INT index, * * Change the caret position and extend the selection to the new caret. */ -static void LISTBOX_MoveCaret( WND *wnd, LB_DESCR *descr, INT index, +static void LISTBOX_MoveCaret( HWND hwnd, LB_DESCR *descr, INT index, BOOL fully_visible ) { - INT oldfocus = descr->focus_item; + INT oldfocus = descr->focus_item; - if ((index < 0) || (index >= descr->nb_items)) + if ((index < 0) || (index >= descr->nb_items)) return; /* Important, repaint needs to be done in this order if @@ -1411,7 +1408,7 @@ static void LISTBOX_MoveCaret( WND *wnd, LB_DESCR *descr, INT index, /* 1. remove the focus and repaint the item */ descr->focus_item = -1; if ((oldfocus != -1) && descr->caret_on && (descr->in_focus)) - LISTBOX_RepaintItem( wnd, descr, oldfocus, ODA_FOCUS ); + LISTBOX_RepaintItem( hwnd, descr, oldfocus, ODA_FOCUS ); /* 2. then turn off the previous selection */ /* 3. repaint the new selected item */ @@ -1422,29 +1419,29 @@ static void LISTBOX_MoveCaret( WND *wnd, LB_DESCR *descr, INT index, INT first = min( index, descr->anchor_item ); INT last = max( index, descr->anchor_item ); if (first > 0) - LISTBOX_SelectItemRange( wnd, descr, 0, first - 1, FALSE ); - LISTBOX_SelectItemRange( wnd, descr, last + 1, -1, FALSE ); - LISTBOX_SelectItemRange( wnd, descr, first, last, TRUE ); + LISTBOX_SelectItemRange( hwnd, descr, 0, first - 1, FALSE ); + LISTBOX_SelectItemRange( hwnd, descr, last + 1, -1, FALSE ); + LISTBOX_SelectItemRange( hwnd, descr, first, last, TRUE ); } } else if (!(descr->style & LBS_MULTIPLESEL)) { /* Set selection to new caret item */ - LISTBOX_SetSelection( wnd, descr, index, TRUE, FALSE ); + LISTBOX_SetSelection( hwnd, descr, index, TRUE, FALSE ); } - + /* 4. repaint the new item with the focus */ descr->focus_item = index; - LISTBOX_MakeItemVisible( wnd, descr, index, fully_visible ); + LISTBOX_MakeItemVisible( hwnd, descr, index, fully_visible ); if (descr->caret_on && (descr->in_focus)) - LISTBOX_RepaintItem( wnd, descr, index, ODA_FOCUS ); + LISTBOX_RepaintItem( hwnd, descr, index, ODA_FOCUS ); } /*********************************************************************** * LISTBOX_InsertItem */ -static LRESULT LISTBOX_InsertItem( WND *wnd, LB_DESCR *descr, INT index, +static LRESULT LISTBOX_InsertItem( HWND hwnd, LB_DESCR *descr, INT index, LPWSTR str, DWORD data ) { LB_ITEMDATA *item; @@ -1462,7 +1459,7 @@ static LRESULT LISTBOX_InsertItem( WND *wnd, LB_DESCR *descr, INT index, if (!(item = HeapReAlloc( GetProcessHeap(), 0, descr->items, max_items * sizeof(LB_ITEMDATA) ))) { - SEND_NOTIFICATION( wnd, descr, LBN_ERRSPACE ); + SEND_NOTIFICATION( hwnd, descr, LBN_ERRSPACE ); return LB_ERRSPACE; } descr->items = item; @@ -1485,32 +1482,33 @@ static LRESULT LISTBOX_InsertItem( WND *wnd, LB_DESCR *descr, INT index, if (descr->style & LBS_OWNERDRAWVARIABLE) { MEASUREITEMSTRUCT mis; + UINT id = GetWindowLongA( hwnd, GWL_ID ); mis.CtlType = ODT_LISTBOX; - mis.CtlID = wnd->wIDmenu; + mis.CtlID = id; mis.itemID = index; mis.itemData = descr->items[index].data; mis.itemHeight = descr->item_height; - SendMessageW( descr->owner, WM_MEASUREITEM, wnd->wIDmenu, (LPARAM)&mis ); + SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis ); item->height = mis.itemHeight ? mis.itemHeight : 1; TRACE("[%04x]: measure item %d (%s) = %d\n", - wnd->hwndSelf, index, str ? debugstr_w(str) : "", item->height ); + hwnd, index, str ? debugstr_w(str) : "", item->height ); } /* Repaint the items */ - LISTBOX_UpdateScroll( wnd, descr ); - LISTBOX_InvalidateItems( wnd, descr, index ); + LISTBOX_UpdateScroll( hwnd, descr ); + LISTBOX_InvalidateItems( hwnd, descr, index ); /* Move selection and focused item */ /* If listbox was empty, set focus to the first item */ if (descr->nb_items == 1) - LISTBOX_SetCaretIndex( wnd, descr, 0, FALSE ); + LISTBOX_SetCaretIndex( hwnd, descr, 0, FALSE ); /* single select don't change selection index in win31 */ else if ((ISWIN31) && !(IS_MULTISELECT(descr))) { descr->selected_item++; - LISTBOX_SetSelection( wnd, descr, descr->selected_item-1, TRUE, FALSE ); + LISTBOX_SetSelection( hwnd, descr, descr->selected_item-1, TRUE, FALSE ); } else { @@ -1527,7 +1525,7 @@ static LRESULT LISTBOX_InsertItem( WND *wnd, LB_DESCR *descr, INT index, /*********************************************************************** * LISTBOX_InsertString */ -static LRESULT LISTBOX_InsertString( WND *wnd, LB_DESCR *descr, INT index, +static LRESULT LISTBOX_InsertString( HWND hwnd, LB_DESCR *descr, INT index, LPCWSTR str ) { LPWSTR new_str = NULL; @@ -1540,7 +1538,7 @@ static LRESULT LISTBOX_InsertString( WND *wnd, LB_DESCR *descr, INT index, if (!str) str = empty_stringW; if (!(new_str = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1) * sizeof(WCHAR) ))) { - SEND_NOTIFICATION( wnd, descr, LBN_ERRSPACE ); + SEND_NOTIFICATION( hwnd, descr, LBN_ERRSPACE ); return LB_ERRSPACE; } strcpyW(new_str, str); @@ -1548,14 +1546,14 @@ static LRESULT LISTBOX_InsertString( WND *wnd, LB_DESCR *descr, INT index, else data = (DWORD)str; if (index == -1) index = descr->nb_items; - if ((ret = LISTBOX_InsertItem( wnd, descr, index, new_str, data )) != 0) + if ((ret = LISTBOX_InsertItem( hwnd, descr, index, new_str, data )) != 0) { if (new_str) HeapFree( GetProcessHeap(), 0, new_str ); return ret; } TRACE("[%04x]: added item %d %s\n", - wnd->hwndSelf, index, HAS_STRINGS(descr) ? debugstr_w(new_str) : "" ); + hwnd, index, HAS_STRINGS(descr) ? debugstr_w(new_str) : "" ); return index; } @@ -1565,7 +1563,7 @@ static LRESULT LISTBOX_InsertString( WND *wnd, LB_DESCR *descr, INT index, * * Delete the content of an item. 'index' must be a valid index. */ -static void LISTBOX_DeleteItem( WND *wnd, LB_DESCR *descr, INT index ) +static void LISTBOX_DeleteItem( HWND hwnd, LB_DESCR *descr, INT index ) { /* Note: Win 3.1 only sends DELETEITEM on owner-draw items, * while Win95 sends it for all items with user data. @@ -1575,13 +1573,14 @@ static void LISTBOX_DeleteItem( WND *wnd, LB_DESCR *descr, INT index ) if (IS_OWNERDRAW(descr) || descr->items[index].data) { DELETEITEMSTRUCT dis; + UINT id = GetWindowLongA( hwnd, GWL_ID ); dis.CtlType = ODT_LISTBOX; - dis.CtlID = wnd->wIDmenu; + dis.CtlID = id; dis.itemID = index; - dis.hwndItem = wnd->hwndSelf; + dis.hwndItem = hwnd; dis.itemData = descr->items[index].data; - SendMessageW( descr->owner, WM_DELETEITEM, wnd->wIDmenu, (LPARAM)&dis ); + SendMessageW( descr->owner, WM_DELETEITEM, id, (LPARAM)&dis ); } if (HAS_STRINGS(descr) && descr->items[index].str) HeapFree( GetProcessHeap(), 0, descr->items[index].str ); @@ -1593,7 +1592,7 @@ static void LISTBOX_DeleteItem( WND *wnd, LB_DESCR *descr, INT index ) * * Remove an item from the listbox and delete its content. */ -static LRESULT LISTBOX_RemoveItem( WND *wnd, LB_DESCR *descr, INT index ) +static LRESULT LISTBOX_RemoveItem( HWND hwnd, LB_DESCR *descr, INT index ) { LB_ITEMDATA *item; INT max_items; @@ -1602,9 +1601,9 @@ static LRESULT LISTBOX_RemoveItem( WND *wnd, LB_DESCR *descr, INT index ) else if ((index < 0) || (index >= descr->nb_items)) return LB_ERR; /* We need to invalidate the original rect instead of the updated one. */ - LISTBOX_InvalidateItems( wnd, descr, index ); + LISTBOX_InvalidateItems( hwnd, descr, index ); - LISTBOX_DeleteItem( wnd, descr, index ); + LISTBOX_DeleteItem( hwnd, descr, index ); /* Remove the item */ @@ -1627,11 +1626,11 @@ static LRESULT LISTBOX_RemoveItem( WND *wnd, LB_DESCR *descr, INT index ) } /* Repaint the items */ - LISTBOX_UpdateScroll( wnd, descr ); + LISTBOX_UpdateScroll( hwnd, descr ); /* if we removed the scrollbar, reset the top of the list (correct for owner-drawn ???) */ if (descr->nb_items == descr->page_size) - LISTBOX_SetTopItem( wnd, descr, 0, TRUE ); + LISTBOX_SetTopItem( hwnd, descr, 0, TRUE ); /* Move selection and focused item */ if (!IS_MULTISELECT(descr)) @@ -1642,7 +1641,7 @@ static LRESULT LISTBOX_RemoveItem( WND *wnd, LB_DESCR *descr, INT index ) { descr->selected_item--; if (ISWIN31) /* win 31 do not change the selected item number */ - LISTBOX_SetSelection( wnd, descr, descr->selected_item + 1, TRUE, FALSE); + LISTBOX_SetSelection( hwnd, descr, descr->selected_item + 1, TRUE, FALSE); } } @@ -1658,11 +1657,11 @@ static LRESULT LISTBOX_RemoveItem( WND *wnd, LB_DESCR *descr, INT index ) /*********************************************************************** * LISTBOX_ResetContent */ -static void LISTBOX_ResetContent( WND *wnd, LB_DESCR *descr ) +static void LISTBOX_ResetContent( HWND hwnd, LB_DESCR *descr ) { INT i; - for (i = 0; i < descr->nb_items; i++) LISTBOX_DeleteItem( wnd, descr, i ); + for (i = 0; i < descr->nb_items; i++) LISTBOX_DeleteItem( hwnd, descr, i ); if (descr->items) HeapFree( GetProcessHeap(), 0, descr->items ); descr->nb_items = 0; descr->top_item = 0; @@ -1676,7 +1675,7 @@ static void LISTBOX_ResetContent( WND *wnd, LB_DESCR *descr ) /*********************************************************************** * LISTBOX_SetCount */ -static LRESULT LISTBOX_SetCount( WND *wnd, LB_DESCR *descr, INT count ) +static LRESULT LISTBOX_SetCount( HWND hwnd, LB_DESCR *descr, INT count ) { LRESULT ret; @@ -1685,13 +1684,13 @@ static LRESULT LISTBOX_SetCount( WND *wnd, LB_DESCR *descr, INT count ) if (count > descr->nb_items) { while (count > descr->nb_items) - if ((ret = LISTBOX_InsertString( wnd, descr, -1, 0 )) < 0) + if ((ret = LISTBOX_InsertString( hwnd, descr, -1, 0 )) < 0) return ret; } else if (count < descr->nb_items) { while (count < descr->nb_items) - if ((ret = LISTBOX_RemoveItem( wnd, descr, -1 )) < 0) + if ((ret = LISTBOX_RemoveItem( hwnd, descr, -1 )) < 0) return ret; } return LB_OKAY; @@ -1701,7 +1700,7 @@ static LRESULT LISTBOX_SetCount( WND *wnd, LB_DESCR *descr, INT count ) /*********************************************************************** * LISTBOX_Directory */ -static LRESULT LISTBOX_Directory( WND *wnd, LB_DESCR *descr, UINT attrib, +static LRESULT LISTBOX_Directory( HWND hwnd, LB_DESCR *descr, UINT attrib, LPCWSTR filespec, BOOL long_names ) { HANDLE handle; @@ -1745,8 +1744,8 @@ static LRESULT LISTBOX_Directory( WND *wnd, LB_DESCR *descr, UINT attrib, else strcpyW( buffer, entry.cAlternateFileName ); } if (!long_names) CharLowerW( buffer ); - pos = LISTBOX_FindFileStrPos( wnd, descr, buffer ); - if ((ret = LISTBOX_InsertString( wnd, descr, pos, buffer )) < 0) + pos = LISTBOX_FindFileStrPos( hwnd, descr, buffer ); + if ((ret = LISTBOX_InsertString( hwnd, descr, pos, buffer )) < 0) break; } while (FindNextFileW( handle, &entry )); FindClose( handle ); @@ -1762,7 +1761,7 @@ static LRESULT LISTBOX_Directory( WND *wnd, LB_DESCR *descr, UINT attrib, for (drive = 0; drive < 26; drive++, buffer[2]++, root[0]++) { if (GetDriveTypeW(root) <= DRIVE_NO_ROOT_DIR) continue; - if ((ret = LISTBOX_InsertString( wnd, descr, -1, buffer )) < 0) + if ((ret = LISTBOX_InsertString( hwnd, descr, -1, buffer )) < 0) break; } } @@ -1773,7 +1772,7 @@ static LRESULT LISTBOX_Directory( WND *wnd, LB_DESCR *descr, UINT attrib, /*********************************************************************** * LISTBOX_HandleVScroll */ -static LRESULT LISTBOX_HandleVScroll( WND *wnd, LB_DESCR *descr, WPARAM wParam ) +static LRESULT LISTBOX_HandleVScroll( HWND hwnd, LB_DESCR *descr, WPARAM wParam ) { SCROLLINFO info; @@ -1781,33 +1780,33 @@ static LRESULT LISTBOX_HandleVScroll( WND *wnd, LB_DESCR *descr, WPARAM wParam ) switch(LOWORD(wParam)) { case SB_LINEUP: - LISTBOX_SetTopItem( wnd, descr, descr->top_item - 1, TRUE ); + LISTBOX_SetTopItem( hwnd, descr, descr->top_item - 1, TRUE ); break; case SB_LINEDOWN: - LISTBOX_SetTopItem( wnd, descr, descr->top_item + 1, TRUE ); + LISTBOX_SetTopItem( hwnd, descr, descr->top_item + 1, TRUE ); break; case SB_PAGEUP: - LISTBOX_SetTopItem( wnd, descr, descr->top_item - + LISTBOX_SetTopItem( hwnd, descr, descr->top_item - LISTBOX_GetCurrentPageSize( descr ), TRUE ); break; case SB_PAGEDOWN: - LISTBOX_SetTopItem( wnd, descr, descr->top_item + + LISTBOX_SetTopItem( hwnd, descr, descr->top_item + LISTBOX_GetCurrentPageSize( descr ), TRUE ); break; case SB_THUMBPOSITION: - LISTBOX_SetTopItem( wnd, descr, HIWORD(wParam), TRUE ); + LISTBOX_SetTopItem( hwnd, descr, HIWORD(wParam), TRUE ); break; case SB_THUMBTRACK: info.cbSize = sizeof(info); info.fMask = SIF_TRACKPOS; - GetScrollInfo( wnd->hwndSelf, SB_VERT, &info ); - LISTBOX_SetTopItem( wnd, descr, info.nTrackPos, TRUE ); + GetScrollInfo( hwnd, SB_VERT, &info ); + LISTBOX_SetTopItem( hwnd, descr, info.nTrackPos, TRUE ); break; case SB_TOP: - LISTBOX_SetTopItem( wnd, descr, 0, TRUE ); + LISTBOX_SetTopItem( hwnd, descr, 0, TRUE ); break; case SB_BOTTOM: - LISTBOX_SetTopItem( wnd, descr, descr->nb_items, TRUE ); + LISTBOX_SetTopItem( hwnd, descr, descr->nb_items, TRUE ); break; } return 0; @@ -1817,7 +1816,7 @@ static LRESULT LISTBOX_HandleVScroll( WND *wnd, LB_DESCR *descr, WPARAM wParam ) /*********************************************************************** * LISTBOX_HandleHScroll */ -static LRESULT LISTBOX_HandleHScroll( WND *wnd, LB_DESCR *descr, WPARAM wParam ) +static LRESULT LISTBOX_HandleHScroll( HWND hwnd, LB_DESCR *descr, WPARAM wParam ) { SCROLLINFO info; INT page; @@ -1827,41 +1826,41 @@ static LRESULT LISTBOX_HandleHScroll( WND *wnd, LB_DESCR *descr, WPARAM wParam ) switch(LOWORD(wParam)) { case SB_LINELEFT: - LISTBOX_SetTopItem( wnd, descr, descr->top_item-descr->page_size, + LISTBOX_SetTopItem( hwnd, descr, descr->top_item-descr->page_size, TRUE ); break; case SB_LINERIGHT: - LISTBOX_SetTopItem( wnd, descr, descr->top_item+descr->page_size, + LISTBOX_SetTopItem( hwnd, descr, descr->top_item+descr->page_size, TRUE ); break; case SB_PAGELEFT: page = descr->width / descr->column_width; if (page < 1) page = 1; - LISTBOX_SetTopItem( wnd, descr, + LISTBOX_SetTopItem( hwnd, descr, descr->top_item - page * descr->page_size, TRUE ); break; case SB_PAGERIGHT: page = descr->width / descr->column_width; if (page < 1) page = 1; - LISTBOX_SetTopItem( wnd, descr, + LISTBOX_SetTopItem( hwnd, descr, descr->top_item + page * descr->page_size, TRUE ); break; case SB_THUMBPOSITION: - LISTBOX_SetTopItem( wnd, descr, HIWORD(wParam)*descr->page_size, + LISTBOX_SetTopItem( hwnd, descr, HIWORD(wParam)*descr->page_size, TRUE ); break; case SB_THUMBTRACK: info.cbSize = sizeof(info); info.fMask = SIF_TRACKPOS; - GetScrollInfo( wnd->hwndSelf, SB_VERT, &info ); - LISTBOX_SetTopItem( wnd, descr, info.nTrackPos*descr->page_size, + GetScrollInfo( hwnd, SB_VERT, &info ); + LISTBOX_SetTopItem( hwnd, descr, info.nTrackPos*descr->page_size, TRUE ); break; case SB_LEFT: - LISTBOX_SetTopItem( wnd, descr, 0, TRUE ); + LISTBOX_SetTopItem( hwnd, descr, 0, TRUE ); break; case SB_RIGHT: - LISTBOX_SetTopItem( wnd, descr, descr->nb_items, TRUE ); + LISTBOX_SetTopItem( hwnd, descr, descr->nb_items, TRUE ); break; } } @@ -1870,33 +1869,33 @@ static LRESULT LISTBOX_HandleHScroll( WND *wnd, LB_DESCR *descr, WPARAM wParam ) switch(LOWORD(wParam)) { case SB_LINELEFT: - LISTBOX_SetHorizontalPos( wnd, descr, descr->horz_pos - 1 ); + LISTBOX_SetHorizontalPos( hwnd, descr, descr->horz_pos - 1 ); break; case SB_LINERIGHT: - LISTBOX_SetHorizontalPos( wnd, descr, descr->horz_pos + 1 ); + LISTBOX_SetHorizontalPos( hwnd, descr, descr->horz_pos + 1 ); break; case SB_PAGELEFT: - LISTBOX_SetHorizontalPos( wnd, descr, + LISTBOX_SetHorizontalPos( hwnd, descr, descr->horz_pos - descr->width ); break; case SB_PAGERIGHT: - LISTBOX_SetHorizontalPos( wnd, descr, + LISTBOX_SetHorizontalPos( hwnd, descr, descr->horz_pos + descr->width ); break; case SB_THUMBPOSITION: - LISTBOX_SetHorizontalPos( wnd, descr, HIWORD(wParam) ); + LISTBOX_SetHorizontalPos( hwnd, descr, HIWORD(wParam) ); break; case SB_THUMBTRACK: info.cbSize = sizeof(info); info.fMask = SIF_TRACKPOS; - GetScrollInfo( wnd->hwndSelf, SB_HORZ, &info ); - LISTBOX_SetHorizontalPos( wnd, descr, info.nTrackPos ); + GetScrollInfo( hwnd, SB_HORZ, &info ); + LISTBOX_SetHorizontalPos( hwnd, descr, info.nTrackPos ); break; case SB_LEFT: - LISTBOX_SetHorizontalPos( wnd, descr, 0 ); + LISTBOX_SetHorizontalPos( hwnd, descr, 0 ); break; case SB_RIGHT: - LISTBOX_SetHorizontalPos( wnd, descr, + LISTBOX_SetHorizontalPos( hwnd, descr, descr->horz_extent - descr->width ); break; } @@ -1904,7 +1903,7 @@ static LRESULT LISTBOX_HandleHScroll( WND *wnd, LB_DESCR *descr, WPARAM wParam ) return 0; } -static LRESULT LISTBOX_HandleMouseWheel(WND *wnd, LB_DESCR *descr, WPARAM wParam ) +static LRESULT LISTBOX_HandleMouseWheel(HWND hwnd, LB_DESCR *descr, WPARAM wParam ) { short gcWheelDelta = 0; UINT pulScrollLines = 3; @@ -1917,7 +1916,7 @@ static LRESULT LISTBOX_HandleMouseWheel(WND *wnd, LB_DESCR *descr, WPARAM wParam { int cLineScroll = (int) min((UINT) descr->page_size, pulScrollLines); cLineScroll *= (gcWheelDelta / WHEEL_DELTA); - LISTBOX_SetTopItem( wnd, descr, descr->top_item + cLineScroll, TRUE ); + LISTBOX_SetTopItem( hwnd, descr, descr->top_item + cLineScroll, TRUE ); } return 0; } @@ -1925,19 +1924,17 @@ static LRESULT LISTBOX_HandleMouseWheel(WND *wnd, LB_DESCR *descr, WPARAM wParam /*********************************************************************** * LISTBOX_HandleLButtonDown */ -static LRESULT LISTBOX_HandleLButtonDown( WND *wnd, LB_DESCR *descr, +static LRESULT LISTBOX_HandleLButtonDown( HWND hwnd, LB_DESCR *descr, WPARAM wParam, INT x, INT y ) { INT index = LISTBOX_GetItemFromPoint( descr, x, y ); - TRACE("[%04x]: lbuttondown %d,%d item %d\n", - wnd->hwndSelf, x, y, index ); + TRACE("[%04x]: lbuttondown %d,%d item %d\n", hwnd, x, y, index ); if (!descr->caret_on && (descr->in_focus)) return 0; if (!descr->in_focus) { - if( !descr->lphc ) SetFocus( wnd->hwndSelf ); - else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit - : descr->lphc->self->hwndSelf ); + if( !descr->lphc ) SetFocus( hwnd ); + else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit : descr->lphc->self ); } if (index == -1) return 0; @@ -1947,44 +1944,44 @@ static LRESULT LISTBOX_HandleLButtonDown( WND *wnd, LB_DESCR *descr, /* we should perhaps make sure that all items are deselected FIXME: needed for !LBS_EXTENDEDSEL, too ? if (!(wParam & (MK_SHIFT|MK_CONTROL))) - LISTBOX_SetSelection( wnd, descr, -1, FALSE, FALSE); + LISTBOX_SetSelection( hwnd, descr, -1, FALSE, FALSE); */ if (!(wParam & MK_SHIFT)) descr->anchor_item = index; if (wParam & MK_CONTROL) { - LISTBOX_SetCaretIndex( wnd, descr, index, FALSE ); - LISTBOX_SetSelection( wnd, descr, index, + LISTBOX_SetCaretIndex( hwnd, descr, index, FALSE ); + LISTBOX_SetSelection( hwnd, descr, index, !descr->items[index].selected, (descr->style & LBS_NOTIFY) != 0); } - else LISTBOX_MoveCaret( wnd, descr, index, FALSE ); + else LISTBOX_MoveCaret( hwnd, descr, index, FALSE ); } else { - LISTBOX_MoveCaret( wnd, descr, index, FALSE ); - LISTBOX_SetSelection( wnd, descr, index, + LISTBOX_MoveCaret( hwnd, descr, index, FALSE ); + LISTBOX_SetSelection( hwnd, descr, index, (!(descr->style & LBS_MULTIPLESEL) || !descr->items[index].selected), (descr->style & LBS_NOTIFY) != 0 ); } descr->captured = TRUE; - SetCapture( wnd->hwndSelf ); + SetCapture( hwnd ); if (!descr->lphc) { if (descr->style & LBS_NOTIFY ) SendMessageW( descr->owner, WM_LBTRACKPOINT, index, MAKELPARAM( x, y ) ); - if (wnd->dwExStyle & WS_EX_DRAGDETECT) + if (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_DRAGDETECT) { POINT pt; - + pt.x = x; pt.y = y; - if (DragDetect( wnd->hwndSelf, pt )) + if (DragDetect( hwnd, pt )) SendMessageW( descr->owner, WM_BEGINDRAG, 0, 0 ); } } @@ -1993,11 +1990,11 @@ static LRESULT LISTBOX_HandleLButtonDown( WND *wnd, LB_DESCR *descr, /************************************************************************* - * LISTBOX_HandleLButtonDownCombo [Internal] + * LISTBOX_HandleLButtonDownCombo [Internal] * * Process LButtonDown message for the ComboListBox * - * PARAMS +nn * PARAMS * pWnd [I] The windows internal structure * pDescr [I] The ListBox internal structure * wParam [I] Key Flag (WM_LBUTTONDOWN doc for more info) @@ -2011,7 +2008,7 @@ static LRESULT LISTBOX_HandleLButtonDown( WND *wnd, LB_DESCR *descr, * This function is only to be used when a ListBox is a ComboListBox */ -static LRESULT LISTBOX_HandleLButtonDownCombo( WND *pWnd, LB_DESCR *pDescr, +static LRESULT LISTBOX_HandleLButtonDownCombo( HWND hwnd, LB_DESCR *pDescr, UINT msg, WPARAM wParam, INT x, INT y) { RECT clientRect, screenRect; @@ -2020,18 +2017,18 @@ static LRESULT LISTBOX_HandleLButtonDownCombo( WND *pWnd, LB_DESCR *pDescr, mousePos.x = x; mousePos.y = y; - GetClientRect(pWnd->hwndSelf, &clientRect); + GetClientRect(hwnd, &clientRect); if(PtInRect(&clientRect, mousePos)) - { + { /* MousePos is in client, resume normal processing */ if (msg == WM_LBUTTONDOWN) { pDescr->lphc->droppedIndex = pDescr->nb_items ? pDescr->selected_item : -1; - return LISTBOX_HandleLButtonDown( pWnd, pDescr, wParam, x, y); + return LISTBOX_HandleLButtonDown( hwnd, pDescr, wParam, x, y); } else if (pDescr->style & LBS_NOTIFY) - SEND_NOTIFICATION( pWnd, pDescr, LBN_DBLCLK ); + SEND_NOTIFICATION( hwnd, pDescr, LBN_DBLCLK ); return 0; } else @@ -2043,13 +2040,13 @@ static LRESULT LISTBOX_HandleLButtonDownCombo( WND *pWnd, LB_DESCR *pDescr, screenMousePos = mousePos; hWndOldCapture = GetCapture(); ReleaseCapture(); - GetWindowRect(pWnd->hwndSelf, &screenRect); - ClientToScreen(pWnd->hwndSelf, &screenMousePos); + GetWindowRect(hwnd, &screenRect); + ClientToScreen(hwnd, &screenMousePos); if(!PtInRect(&screenRect, screenMousePos)) - { - LISTBOX_SetCaretIndex( pWnd, pDescr, pDescr->lphc->droppedIndex, FALSE ); - LISTBOX_SetSelection( pWnd, pDescr, pDescr->lphc->droppedIndex, FALSE, FALSE ); + { + LISTBOX_SetCaretIndex( hwnd, pDescr, pDescr->lphc->droppedIndex, FALSE ); + LISTBOX_SetSelection( hwnd, pDescr, pDescr->lphc->droppedIndex, FALSE, FALSE ); COMBO_FlipListbox( pDescr->lphc, FALSE, FALSE ); return 0; } @@ -2057,17 +2054,18 @@ static LRESULT LISTBOX_HandleLButtonDownCombo( WND *pWnd, LB_DESCR *pDescr, { /* Check to see the NC is a scrollbar */ INT nHitTestType=0; + LONG style = GetWindowLongA( hwnd, GWL_STYLE ); /* Check Vertical scroll bar */ - if (pWnd->dwStyle & WS_VSCROLL) + if (style & WS_VSCROLL) { clientRect.right += GetSystemMetrics(SM_CXVSCROLL); - if (PtInRect( &clientRect, mousePos )) + if (PtInRect( &clientRect, mousePos )) { nHitTestType = HTVSCROLL; } } /* Check horizontal scroll bar */ - if (pWnd->dwStyle & WS_HSCROLL) + if (style & WS_HSCROLL) { clientRect.bottom += GetSystemMetrics(SM_CYHSCROLL); if (PtInRect( &clientRect, mousePos )) @@ -2077,10 +2075,10 @@ static LRESULT LISTBOX_HandleLButtonDownCombo( WND *pWnd, LB_DESCR *pDescr, } /* Windows sends this message when a scrollbar is clicked */ - + if(nHitTestType != 0) { - SendMessageW(pWnd->hwndSelf, WM_NCLBUTTONDOWN, nHitTestType, + SendMessageW(hwnd, WM_NCLBUTTONDOWN, nHitTestType, MAKELONG(screenMousePos.x, screenMousePos.y)); } /* Resume the Capture after scrolling is complete @@ -2097,17 +2095,17 @@ static LRESULT LISTBOX_HandleLButtonDownCombo( WND *pWnd, LB_DESCR *pDescr, /*********************************************************************** * LISTBOX_HandleLButtonUp */ -static LRESULT LISTBOX_HandleLButtonUp( WND *wnd, LB_DESCR *descr ) +static LRESULT LISTBOX_HandleLButtonUp( HWND hwnd, LB_DESCR *descr ) { if (LISTBOX_Timer != LB_TIMER_NONE) - KillSystemTimer( wnd->hwndSelf, LB_TIMER_ID ); + KillSystemTimer( hwnd, LB_TIMER_ID ); LISTBOX_Timer = LB_TIMER_NONE; if (descr->captured) { descr->captured = FALSE; - if (GetCapture() == wnd->hwndSelf) ReleaseCapture(); + if (GetCapture() == hwnd) ReleaseCapture(); if ((descr->style & LBS_NOTIFY) && descr->nb_items) - SEND_NOTIFICATION( wnd, descr, LBN_SELCHANGE ); + SEND_NOTIFICATION( hwnd, descr, LBN_SELCHANGE ); } return 0; } @@ -2119,7 +2117,7 @@ static LRESULT LISTBOX_HandleLButtonUp( WND *wnd, LB_DESCR *descr ) * Handle scrolling upon a timer event. * Return TRUE if scrolling should continue. */ -static LRESULT LISTBOX_HandleTimer( WND *wnd, LB_DESCR *descr, +static LRESULT LISTBOX_HandleTimer( HWND hwnd, LB_DESCR *descr, INT index, TIMER_DIRECTION dir ) { switch(dir) @@ -2144,7 +2142,7 @@ static LRESULT LISTBOX_HandleTimer( WND *wnd, LB_DESCR *descr, break; } if (index == descr->focus_item) return FALSE; - LISTBOX_MoveCaret( wnd, descr, index, FALSE ); + LISTBOX_MoveCaret( hwnd, descr, index, FALSE ); return TRUE; } @@ -2154,11 +2152,11 @@ static LRESULT LISTBOX_HandleTimer( WND *wnd, LB_DESCR *descr, * * WM_SYSTIMER handler. */ -static LRESULT LISTBOX_HandleSystemTimer( WND *wnd, LB_DESCR *descr ) +static LRESULT LISTBOX_HandleSystemTimer( HWND hwnd, LB_DESCR *descr ) { - if (!LISTBOX_HandleTimer( wnd, descr, descr->focus_item, LISTBOX_Timer )) + if (!LISTBOX_HandleTimer( hwnd, descr, descr->focus_item, LISTBOX_Timer )) { - KillSystemTimer( wnd->hwndSelf, LB_TIMER_ID ); + KillSystemTimer( hwnd, LB_TIMER_ID ); LISTBOX_Timer = LB_TIMER_NONE; } return 0; @@ -2170,7 +2168,7 @@ static LRESULT LISTBOX_HandleSystemTimer( WND *wnd, LB_DESCR *descr ) * * WM_MOUSEMOVE handler. */ -static void LISTBOX_HandleMouseMove( WND *wnd, LB_DESCR *descr, +static void LISTBOX_HandleMouseMove( HWND hwnd, LB_DESCR *descr, INT x, INT y ) { INT index; @@ -2203,14 +2201,14 @@ static void LISTBOX_HandleMouseMove( WND *wnd, LB_DESCR *descr, index = LISTBOX_GetItemFromPoint( descr, x, y ); if (index == -1) index = descr->focus_item; - if (!LISTBOX_HandleTimer( wnd, descr, index, dir )) dir = LB_TIMER_NONE; + if (!LISTBOX_HandleTimer( hwnd, descr, index, dir )) dir = LB_TIMER_NONE; /* Start/stop the system timer */ if (dir != LB_TIMER_NONE) - SetSystemTimer( wnd->hwndSelf, LB_TIMER_ID, LB_SCROLL_TIMEOUT, NULL); + SetSystemTimer( hwnd, LB_TIMER_ID, LB_SCROLL_TIMEOUT, NULL); else if (LISTBOX_Timer != LB_TIMER_NONE) - KillSystemTimer( wnd->hwndSelf, LB_TIMER_ID ); + KillSystemTimer( hwnd, LB_TIMER_ID ); LISTBOX_Timer = dir; } @@ -2218,7 +2216,7 @@ static void LISTBOX_HandleMouseMove( WND *wnd, LB_DESCR *descr, /*********************************************************************** * LISTBOX_HandleKeyDown */ -static LRESULT LISTBOX_HandleKeyDown( WND *wnd, LB_DESCR *descr, WPARAM wParam ) +static LRESULT LISTBOX_HandleKeyDown( HWND hwnd, LB_DESCR *descr, WPARAM wParam ) { INT caret = -1; BOOL bForceSelection = TRUE; /* select item pointed to by focus_item */ @@ -2229,7 +2227,7 @@ static LRESULT LISTBOX_HandleKeyDown( WND *wnd, LB_DESCR *descr, WPARAM wParam ) { caret = SendMessageW( descr->owner, WM_VKEYTOITEM, MAKEWPARAM(LOWORD(wParam), descr->focus_item), - wnd->hwndSelf ); + hwnd ); if (caret == -2) return 0; } if (caret == -1) switch(wParam) @@ -2291,7 +2289,7 @@ static LRESULT LISTBOX_HandleKeyDown( WND *wnd, LB_DESCR *descr, WPARAM wParam ) if (descr->style & LBS_EXTENDEDSEL) caret = descr->focus_item; else if (descr->style & LBS_MULTIPLESEL) { - LISTBOX_SetSelection( wnd, descr, descr->focus_item, + LISTBOX_SetSelection( hwnd, descr, descr->focus_item, !descr->items[descr->focus_item].selected, (descr->style & LBS_NOTIFY) != 0 ); } @@ -2306,8 +2304,8 @@ static LRESULT LISTBOX_HandleKeyDown( WND *wnd, LB_DESCR *descr, WPARAM wParam ) if ((descr->style & LBS_EXTENDEDSEL) && !(GetKeyState( VK_SHIFT ) & 0x8000)) descr->anchor_item = caret; - LISTBOX_MoveCaret( wnd, descr, caret, TRUE ); - LISTBOX_SetSelection( wnd, descr, caret, TRUE, FALSE); + LISTBOX_MoveCaret( hwnd, descr, caret, TRUE ); + LISTBOX_SetSelection( hwnd, descr, caret, TRUE, FALSE); if (descr->style & LBS_NOTIFY) { if( descr->lphc ) @@ -2315,7 +2313,7 @@ static LRESULT LISTBOX_HandleKeyDown( WND *wnd, LB_DESCR *descr, WPARAM wParam ) /* make sure that combo parent doesn't hide us */ descr->lphc->wState |= CBF_NOROLLUP; } - if (descr->nb_items) SEND_NOTIFICATION( wnd, descr, LBN_SELCHANGE ); + if (descr->nb_items) SEND_NOTIFICATION( hwnd, descr, LBN_SELCHANGE ); } } return 0; @@ -2325,7 +2323,7 @@ static LRESULT LISTBOX_HandleKeyDown( WND *wnd, LB_DESCR *descr, WPARAM wParam ) /*********************************************************************** * LISTBOX_HandleChar */ -static LRESULT LISTBOX_HandleChar( WND *wnd, LB_DESCR *descr, WCHAR charW ) +static LRESULT LISTBOX_HandleChar( HWND hwnd, LB_DESCR *descr, WCHAR charW ) { INT caret = -1; WCHAR str[2]; @@ -2337,18 +2335,18 @@ static LRESULT LISTBOX_HandleChar( WND *wnd, LB_DESCR *descr, WCHAR charW ) { caret = SendMessageW( descr->owner, WM_CHARTOITEM, MAKEWPARAM(charW, descr->focus_item), - wnd->hwndSelf ); + hwnd ); if (caret == -2) return 0; } if (caret == -1) - caret = LISTBOX_FindString( wnd, descr, descr->focus_item, str, FALSE); + caret = LISTBOX_FindString( hwnd, descr, descr->focus_item, str, FALSE); if (caret != -1) { if ((!IS_MULTISELECT(descr)) && descr->selected_item == -1) - LISTBOX_SetSelection( wnd, descr, caret, TRUE, FALSE); - LISTBOX_MoveCaret( wnd, descr, caret, TRUE ); + LISTBOX_SetSelection( hwnd, descr, caret, TRUE, FALSE); + LISTBOX_MoveCaret( hwnd, descr, caret, TRUE ); if ((descr->style & LBS_NOTIFY) && descr->nb_items) - SEND_NOTIFICATION( wnd, descr, LBN_SELCHANGE ); + SEND_NOTIFICATION( hwnd, descr, LBN_SELCHANGE ); } return 0; } @@ -2357,7 +2355,7 @@ static LRESULT LISTBOX_HandleChar( WND *wnd, LB_DESCR *descr, WCHAR charW ) /*********************************************************************** * LISTBOX_Create */ -static BOOL LISTBOX_Create( WND *wnd, LPHEADCOMBO lphc ) +static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) { LB_DESCR *descr; MEASUREITEMSTRUCT mis; @@ -2366,9 +2364,9 @@ static BOOL LISTBOX_Create( WND *wnd, LPHEADCOMBO lphc ) if (!(descr = HeapAlloc( GetProcessHeap(), 0, sizeof(*descr) ))) return FALSE; - GetClientRect( wnd->hwndSelf, &rect ); - descr->owner = GetParent( wnd->hwndSelf ); - descr->style = wnd->dwStyle; + GetClientRect( hwnd, &rect ); + descr->owner = GetParent( hwnd ); + descr->style = GetWindowLongA( hwnd, GWL_STYLE ); descr->width = rect.right - rect.left; descr->height = rect.bottom - rect.top; descr->items = NULL; @@ -2380,7 +2378,7 @@ static BOOL LISTBOX_Create( WND *wnd, LPHEADCOMBO lphc ) descr->item_height = 1; descr->page_size = 1; descr->column_width = 150; - descr->horz_extent = (wnd->dwStyle & WS_HSCROLL) ? 1 : 0; + descr->horz_extent = (descr->style & WS_HSCROLL) ? 1 : 0; descr->horz_pos = 0; descr->nb_tabs = 0; descr->tabs = NULL; @@ -2392,8 +2390,7 @@ static BOOL LISTBOX_Create( WND *wnd, LPHEADCOMBO lphc ) descr->locale = 0; /* FIXME */ descr->lphc = lphc; - if( ( GetExpWinVer16( wnd->hInstance ) & 0xFF00 ) == 0x0300 - && ( descr->style & ( WS_VSCROLL | WS_HSCROLL ) ) ) + if (is_old_app(hwnd) && ( descr->style & ( WS_VSCROLL | WS_HSCROLL ) ) ) { /* Win95 document "List Box Differences" from MSDN: If a list box in a version 3.x application has either the @@ -2406,18 +2403,18 @@ static BOOL LISTBOX_Create( WND *wnd, LPHEADCOMBO lphc ) if( lphc ) { TRACE_(combo)("[%04x]: resetting owner %04x -> %04x\n", - wnd->hwndSelf, descr->owner, lphc->self->hwndSelf ); - descr->owner = lphc->self->hwndSelf; + hwnd, descr->owner, lphc->self ); + descr->owner = lphc->self; } - *(LB_DESCR **)wnd->wExtra = descr; + SetWindowLongA( hwnd, 0, (LONG)descr ); /* if (wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) descr->style &= ~LBS_NOTIFY; */ if (descr->style & LBS_EXTENDEDSEL) descr->style |= LBS_MULTIPLESEL; if (descr->style & LBS_MULTICOLUMN) descr->style &= ~LBS_OWNERDRAWVARIABLE; if (descr->style & LBS_OWNERDRAWVARIABLE) descr->style |= LBS_NOINTEGRALHEIGHT; - descr->item_height = LISTBOX_SetFont( wnd, descr, 0 ); + descr->item_height = LISTBOX_SetFont( hwnd, descr, 0 ); if (descr->style & LBS_OWNERDRAWFIXED) { @@ -2428,13 +2425,14 @@ static BOOL LISTBOX_Create( WND *wnd, LPHEADCOMBO lphc ) } else { + UINT id = GetWindowLongA( hwnd, GWL_ID ); mis.CtlType = ODT_LISTBOX; - mis.CtlID = wnd->wIDmenu; + mis.CtlID = id; mis.itemID = -1; mis.itemWidth = 0; mis.itemData = 0; mis.itemHeight = descr->item_height; - SendMessageW( descr->owner, WM_MEASUREITEM, wnd->wIDmenu, (LPARAM)&mis ); + SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis ); descr->item_height = mis.itemHeight ? mis.itemHeight : 1; } } @@ -2447,32 +2445,31 @@ static BOOL LISTBOX_Create( WND *wnd, LPHEADCOMBO lphc ) /*********************************************************************** * LISTBOX_Destroy */ -static BOOL LISTBOX_Destroy( WND *wnd, LB_DESCR *descr ) +static BOOL LISTBOX_Destroy( HWND hwnd, LB_DESCR *descr ) { - LISTBOX_ResetContent( wnd, descr ); + LISTBOX_ResetContent( hwnd, descr ); + SetWindowLongA( hwnd, 0, 0 ); HeapFree( GetProcessHeap(), 0, descr ); - wnd->wExtra[0] = 0; return TRUE; } /*********************************************************************** - * ListBoxWndProc + * ListBoxWndProc_common */ -static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, +static LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode ) { LRESULT ret; LB_DESCR *descr; - HWND hwnd = wnd->hwndSelf; - if (!(descr = *(LB_DESCR **)wnd->wExtra)) + if (!(descr = (LB_DESCR *)GetWindowLongA( hwnd, 0 ))) { if (msg == WM_CREATE) { - if (!LISTBOX_Create( wnd, NULL )) + if (!LISTBOX_Create( hwnd, NULL )) return -1; - TRACE("creating wnd=%04x descr=%p\n", hwnd, *(LB_DESCR **)wnd->wExtra ); + TRACE("creating wnd=%04x descr=%lx\n", hwnd, GetWindowLongA( hwnd, 0 ) ); return 0; } /* Ignore all other messages before we get a WM_CREATE */ @@ -2481,14 +2478,14 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, } TRACE("[%04x]: msg %s wp %08x lp %08lx\n", - wnd->hwndSelf, SPY_GetMsgName(msg), wParam, lParam ); + hwnd, SPY_GetMsgName(msg), wParam, lParam ); switch(msg) { case LB_RESETCONTENT16: case LB_RESETCONTENT: - LISTBOX_ResetContent( wnd, descr ); - LISTBOX_UpdateScroll( wnd, descr ); - InvalidateRect( wnd->hwndSelf, NULL, TRUE ); + LISTBOX_ResetContent( hwnd, descr ); + LISTBOX_UpdateScroll( hwnd, descr ); + InvalidateRect( hwnd, NULL, TRUE ); return 0; case LB_ADDSTRING16: @@ -2507,8 +2504,8 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, if((textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW); } - wParam = LISTBOX_FindStringPos( wnd, descr, textW, FALSE ); - ret = LISTBOX_InsertString( wnd, descr, wParam, textW ); + wParam = LISTBOX_FindStringPos( hwnd, descr, textW, FALSE ); + ret = LISTBOX_InsertString( hwnd, descr, wParam, textW ); if (!unicode && HAS_STRINGS(descr)) HeapFree(GetProcessHeap(), 0, textW); return ret; @@ -2531,7 +2528,7 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, if((textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW); } - ret = LISTBOX_InsertString( wnd, descr, wParam, textW ); + ret = LISTBOX_InsertString( hwnd, descr, wParam, textW ); if(!unicode && HAS_STRINGS(descr)) HeapFree(GetProcessHeap(), 0, textW); return ret; @@ -2553,8 +2550,8 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, if((textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW); } - wParam = LISTBOX_FindFileStrPos( wnd, descr, textW ); - ret = LISTBOX_InsertString( wnd, descr, wParam, textW ); + wParam = LISTBOX_FindFileStrPos( hwnd, descr, textW ); + ret = LISTBOX_InsertString( hwnd, descr, wParam, textW ); if(!unicode && HAS_STRINGS(descr)) HeapFree(GetProcessHeap(), 0, textW); return ret; @@ -2562,7 +2559,7 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, case LB_DELETESTRING16: case LB_DELETESTRING: - if (LISTBOX_RemoveItem( wnd, descr, wParam) != LB_ERR) + if (LISTBOX_RemoveItem( hwnd, descr, wParam) != LB_ERR) return descr->nb_items; else return LB_ERR; @@ -2623,7 +2620,7 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, lParam = LOWORD(lParam); /* fall through */ case LB_SETITEMHEIGHT: - return LISTBOX_SetItemHeight( wnd, descr, wParam, lParam ); + return LISTBOX_SetItemHeight( hwnd, descr, wParam, lParam ); case LB_ITEMFROMPOINT: { @@ -2644,7 +2641,7 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, case LB_SETCARETINDEX16: case LB_SETCARETINDEX: if ((!IS_MULTISELECT(descr)) && (descr->selected_item != -1)) return LB_ERR; - if (LISTBOX_SetCaretIndex( wnd, descr, wParam, !lParam ) == LB_ERR) + if (LISTBOX_SetCaretIndex( hwnd, descr, wParam, !lParam ) == LB_ERR) return LB_ERR; else if (ISWIN31) return wParam; @@ -2657,11 +2654,11 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, case LB_SETTOPINDEX16: case LB_SETTOPINDEX: - return LISTBOX_SetTopItem( wnd, descr, wParam, TRUE ); + return LISTBOX_SetTopItem( hwnd, descr, wParam, TRUE ); case LB_SETCOLUMNWIDTH16: case LB_SETCOLUMNWIDTH: - return LISTBOX_SetColumnWidth( wnd, descr, wParam ); + return LISTBOX_SetColumnWidth( hwnd, descr, wParam ); case LB_GETITEMRECT16: { @@ -2691,7 +2688,7 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, if((textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW); } - ret = LISTBOX_FindString( wnd, descr, wParam, textW, FALSE ); + ret = LISTBOX_FindString( hwnd, descr, wParam, textW, FALSE ); if(!unicode && HAS_STRINGS(descr)) HeapFree(GetProcessHeap(), 0, textW); return ret; @@ -2714,7 +2711,7 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, if((textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW); } - ret = LISTBOX_FindString( wnd, descr, wParam, textW, TRUE ); + ret = LISTBOX_FindString( hwnd, descr, wParam, textW, TRUE ); if(!unicode && HAS_STRINGS(descr)) HeapFree(GetProcessHeap(), 0, textW); return ret; @@ -2741,13 +2738,13 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, if((textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW); } - index = LISTBOX_FindString( wnd, descr, wParam, textW, FALSE ); + index = LISTBOX_FindString( hwnd, descr, wParam, textW, FALSE ); if(!unicode && HAS_STRINGS(descr)) HeapFree(GetProcessHeap(), 0, textW); if (index != LB_ERR) { - LISTBOX_SetCaretIndex( wnd, descr, index, TRUE ); - LISTBOX_SetSelection( wnd, descr, index, TRUE, FALSE ); + LISTBOX_SetCaretIndex( hwnd, descr, index, TRUE ); + LISTBOX_SetSelection( hwnd, descr, index, TRUE, FALSE ); } return index; } @@ -2764,15 +2761,15 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, lParam = (INT)(INT16)lParam; /* fall through */ case LB_SETSEL: - return LISTBOX_SetSelection( wnd, descr, lParam, wParam, FALSE ); + return LISTBOX_SetSelection( hwnd, descr, lParam, wParam, FALSE ); case LB_SETCURSEL16: wParam = (INT)(INT16)wParam; /* fall through */ case LB_SETCURSEL: if (IS_MULTISELECT(descr)) return LB_ERR; - LISTBOX_SetCaretIndex( wnd, descr, wParam, TRUE ); - return LISTBOX_SetSelection( wnd, descr, wParam, TRUE, FALSE ); + LISTBOX_SetCaretIndex( hwnd, descr, wParam, TRUE ); + return LISTBOX_SetSelection( hwnd, descr, wParam, TRUE, FALSE ); case LB_GETSELCOUNT16: case LB_GETSELCOUNT: @@ -2787,18 +2784,18 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, case LB_SELITEMRANGE16: case LB_SELITEMRANGE: if (LOWORD(lParam) <= HIWORD(lParam)) - return LISTBOX_SelectItemRange( wnd, descr, LOWORD(lParam), + return LISTBOX_SelectItemRange( hwnd, descr, LOWORD(lParam), HIWORD(lParam), wParam ); else - return LISTBOX_SelectItemRange( wnd, descr, HIWORD(lParam), + return LISTBOX_SelectItemRange( hwnd, descr, HIWORD(lParam), LOWORD(lParam), wParam ); case LB_SELITEMRANGEEX16: case LB_SELITEMRANGEEX: if ((INT)lParam >= (INT)wParam) - return LISTBOX_SelectItemRange( wnd, descr, wParam, lParam, TRUE ); + return LISTBOX_SelectItemRange( hwnd, descr, wParam, lParam, TRUE ); else - return LISTBOX_SelectItemRange( wnd, descr, lParam, wParam, FALSE); + return LISTBOX_SelectItemRange( hwnd, descr, lParam, wParam, FALSE); case LB_GETHORIZONTALEXTENT16: case LB_GETHORIZONTALEXTENT: @@ -2806,7 +2803,7 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, case LB_SETHORIZONTALEXTENT16: case LB_SETHORIZONTALEXTENT: - return LISTBOX_SetHorizontalExtent( wnd, descr, wParam ); + return LISTBOX_SetHorizontalExtent( hwnd, descr, wParam ); case LB_GETANCHORINDEX16: case LB_GETANCHORINDEX: @@ -2840,7 +2837,7 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, if((textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW); } - ret = LISTBOX_Directory( wnd, descr, wParam, textW, msg == LB_DIR ); + ret = LISTBOX_Directory( hwnd, descr, wParam, textW, msg == LB_DIR ); if(!unicode) HeapFree(GetProcessHeap(), 0, textW); return ret; @@ -2854,16 +2851,16 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, return LB_OKAY; case LB_INITSTORAGE: - return LISTBOX_InitStorage( wnd, descr, wParam ); + return LISTBOX_InitStorage( hwnd, descr, wParam ); case LB_SETCOUNT: - return LISTBOX_SetCount( wnd, descr, (INT)wParam ); + return LISTBOX_SetCount( hwnd, descr, (INT)wParam ); case LB_SETTABSTOPS16: - return LISTBOX_SetTabStops( wnd, descr, (INT)(INT16)wParam, MapSL(lParam), TRUE ); + return LISTBOX_SetTabStops( hwnd, descr, (INT)(INT16)wParam, MapSL(lParam), TRUE ); case LB_SETTABSTOPS: - return LISTBOX_SetTabStops( wnd, descr, wParam, (LPINT)lParam, FALSE ); + return LISTBOX_SetTabStops( hwnd, descr, wParam, (LPINT)lParam, FALSE ); case LB_CARETON16: case LB_CARETON: @@ -2871,7 +2868,7 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, return LB_OKAY; descr->caret_on = TRUE; if ((descr->focus_item != -1) && (descr->in_focus)) - LISTBOX_RepaintItem( wnd, descr, descr->focus_item, ODA_FOCUS ); + LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); return LB_OKAY; case LB_CARETOFF16: @@ -2880,18 +2877,18 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, return LB_OKAY; descr->caret_on = FALSE; if ((descr->focus_item != -1) && (descr->in_focus)) - LISTBOX_RepaintItem( wnd, descr, descr->focus_item, ODA_FOCUS ); + LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); return LB_OKAY; - + case WM_DESTROY: - return LISTBOX_Destroy( wnd, descr ); + return LISTBOX_Destroy( hwnd, descr ); case WM_ENABLE: InvalidateRect( hwnd, NULL, TRUE ); return 0; case WM_SETREDRAW: - LISTBOX_SetRedraw( wnd, descr, wParam != 0 ); + LISTBOX_SetRedraw( hwnd, descr, wParam != 0 ); return 0; case WM_GETDLGCODE: @@ -2900,60 +2897,58 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, case WM_PAINT: { PAINTSTRUCT ps; - HDC hdc = ( wParam ) ? ((HDC)wParam) - : BeginPaint( hwnd, &ps ); - ret = LISTBOX_Paint( wnd, descr, hdc ); + HDC hdc = ( wParam ) ? ((HDC)wParam) : BeginPaint( hwnd, &ps ); + ret = LISTBOX_Paint( hwnd, descr, hdc ); if( !wParam ) EndPaint( hwnd, &ps ); } return ret; case WM_SIZE: - LISTBOX_UpdateSize( wnd, descr ); + LISTBOX_UpdateSize( hwnd, descr ); return 0; case WM_GETFONT: return descr->font; case WM_SETFONT: - LISTBOX_SetFont( wnd, descr, (HFONT)wParam ); - if (lParam) InvalidateRect( wnd->hwndSelf, 0, TRUE ); + LISTBOX_SetFont( hwnd, descr, (HFONT)wParam ); + if (lParam) InvalidateRect( hwnd, 0, TRUE ); return 0; case WM_SETFOCUS: descr->in_focus = TRUE; descr->caret_on = TRUE; if (descr->focus_item != -1) - LISTBOX_RepaintItem( wnd, descr, descr->focus_item, ODA_FOCUS ); - SEND_NOTIFICATION( wnd, descr, LBN_SETFOCUS ); + LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); + SEND_NOTIFICATION( hwnd, descr, LBN_SETFOCUS ); return 0; case WM_KILLFOCUS: descr->in_focus = FALSE; if ((descr->focus_item != -1) && descr->caret_on) - LISTBOX_RepaintItem( wnd, descr, descr->focus_item, ODA_FOCUS ); - SEND_NOTIFICATION( wnd, descr, LBN_KILLFOCUS ); + LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); + SEND_NOTIFICATION( hwnd, descr, LBN_KILLFOCUS ); return 0; case WM_HSCROLL: - return LISTBOX_HandleHScroll( wnd, descr, wParam ); + return LISTBOX_HandleHScroll( hwnd, descr, wParam ); case WM_VSCROLL: - return LISTBOX_HandleVScroll( wnd, descr, wParam ); + return LISTBOX_HandleVScroll( hwnd, descr, wParam ); case WM_MOUSEWHEEL: if (wParam & (MK_SHIFT | MK_CONTROL)) - return unicode ? DefWindowProcW( hwnd, msg, wParam, lParam ) : - DefWindowProcA( hwnd, msg, wParam, lParam ); - return LISTBOX_HandleMouseWheel( wnd, descr, wParam ); + return DefWindowProcW( hwnd, msg, wParam, lParam ); + return LISTBOX_HandleMouseWheel( hwnd, descr, wParam ); case WM_LBUTTONDOWN: - return LISTBOX_HandleLButtonDown( wnd, descr, wParam, + return LISTBOX_HandleLButtonDown( hwnd, descr, wParam, (INT16)LOWORD(lParam), (INT16)HIWORD(lParam) ); case WM_LBUTTONDBLCLK: if (descr->style & LBS_NOTIFY) - SEND_NOTIFICATION( wnd, descr, LBN_DBLCLK ); + SEND_NOTIFICATION( hwnd, descr, LBN_DBLCLK ); return 0; case WM_MOUSEMOVE: if (GetCapture() == hwnd) - LISTBOX_HandleMouseMove( wnd, descr, (INT16)LOWORD(lParam), + LISTBOX_HandleMouseMove( hwnd, descr, (INT16)LOWORD(lParam), (INT16)HIWORD(lParam) ); return 0; case WM_LBUTTONUP: - return LISTBOX_HandleLButtonUp( wnd, descr ); + return LISTBOX_HandleLButtonUp( hwnd, descr ); case WM_KEYDOWN: - return LISTBOX_HandleKeyDown( wnd, descr, wParam ); + return LISTBOX_HandleKeyDown( hwnd, descr, wParam ); case WM_CHAR: { WCHAR charW; @@ -2964,16 +2959,16 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, CHAR charA = (CHAR)wParam; MultiByteToWideChar(CP_ACP, 0, &charA, 1, &charW, 1); } - return LISTBOX_HandleChar( wnd, descr, charW ); + return LISTBOX_HandleChar( hwnd, descr, charW ); } case WM_SYSTIMER: - return LISTBOX_HandleSystemTimer( wnd, descr ); + return LISTBOX_HandleSystemTimer( hwnd, descr ); case WM_ERASEBKGND: if ((IS_OWNERDRAW(descr)) && !(descr->style & LBS_DISPLAYCHANGED)) { RECT rect; HBRUSH hbrush = SendMessageW( descr->owner, WM_CTLCOLORLISTBOX, - wParam, (LPARAM)wnd->hwndSelf ); + wParam, (LPARAM)hwnd ); TRACE("hbrush = %04x\n", hbrush); if(!hbrush) hbrush = GetSysColorBrush(COLOR_WINDOW); @@ -3021,15 +3016,8 @@ static LRESULT WINAPI ListBoxWndProc_locked( WND* wnd, UINT msg, */ static LRESULT WINAPI ListBoxWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { - LRESULT res = 0; - WND* wndPtr = WIN_FindWndPtr( hwnd ); - - if (wndPtr) - { - res = ListBoxWndProc_locked(wndPtr, msg, wParam, lParam, FALSE); - WIN_ReleaseWndPtr(wndPtr); - } - return res; + if (!IsWindow(hwnd)) return 0; + return ListBoxWndProc_common( hwnd, msg, wParam, lParam, FALSE ); } /*********************************************************************** @@ -3037,33 +3025,23 @@ static LRESULT WINAPI ListBoxWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARA */ static LRESULT WINAPI ListBoxWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { - LRESULT res = 0; - WND* wndPtr = WIN_FindWndPtr( hwnd ); - - if (wndPtr) - { - res = ListBoxWndProc_locked(wndPtr, msg, wParam, lParam, TRUE); - WIN_ReleaseWndPtr(wndPtr); - } - return res; + if (!IsWindow(hwnd)) return 0; + return ListBoxWndProc_common( hwnd, msg, wParam, lParam, TRUE ); } /*********************************************************************** - * ComboLBWndProc_locked + * ComboLBWndProc_common * - * The real combo listbox wndproc, but called with locked WND struct. + * The real combo listbox wndproc */ -static LRESULT WINAPI ComboLBWndProc_locked( WND* wnd, UINT msg, +static LRESULT WINAPI ComboLBWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode ) { LRESULT lRet = 0; - HWND hwnd; - LB_DESCR *descr = *(LB_DESCR **)wnd->wExtra; + LB_DESCR *descr = (LB_DESCR *)GetWindowLongA( hwnd, 0 ); TRACE_(combo)("[%04x]: msg %s wp %08x lp %08lx\n", - wnd->hwndSelf, SPY_GetMsgName(msg), wParam, lParam ); - - hwnd = wnd->hwndSelf; + hwnd, SPY_GetMsgName(msg), wParam, lParam ); if( descr || msg == WM_CREATE ) { @@ -3076,7 +3054,7 @@ static LRESULT WINAPI ComboLBWndProc_locked( WND* wnd, UINT msg, CREATESTRUCTA *lpcs = (CREATESTRUCTA *)lParam; TRACE_(combo)("\tpassed parent handle = %p\n",lpcs->lpCreateParams); lphc = (LPHEADCOMBO)(lpcs->lpCreateParams); - return LISTBOX_Create( wnd, lphc ); + return LISTBOX_Create( hwnd, lphc ); } case WM_MOUSEMOVE: if ( (TWEAK_WineLook > WIN31_LOOK) && @@ -3100,7 +3078,7 @@ static LRESULT WINAPI ComboLBWndProc_locked( WND* wnd, UINT msg, captured = descr->captured; descr->captured = TRUE; - LISTBOX_HandleMouseMove( wnd, descr, + LISTBOX_HandleMouseMove( hwnd, descr, mousePos.x, mousePos.y); descr->captured = captured; @@ -3108,7 +3086,7 @@ static LRESULT WINAPI ComboLBWndProc_locked( WND* wnd, UINT msg, } else { - LISTBOX_HandleMouseMove( wnd, descr, + LISTBOX_HandleMouseMove( hwnd, descr, mousePos.x, mousePos.y); } @@ -3148,13 +3126,13 @@ static LRESULT WINAPI ComboLBWndProc_locked( WND* wnd, UINT msg, if ( (lParam == (LPARAM)-1) || (!PtInRect( &clientRect, mousePos )) ) { - LISTBOX_MoveCaret( wnd, descr, lphc->droppedIndex, FALSE ); + LISTBOX_MoveCaret( hwnd, descr, lphc->droppedIndex, FALSE ); } } - return LISTBOX_HandleLButtonUp( wnd, descr ); + return LISTBOX_HandleLButtonUp( hwnd, descr ); case WM_LBUTTONDBLCLK: case WM_LBUTTONDOWN: - return LISTBOX_HandleLButtonDownCombo(wnd, descr, msg, wParam, + return LISTBOX_HandleLButtonDownCombo(hwnd, descr, msg, wParam, (INT16)LOWORD(lParam), (INT16)HIWORD(lParam) ); case WM_NCACTIVATE: @@ -3173,13 +3151,13 @@ static LRESULT WINAPI ComboLBWndProc_locked( WND* wnd, UINT msg, return 0; } } - return LISTBOX_HandleKeyDown( wnd, descr, wParam ); + return LISTBOX_HandleKeyDown( hwnd, descr, wParam ); case LB_SETCURSEL16: case LB_SETCURSEL: lRet = unicode ? ListBoxWndProcW( hwnd, msg, wParam, lParam ) : ListBoxWndProcA( hwnd, msg, wParam, lParam ); - lRet =(lRet == LB_ERR) ? lRet : descr->selected_item; + lRet =(lRet == LB_ERR) ? lRet : descr->selected_item; return lRet; case WM_NCDESTROY: if( CB_GETTYPE(lphc) != CBS_SIMPLE ) @@ -3204,22 +3182,11 @@ static LRESULT WINAPI ComboLBWndProc_locked( WND* wnd, UINT msg, * * NOTE: in Windows, winproc address of the ComboLBox is the same * as that of the Listbox. - * - * This is just a wrapper for the real wndproc, it only does window locking - * and unlocking. */ -LRESULT WINAPI ComboLBWndProcA( HWND hwnd, UINT msg, - WPARAM wParam, LPARAM lParam ) +LRESULT WINAPI ComboLBWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { - LRESULT res = 0; - WND *wnd = WIN_FindWndPtr( hwnd ); - - if (wnd) - { - res = ComboLBWndProc_locked(wnd, msg, wParam, lParam, FALSE); - WIN_ReleaseWndPtr(wnd); - } - return res; + if (!IsWindow(hwnd)) return 0; + return ComboLBWndProc_common( hwnd, msg, wParam, lParam, FALSE ); } /*********************************************************************** @@ -3227,13 +3194,6 @@ LRESULT WINAPI ComboLBWndProcA( HWND hwnd, UINT msg, */ LRESULT WINAPI ComboLBWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { - LRESULT res = 0; - WND *wnd = WIN_FindWndPtr( hwnd ); - - if (wnd) - { - res = ComboLBWndProc_locked(wnd, msg, wParam, lParam, TRUE); - WIN_ReleaseWndPtr(wnd); - } - return res; + if (!IsWindow(hwnd)) return 0; + return ComboLBWndProc_common( hwnd, msg, wParam, lParam, TRUE ); } diff --git a/controls/menu.c b/controls/menu.c index 7608eca2cc9..708905c054b 100644 --- a/controls/menu.c +++ b/controls/menu.c @@ -285,7 +285,7 @@ static void do_debug_print_menuitem(const char *prefix, MENUITEM * mp, * * Validate the given menu handle and returns the menu structure pointer. */ -POPUPMENU *MENU_GetMenu(HMENU hMenu) +static POPUPMENU *MENU_GetMenu(HMENU hMenu) { POPUPMENU *menu = USER_HEAP_LIN_ADDR(hMenu); if (!menu || menu->wMagic != MENU_MAGIC) @@ -296,6 +296,23 @@ POPUPMENU *MENU_GetMenu(HMENU hMenu) return menu; } +/*********************************************************************** + * get_win_sys_menu + * + * Get the system menu of a window + */ +static HMENU get_win_sys_menu( HWND hwnd ) +{ + HMENU ret = 0; + WND *win = WIN_FindWndPtr( hwnd ); + if (win) + { + ret = win->hSysMenu; + WIN_ReleaseWndPtr( win ); + } + return ret; +} + /*********************************************************************** * MENU_CopySysPopup * @@ -643,12 +660,7 @@ static UINT MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu, { TRACE("\tlooking for '%c' in [%04x]\n", (char)key, (UINT16)hmenu ); - if (!IsMenu( hmenu )) - { - WND* w = WIN_FindWndPtr(hwndOwner); - hmenu = GetSubMenu(w->hSysMenu, 0); - WIN_ReleaseWndPtr(w); - } + if (!IsMenu( hmenu )) hmenu = GetSubMenu( get_win_sys_menu(hwndOwner), 0); if (hmenu) { @@ -1457,10 +1469,9 @@ UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect, HWND hwnd, LPPOPUPMENU lppop; UINT i,retvalue; HFONT hfontOld = 0; + HMENU hMenu = GetMenu(hwnd); - WND *wndPtr = WIN_FindWndPtr( hwnd ); - - lppop = MENU_GetMenu ((HMENU)wndPtr->wIDmenu ); + lppop = MENU_GetMenu( hMenu ); if (lppop == NULL || lprect == NULL) { retvalue = GetSystemMetrics(SM_CYMENU); @@ -1505,16 +1516,13 @@ UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect, HWND hwnd, for (i = 0; i < lppop->nItems; i++) { - MENU_DrawMenuItem( hwnd, (HMENU)wndPtr->wIDmenu, hwnd, - hDC, &lppop->items[i], lppop->Height, TRUE, ODA_DRAWENTIRE ); + MENU_DrawMenuItem( hwnd, hMenu, hwnd, + hDC, &lppop->items[i], lppop->Height, TRUE, ODA_DRAWENTIRE ); } retvalue = lppop->Height; END: - if (hfontOld) - SelectObject (hDC, hfontOld); - - WIN_ReleaseWndPtr(wndPtr); + if (hfontOld) SelectObject (hDC, hfontOld); return retvalue; } @@ -1527,8 +1535,8 @@ END: static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, INT x, INT y, INT xanchor, INT yanchor ) { - POPUPMENU *menu; - WND *wndOwner = NULL; + POPUPMENU *menu; + UINT width, height; TRACE("owner=0x%04x hmenu=0x%04x id=0x%04x x=0x%04x y=0x%04x xa=0x%04x ya=0x%04x\n", hwndOwner, hmenu, id, x, y, xanchor, yanchor); @@ -1543,62 +1551,52 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, /* store the owner for DrawItem */ menu->hwndOwner = hwndOwner; - if( (wndOwner = WIN_FindWndPtr( hwndOwner )) ) + + MENU_PopupMenuCalcSize( menu, hwndOwner ); + + /* adjust popup menu pos so that it fits within the desktop */ + + width = menu->Width + GetSystemMetrics(SM_CXBORDER); + height = menu->Height + GetSystemMetrics(SM_CYBORDER); + + if( x + width > GetSystemMetrics(SM_CXSCREEN )) { - UINT width, height; - - MENU_PopupMenuCalcSize( menu, hwndOwner ); - - /* adjust popup menu pos so that it fits within the desktop */ - - width = menu->Width + GetSystemMetrics(SM_CXBORDER); - height = menu->Height + GetSystemMetrics(SM_CYBORDER); - - if( x + width > GetSystemMetrics(SM_CXSCREEN )) - { - if( xanchor ) - x -= width - xanchor; - if( x + width > GetSystemMetrics(SM_CXSCREEN)) - x = GetSystemMetrics(SM_CXSCREEN) - width; - } - if( x < 0 ) x = 0; - - if( y + height > GetSystemMetrics(SM_CYSCREEN )) - { - if( yanchor ) - y -= height + yanchor; - if( y + height > GetSystemMetrics(SM_CYSCREEN )) - y = GetSystemMetrics(SM_CYSCREEN) - height; - } - if( y < 0 ) y = 0; - - if( TWEAK_WineLook == WIN31_LOOK ) - { - width += POPUP_XSHADE * GetSystemMetrics(SM_CXBORDER); /* add space for shading */ - height += POPUP_YSHADE * GetSystemMetrics(SM_CYBORDER); - } - - /* NOTE: In Windows, top menu popup is not owned. */ - menu->hWnd = CreateWindowA( POPUPMENU_CLASS_ATOM, NULL, - WS_POPUP, x, y, width, height, - hwndOwner, 0, wndOwner->hInstance, - (LPVOID)hmenu ); - if( !menu->hWnd ) - { - WIN_ReleaseWndPtr(wndOwner); - return FALSE; - } - if (!top_popup) top_popup = menu->hWnd; - - /* Display the window */ - - SetWindowPos( menu->hWnd, HWND_TOP, 0, 0, 0, 0, - SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE ); - UpdateWindow( menu->hWnd ); - WIN_ReleaseWndPtr(wndOwner); - return TRUE; + if( xanchor ) + x -= width - xanchor; + if( x + width > GetSystemMetrics(SM_CXSCREEN)) + x = GetSystemMetrics(SM_CXSCREEN) - width; } - return FALSE; + if( x < 0 ) x = 0; + + if( y + height > GetSystemMetrics(SM_CYSCREEN )) + { + if( yanchor ) + y -= height + yanchor; + if( y + height > GetSystemMetrics(SM_CYSCREEN )) + y = GetSystemMetrics(SM_CYSCREEN) - height; + } + if( y < 0 ) y = 0; + + if( TWEAK_WineLook == WIN31_LOOK ) + { + width += POPUP_XSHADE * GetSystemMetrics(SM_CXBORDER); /* add space for shading */ + height += POPUP_YSHADE * GetSystemMetrics(SM_CYBORDER); + } + + /* NOTE: In Windows, top menu popup is not owned. */ + menu->hWnd = CreateWindowA( POPUPMENU_CLASS_ATOM, NULL, + WS_POPUP, x, y, width, height, + hwndOwner, 0, GetWindowLongA(hwndOwner,GWL_HINSTANCE), + (LPVOID)hmenu ); + if( !menu->hWnd ) return FALSE; + if (!top_popup) top_popup = menu->hWnd; + + /* Display the window */ + + SetWindowPos( menu->hWnd, HWND_TOP, 0, 0, 0, 0, + SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE ); + UpdateWindow( menu->hWnd ); + return TRUE; } @@ -2005,27 +2003,17 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu, RECT rect; POPUPMENU *menu; MENUITEM *item; - WND *wndPtr; HDC hdc; TRACE("owner=0x%04x hmenu=0x%04x 0x%04x\n", hwndOwner, hmenu, selectFirst); if (!(menu = MENU_GetMenu( hmenu ))) return hmenu; - if (!(wndPtr = WIN_FindWndPtr( menu->hWnd )) || - (menu->FocusedItem == NO_SELECTED_ITEM)) - { - WIN_ReleaseWndPtr(wndPtr); - return hmenu; - } + if (menu->FocusedItem == NO_SELECTED_ITEM) return hmenu; item = &menu->items[menu->FocusedItem]; - if (!(item->fType & MF_POPUP) || - (item->fState & (MF_GRAYED | MF_DISABLED))) - { - WIN_ReleaseWndPtr(wndPtr); + if (!(item->fType & MF_POPUP) || (item->fState & (MF_GRAYED | MF_DISABLED))) return hmenu; - } /* message must be sent before using item, because nearly everything may be changed by the application ! */ @@ -2057,26 +2045,29 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu, if (IS_SYSTEM_MENU(menu)) { - MENU_InitSysMenuPopup(item->hSubMenu, wndPtr->dwStyle, GetClassLongA(wndPtr->hwndSelf, GCL_STYLE)); + MENU_InitSysMenuPopup(item->hSubMenu, + GetWindowLongA( menu->hWnd, GWL_STYLE ), + GetClassLongA( menu->hWnd, GCL_STYLE)); - NC_GetSysPopupPos( wndPtr, &rect ); + NC_GetSysPopupPos( menu->hWnd, &rect ); rect.top = rect.bottom; rect.right = GetSystemMetrics(SM_CXSIZE); rect.bottom = GetSystemMetrics(SM_CYSIZE); } else { + GetWindowRect( menu->hWnd, &rect ); if (menu->wFlags & MF_POPUP) { - rect.left = wndPtr->rectWindow.left + item->rect.right - GetSystemMetrics(SM_CXBORDER); - rect.top = wndPtr->rectWindow.top + item->rect.top; + rect.left += item->rect.right - GetSystemMetrics(SM_CXBORDER); + rect.top += item->rect.top; rect.right = item->rect.left - item->rect.right + GetSystemMetrics(SM_CXBORDER); rect.bottom = item->rect.top - item->rect.bottom; } else { - rect.left = wndPtr->rectWindow.left + item->rect.left; - rect.top = wndPtr->rectWindow.top + item->rect.bottom; + rect.left += item->rect.left; + rect.top += item->rect.bottom; rect.right = item->rect.right - item->rect.left; rect.bottom = item->rect.bottom - item->rect.top; } @@ -2086,7 +2077,6 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu, rect.left, rect.top, rect.right, rect.bottom ); if (selectFirst) MENU_MoveSelection( hwndOwner, item->hSubMenu, ITEM_NEXT ); - WIN_ReleaseWndPtr(wndPtr); return item->hSubMenu; } @@ -2108,30 +2098,28 @@ BOOL MENU_IsMenuActive(void) static HMENU MENU_PtMenu( HMENU hMenu, POINT pt ) { POPUPMENU *menu = MENU_GetMenu( hMenu ); - register UINT ht = menu->FocusedItem; + UINT item = menu->FocusedItem; + HMENU ret; /* try subpopup first (if any) */ - ht = (ht != NO_SELECTED_ITEM && - (menu->items[ht].fType & MF_POPUP) && - (menu->items[ht].fState & MF_MOUSESELECT)) - ? (UINT) MENU_PtMenu(menu->items[ht].hSubMenu, pt) : 0; + ret = (item != NO_SELECTED_ITEM && + (menu->items[item].fType & MF_POPUP) && + (menu->items[item].fState & MF_MOUSESELECT)) + ? MENU_PtMenu(menu->items[item].hSubMenu, pt) : 0; - if( !ht ) /* check the current window (avoiding WM_HITTEST) */ + if (!ret) /* check the current window (avoiding WM_HITTEST) */ { - ht = (UINT)NC_HandleNCHitTest( menu->hWnd, pt ); - if( menu->wFlags & MF_POPUP ) - ht = (ht != (UINT)HTNOWHERE && - ht != (UINT)HTERROR) ? (UINT)hMenu : 0; - else - { - WND* wndPtr = WIN_FindWndPtr(menu->hWnd); - - ht = ( ht == HTSYSMENU ) ? (UINT)(wndPtr->hSysMenu) - : ( ht == HTMENU ) ? (UINT)(wndPtr->wIDmenu) : 0; - WIN_ReleaseWndPtr(wndPtr); - } + INT ht = NC_HandleNCHitTest( menu->hWnd, pt ); + if( menu->wFlags & MF_POPUP ) + { + if (ht != HTNOWHERE && ht != HTERROR) ret = hMenu; + } + else if (ht == HTSYSMENU) + ret = get_win_sys_menu( menu->hWnd ); + else if (ht == HTMENU) + ret = GetMenu( menu->hWnd ); } - return (HMENU)ht; + return ret; } /*********************************************************************** @@ -2335,7 +2323,6 @@ static LRESULT MENU_DoNextMenu( MTRACKER* pmt, UINT vk ) if( (vk == VK_LEFT && menu->FocusedItem == 0 ) || (vk == VK_RIGHT && menu->FocusedItem == menu->nItems - 1)) { - WND* wndPtr; HMENU hNewMenu; HWND hNewWnd; UINT id = 0; @@ -2347,62 +2334,50 @@ static LRESULT MENU_DoNextMenu( MTRACKER* pmt, UINT vk ) if( l == 0 ) { - wndPtr = WIN_FindWndPtr(pmt->hOwnerWnd); - + DWORD style = GetWindowLongA( pmt->hOwnerWnd, GWL_STYLE ); hNewWnd = pmt->hOwnerWnd; if( IS_SYSTEM_MENU(menu) ) { /* switch to the menu bar */ - if( wndPtr->dwStyle & WS_CHILD || !wndPtr->wIDmenu ) - { - WIN_ReleaseWndPtr(wndPtr); - return FALSE; - } + if(style & WS_CHILD || !(hNewMenu = GetMenu(hNewWnd))) return FALSE; - hNewMenu = wndPtr->wIDmenu; if( vk == VK_LEFT ) { menu = MENU_GetMenu( hNewMenu ); id = menu->nItems - 1; } } - else if( wndPtr->dwStyle & WS_SYSMENU ) + else if (style & WS_SYSMENU ) { /* switch to the system menu */ - hNewMenu = wndPtr->hSysMenu; + hNewMenu = get_win_sys_menu( hNewWnd ); } - else - { - WIN_ReleaseWndPtr(wndPtr); - return FALSE; - } - WIN_ReleaseWndPtr(wndPtr); + else return FALSE; } else /* application returned a new menu to switch to */ { - hNewMenu = LOWORD(l); hNewWnd = HIWORD(l); + hNewMenu = LOWORD(l); + hNewWnd = HIWORD(l); if( IsMenu(hNewMenu) && IsWindow(hNewWnd) ) { - wndPtr = WIN_FindWndPtr(hNewWnd); + DWORD style = GetWindowLongA( hNewWnd, GWL_STYLE ); - if( wndPtr->dwStyle & WS_SYSMENU && - GetSubMenu(wndPtr->hSysMenu, 0) == hNewMenu ) + if (style & WS_SYSMENU && + GetSubMenu(get_win_sys_menu(hNewWnd), 0) == hNewMenu ) { /* get the real system menu */ - hNewMenu = wndPtr->hSysMenu; + hNewMenu = get_win_sys_menu(hNewWnd); } - else if( wndPtr->dwStyle & WS_CHILD || wndPtr->wIDmenu != hNewMenu ) + else if (style & WS_CHILD || GetMenu(hNewWnd) != hNewMenu ) { /* FIXME: Not sure what to do here; * perhaps try to track hNewMenu as a popup? */ TRACE(" -- got confused.\n"); - WIN_ReleaseWndPtr(wndPtr); return FALSE; } - WIN_ReleaseWndPtr(wndPtr); } else return FALSE; } @@ -2955,13 +2930,12 @@ static BOOL MENU_ExitTracking(HWND hWnd) * * Menu-bar tracking upon a mouse event. Called from NC_HandleSysCommand(). */ -void MENU_TrackMouseMenuBar( WND* wndPtr, INT ht, POINT pt ) +void MENU_TrackMouseMenuBar( HWND hWnd, INT ht, POINT pt ) { - HWND hWnd = wndPtr->hwndSelf; - HMENU hMenu = (ht == HTSYSMENU) ? wndPtr->hSysMenu : wndPtr->wIDmenu; + HMENU hMenu = (ht == HTSYSMENU) ? get_win_sys_menu( hWnd ) : GetMenu( hWnd ); UINT wFlags = TPM_ENTERIDLEEX | TPM_BUTTONDOWN | TPM_LEFTALIGN | TPM_LEFTBUTTON; - TRACE("pwnd=%p ht=0x%04x (%ld,%ld)\n", wndPtr, ht, pt.x, pt.y); + TRACE("wnd=%x ht=0x%04x (%ld,%ld)\n", hWnd, ht, pt.x, pt.y); if (IsMenu(hMenu)) { @@ -2977,59 +2951,54 @@ void MENU_TrackMouseMenuBar( WND* wndPtr, INT ht, POINT pt ) * * Menu-bar tracking upon a keyboard event. Called from NC_HandleSysCommand(). */ -void MENU_TrackKbdMenuBar( WND* wndPtr, UINT wParam, INT vkey) +void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, INT vkey) { - UINT uItem = NO_SELECTED_ITEM; - HMENU hTrackMenu; - UINT wFlags = TPM_ENTERIDLEEX | TPM_LEFTALIGN | TPM_LEFTBUTTON; + UINT uItem = NO_SELECTED_ITEM; + HMENU hTrackMenu; + UINT wFlags = TPM_ENTERIDLEEX | TPM_LEFTALIGN | TPM_LEFTBUTTON; /* find window that has a menu */ - - while( wndPtr->dwStyle & WS_CHILD) - if( !(wndPtr = wndPtr->parent) ) return; + + while (GetWindowLongA( hwnd, GWL_STYLE ) & WS_CHILD) + if (!(hwnd = GetParent( hwnd ))) return; /* check if we have to track a system menu */ - - if( (wndPtr->dwStyle & (WS_CHILD | WS_MINIMIZE)) || - !wndPtr->wIDmenu || vkey == VK_SPACE ) + + hTrackMenu = GetMenu( hwnd ); + if (!hTrackMenu || IsIconic(hwnd) || vkey == VK_SPACE ) { - if( !(wndPtr->dwStyle & WS_SYSMENU) ) return; - hTrackMenu = wndPtr->hSysMenu; - uItem = 0; - wParam |= HTSYSMENU; /* prevent item lookup */ + if (!(GetWindowLongA( hwnd, GWL_STYLE ) & WS_SYSMENU)) return; + hTrackMenu = get_win_sys_menu( hwnd ); + uItem = 0; + wParam |= HTSYSMENU; /* prevent item lookup */ } - else - hTrackMenu = wndPtr->wIDmenu; - if (IsMenu( hTrackMenu )) + if (!IsMenu( hTrackMenu )) return; + + MENU_InitTracking( hwnd, hTrackMenu, FALSE, wFlags ); + + if( vkey && vkey != VK_SPACE ) { - MENU_InitTracking( wndPtr->hwndSelf, hTrackMenu, FALSE, wFlags ); - - if( vkey && vkey != VK_SPACE ) + uItem = MENU_FindItemByKey( hwnd, hTrackMenu, vkey, (wParam & HTSYSMENU) ); + if( uItem >= (UINT)(-2) ) { - uItem = MENU_FindItemByKey( wndPtr->hwndSelf, hTrackMenu, - vkey, (wParam & HTSYSMENU) ); - if( uItem >= (UINT)(-2) ) - { - if( uItem == (UINT)(-1) ) MessageBeep(0); - hTrackMenu = 0; - } + if( uItem == (UINT)(-1) ) MessageBeep(0); + hTrackMenu = 0; } - - if( hTrackMenu ) - { - MENU_SelectItem( wndPtr->hwndSelf, hTrackMenu, uItem, TRUE, 0 ); - - if( uItem == NO_SELECTED_ITEM ) - MENU_MoveSelection( wndPtr->hwndSelf, hTrackMenu, ITEM_NEXT ); - else if( vkey ) - PostMessageA( wndPtr->hwndSelf, WM_KEYDOWN, VK_DOWN, 0L ); - - MENU_TrackMenu( hTrackMenu, wFlags, 0, 0, wndPtr->hwndSelf, NULL ); - } - - MENU_ExitTracking (wndPtr->hwndSelf); } + + if( hTrackMenu ) + { + MENU_SelectItem( hwnd, hTrackMenu, uItem, TRUE, 0 ); + + if( uItem == NO_SELECTED_ITEM ) + MENU_MoveSelection( hwnd, hTrackMenu, ITEM_NEXT ); + else if( vkey ) + PostMessageA( hwnd, WM_KEYDOWN, VK_DOWN, 0L ); + + MENU_TrackMenu( hTrackMenu, wFlags, 0, 0, hwnd, NULL ); + } + MENU_ExitTracking( hwnd ); } @@ -3159,30 +3128,19 @@ UINT MENU_GetMenuBarHeight( HWND hwnd, UINT menubarWidth, { HDC hdc; RECT rectBar; - WND *wndPtr; LPPOPUPMENU lppop; - UINT retvalue; TRACE("HWND 0x%x, width %d, at (%d, %d).\n", - hwnd, menubarWidth, orgX, orgY ); - - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) - return 0; + hwnd, menubarWidth, orgX, orgY ); - if (!(lppop = MENU_GetMenu((HMENU16)wndPtr->wIDmenu))) - { - WIN_ReleaseWndPtr(wndPtr); - return 0; - } + if (!(lppop = MENU_GetMenu( GetMenu(hwnd) ))) return 0; hdc = GetDCEx( hwnd, 0, DCX_CACHE | DCX_WINDOW ); SelectObject( hdc, hMenuFont); SetRect(&rectBar, orgX, orgY, orgX+menubarWidth, orgY+GetSystemMetrics(SM_CYMENU)); MENU_MenuBarCalcSize( hdc, &rectBar, lppop, hwnd ); ReleaseDC( hwnd, hdc ); - retvalue = lppop->Height; - WIN_ReleaseWndPtr(wndPtr); - return retvalue; + return lppop->Height; } @@ -3977,15 +3935,8 @@ HMENU16 WINAPI GetMenu16( HWND16 hWnd ) */ HMENU WINAPI GetMenu( HWND hWnd ) { - HMENU retvalue; - WND * wndPtr = WIN_FindWndPtr(hWnd); - - if (!wndPtr) return 0; - - retvalue = (HMENU)wndPtr->wIDmenu; - TRACE("for %swindow %04x returning %04x\n", - (wndPtr->dwStyle & WS_CHILD) ? "child " : "", hWnd, retvalue); - WIN_ReleaseWndPtr(wndPtr); + HMENU retvalue = (HMENU)GetWindowLongA( hWnd, GWL_ID ); + TRACE("for %04x returning %04x\n", hWnd, retvalue); return retvalue; } @@ -4004,40 +3955,32 @@ BOOL16 WINAPI SetMenu16( HWND16 hWnd, HMENU16 hMenu ) */ BOOL WINAPI SetMenu( HWND hWnd, HMENU hMenu ) { - WND * wndPtr = WIN_FindWndPtr(hWnd); - BOOL res = FALSE; - TRACE("(%04x, %04x);\n", hWnd, hMenu); if (hMenu && !IsMenu(hMenu)) { - WARN("hMenu is not a menu handle\n"); - goto exit; + WARN("hMenu %x is not a menu handle\n", hMenu); + return FALSE; } + if (GetWindowLongA( hWnd, GWL_STYLE ) & WS_CHILD) return FALSE; - if (wndPtr && !(wndPtr->dwStyle & WS_CHILD)) + if (GetCapture() == hWnd) ReleaseCapture(); + + if (hMenu != 0) { - if (GetCapture() == hWnd) ReleaseCapture(); + LPPOPUPMENU lpmenu; - wndPtr->wIDmenu = (UINT)hMenu; - if (hMenu != 0) - { - LPPOPUPMENU lpmenu; + if (!(lpmenu = MENU_GetMenu(hMenu))) return FALSE; - if (!(lpmenu = MENU_GetMenu(hMenu))) - goto exit; - - lpmenu->hWnd = hWnd; - lpmenu->Height = 0; /* Make sure we recalculate the size */ - } - if (IsWindowVisible(hWnd)) - SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | - SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); - res = TRUE; + lpmenu->hWnd = hWnd; + lpmenu->Height = 0; /* Make sure we recalculate the size */ } -exit: - WIN_ReleaseWndPtr(wndPtr); - return res; + SetWindowLongA( hWnd, GWL_ID, hMenu ); + + if (IsWindowVisible(hWnd)) + SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | + SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); + return TRUE; } @@ -4079,25 +4022,16 @@ void WINAPI DrawMenuBar16( HWND16 hWnd ) BOOL WINAPI DrawMenuBar( HWND hWnd ) { LPPOPUPMENU lppop; - WND *wndPtr = WIN_FindWndPtr(hWnd); - if (wndPtr && !(wndPtr->dwStyle & WS_CHILD) && wndPtr->wIDmenu) - { - lppop = MENU_GetMenu((HMENU16)wndPtr->wIDmenu); - if (lppop == NULL) - { - WIN_ReleaseWndPtr(wndPtr); - return FALSE; - } + HMENU hMenu = GetMenu(hWnd); - lppop->Height = 0; /* Make sure we call MENU_MenuBarCalcSize */ - lppop->hwndOwner = hWnd; - SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | - SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); - WIN_ReleaseWndPtr(wndPtr); - return TRUE; - } - WIN_ReleaseWndPtr(wndPtr); - return FALSE; + if (GetWindowLongA( hWnd, GWL_STYLE ) & WS_CHILD) return FALSE; + if (!hMenu || !(lppop = MENU_GetMenu( hMenu ))) return FALSE; + + lppop->Height = 0; /* Make sure we call MENU_MenuBarCalcSize */ + lppop->hwndOwner = hWnd; + SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | + SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); + return TRUE; } /*********************************************************************** @@ -4967,11 +4901,9 @@ static BOOL translate_accelerator( HWND hWnd, UINT message, WPARAM wParam, LPARA { HMENU hMenu, hSubMenu, hSysMenu; UINT uSysStat = (UINT)-1, uStat = (UINT)-1, nPos; - WND* wndPtr = WIN_FindWndPtr(hWnd); - hMenu = (wndPtr->dwStyle & WS_CHILD) ? 0 : (HMENU)wndPtr->wIDmenu; - hSysMenu = wndPtr->hSysMenu; - WIN_ReleaseWndPtr(wndPtr); + hMenu = (GetWindowLongA( hWnd, GWL_STYLE ) & WS_CHILD) ? 0 : GetMenu(hWnd); + hSysMenu = get_win_sys_menu( hWnd ); /* find menu item and ask application to initialize it */ /* 1. in the system menu */ diff --git a/controls/scroll.c b/controls/scroll.c index 25a277ddefa..d9384caaa03 100644 --- a/controls/scroll.c +++ b/controls/scroll.c @@ -144,11 +144,12 @@ static void SCROLL_LoadBitmaps(void) /*********************************************************************** - * SCROLL_GetPtrScrollInfo + * SCROLL_GetScrollInfo */ -static SCROLLBAR_INFO *SCROLL_GetPtrScrollInfo( WND* wndPtr, INT nBar ) +static SCROLLBAR_INFO *SCROLL_GetScrollInfo( HWND hwnd, INT nBar ) { SCROLLBAR_INFO *infoPtr; + WND *wndPtr = WIN_FindWndPtr( hwnd ); if (!wndPtr) return NULL; switch(nBar) @@ -156,7 +157,9 @@ static SCROLLBAR_INFO *SCROLL_GetPtrScrollInfo( WND* wndPtr, INT nBar ) case SB_HORZ: infoPtr = (SCROLLBAR_INFO *)wndPtr->pHScroll; break; case SB_VERT: infoPtr = (SCROLLBAR_INFO *)wndPtr->pVScroll; break; case SB_CTL: infoPtr = (SCROLLBAR_INFO *)wndPtr->wExtra; break; - default: return NULL; + default: + WIN_ReleaseWndPtr( wndPtr ); + return NULL; } if (!infoPtr) /* Create the info structure if needed */ @@ -171,23 +174,11 @@ static SCROLLBAR_INFO *SCROLL_GetPtrScrollInfo( WND* wndPtr, INT nBar ) } if (!hUpArrow) SCROLL_LoadBitmaps(); } + WIN_ReleaseWndPtr( wndPtr ); return infoPtr; } -/*********************************************************************** - * SCROLL_GetScrollInfo - */ -static SCROLLBAR_INFO *SCROLL_GetScrollInfo( HWND hwnd, INT nBar ) -{ - SCROLLBAR_INFO *retvalue; - WND *wndPtr = WIN_FindWndPtr( hwnd ); - retvalue = SCROLL_GetPtrScrollInfo( wndPtr, nBar ); - WIN_ReleaseWndPtr(wndPtr); - return retvalue; -} - - /*********************************************************************** * SCROLL_GetScrollBarRect * @@ -258,7 +249,7 @@ static BOOL SCROLL_GetScrollBarRect( HWND hwnd, INT nBar, RECT *lprect, } else { - SCROLLBAR_INFO *info = SCROLL_GetPtrScrollInfo( wndPtr, nBar ); + SCROLLBAR_INFO *info = SCROLL_GetScrollInfo( hwnd, nBar ); *arrowSize = GetSystemMetrics(SM_CXVSCROLL); pixels -= (2 * (GetSystemMetrics(SM_CXVSCROLL) - SCROLL_ARROW_THUMB_OVERLAP)); @@ -793,7 +784,7 @@ void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar, RECT rect; BOOL vertical; WND *wndPtr = WIN_FindWndPtr( hwnd ); - SCROLLBAR_INFO *infoPtr = SCROLL_GetPtrScrollInfo( wndPtr, nBar ); + SCROLLBAR_INFO *infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ); BOOL Save_SCROLL_MovingThumb = SCROLL_MovingThumb; if (!wndPtr || !infoPtr || @@ -877,9 +868,8 @@ static void SCROLL_RefreshScrollBar( HWND hwnd, INT nBar, */ static void SCROLL_HandleKbdEvent( HWND hwnd, WPARAM wParam ) { - WND *wndPtr = WIN_FindWndPtr( hwnd ); WPARAM msg; - + switch(wParam) { case VK_PRIOR: msg = SB_PAGEUP; break; @@ -888,14 +878,11 @@ static void SCROLL_HandleKbdEvent( HWND hwnd, WPARAM wParam ) case VK_END: msg = SB_BOTTOM; break; case VK_UP: msg = SB_LINEUP; break; case VK_DOWN: msg = SB_LINEDOWN; break; - default: - WIN_ReleaseWndPtr(wndPtr); - return; + default: return; } SendMessageW( GetParent(hwnd), - (wndPtr->dwStyle & SBS_VERT) ? WM_VSCROLL : WM_HSCROLL, - msg, hwnd ); - WIN_ReleaseWndPtr(wndPtr); + (GetWindowLongA( hwnd, GWL_STYLE ) & SBS_VERT) ? WM_VSCROLL : WM_HSCROLL, + msg, hwnd ); } @@ -1651,30 +1638,33 @@ BOOL bRedraw /* [in] Should scrollbar be redrawn afterwards ? */) * * Updates both scrollbars at the same time. Used by MDI CalcChildScroll(). */ -INT SCROLL_SetNCSbState(WND* wndPtr, int vMin, int vMax, int vPos, - int hMin, int hMax, int hPos) +INT SCROLL_SetNCSbState(HWND hwnd, int vMin, int vMax, int vPos, + int hMin, int hMax, int hPos) { INT vA, hA; SCROLLINFO vInfo, hInfo; - + vInfo.cbSize = hInfo.cbSize = sizeof(SCROLLINFO); - vInfo.nMin = vMin; hInfo.nMin = hMin; - vInfo.nMax = vMax; hInfo.nMax = hMax; - vInfo.nPos = vPos; hInfo.nPos = hPos; + vInfo.nMin = vMin; + vInfo.nMax = vMax; + vInfo.nPos = vPos; + hInfo.nMin = hMin; + hInfo.nMax = hMax; + hInfo.nPos = hPos; vInfo.fMask = hInfo.fMask = SIF_RANGE | SIF_POS; - SCROLL_SetScrollInfo( wndPtr->hwndSelf, SB_VERT, &vInfo, &vA ); - SCROLL_SetScrollInfo( wndPtr->hwndSelf, SB_HORZ, &hInfo, &hA ); + SCROLL_SetScrollInfo( hwnd, SB_VERT, &vInfo, &vA ); + SCROLL_SetScrollInfo( hwnd, SB_HORZ, &hInfo, &hA ); - if( !SCROLL_ShowScrollBar( wndPtr->hwndSelf, SB_BOTH, + if( !SCROLL_ShowScrollBar( hwnd, SB_BOTH, (hA & SA_SSI_SHOW),(vA & SA_SSI_SHOW) ) ) { /* SetWindowPos() wasn't called, just redraw the scrollbars if needed */ if( vA & SA_SSI_REFRESH ) - SCROLL_RefreshScrollBar( wndPtr->hwndSelf, SB_VERT, FALSE, TRUE ); + SCROLL_RefreshScrollBar( hwnd, SB_VERT, FALSE, TRUE ); if( hA & SA_SSI_REFRESH ) - SCROLL_RefreshScrollBar( wndPtr->hwndSelf, SB_HORZ, FALSE, TRUE ); + SCROLL_RefreshScrollBar( hwnd, SB_HORZ, FALSE, TRUE ); } return 0; } diff --git a/controls/static.c b/controls/static.c index 0912ea973b3..8724a8449db 100644 --- a/controls/static.c +++ b/controls/static.c @@ -8,7 +8,6 @@ #include "windef.h" #include "wingdi.h" #include "wine/winuser16.h" -#include "win.h" #include "cursoricon.h" #include "controls.h" #include "user.h" @@ -16,25 +15,23 @@ DEFAULT_DEBUG_CHANNEL(static); -static void STATIC_PaintOwnerDrawfn( WND *wndPtr, HDC hdc ); -static void STATIC_PaintTextfn( WND *wndPtr, HDC hdc ); -static void STATIC_PaintRectfn( WND *wndPtr, HDC hdc ); -static void STATIC_PaintIconfn( WND *wndPtr, HDC hdc ); -static void STATIC_PaintBitmapfn( WND *wndPtr, HDC hdc ); -static void STATIC_PaintEtchedfn( WND *wndPtr, HDC hdc ); +static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style ); +static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style ); +static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style ); +static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style ); +static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc, DWORD style ); +static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style ); static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); static COLORREF color_windowframe, color_background, color_window; -typedef struct -{ - HFONT16 hFont; /* Control font (or 0 for system font) */ - WORD dummy; /* Don't know what MS-Windows puts in there */ - HICON16 hIcon; /* Icon handle for SS_ICON controls */ -} STATICINFO; +/* offsets for GetWindowLong for static private information */ +#define HFONT_GWL_OFFSET 0 +#define HICON_GWL_OFFSET (sizeof(HFONT)) +#define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON)) -typedef void (*pfPaint)( WND *, HDC ); +typedef void (*pfPaint)( HWND hwnd, HDC hdc, DWORD style ); static pfPaint staticPaintFunc[SS_TYPEMASK+1] = { @@ -69,7 +66,7 @@ const struct builtin_class_descr STATIC_builtin_class = CS_GLOBALCLASS | CS_DBLCLKS | CS_PARENTDC, /* style */ StaticWndProcA, /* procA */ StaticWndProcW, /* procW */ - sizeof(STATICINFO), /* extra */ + STATIC_EXTRA_BYTES, /* extra */ IDC_ARROWA, /* cursor */ 0 /* brush */ }; @@ -80,22 +77,20 @@ const struct builtin_class_descr STATIC_builtin_class = * * Set the icon for an SS_ICON control. */ -static HICON16 STATIC_SetIcon( WND *wndPtr, HICON16 hicon ) +static HICON STATIC_SetIcon( HWND hwnd, HICON hicon, DWORD style ) { - HICON16 prevIcon; - STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra; + HICON prevIcon; CURSORICONINFO *info = hicon?(CURSORICONINFO *) GlobalLock16( hicon ):NULL; - if ((wndPtr->dwStyle & SS_TYPEMASK) != SS_ICON) return 0; + if ((style & SS_TYPEMASK) != SS_ICON) return 0; if (hicon && !info) { ERR("huh? hicon!=0, but info=0???\n"); return 0; } - prevIcon = infoPtr->hIcon; - infoPtr->hIcon = hicon; + prevIcon = SetWindowLongA( hwnd, HICON_GWL_OFFSET, hicon ); if (hicon) { - SetWindowPos( wndPtr->hwndSelf, 0, 0, 0, info->nWidth, info->nHeight, + SetWindowPos( hwnd, 0, 0, 0, info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER ); GlobalUnlock16( hicon ); } @@ -107,23 +102,21 @@ static HICON16 STATIC_SetIcon( WND *wndPtr, HICON16 hicon ) * * Set the bitmap for an SS_BITMAP control. */ -static HBITMAP16 STATIC_SetBitmap( WND *wndPtr, HBITMAP16 hBitmap ) +static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap, DWORD style ) { - HBITMAP16 hOldBitmap; - STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra; + HBITMAP hOldBitmap; - if ((wndPtr->dwStyle & SS_TYPEMASK) != SS_BITMAP) return 0; + if ((style & SS_TYPEMASK) != SS_BITMAP) return 0; if (hBitmap && GetObjectType(hBitmap) != OBJ_BITMAP) { ERR("huh? hBitmap!=0, but not bitmap\n"); return 0; } - hOldBitmap = infoPtr->hIcon; - infoPtr->hIcon = hBitmap; + hOldBitmap = SetWindowLongA( hwnd, HICON_GWL_OFFSET, hBitmap ); if (hBitmap) { BITMAP bm; GetObjectW(hBitmap, sizeof(bm), &bm); - SetWindowPos( wndPtr->hwndSelf, 0, 0, 0, bm.bmWidth, bm.bmHeight, + SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER ); } return hOldBitmap; @@ -134,9 +127,10 @@ static HBITMAP16 STATIC_SetBitmap( WND *wndPtr, HBITMAP16 hBitmap ) * * Load the icon for an SS_ICON control. */ -static HICON STATIC_LoadIconA( WND *wndPtr, LPCSTR name ) +static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name ) { - HICON hicon = LoadIconA( wndPtr->hInstance, name ); + HINSTANCE hInstance = GetWindowLongA( hwnd, GWL_HINSTANCE ); + HICON hicon = LoadIconA( hInstance, name ); if (!hicon) hicon = LoadIconA( 0, name ); return hicon; } @@ -146,9 +140,10 @@ static HICON STATIC_LoadIconA( WND *wndPtr, LPCSTR name ) * * Load the icon for an SS_ICON control. */ -static HICON STATIC_LoadIconW( WND *wndPtr, LPCWSTR name ) +static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name ) { - HICON hicon = LoadIconW( wndPtr->hInstance, name ); + HINSTANCE hInstance = GetWindowLongA( hwnd, GWL_HINSTANCE ); + HICON hicon = LoadIconW( hInstance, name ); if (!hicon) hicon = LoadIconW( 0, name ); return hicon; } @@ -158,9 +153,10 @@ static HICON STATIC_LoadIconW( WND *wndPtr, LPCWSTR name ) * * Load the bitmap for an SS_BITMAP control. */ -static HBITMAP STATIC_LoadBitmapA( WND *wndPtr, LPCSTR name ) +static HBITMAP STATIC_LoadBitmapA( HWND hwnd, LPCSTR name ) { - HBITMAP hbitmap = LoadBitmapA( wndPtr->hInstance, name ); + HINSTANCE hInstance = GetWindowLongA( hwnd, GWL_HINSTANCE ); + HBITMAP hbitmap = LoadBitmapA( hInstance, name ); if (!hbitmap) /* Try OEM icon (FIXME: is this right?) */ hbitmap = LoadBitmapA( 0, name ); return hbitmap; @@ -171,23 +167,24 @@ static HBITMAP STATIC_LoadBitmapA( WND *wndPtr, LPCSTR name ) * * Load the bitmap for an SS_BITMAP control. */ -static HBITMAP STATIC_LoadBitmapW( WND *wndPtr, LPCWSTR name ) +static HBITMAP STATIC_LoadBitmapW( HWND hwnd, LPCWSTR name ) { - HBITMAP hbitmap = LoadBitmapW( wndPtr->hInstance, name ); + HINSTANCE hInstance = GetWindowLongA( hwnd, GWL_HINSTANCE ); + HBITMAP hbitmap = LoadBitmapW( hInstance, name ); if (!hbitmap) /* Try OEM icon (FIXME: is this right?) */ hbitmap = LoadBitmapW( 0, name ); return hbitmap; } /*********************************************************************** - * StaticWndProc_locked + * StaticWndProc_common */ -static LRESULT StaticWndProc_locked( WND *wndPtr, UINT uMsg, WPARAM wParam, +static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode ) { LRESULT lResult = 0; - LONG style = wndPtr->dwStyle & SS_TYPEMASK; - STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra; + LONG full_style = GetWindowLongA( hwnd, GWL_STYLE ); + LONG style = full_style & SS_TYPEMASK; switch (uMsg) { @@ -195,8 +192,7 @@ static LRESULT StaticWndProc_locked( WND *wndPtr, UINT uMsg, WPARAM wParam, if (style < 0L || style > SS_TYPEMASK) { ERR("Unknown style 0x%02lx\n", style ); - lResult = -1L; - break; + return -1; } /* initialise colours */ color_windowframe = GetSysColor(COLOR_WINDOWFRAME); @@ -214,36 +210,36 @@ static LRESULT StaticWndProc_locked( WND *wndPtr, UINT uMsg, WPARAM wParam, * had already been loaded by the application the last thing we want to do is * GlobalFree16 the handle. */ - } else { - lResult = unicode ? DefWindowProcW(wndPtr->hwndSelf, uMsg, wParam, lParam) : - DefWindowProcA(wndPtr->hwndSelf, uMsg, wParam, lParam); - } - break; + break; + } + else return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) : + DefWindowProcA(hwnd, uMsg, wParam, lParam); case WM_PAINT: { PAINTSTRUCT ps; - BeginPaint(wndPtr->hwndSelf, &ps); + BeginPaint(hwnd, &ps); if (staticPaintFunc[style]) - (staticPaintFunc[style])( wndPtr, ps.hdc ); - EndPaint(wndPtr->hwndSelf, &ps); + (staticPaintFunc[style])( hwnd, ps.hdc, full_style ); + EndPaint(hwnd, &ps); } break; case WM_ENABLE: - InvalidateRect(wndPtr->hwndSelf, NULL, FALSE); + InvalidateRect(hwnd, NULL, FALSE); break; case WM_SYSCOLORCHANGE: color_windowframe = GetSysColor(COLOR_WINDOWFRAME); color_background = GetSysColor(COLOR_BACKGROUND); color_window = GetSysColor(COLOR_WINDOW); - InvalidateRect(wndPtr->hwndSelf, NULL, TRUE); + InvalidateRect(hwnd, NULL, TRUE); break; case WM_NCCREATE: - if ((TWEAK_WineLook > WIN31_LOOK) && (wndPtr->dwStyle & SS_SUNKEN)) - wndPtr->dwExStyle |= WS_EX_STATICEDGE; + if ((TWEAK_WineLook > WIN31_LOOK) && (full_style & SS_SUNKEN)) + SetWindowLongA( hwnd, GWL_EXSTYLE, + GetWindowLongA( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE ); if(unicode) lParam = (LPARAM)(((LPCREATESTRUCTW)lParam)->lpszName); @@ -255,98 +251,81 @@ static LRESULT StaticWndProc_locked( WND *wndPtr, UINT uMsg, WPARAM wParam, { HICON hIcon; if(unicode) - hIcon = STATIC_LoadIconW(wndPtr, (LPCWSTR)lParam); + hIcon = STATIC_LoadIconW(hwnd, (LPCWSTR)lParam); else - hIcon = STATIC_LoadIconA(wndPtr, (LPCSTR)lParam); + hIcon = STATIC_LoadIconA(hwnd, (LPCSTR)lParam); /* FIXME : should we also return the previous hIcon here ??? */ - STATIC_SetIcon(wndPtr, hIcon); + STATIC_SetIcon(hwnd, hIcon, style); } else if (style == SS_BITMAP) { HBITMAP hBitmap; if(unicode) - hBitmap = STATIC_LoadBitmapW(wndPtr, (LPCWSTR)lParam); + hBitmap = STATIC_LoadBitmapW(hwnd, (LPCWSTR)lParam); else - hBitmap = STATIC_LoadBitmapA(wndPtr, (LPCSTR)lParam); - STATIC_SetBitmap(wndPtr, hBitmap); + hBitmap = STATIC_LoadBitmapA(hwnd, (LPCSTR)lParam); + STATIC_SetBitmap(hwnd, hBitmap, style); } - else if(lParam && HIWORD(lParam)) + else if (HIWORD(lParam)) { if(unicode) - DEFWND_SetTextW(wndPtr, (LPCWSTR)lParam); + lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam ); else - DEFWND_SetTextA(wndPtr, (LPCSTR)lParam); + lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam ); } if(uMsg == WM_SETTEXT) - InvalidateRect(wndPtr->hwndSelf, NULL, FALSE); - lResult = 1; /* success. FIXME: check text length */ - break; + InvalidateRect(hwnd, NULL, FALSE); + return 1; /* success. FIXME: check text length */ case WM_SETFONT: - if (style == SS_ICON) - { - lResult = 0; - goto END; - } - if (style == SS_BITMAP) - { - lResult = 0; - goto END; - } - infoPtr->hFont = (HFONT16)wParam; + if ((style == SS_ICON) || (style == SS_BITMAP)) return 0; + SetWindowLongA( hwnd, HFONT_GWL_OFFSET, wParam ); if (LOWORD(lParam)) - InvalidateRect( wndPtr->hwndSelf, NULL, FALSE ); + InvalidateRect( hwnd, NULL, FALSE ); break; case WM_GETFONT: - lResult = infoPtr->hFont; - goto END; + return GetWindowLongA( hwnd, HFONT_GWL_OFFSET ); case WM_NCHITTEST: - if (wndPtr->dwStyle & SS_NOTIFY) - lResult = HTCLIENT; + if (full_style & SS_NOTIFY) + return HTCLIENT; else - lResult = HTTRANSPARENT; - goto END; + return HTTRANSPARENT; case WM_GETDLGCODE: - lResult = DLGC_STATIC; - goto END; + return DLGC_STATIC; case STM_GETIMAGE: case STM_GETICON16: case STM_GETICON: - lResult = infoPtr->hIcon; - goto END; + return GetWindowLongA( hwnd, HICON_GWL_OFFSET ); case STM_SETIMAGE: switch(wParam) { case IMAGE_BITMAP: - lResult = STATIC_SetBitmap( wndPtr, (HBITMAP)lParam ); + lResult = STATIC_SetBitmap( hwnd, (HBITMAP)lParam, style ); break; case IMAGE_ICON: - lResult = STATIC_SetIcon( wndPtr, (HICON16)lParam ); + lResult = STATIC_SetIcon( hwnd, (HICON)lParam, style ); break; default: FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam); break; } - InvalidateRect( wndPtr->hwndSelf, NULL, FALSE ); + InvalidateRect( hwnd, NULL, FALSE ); break; case STM_SETICON16: case STM_SETICON: - lResult = STATIC_SetIcon( wndPtr, (HICON16)wParam ); - InvalidateRect( wndPtr->hwndSelf, NULL, FALSE ); + lResult = STATIC_SetIcon( hwnd, (HICON)wParam, style ); + InvalidateRect( hwnd, NULL, FALSE ); break; default: - lResult = unicode ? DefWindowProcW(wndPtr->hwndSelf, uMsg, wParam, lParam) : - DefWindowProcA(wndPtr->hwndSelf, uMsg, wParam, lParam); - break; + return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) : + DefWindowProcA(hwnd, uMsg, wParam, lParam); } - -END: return lResult; } @@ -355,15 +334,8 @@ END: */ static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { - LRESULT lResult = 0; - WND *wndPtr = WIN_FindWndPtr(hWnd); - - if (wndPtr) - { - lResult = StaticWndProc_locked(wndPtr, uMsg, wParam, lParam, FALSE); - WIN_ReleaseWndPtr(wndPtr); - } - return lResult; + if (!IsWindow( hWnd )) return 0; + return StaticWndProc_common(hWnd, uMsg, wParam, lParam, FALSE); } /*********************************************************************** @@ -371,47 +343,39 @@ static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARA */ static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { - LRESULT lResult = 0; - WND *wndPtr = WIN_FindWndPtr(hWnd); - - if (wndPtr) - { - lResult = StaticWndProc_locked(wndPtr, uMsg, wParam, lParam, TRUE); - WIN_ReleaseWndPtr(wndPtr); - } - return lResult; + if (!IsWindow( hWnd )) return 0; + return StaticWndProc_common(hWnd, uMsg, wParam, lParam, TRUE); } -static void STATIC_PaintOwnerDrawfn( WND *wndPtr, HDC hdc ) +static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style ) { DRAWITEMSTRUCT dis; + LONG id = GetWindowLongA( hwnd, GWL_ID ); dis.CtlType = ODT_STATIC; - dis.CtlID = wndPtr->wIDmenu; + dis.CtlID = id; dis.itemID = 0; dis.itemAction = ODA_DRAWENTIRE; dis.itemState = 0; - dis.hwndItem = wndPtr->hwndSelf; + dis.hwndItem = hwnd; dis.hDC = hdc; dis.itemData = 0; - GetClientRect( wndPtr->hwndSelf, &dis.rcItem ); + GetClientRect( hwnd, &dis.rcItem ); - SendMessageW( GetParent(wndPtr->hwndSelf), WM_CTLCOLORSTATIC, - hdc, wndPtr->hwndSelf ); - SendMessageW( GetParent(wndPtr->hwndSelf), WM_DRAWITEM, - wndPtr->wIDmenu, (LPARAM)&dis ); + SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, hdc, hwnd ); + SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis ); } -static void STATIC_PaintTextfn( WND *wndPtr, HDC hdc ) +static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style ) { RECT rc; HBRUSH hBrush; + HFONT hFont; WORD wFormat; + INT len; + WCHAR *text; - LONG style = wndPtr->dwStyle; - STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra; - - GetClientRect( wndPtr->hwndSelf, &rc); + GetClientRect( hwnd, &rc); switch (style & SS_TYPEMASK) { @@ -442,31 +406,32 @@ static void STATIC_PaintTextfn( WND *wndPtr, HDC hdc ) if (style & SS_NOPREFIX) wFormat |= DT_NOPREFIX; - if (infoPtr->hFont) SelectObject( hdc, infoPtr->hFont ); + if ((hFont = GetWindowLongA( hwnd, HFONT_GWL_OFFSET ))) SelectObject( hdc, hFont ); if ((style & SS_NOPREFIX) || ((style & SS_TYPEMASK) != SS_SIMPLE)) { - hBrush = SendMessageW( GetParent(wndPtr->hwndSelf), WM_CTLCOLORSTATIC, - hdc, wndPtr->hwndSelf ); + hBrush = SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, hdc, hwnd ); if (!hBrush) /* did the app forget to call defwindowproc ? */ - hBrush = DefWindowProcW(GetParent(wndPtr->hwndSelf), WM_CTLCOLORSTATIC, - hdc, wndPtr->hwndSelf); - FillRect( hdc, &rc, hBrush ); + hBrush = DefWindowProcW(GetParent(hwnd), WM_CTLCOLORSTATIC, hdc, hwnd); + FillRect( hdc, &rc, hBrush ); } - if (!IsWindowEnabled(wndPtr->hwndSelf)) - SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); + if (!IsWindowEnabled(hwnd)) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); - if (wndPtr->text) DrawTextW( hdc, wndPtr->text, -1, &rc, wFormat ); + if (!(len = SendMessageW( hwnd, WM_GETTEXTLENGTH, 0, 0 ))) return; + if (!(text = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return; + SendMessageW( hwnd, WM_GETTEXT, len + 1, (LPARAM)text ); + DrawTextW( hdc, text, -1, &rc, wFormat ); + HeapFree( GetProcessHeap(), 0, text ); } -static void STATIC_PaintRectfn( WND *wndPtr, HDC hdc ) +static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style ) { RECT rc; HBRUSH hBrush; - GetClientRect( wndPtr->hwndSelf, &rc); + GetClientRect( hwnd, &rc); - switch (wndPtr->dwStyle & SS_TYPEMASK) + switch (style & SS_TYPEMASK) { case SS_BLACKRECT: hBrush = CreateSolidBrush(color_windowframe); @@ -499,42 +464,41 @@ static void STATIC_PaintRectfn( WND *wndPtr, HDC hdc ) } -static void STATIC_PaintIconfn( WND *wndPtr, HDC hdc ) +static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style ) { RECT rc; HBRUSH hbrush; - STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra; + HICON hIcon; - GetClientRect( wndPtr->hwndSelf, &rc ); - hbrush = SendMessageW( GetParent(wndPtr->hwndSelf), WM_CTLCOLORSTATIC, - hdc, wndPtr->hwndSelf ); + GetClientRect( hwnd, &rc ); + hbrush = SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, hdc, hwnd ); FillRect( hdc, &rc, hbrush ); - if (infoPtr->hIcon) DrawIcon( hdc, rc.left, rc.top, infoPtr->hIcon ); + if ((hIcon = GetWindowLongA( hwnd, HICON_GWL_OFFSET ))) + DrawIcon( hdc, rc.left, rc.top, hIcon ); } -static void STATIC_PaintBitmapfn(WND *wndPtr, HDC hdc ) +static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style ) { RECT rc; HBRUSH hbrush; - STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra; + HICON hIcon; HDC hMemDC; HBITMAP oldbitmap; - GetClientRect( wndPtr->hwndSelf, &rc ); - hbrush = SendMessageW( GetParent(wndPtr->hwndSelf), WM_CTLCOLORSTATIC, - hdc, wndPtr->hwndSelf ); + GetClientRect( hwnd, &rc ); + hbrush = SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, hdc, hwnd ); FillRect( hdc, &rc, hbrush ); - if (infoPtr->hIcon) { + if ((hIcon = GetWindowLongA( hwnd, HICON_GWL_OFFSET ))) + { BITMAP bm; SIZE sz; - if(GetObjectType(infoPtr->hIcon) != OBJ_BITMAP) - return; + if(GetObjectType(hIcon) != OBJ_BITMAP) return; if (!(hMemDC = CreateCompatibleDC( hdc ))) return; - GetObjectW(infoPtr->hIcon, sizeof(bm), &bm); - GetBitmapDimensionEx(infoPtr->hIcon, &sz); - oldbitmap = SelectObject(hMemDC, infoPtr->hIcon); + GetObjectW(hIcon, sizeof(bm), &bm); + GetBitmapDimensionEx(hIcon, &sz); + oldbitmap = SelectObject(hMemDC, hIcon); BitBlt(hdc, sz.cx, sz.cy, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); SelectObject(hMemDC, oldbitmap); @@ -543,15 +507,15 @@ static void STATIC_PaintBitmapfn(WND *wndPtr, HDC hdc ) } -static void STATIC_PaintEtchedfn( WND *wndPtr, HDC hdc ) +static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style ) { RECT rc; if (TWEAK_WineLook == WIN31_LOOK) return; - GetClientRect( wndPtr->hwndSelf, &rc ); - switch (wndPtr->dwStyle & SS_TYPEMASK) + GetClientRect( hwnd, &rc ); + switch (style & SS_TYPEMASK) { case SS_ETCHEDHORZ: DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM); @@ -564,4 +528,3 @@ static void STATIC_PaintEtchedfn( WND *wndPtr, HDC hdc ) break; } } - diff --git a/dlls/user/controls.h b/dlls/user/controls.h index 2a68315a324..d14fbb1d91b 100644 --- a/dlls/user/controls.h +++ b/dlls/user/controls.h @@ -10,8 +10,6 @@ #include "winuser.h" #include "winproc.h" -struct tagWND; - /* Built-in class names (see _Undocumented_Windows_ p.418) */ #define POPUPMENU_CLASS_ATOM MAKEINTATOM(32768) /* PopupMenu */ #define DESKTOP_CLASS_ATOM MAKEINTATOM(32769) /* Desktop */ @@ -36,7 +34,7 @@ struct builtin_class_descr extern BOOL DESKTOP_SetPattern( LPCSTR pattern ); /* icon title */ -extern HWND ICONTITLE_Create( struct tagWND * ); +extern HWND ICONTITLE_Create( HWND hwnd ); /* menu controls */ extern BOOL MENU_Init(void); @@ -44,8 +42,8 @@ extern BOOL MENU_IsMenuActive(void); extern HMENU MENU_GetSysMenu(HWND hWndOwner, HMENU hSysPopup); extern UINT MENU_GetMenuBarHeight( HWND hwnd, UINT menubarWidth, INT orgX, INT orgY ); -extern void MENU_TrackMouseMenuBar( struct tagWND *wnd, INT ht, POINT pt ); -extern void MENU_TrackKbdMenuBar( struct tagWND *wnd, UINT wParam, INT vkey ); +extern void MENU_TrackMouseMenuBar( HWND hwnd, INT ht, POINT pt ); +extern void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, INT vkey ); extern UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect, HWND hwnd, BOOL suppress_draw ); extern UINT MENU_FindSubMenu( HMENU *hmenu, HMENU hSubTarget ); @@ -53,7 +51,7 @@ extern UINT MENU_FindSubMenu( HMENU *hmenu, HMENU hSubTarget ); /* scrollbar */ extern void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar, BOOL arrows, BOOL interior ); extern void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt ); -extern INT SCROLL_SetNCSbState( struct tagWND *wndPtr, int vMin, int vMax, int vPos, +extern INT SCROLL_SetNCSbState( HWND hwnd, int vMin, int vMax, int vPos, int hMin, int hMax, int hPos ); /* combo box */ @@ -80,7 +78,7 @@ extern INT SCROLL_SetNCSbState( struct tagWND *wndPtr, int vMin, int vMax, int v /* combo state struct */ typedef struct { - struct tagWND *self; + HWND self; HWND owner; UINT dwStyle; HWND hWndEdit; @@ -98,10 +96,6 @@ typedef struct /* Note, that CBS_DROPDOWNLIST style is actually (CBS_SIMPLE | CBS_DROPDOWN) */ #define CB_GETTYPE( lphc ) ((lphc)->dwStyle & (CBS_DROPDOWNLIST)) -#define CB_DISABLED( lphc ) ((lphc)->self->dwStyle & WS_DISABLED) -#define CB_OWNERDRAWN( lphc ) ((lphc)->dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) -#define CB_HASSTRINGS( lphc ) ((lphc)->dwStyle & CBS_HASSTRINGS) -#define CB_HWND( lphc ) ((lphc)->self->hwndSelf) extern BOOL COMBO_FlipListbox( LPHEADCOMBO, BOOL, BOOL ); diff --git a/dlls/x11drv/winpos.c b/dlls/x11drv/winpos.c index daed7d0f092..a95ca807b3e 100644 --- a/dlls/x11drv/winpos.c +++ b/dlls/x11drv/winpos.c @@ -953,12 +953,12 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect ) break; case SW_MAXIMIZE: - WINPOS_GetMinMaxInfo( wndPtr, &size, &wpl.ptMaxPosition, NULL, NULL ); + WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL ); if( wndPtr->dwStyle & WS_MINIMIZE ) { wndPtr->dwStyle &= ~WS_MINIMIZE; - WINPOS_ShowIconTitle( wndPtr, FALSE ); + WINPOS_ShowIconTitle( hwnd, FALSE ); X11DRV_set_iconic_state( wndPtr ); } wndPtr->dwStyle |= WS_MAXIMIZE; @@ -970,13 +970,13 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect ) if( wndPtr->dwStyle & WS_MINIMIZE ) { wndPtr->dwStyle &= ~WS_MINIMIZE; - WINPOS_ShowIconTitle( wndPtr, FALSE ); + WINPOS_ShowIconTitle( hwnd, FALSE ); X11DRV_set_iconic_state( wndPtr ); if( wndPtr->flags & WIN_RESTORE_MAX) { /* Restore to maximized position */ - WINPOS_GetMinMaxInfo( wndPtr, &size, &wpl.ptMaxPosition, NULL, NULL); + WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL); wndPtr->dwStyle |= WS_MAXIMIZE; SetRect( rect, wpl.ptMaxPosition.x, wpl.ptMaxPosition.y, size.x, size.y ); break; @@ -1103,14 +1103,14 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd ) */ if (hwnd == GetActiveWindow()) - WINPOS_ActivateOtherWindow(wndPtr); + WINPOS_ActivateOtherWindow(hwnd); /* Revert focus to parent */ if (hwnd == GetFocus() || IsChild(hwnd, GetFocus())) SetFocus( GetParent(hwnd) ); } if (!IsWindow( hwnd )) goto END; - else if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_ShowIconTitle( wndPtr, TRUE ); + else if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_ShowIconTitle( hwnd, TRUE ); if (wndPtr->flags & WIN_NEED_SIZE) { @@ -1704,7 +1704,7 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam ) /* Get min/max info */ - WINPOS_GetMinMaxInfo( wndPtr, NULL, NULL, &minTrack, &maxTrack ); + WINPOS_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack ); sizingRect = wndPtr->rectWindow; origRect = sizingRect; if (wndPtr->dwStyle & WS_CHILD) @@ -1816,7 +1816,7 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam ) { hOldCursor = SetCursor(hDragCursor); ShowCursor( TRUE ); - WINPOS_ShowIconTitle( wndPtr, FALSE ); + WINPOS_ShowIconTitle( hwnd, FALSE ); } else if(!DragFullWindows) draw_moving_frame( hdc, &sizingRect, thickframe ); @@ -1934,7 +1934,7 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam ) SendMessageA( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y)); } - else WINPOS_ShowIconTitle( wndPtr, TRUE ); + else WINPOS_ShowIconTitle( hwnd, TRUE ); } END: diff --git a/include/nonclient.h b/include/nonclient.h index cc0dc9206ec..0b95d2aebb8 100644 --- a/include/nonclient.h +++ b/include/nonclient.h @@ -9,19 +9,17 @@ #include "windef.h" -struct tagWND; - -extern LONG NC_HandleNCPaint( HWND hwnd , HRGN clip); -extern LONG NC_HandleNCActivate( struct tagWND *pwnd, WPARAM wParam ); -extern LONG NC_HandleNCCalcSize( struct tagWND *pWnd, RECT *winRect ); -extern LONG NC_HandleNCHitTest( HWND hwnd, POINT pt ); -extern LONG NC_HandleNCLButtonDown( struct tagWND* pWnd, WPARAM wParam, LPARAM lParam ); -extern LONG NC_HandleNCLButtonDblClk( struct tagWND *pWnd, WPARAM wParam, LPARAM lParam); -extern LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt ); -extern LONG NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam ); -extern void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down ); +extern LONG NC_HandleNCPaint( HWND hwnd , HRGN clip); +extern LONG NC_HandleNCActivate( HWND hwnd, WPARAM wParam ); +extern LONG NC_HandleNCCalcSize( HWND hwnd, RECT *winRect ); +extern LONG NC_HandleNCHitTest( HWND hwnd, POINT pt ); +extern LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam ); +extern LONG NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam); +extern LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt ); +extern LONG NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam ); +extern void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down ); extern BOOL NC_DrawSysButton95( HWND hwnd, HDC hdc, BOOL down ); -extern BOOL NC_GetSysPopupPos( struct tagWND* wndPtr, RECT* rect ); +extern void NC_GetSysPopupPos( HWND hwnd, RECT* rect ); extern void NC_GetInsideRect( HWND hwnd, RECT *rect ); #endif /* __WINE_NONCLIENT_H */ diff --git a/include/winpos.h b/include/winpos.h index bf285bd94b0..25f8948aacb 100644 --- a/include/winpos.h +++ b/include/winpos.h @@ -12,8 +12,6 @@ #include "wingdi.h" #include "winuser.h" -struct tagWND; - /* undocumented SWP flags - from SDK 3.1 */ #define SWP_NOCLIENTSIZE 0x0800 #define SWP_NOCLIENTMOVE 0x1000 @@ -24,10 +22,9 @@ struct tagWND; struct tagWINDOWPOS16; extern BOOL WINPOS_RedrawIconTitle( HWND hWnd ); -extern BOOL WINPOS_ShowIconTitle( struct tagWND* pWnd, BOOL bShow ); -extern void WINPOS_GetMinMaxInfo( struct tagWND* pWnd, POINT *maxSize, - POINT *maxPos, POINT *minTrack, - POINT *maxTrack ); +extern BOOL WINPOS_ShowIconTitle( HWND hwnd, BOOL bShow ); +extern void WINPOS_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos, POINT *minTrack, + POINT *maxTrack ); extern BOOL WINPOS_SetActiveWindow( HWND hWnd, BOOL fMouse, BOOL fChangeFocus ); extern BOOL WINPOS_ChangeActiveWindow( HWND hwnd, BOOL mouseMsg ); @@ -35,11 +32,11 @@ extern LONG WINPOS_SendNCCalcSize(HWND hwnd, BOOL calcValidRect, RECT *newWindowRect, RECT *oldWindowRect, RECT *oldClientRect, WINDOWPOS *winpos, RECT *newClientRect ); -extern LONG WINPOS_HandleWindowPosChanging16(struct tagWND *wndPtr, struct tagWINDOWPOS16 *winpos); -extern LONG WINPOS_HandleWindowPosChanging(struct tagWND *wndPtr, WINDOWPOS *winpos); +extern LONG WINPOS_HandleWindowPosChanging16(HWND hwnd, struct tagWINDOWPOS16 *winpos); +extern LONG WINPOS_HandleWindowPosChanging(HWND hwnd, WINDOWPOS *winpos); extern HWND WINPOS_WindowFromPoint( HWND hwndScope, POINT pt, INT *hittest ); -extern void WINPOS_CheckInternalPos( struct tagWND* wndPtr ); -extern BOOL WINPOS_ActivateOtherWindow(struct tagWND* pWnd); +extern void WINPOS_CheckInternalPos( HWND hwnd ); +extern BOOL WINPOS_ActivateOtherWindow( HWND hwnd ); extern BOOL WINPOS_CreateInternalPosAtom(void); #endif /* __WINE_WINPOS_H */ diff --git a/include/x11drv.h b/include/x11drv.h index 3aaa14f5db8..4bbe78174d4 100644 --- a/include/x11drv.h +++ b/include/x11drv.h @@ -29,7 +29,6 @@ struct tagCURSORICONINFO; struct tagDC; struct tagDeviceCaps; struct tagPALETTEOBJ; -struct tagWND; struct tagWINDOWPOS; struct DIDEVICEOBJECTDATA; @@ -367,8 +366,6 @@ extern INT16 X11DRV_GetKeyNameText(LONG lParam, LPSTR lpBuffer, INT16 nSize); extern BOOL X11DRV_GetDIState(DWORD len, LPVOID ptr); extern BOOL X11DRV_GetDIData(BYTE *keystate, DWORD dodsize, struct DIDEVICEOBJECTDATA *dod, LPDWORD entries, DWORD flags); -extern void X11DRV_HandleEvent(struct tagWND *pWnd, XKeyEvent *event); - /* X11 mouse driver */ extern void X11DRV_InitMouse(LPMOUSE_EVENT_PROC); diff --git a/windows/defwnd.c b/windows/defwnd.c index cf329b470ce..11277947662 100644 --- a/windows/defwnd.c +++ b/windows/defwnd.c @@ -307,11 +307,11 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam, } case WM_NCLBUTTONDOWN: - return NC_HandleNCLButtonDown( wndPtr, wParam, lParam ); + return NC_HandleNCLButtonDown( wndPtr->hwndSelf, wParam, lParam ); case WM_LBUTTONDBLCLK: case WM_NCLBUTTONDBLCLK: - return NC_HandleNCLButtonDblClk( wndPtr, wParam, lParam ); + return NC_HandleNCLButtonDblClk( wndPtr->hwndSelf, wParam, lParam ); case WM_NCRBUTTONDOWN: /* in Windows, capture is taken when right-clicking on the caption bar */ @@ -376,7 +376,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam, break; case WM_NCACTIVATE: - return NC_HandleNCActivate( wndPtr, wParam ); + return NC_HandleNCActivate( wndPtr->hwndSelf, wParam ); case WM_NCDESTROY: if (wndPtr->text) HeapFree( GetProcessHeap(), 0, wndPtr->text ); @@ -674,13 +674,13 @@ LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, { RECT rect32; CONV_RECT16TO32( MapSL(lParam), &rect32 ); - result = NC_HandleNCCalcSize( wndPtr, &rect32 ); + result = NC_HandleNCCalcSize( hwnd, &rect32 ); CONV_RECT32TO16( &rect32, MapSL(lParam) ); } break; case WM_WINDOWPOSCHANGING: - result = WINPOS_HandleWindowPosChanging16( wndPtr, MapSL(lParam) ); + result = WINPOS_HandleWindowPosChanging16( hwnd, MapSL(lParam) ); break; case WM_WINDOWPOSCHANGED: @@ -751,12 +751,11 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, break; case WM_NCCALCSIZE: - result = NC_HandleNCCalcSize( wndPtr, (RECT *)lParam ); + result = NC_HandleNCCalcSize( hwnd, (RECT *)lParam ); break; case WM_WINDOWPOSCHANGING: - result = WINPOS_HandleWindowPosChanging( wndPtr, - (WINDOWPOS *)lParam ); + result = WINPOS_HandleWindowPosChanging( hwnd, (WINDOWPOS *)lParam ); break; case WM_WINDOWPOSCHANGED: @@ -875,12 +874,11 @@ LRESULT WINAPI DefWindowProcW( break; case WM_NCCALCSIZE: - result = NC_HandleNCCalcSize( wndPtr, (RECT *)lParam ); + result = NC_HandleNCCalcSize( hwnd, (RECT *)lParam ); break; case WM_WINDOWPOSCHANGING: - result = WINPOS_HandleWindowPosChanging( wndPtr, - (WINDOWPOS *)lParam ); + result = WINPOS_HandleWindowPosChanging( hwnd, (WINDOWPOS *)lParam ); break; case WM_WINDOWPOSCHANGED: diff --git a/windows/mdi.c b/windows/mdi.c index b81d18462d0..e0d1975b750 100644 --- a/windows/mdi.c +++ b/windows/mdi.c @@ -1309,7 +1309,7 @@ static LRESULT WINAPI MDIClientWndProc_locked( WND *wndPtr, UINT message, AppendMenuW( ci->hWindowMenu, MF_SEPARATOR, 0, NULL ); GetClientRect(frameWnd->hwndSelf, &rect); - NC_HandleNCCalcSize( wndPtr, &rect ); + NC_HandleNCCalcSize( wndPtr->hwndSelf, &rect ); wndPtr->rectClient = rect; TRACE("Client created - hwnd = %04x, idFirst = %u\n", @@ -2270,8 +2270,8 @@ void WINAPI CalcChildScroll( HWND hwnd, INT scroll ) SetScrollInfo(hwnd, scroll, &info, TRUE); break; case SB_BOTH: - SCROLL_SetNCSbState( Wnd, vmin, vmax, vpos, - hmin, hmax, hpos); + SCROLL_SetNCSbState( Wnd->hwndSelf, vmin, vmax, vpos, + hmin, hmax, hpos); } WIN_ReleaseWndPtr(Wnd); } diff --git a/windows/nonclient.c b/windows/nonclient.c index f52a5f7df6c..7c1242c81f6 100644 --- a/windows/nonclient.c +++ b/windows/nonclient.c @@ -495,41 +495,45 @@ BOOL WINAPI AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exSty * * Handle a WM_NCCALCSIZE message. Called from DefWindowProc(). */ -LONG NC_HandleNCCalcSize( WND *pWnd, RECT *winRect ) +LONG NC_HandleNCCalcSize( HWND hwnd, RECT *winRect ) { RECT tmpRect = { 0, 0, 0, 0 }; LONG result = 0; - UINT style = (UINT) GetClassLongA(pWnd->hwndSelf, GCL_STYLE); + LONG cls_style = GetClassLongA(hwnd, GCL_STYLE); + LONG style = GetWindowLongA( hwnd, GWL_STYLE ); + LONG exStyle = GetWindowLongA( hwnd, GWL_EXSTYLE ); - if (style & CS_VREDRAW) result |= WVR_VREDRAW; - if (style & CS_HREDRAW) result |= WVR_HREDRAW; + if (cls_style & CS_VREDRAW) result |= WVR_VREDRAW; + if (cls_style & CS_HREDRAW) result |= WVR_HREDRAW; - if( !( pWnd->dwStyle & WS_MINIMIZE ) ) { + if (!IsIconic(hwnd)) + { if (TWEAK_WineLook == WIN31_LOOK) - NC_AdjustRect( &tmpRect, pWnd->dwStyle, FALSE, pWnd->dwExStyle ); + NC_AdjustRect( &tmpRect, style, FALSE, exStyle ); else - NC_AdjustRectOuter95( &tmpRect, pWnd->dwStyle, FALSE, pWnd->dwExStyle ); + NC_AdjustRectOuter95( &tmpRect, style, FALSE, exStyle ); winRect->left -= tmpRect.left; winRect->top -= tmpRect.top; winRect->right -= tmpRect.right; winRect->bottom -= tmpRect.bottom; - if (HAS_MENU(pWnd)) { + if (!(style & WS_CHILD) && GetMenu(hwnd)) + { TRACE("Calling GetMenuBarHeight with HWND 0x%x, width %d, " - "at (%d, %d).\n", pWnd->hwndSelf, + "at (%d, %d).\n", hwnd, winRect->right - winRect->left, -tmpRect.left, -tmpRect.top ); winRect->top += - MENU_GetMenuBarHeight( pWnd->hwndSelf, + MENU_GetMenuBarHeight( hwnd, winRect->right - winRect->left, -tmpRect.left, -tmpRect.top ) + 1; } if (TWEAK_WineLook > WIN31_LOOK) { SetRect(&tmpRect, 0, 0, 0, 0); - NC_AdjustRectInner95 (&tmpRect, pWnd->dwStyle, pWnd->dwExStyle); + NC_AdjustRectInner95 (&tmpRect, style, exStyle); winRect->left -= tmpRect.left; winRect->top -= tmpRect.top; winRect->right -= tmpRect.right; @@ -1693,23 +1697,26 @@ LONG NC_HandleNCPaint( HWND hwnd , HRGN clip) * * Handle a WM_NCACTIVATE message. Called from DefWindowProc(). */ -LONG NC_HandleNCActivate( WND *wndPtr, WPARAM wParam ) +LONG NC_HandleNCActivate( HWND hwnd, WPARAM wParam ) { + WND* wndPtr = WIN_FindWndPtr( hwnd ); + /* Lotus Notes draws menu descriptions in the caption of its main * window. When it wants to restore original "system" view, it just * sends WM_NCACTIVATE message to itself. Any optimizations here in * attempt to minimize redrawings lead to a not restored caption. */ + if (wndPtr) { if (wParam) wndPtr->flags |= WIN_NCACTIVATED; else wndPtr->flags &= ~WIN_NCACTIVATED; - if( wndPtr->dwStyle & WS_MINIMIZE ) - WINPOS_RedrawIconTitle( wndPtr->hwndSelf ); + if (IsIconic(hwnd)) WINPOS_RedrawIconTitle( hwnd ); else if (TWEAK_WineLook == WIN31_LOOK) NC_DoNCPaint( wndPtr, (HRGN)1, FALSE ); else NC_DoNCPaint95( wndPtr, (HRGN)1, FALSE ); + WIN_ReleaseWndPtr(wndPtr); } return TRUE; } @@ -1769,30 +1776,28 @@ LONG NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam ) /*********************************************************************** * NC_GetSysPopupPos */ -BOOL NC_GetSysPopupPos( WND* wndPtr, RECT* rect ) +void NC_GetSysPopupPos( HWND hwnd, RECT* rect ) { - if( wndPtr->hSysMenu ) - { - if( wndPtr->dwStyle & WS_MINIMIZE ) - GetWindowRect( wndPtr->hwndSelf, rect ); - else - { - NC_GetInsideRect( wndPtr->hwndSelf, rect ); - OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top); - if (wndPtr->dwStyle & WS_CHILD) - ClientToScreen( wndPtr->parent->hwndSelf, (POINT *)rect ); - if (TWEAK_WineLook == WIN31_LOOK) { + if (IsIconic(hwnd)) GetWindowRect( hwnd, rect ); + else + { + WND *wndPtr = WIN_FindWndPtr( hwnd ); + if (!wndPtr) return; + + NC_GetInsideRect( hwnd, rect ); + OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top); + if (wndPtr->dwStyle & WS_CHILD) + ClientToScreen( wndPtr->parent->hwndSelf, (POINT *)rect ); + if (TWEAK_WineLook == WIN31_LOOK) { rect->right = rect->left + GetSystemMetrics(SM_CXSIZE); rect->bottom = rect->top + GetSystemMetrics(SM_CYSIZE); - } - else { + } + else { rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1; rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1; - } - } - return TRUE; - } - return FALSE; + } + WIN_ReleaseWndPtr( wndPtr ); + } } /*********************************************************************** @@ -2052,23 +2057,25 @@ END: * * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc(). */ -LONG NC_HandleNCLButtonDown( WND* pWnd, WPARAM wParam, LPARAM lParam ) +LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam ) { - HWND hwnd = pWnd->hwndSelf; + LONG style = GetWindowLongA( hwnd, GWL_STYLE ); switch(wParam) /* Hit test */ { case HTCAPTION: - hwnd = WIN_GetTopParent(hwnd); + { + HWND top = WIN_GetTopParent(hwnd); - if( WINPOS_SetActiveWindow(hwnd, TRUE, TRUE) || (GetActiveWindow() == hwnd) ) - SendMessageW( pWnd->hwndSelf, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam ); - break; + if( WINPOS_SetActiveWindow(top, TRUE, TRUE) || (GetActiveWindow() == top) ) + SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam ); + break; + } case HTSYSMENU: - if( pWnd->dwStyle & WS_SYSMENU ) + if( style & WS_SYSMENU ) { - if( !(pWnd->dwStyle & WS_MINIMIZE) ) + if( !(style & WS_MINIMIZE) ) { HDC hDC = GetWindowDC(hwnd); if (TWEAK_WineLook == WIN31_LOOK) @@ -2130,15 +2137,15 @@ LONG NC_HandleNCLButtonDown( WND* pWnd, WPARAM wParam, LPARAM lParam ) * * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc(). */ -LONG NC_HandleNCLButtonDblClk( WND *pWnd, WPARAM wParam, LPARAM lParam ) +LONG NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam ) { /* * if this is an icon, send a restore since we are handling * a double click */ - if (pWnd->dwStyle & WS_MINIMIZE) + if (IsIconic(hwnd)) { - SendMessageW( pWnd->hwndSelf, WM_SYSCOMMAND, SC_RESTORE, lParam ); + SendMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, lParam ); return 0; } @@ -2146,22 +2153,22 @@ LONG NC_HandleNCLButtonDblClk( WND *pWnd, WPARAM wParam, LPARAM lParam ) { case HTCAPTION: /* stop processing if WS_MAXIMIZEBOX is missing */ - if (pWnd->dwStyle & WS_MAXIMIZEBOX) - SendMessageW( pWnd->hwndSelf, WM_SYSCOMMAND, - (pWnd->dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE, lParam ); + if (GetWindowLongA( hwnd, GWL_STYLE ) & WS_MAXIMIZEBOX) + SendMessageW( hwnd, WM_SYSCOMMAND, + IsZoomed(hwnd) ? SC_RESTORE : SC_MAXIMIZE, lParam ); break; case HTSYSMENU: - if (!(GetClassWord(pWnd->hwndSelf, GCW_STYLE) & CS_NOCLOSE)) - SendMessageW( pWnd->hwndSelf, WM_SYSCOMMAND, SC_CLOSE, lParam ); + if (!(GetClassWord(hwnd, GCW_STYLE) & CS_NOCLOSE)) + SendMessageW( hwnd, WM_SYSCOMMAND, SC_CLOSE, lParam ); break; case HTHSCROLL: - SendMessageW( pWnd->hwndSelf, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam ); + SendMessageW( hwnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam ); break; case HTVSCROLL: - SendMessageW( pWnd->hwndSelf, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam ); + SendMessageW( hwnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam ); break; } return 0; @@ -2219,11 +2226,11 @@ LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt ) break; case SC_MOUSEMENU: - MENU_TrackMouseMenuBar( wndPtr, wParam & 0x000F, pt ); + MENU_TrackMouseMenuBar( hwnd, wParam & 0x000F, pt ); break; case SC_KEYMENU: - MENU_TrackKbdMenuBar( wndPtr , wParam , pt.x ); + MENU_TrackKbdMenuBar( hwnd, wParam , pt.x ); break; case SC_TASKLIST: diff --git a/windows/win.c b/windows/win.c index 4c021f110c4..419397d27e9 100644 --- a/windows/win.c +++ b/windows/win.c @@ -438,7 +438,7 @@ static WND* WIN_DestroyWindow( WND* wndPtr ) /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */ - WINPOS_CheckInternalPos( wndPtr ); + WINPOS_CheckInternalPos( hwnd ); if( hwnd == GetCapture()) ReleaseCapture(); /* free resources associated with the window */ @@ -844,7 +844,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom, if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD))) { - WINPOS_GetMinMaxInfo( wndPtr, &maxSize, &maxPos, &minTrack, &maxTrack); + WINPOS_GetMinMaxInfo( hwnd, &maxSize, &maxPos, &minTrack, &maxTrack); if (maxSize.x < cs->cx) cs->cx = maxSize.x; if (maxSize.y < cs->cy) cs->cy = maxSize.y; if (cs->cx < minTrack.x ) cs->cx = minTrack.x; @@ -1321,7 +1321,7 @@ BOOL WINAPI DestroyWindow( HWND hwnd ) else break; } - WINPOS_ActivateOtherWindow(wndPtr); + WINPOS_ActivateOtherWindow(wndPtr->hwndSelf); if( wndPtr->owner && wndPtr->owner->hwndLastActive == wndPtr->hwndSelf ) diff --git a/windows/winpos.c b/windows/winpos.c index 7eb9276e4dd..d1ece6f13df 100644 --- a/windows/winpos.c +++ b/windows/winpos.c @@ -79,11 +79,11 @@ BOOL WINPOS_CreateInternalPosAtom() * * Called when a window is destroyed. */ -void WINPOS_CheckInternalPos( WND* wndPtr ) +void WINPOS_CheckInternalPos( HWND hwnd ) { LPINTERNALPOS lpPos; MESSAGEQUEUE *pMsgQ = 0; - HWND hwnd = wndPtr->hwndSelf; + WND *wndPtr = WIN_FindWndPtr( hwnd ); lpPos = (LPINTERNALPOS) GetPropA( hwnd, atomInternalPos ); @@ -92,6 +92,7 @@ void WINPOS_CheckInternalPos( WND* wndPtr ) if ( !pMsgQ ) { WARN("\tMessage queue not found. Exiting!\n" ); + WIN_ReleaseWndPtr( wndPtr ); return; } @@ -111,6 +112,7 @@ void WINPOS_CheckInternalPos( WND* wndPtr ) } QUEUE_Unlock( pMsgQ ); + WIN_ReleaseWndPtr( wndPtr ); return; } @@ -141,16 +143,13 @@ UINT WINAPI ArrangeIconicWindows( HWND parent ) { if( IsIconic( hwndChild ) ) { - WND *wndPtr = WIN_FindWndPtr(hwndChild); - - WINPOS_ShowIconTitle( wndPtr, FALSE ); - + WINPOS_ShowIconTitle( hwndChild, FALSE ); + SetWindowPos( hwndChild, 0, x + (xspacing - GetSystemMetrics(SM_CXICON)) / 2, y - yspacing - GetSystemMetrics(SM_CYICON)/2, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); if( IsWindow(hwndChild) ) - WINPOS_ShowIconTitle(wndPtr , TRUE ); - WIN_ReleaseWndPtr(wndPtr); + WINPOS_ShowIconTitle(hwndChild , TRUE ); if (x <= rectParent.right - xspacing) x += xspacing; else @@ -1050,32 +1049,28 @@ BOOL WINPOS_RedrawIconTitle( HWND hWnd ) /*********************************************************************** * WINPOS_ShowIconTitle */ -BOOL WINPOS_ShowIconTitle( WND* pWnd, BOOL bShow ) +BOOL WINPOS_ShowIconTitle( HWND hwnd, BOOL bShow ) { - LPINTERNALPOS lpPos = (LPINTERNALPOS)GetPropA( pWnd->hwndSelf, atomInternalPos ); + LPINTERNALPOS lpPos = (LPINTERNALPOS)GetPropA( hwnd, atomInternalPos ); - if( lpPos && !(pWnd->dwExStyle & WS_EX_MANAGED)) + if( lpPos && !(GetWindowLongA( hwnd, GWL_EXSTYLE) & WS_EX_MANAGED)) { - HWND16 hWnd = lpPos->hwndIconTitle; + HWND title = lpPos->hwndIconTitle; - TRACE("0x%04x %i\n", pWnd->hwndSelf, (bShow != 0) ); + TRACE("0x%04x %i\n", hwnd, (bShow != 0) ); - if( !hWnd ) - lpPos->hwndIconTitle = hWnd = ICONTITLE_Create( pWnd ); + if( !title ) + lpPos->hwndIconTitle = title = ICONTITLE_Create( hwnd ); if( bShow ) { - if( ( pWnd = WIN_FindWndPtr(hWnd) ) != NULL) - { - if( !(pWnd->dwStyle & WS_VISIBLE) ) - { - SendMessageA( hWnd, WM_SHOWWINDOW, TRUE, 0 ); - SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | - SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW ); - } - WIN_ReleaseWndPtr(pWnd); - } + if (!IsWindowVisible(title)) + { + SendMessageA( title, WM_SHOWWINDOW, TRUE, 0 ); + SetWindowPos( title, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | + SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW ); + } } - else ShowWindow( hWnd, SW_HIDE ); + else ShowWindow( title, SW_HIDE ); } return FALSE; } @@ -1085,12 +1080,14 @@ BOOL WINPOS_ShowIconTitle( WND* pWnd, BOOL bShow ) * * Get the minimized and maximized information for a window. */ -void WINPOS_GetMinMaxInfo( WND *wndPtr, POINT *maxSize, POINT *maxPos, +void WINPOS_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack ) { LPINTERNALPOS lpPos; MINMAXINFO MinMax; INT xinc, yinc; + LONG style = GetWindowLongA( hwnd, GWL_STYLE ); + LONG exstyle = GetWindowLongA( hwnd, GWL_EXSTYLE ); /* Compute default values */ @@ -1101,7 +1098,7 @@ void WINPOS_GetMinMaxInfo( WND *wndPtr, POINT *maxSize, POINT *maxPos, MinMax.ptMaxTrackSize.x = GetSystemMetrics(SM_CXSCREEN); MinMax.ptMaxTrackSize.y = GetSystemMetrics(SM_CYSCREEN); - if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle )) + if (HAS_DLGFRAME( style, exstyle )) { xinc = GetSystemMetrics(SM_CXDLGFRAME); yinc = GetSystemMetrics(SM_CYDLGFRAME); @@ -1109,12 +1106,12 @@ void WINPOS_GetMinMaxInfo( WND *wndPtr, POINT *maxSize, POINT *maxPos, else { xinc = yinc = 0; - if (HAS_THICKFRAME(wndPtr->dwStyle)) + if (HAS_THICKFRAME(style)) { xinc += GetSystemMetrics(SM_CXFRAME); yinc += GetSystemMetrics(SM_CYFRAME); } - if (wndPtr->dwStyle & WS_BORDER) + if (style & WS_BORDER) { xinc += GetSystemMetrics(SM_CXBORDER); yinc += GetSystemMetrics(SM_CYBORDER); @@ -1123,7 +1120,7 @@ void WINPOS_GetMinMaxInfo( WND *wndPtr, POINT *maxSize, POINT *maxPos, MinMax.ptMaxSize.x += 2 * xinc; MinMax.ptMaxSize.y += 2 * yinc; - lpPos = (LPINTERNALPOS)GetPropA( wndPtr->hwndSelf, atomInternalPos ); + lpPos = (LPINTERNALPOS)GetPropA( hwnd, atomInternalPos ); if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) ) CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition ); else @@ -1132,7 +1129,7 @@ void WINPOS_GetMinMaxInfo( WND *wndPtr, POINT *maxSize, POINT *maxPos, MinMax.ptMaxPosition.y = -yinc; } - SendMessageA( wndPtr->hwndSelf, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax ); + SendMessageA( hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax ); /* Some sanity checks */ @@ -1292,7 +1289,7 @@ static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT16 *wndpl, if( pWnd->dwStyle & WS_MINIMIZE ) { - WINPOS_ShowIconTitle( pWnd, FALSE ); + WINPOS_ShowIconTitle( pWnd->hwndSelf, FALSE ); if( wndpl->flags & WPF_SETMINPOSITION && !EMPTYPOINT(lpPos->ptIconPos)) SetWindowPos( hwnd, 0, lpPos->ptIconPos.x, lpPos->ptIconPos.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); @@ -1312,7 +1309,7 @@ static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT16 *wndpl, ShowWindow( hwnd, wndpl->showCmd ); if( IsWindow(hwnd) && pWnd->dwStyle & WS_MINIMIZE ) { - if( pWnd->dwStyle & WS_VISIBLE ) WINPOS_ShowIconTitle( pWnd, TRUE ); + if( pWnd->dwStyle & WS_VISIBLE ) WINPOS_ShowIconTitle( pWnd->hwndSelf, TRUE ); /* SDK: ...valid only the next time... */ if( wndpl->flags & WPF_RESTORETOMAXIMIZED ) pWnd->flags |= WIN_RESTORE_MAX; @@ -1680,11 +1677,11 @@ CLEANUP_END: * * Activates window other than pWnd. */ -BOOL WINPOS_ActivateOtherWindow(WND* pWnd) +BOOL WINPOS_ActivateOtherWindow(HWND hwnd) { - BOOL bRet = 0; - WND* pWndTo = NULL; - HWND hwndActive = 0; + BOOL bRet = 0; + WND *pWnd, *pWndTo = NULL; + HWND hwndActive = 0; /* Get current active window from the active queue */ if ( hActiveQueue ) @@ -1697,37 +1694,42 @@ BOOL WINPOS_ActivateOtherWindow(WND* pWnd) } } - if( pWnd->hwndSelf == hwndPrevActive ) - hwndPrevActive = 0; + if( hwnd == hwndPrevActive ) + hwndPrevActive = 0; - if( hwndActive != pWnd->hwndSelf && - ( hwndActive || QUEUE_IsExitingQueue(pWnd->hmemTaskQ)) ) - return 0; + pWnd = WIN_FindWndPtr( hwnd ); + if( hwndActive != hwnd && + ( hwndActive || QUEUE_IsExitingQueue(pWnd->hmemTaskQ)) ) + { + WIN_ReleaseWndPtr( pWnd ); + return 0; + } - if( !(pWnd->dwStyle & WS_POPUP) || !(pWnd->owner) || - !WINPOS_CanActivate((pWndTo = WIN_GetTopParentPtr(pWnd->owner))) ) - { - WND* pWndPtr = WIN_GetTopParentPtr(pWnd); + if( !(pWnd->dwStyle & WS_POPUP) || !(pWnd->owner) || + !WINPOS_CanActivate((pWndTo = WIN_GetTopParentPtr(pWnd->owner))) ) + { + WND* pWndPtr = WIN_GetTopParentPtr(pWnd); - WIN_ReleaseWndPtr(pWndTo); - pWndTo = WIN_FindWndPtr(hwndPrevActive); + WIN_ReleaseWndPtr(pWndTo); + pWndTo = WIN_FindWndPtr(hwndPrevActive); - while( !WINPOS_CanActivate(pWndTo) ) - { - /* by now owned windows should've been taken care of */ - WIN_UpdateWndPtr(&pWndTo,pWndPtr->next); - WIN_UpdateWndPtr(&pWndPtr,pWndTo); - if( !pWndTo ) break; - } - WIN_ReleaseWndPtr(pWndPtr); - } + while( !WINPOS_CanActivate(pWndTo) ) + { + /* by now owned windows should've been taken care of */ + WIN_UpdateWndPtr(&pWndTo,pWndPtr->next); + WIN_UpdateWndPtr(&pWndPtr,pWndTo); + if( !pWndTo ) break; + } + WIN_ReleaseWndPtr(pWndPtr); + } + WIN_ReleaseWndPtr( pWnd ); - bRet = WINPOS_SetActiveWindow( pWndTo ? pWndTo->hwndSelf : 0, FALSE, TRUE ); + bRet = WINPOS_SetActiveWindow( pWndTo ? pWndTo->hwndSelf : 0, FALSE, TRUE ); - if( pWndTo ) WIN_ReleaseWndPtr(pWndTo); + if( pWndTo ) WIN_ReleaseWndPtr(pWndTo); - hwndPrevActive = 0; - return bRet; + hwndPrevActive = 0; + return bRet; } /******************************************************************* @@ -1827,17 +1829,18 @@ LONG WINPOS_SendNCCalcSize( HWND hwnd, BOOL calcValidRect, * * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc(). */ -LONG WINPOS_HandleWindowPosChanging16( WND *wndPtr, WINDOWPOS16 *winpos ) +LONG WINPOS_HandleWindowPosChanging16( HWND hwnd, WINDOWPOS16 *winpos ) { POINT maxSize, minTrack; + LONG style = GetWindowLongA( hwnd, GWL_STYLE ); + if (winpos->flags & SWP_NOSIZE) return 0; - if ((wndPtr->dwStyle & WS_THICKFRAME) || - ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0)) + if ((style & WS_THICKFRAME) || ((style & (WS_POPUP | WS_CHILD)) == 0)) { - WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, &minTrack, NULL ); + WINPOS_GetMinMaxInfo( hwnd, &maxSize, NULL, &minTrack, NULL ); if (maxSize.x < winpos->cx) winpos->cx = maxSize.x; if (maxSize.y < winpos->cy) winpos->cy = maxSize.y; - if (!(wndPtr->dwStyle & WS_MINIMIZE)) + if (!(style & WS_MINIMIZE)) { if (winpos->cx < minTrack.x ) winpos->cx = minTrack.x; if (winpos->cy < minTrack.y ) winpos->cy = minTrack.y; @@ -1852,17 +1855,18 @@ LONG WINPOS_HandleWindowPosChanging16( WND *wndPtr, WINDOWPOS16 *winpos ) * * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc(). */ -LONG WINPOS_HandleWindowPosChanging( WND *wndPtr, WINDOWPOS *winpos ) +LONG WINPOS_HandleWindowPosChanging( HWND hwnd, WINDOWPOS *winpos ) { POINT maxSize, minTrack; + LONG style = GetWindowLongA( hwnd, GWL_STYLE ); + if (winpos->flags & SWP_NOSIZE) return 0; - if ((wndPtr->dwStyle & WS_THICKFRAME) || - ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0)) + if ((style & WS_THICKFRAME) || ((style & (WS_POPUP | WS_CHILD)) == 0)) { - WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, &minTrack, NULL ); + WINPOS_GetMinMaxInfo( hwnd, &maxSize, NULL, &minTrack, NULL ); winpos->cx = min( winpos->cx, maxSize.x ); winpos->cy = min( winpos->cy, maxSize.y ); - if (!(wndPtr->dwStyle & WS_MINIMIZE)) + if (!(style & WS_MINIMIZE)) { if (winpos->cx < minTrack.x ) winpos->cx = minTrack.x; if (winpos->cy < minTrack.y ) winpos->cy = minTrack.y;