Commit de42428f authored by Alexandre Julliard's avatar Alexandre Julliard

Removed a number of direct accesses to the WND structure, replacing

them by API calls.
parent e5b5af9d
......@@ -6,8 +6,8 @@
*/
#include <string.h>
#include <stdlib.h> /* for abs() */
#include "win.h"
#include <stdlib.h>
#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,37 +433,12 @@ 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);
}
......@@ -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;
TRACE("[%04x]: ownerdraw op %04x\n", CB_HWND(lphc), msg );
#define lpIS ((LPDELETEITEMSTRUCT)lParam)
HWND hWnd = lphc->self;
UINT id = GetWindowLongA( hWnd, GWL_ID );
/* two first items are the same in all 4 structs */
lpIS->CtlType = ODT_COMBOBOX;
lpIS->CtlID = lphc->self->wIDmenu;
TRACE("[%04x]: ownerdraw op %04x\n", lphc->self, msg );
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 );
}
......@@ -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;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -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 )
{
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 )
int length = GetWindowTextW( owner, str, sizeof(str)/sizeof(WCHAR) );
while (length && str[length - 1] == ' ') /* remove trailing spaces */
str[--length] = 0;
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;
......
......@@ -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 );
}
......@@ -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)
......@@ -297,6 +297,23 @@ POPUPMENU *MENU_GetMenu(HMENU hMenu)
}
/***********************************************************************
* 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
*
* Return the default system menu.
......@@ -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 )) )
{
UINT width, height;
MENU_PopupMenuCalcSize( menu, hwndOwner );
MENU_PopupMenuCalcSize( menu, hwndOwner );
/* adjust popup menu pos so that it fits within the desktop */
/* adjust popup menu pos so that it fits within the desktop */
width = menu->Width + GetSystemMetrics(SM_CXBORDER);
height = menu->Height + GetSystemMetrics(SM_CYBORDER);
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( 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( TWEAK_WineLook == WIN31_LOOK )
{
width += POPUP_XSHADE * GetSystemMetrics(SM_CXBORDER); /* add space for shading */
height += POPUP_YSHADE * GetSystemMetrics(SM_CYBORDER);
}
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;
/* 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;
if( TWEAK_WineLook == WIN31_LOOK )
{
width += POPUP_XSHADE * GetSystemMetrics(SM_CXBORDER); /* add space for shading */
height += POPUP_YSHADE * GetSystemMetrics(SM_CYBORDER);
}
/* Display the window */
/* 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;
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;
}
return FALSE;
/* 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 ))
{
MENU_InitTracking( wndPtr->hwndSelf, hTrackMenu, FALSE, wFlags );
if (!IsMenu( hTrackMenu )) return;
MENU_InitTracking( hwnd, hTrackMenu, FALSE, wFlags );
if( vkey && vkey != VK_SPACE )
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 );
if( hTrackMenu )
{
MENU_SelectItem( hwnd, hTrackMenu, uItem, TRUE, 0 );
MENU_TrackMenu( hTrackMenu, wFlags, 0, 0, wndPtr->hwndSelf, NULL );
}
if( uItem == NO_SELECTED_ITEM )
MENU_MoveSelection( hwnd, hTrackMenu, ITEM_NEXT );
else if( vkey )
PostMessageA( hwnd, WM_KEYDOWN, VK_DOWN, 0L );
MENU_ExitTracking (wndPtr->hwndSelf);
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 (GetCapture() == hWnd) ReleaseCapture();
wndPtr->wIDmenu = (UINT)hMenu;
if (hMenu != 0)
{
LPPOPUPMENU lpmenu;
if (hMenu != 0)
{
LPPOPUPMENU lpmenu;
if (!(lpmenu = MENU_GetMenu(hMenu)))
goto exit;
if (!(lpmenu = MENU_GetMenu(hMenu))) return FALSE;
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 */
......
......@@ -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,24 +174,12 @@ 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
*
* Compute the scroll bar rectangle, in drawing coordinates (i.e. client
......@@ -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;
}
......
......@@ -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;
}
}
......@@ -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 );
......
......@@ -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:
......
......@@ -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 */
......@@ -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 */
......@@ -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);
......
......@@ -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:
......
......@@ -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);
}
......
......@@ -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:
......
......@@ -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 )
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment