Small additions, not yet finished

svn path=/trunk/; revision=618
This commit is contained in:
Boudewijn Dekker 1999-08-20 09:37:25 +00:00
parent 90129544e0
commit 007128eb66
37 changed files with 13556 additions and 1776 deletions

View file

@ -0,0 +1,598 @@
/* File: button.c -- Button type widgets
*
* Copyright (C) 1993 Johannes Ruscheinski
* Copyright (C) 1993 David Metcalfe
* Copyright (C) 1994 Alexandre Julliard
*/
#include <windows.h>
#include <user32/win.h>
#include <user32/button.h>
#include <user32/paint.h>
#include <user32/nc.h>
#include <user32/syscolor.h>
#include <user32/defwnd.h>
static void PB_Paint( WND *wndPtr, HDC hDC, WORD action );
static void PB_PaintGrayOnGray(HDC hDC,HFONT hFont,RECT *rc,char *text);
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 );
#define MAX_BTN_TYPE 12
static const WORD maxCheckState[MAX_BTN_TYPE] =
{
BUTTON_UNCHECKED, /* BS_PUSHBUTTON */
BUTTON_UNCHECKED, /* BS_DEFPUSHBUTTON */
BUTTON_CHECKED, /* BS_CHECKBOX */
BUTTON_CHECKED, /* BS_AUTOCHECKBOX */
BUTTON_CHECKED, /* BS_RADIOBUTTON */
BUTTON_3STATE, /* BS_3STATE */
BUTTON_3STATE, /* BS_AUTO3STATE */
BUTTON_UNCHECKED, /* BS_GROUPBOX */
BUTTON_UNCHECKED, /* BS_USERBUTTON */
BUTTON_CHECKED, /* BS_AUTORADIOBUTTON */
BUTTON_UNCHECKED, /* Not defined */
BUTTON_UNCHECKED /* BS_OWNERDRAW */
};
typedef void (*pfPaint)( WND *wndPtr, HDC hdc, WORD action );
static const pfPaint btnPaintFunc[MAX_BTN_TYPE] =
{
PB_Paint, /* BS_PUSHBUTTON */
PB_Paint, /* BS_DEFPUSHBUTTON */
CB_Paint, /* BS_CHECKBOX */
CB_Paint, /* BS_AUTOCHECKBOX */
CB_Paint, /* BS_RADIOBUTTON */
CB_Paint, /* BS_3STATE */
CB_Paint, /* BS_AUTO3STATE */
GB_Paint, /* BS_GROUPBOX */
UB_Paint, /* BS_USERBUTTON */
CB_Paint, /* BS_AUTORADIOBUTTON */
NULL, /* Not defined */
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) \
SendMessageA( GetParent((wndPtr)->hwndSelf), WM_CTLCOLORBTN, \
(WPARAM)(hdc), (LPARAM)(wndPtr)->hwndSelf )
static HBITMAP hbitmapCheckBoxes = 0;
static WORD checkBoxWidth = 0, checkBoxHeight = 0;
/***********************************************************************
* ButtonWndProc
*/
LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam )
{
RECT rect;
POINT pt = { LOWORD(lParam), HIWORD(lParam) };
WND *wndPtr = WIN_FindWndPtr(hWnd);
BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
LONG style = wndPtr->dwStyle & 0x0f;
switch (uMsg)
{
case WM_GETDLGCODE:
switch(style)
{
case BS_PUSHBUTTON: return DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON;
case BS_DEFPUSHBUTTON: return DLGC_BUTTON | DLGC_DEFPUSHBUTTON;
case BS_RADIOBUTTON:
case BS_AUTORADIOBUTTON: return DLGC_BUTTON | DLGC_RADIOBUTTON;
default: return DLGC_BUTTON;
}
case WM_ENABLE:
PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
break;
case WM_CREATE:
if (!hbitmapCheckBoxes)
{
BITMAP bmp;
hbitmapCheckBoxes = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_CHECKBOXES));
GetObjectA( hbitmapCheckBoxes, sizeof(bmp), &bmp );
checkBoxWidth = bmp.bmWidth / 4;
checkBoxHeight = bmp.bmHeight / 3;
}
if (style < 0L || style >= MAX_BTN_TYPE) return -1; /* abort */
infoPtr->state = BUTTON_UNCHECKED;
infoPtr->hFont = 0;
return 0;
case WM_ERASEBKGND:
return 1;
case WM_PAINT:
if (btnPaintFunc[style])
{
PAINTSTRUCT ps;
HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
SetBkMode( hdc, OPAQUE );
(btnPaintFunc[style])( wndPtr, hdc, ODA_DRAWENTIRE );
if( !wParam ) EndPaint( hWnd, &ps );
}
break;
case WM_LBUTTONDOWN:
case WM_LBUTTONDBLCLK:
SendMessageA( hWnd, BM_SETSTATE, TRUE, 0 );
SetFocus( hWnd );
SetCapture( hWnd );
break;
case WM_LBUTTONUP:
ReleaseCapture();
if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
SendMessageA( hWnd, BM_SETSTATE, FALSE, 0 );
GetClientRect( hWnd, &rect );
if (PtInRect( &rect, pt ))
{
switch(style)
{
case BS_AUTOCHECKBOX:
SendMessageA( hWnd, BM_SETCHECK,
!(infoPtr->state & BUTTON_CHECKED), 0 );
break;
case BS_AUTORADIOBUTTON:
SendMessageA( hWnd, BM_SETCHECK, TRUE, 0 );
break;
case BS_AUTO3STATE:
SendMessageA( hWnd, BM_SETCHECK,
(infoPtr->state & BUTTON_3STATE) ? 0 :
((infoPtr->state & 3) + 1), 0 );
break;
}
SendMessageA( GetParent(hWnd), WM_COMMAND,
MAKEWPARAM( wndPtr->wIDmenu, BN_CLICKED ), (LPARAM)hWnd);
}
break;
case WM_MOUSEMOVE:
if (GetCapture() == hWnd)
{
GetClientRect( hWnd, &rect );
SendMessageA( hWnd, BM_SETSTATE, PtInRect(&rect, pt), 0 );
}
break;
case WM_NCHITTEST:
if(style == BS_GROUPBOX) return HTTRANSPARENT;
return DefWindowProcA( hWnd, uMsg, wParam, lParam );
case WM_SETTEXT:
DEFWND_SetTextA( wndPtr, (LPCSTR)lParam );
if( wndPtr->dwStyle & WS_VISIBLE )
PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
return 0;
case WM_SETFONT:
infoPtr->hFont = (HFONT)wParam;
if (lParam && (wndPtr->dwStyle & WS_VISIBLE))
PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
break;
case WM_GETFONT:
return (LRESULT)infoPtr->hFont;
case WM_SETFOCUS:
infoPtr->state |= BUTTON_HASFOCUS;
if (style == BS_AUTORADIOBUTTON)
{
SendMessageA( hWnd, BM_SETCHECK, 1, 0 );
}
PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
break;
case WM_KILLFOCUS:
infoPtr->state &= ~BUTTON_HASFOCUS;
PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
InvalidateRect( hWnd, NULL, TRUE );
break;
case WM_SYSCOLORCHANGE:
InvalidateRect( hWnd, NULL, FALSE );
break;
case BM_SETSTYLE:
if ((wParam & 0x0f) >= MAX_BTN_TYPE) break;
wndPtr->dwStyle = (wndPtr->dwStyle & 0xfffffff0)
| (wParam & 0x0000000f);
style = wndPtr->dwStyle & 0x0000000f;
PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
break;
case BM_GETCHECK:
return infoPtr->state & 3;
case BM_SETCHECK:
if (wParam > maxCheckState[style]) wParam = maxCheckState[style];
if ((infoPtr->state & 3) != wParam)
{
if ((style == BS_RADIOBUTTON) || (style == BS_AUTORADIOBUTTON))
{
if (wParam)
wndPtr->dwStyle |= WS_TABSTOP;
else
wndPtr->dwStyle &= ~WS_TABSTOP;
}
infoPtr->state = (infoPtr->state & ~3) | wParam;
PAINT_BUTTON( wndPtr, style, ODA_SELECT );
}
if ((style == BS_AUTORADIOBUTTON) && (wParam == BUTTON_CHECKED))
BUTTON_CheckAutoRadioButton( wndPtr );
break;
case BM_GETSTATE:
return infoPtr->state;
case BM_SETSTATE:
if (wParam)
{
if (infoPtr->state & BUTTON_HIGHLIGHTED) break;
infoPtr->state |= BUTTON_HIGHLIGHTED;
}
else
{
if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
infoPtr->state &= ~BUTTON_HIGHLIGHTED;
}
PAINT_BUTTON( wndPtr, style, ODA_SELECT );
break;
default:
return DefWindowProcA(hWnd, uMsg, wParam, lParam);
}
return 0;
}
/**********************************************************************
* Push Button Functions
*/
static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
{
RECT rc;
HPEN hOldPen;
HBRUSH hOldBrush;
BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
GetClientRect( wndPtr->hwndSelf, &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 );
hOldPen = (HPEN)SelectObject(hDC, GetSysColorPen(COLOR_WINDOWFRAME));
hOldBrush =(HBRUSH)SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE));
SetBkMode(hDC, TRANSPARENT);
Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
if (action == ODA_DRAWENTIRE)
{
SetPixel( hDC, rc.left, rc.top, GetSysColor(COLOR_WINDOW) );
SetPixel( hDC, rc.left, rc.bottom-1, GetSysColor(COLOR_WINDOW) );
SetPixel( hDC, rc.right-1, rc.top, GetSysColor(COLOR_WINDOW) );
SetPixel( hDC, rc.right-1, rc.bottom-1, GetSysColor(COLOR_WINDOW));
}
InflateRect( &rc, -1, -1 );
if ((wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON)
{
Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
InflateRect( &rc, -1, -1 );
}
if (infoPtr->state & BUTTON_HIGHLIGHTED)
{
/* draw button shadow: */
SelectObject(hDC, GetSysColorBrush(COLOR_BTNSHADOW));
PatBlt(hDC, rc.left, rc.top, 1, rc.bottom-rc.top, PATCOPY );
PatBlt(hDC, rc.left, rc.top, rc.right-rc.left, 1, PATCOPY );
rc.left += 2; /* To position the text down and right */
rc.top += 2;
} else {
rc.right++, rc.bottom++;
DrawEdge( hDC, &rc, EDGE_RAISED, BF_RECT );
rc.right--, rc.bottom--;
}
/* draw button label, if any: */
// && wndPtr->text[0]
if (wndPtr->text )
{
LOGBRUSH lb;
GetObject( GetSysColorBrush(COLOR_BTNFACE), sizeof(lb), &lb );
if (wndPtr->dwStyle & WS_DISABLED &&
GetSysColor(COLOR_GRAYTEXT)==lb.lbColor)
/* don't write gray text on gray bkg */
PB_PaintGrayOnGray(hDC,infoPtr->hFont,&rc,wndPtr->text);
else
{
SetTextColor( hDC, (wndPtr->dwStyle & WS_DISABLED) ?
GetSysColor(COLOR_GRAYTEXT) :
GetSysColor(COLOR_BTNTEXT) );
DrawTextA( hDC, wndPtr->text, -1, &rc,
DT_SINGLELINE | DT_CENTER | DT_VCENTER );
/* do we have the focus? */
if (infoPtr->state & BUTTON_HASFOCUS)
{
RECT r = { 0, 0, 0, 0 };
INT xdelta, ydelta;
DrawTextA( hDC, wndPtr->text, -1, &r,
DT_SINGLELINE | DT_CALCRECT );
xdelta = ((rc.right - rc.left) - (r.right - r.left) - 1) / 2;
ydelta = ((rc.bottom - rc.top) - (r.bottom - r.top) - 1) / 2;
if (xdelta < 0) xdelta = 0;
if (ydelta < 0) ydelta = 0;
InflateRect( &rc, -xdelta, -ydelta );
DrawFocusRect( hDC, &rc );
}
}
}
SelectObject( hDC, hOldPen );
SelectObject( hDC, hOldBrush );
}
/**********************************************************************
* Push Button sub function [internal]
* using a raster brush to avoid gray text on gray background
*/
void PB_PaintGrayOnGray(HDC hDC,HFONT hFont,RECT *rc,char *text)
{
static const int Pattern[] = {0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55};
HBITMAP hbm = CreateBitmap( 8, 8, 1, 1, Pattern );
HDC hdcMem = CreateCompatibleDC(hDC);
HBITMAP hbmMem;
HBRUSH hBr;
RECT rect,rc2;
rect=*rc;
DrawTextA( hDC, text, -1, &rect, DT_SINGLELINE | DT_CALCRECT);
rc2=rect;
rect.left=(rc->right-rect.right)/2; /* for centering text bitmap */
rect.top=(rc->bottom-rect.bottom)/2;
hbmMem = CreateCompatibleBitmap( hDC,rect.right,rect.bottom );
SelectObject( hdcMem, hbmMem);
hBr = SelectObject( hdcMem, CreatePatternBrush(hbm) );
DeleteObject( hbm );
PatBlt( hdcMem,0,0,rect.right,rect.bottom,WHITENESS);
if (hFont) SelectObject( hdcMem, hFont);
DrawTextA( hdcMem, text, -1, &rc2, DT_SINGLELINE);
PatBlt( hdcMem,0,0,rect.right,rect.bottom,0xFA0089);
DeleteObject( SelectObject( hdcMem,hBr) );
BitBlt(hDC,rect.left,rect.top,rect.right,rect.bottom,hdcMem,0,0,0x990000);
DeleteDC( hdcMem);
DeleteObject( hbmMem );
}
/**********************************************************************
* Check Box & Radio Button Functions
*/
static void CB_Paint( WND *wndPtr, HDC hDC, WORD action )
{
RECT rbox, rtext, client;
HBRUSH hBrush;
int textlen, delta;
BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
textlen = 0;
GetClientRect(wndPtr->hwndSelf, &client);
rbox = rtext = client;
if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
/* Something is still not right, checkboxes (and edit controls)
* in wsping have white backgrounds instead of dark grey.
* BUTTON_SEND_CTLCOLOR() is even worse since it returns 0 in this
* particular case and the background is not painted at all.
*/
hBrush = GetControlBrush( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
if (wndPtr->dwStyle & BS_LEFTTEXT)
{
/* magic +4 is what CTL3D expects */
rtext.right -= checkBoxWidth + 4;
rbox.left = rbox.right - checkBoxWidth;
}
else
{
rtext.left += checkBoxWidth + 4;
rbox.right = checkBoxWidth;
}
/* Draw the check-box bitmap */
if (wndPtr->text) {
textlen = lstrlenA( wndPtr->text );
}
if (action == ODA_DRAWENTIRE || action == ODA_SELECT)
{
HDC hMemDC = CreateCompatibleDC( hDC );
int x = 0, y = 0;
delta = (rbox.bottom - rbox.top - checkBoxHeight) >> 1;
if (action == ODA_SELECT) FillRect( hDC, &rbox, hBrush );
else FillRect( hDC, &client, hBrush );
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;
SelectObject( hMemDC, hbitmapCheckBoxes );
BitBlt( hDC, rbox.left, rbox.top + delta, checkBoxWidth,
checkBoxHeight, hMemDC, x, y, SRCCOPY );
DeleteDC( hMemDC );
if( textlen && action != ODA_SELECT )
{
if (wndPtr->dwStyle & WS_DISABLED)
SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
DrawTextA( hDC, wndPtr->text, textlen, &rtext,
DT_SINGLELINE | DT_VCENTER );
textlen = 0; /* skip DrawText() below */
}
}
if ((action == ODA_FOCUS) ||
((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
{
/* again, this is what CTL3D expects */
SetRectEmpty(&rbox);
if( textlen )
DrawTextA( hDC, wndPtr->text, textlen, &rbox,
DT_SINGLELINE | DT_CALCRECT );
textlen = rbox.bottom - rbox.top;
delta = ((rtext.bottom - rtext.top) - textlen)/2;
rbox.bottom = (rbox.top = rtext.top + delta - 1) + textlen + 2;
textlen = rbox.right - rbox.left;
rbox.right = (rbox.left += --rtext.left) + textlen + 2;
IntersectRect(&rbox, &rbox, &rtext);
DrawFocusRect( hDC, &rbox );
}
}
/**********************************************************************
* BUTTON_CheckAutoRadioButton
*
* wndPtr is checked, uncheck every other auto radio button in group
*/
static void BUTTON_CheckAutoRadioButton( WND *wndPtr )
{
HWND parent, sibling, start;
WND *sibPtr;
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 );
do
{
if (!sibling) break;
sibPtr = WIN_FindWndPtr(sibling);
if (!sibPtr) break;
if ((wndPtr->hwndSelf != sibling) &&
((sibPtr->dwStyle & 0x0f) == BS_AUTORADIOBUTTON))
SendMessageA( sibling, BM_SETCHECK, BUTTON_UNCHECKED, 0 );
sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
} while (sibling != start);
}
/**********************************************************************
* Group Box Functions
*/
static void GB_Paint( WND *wndPtr, HDC hDC, WORD action )
{
RECT rc, rcFrame;
BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
if (action != ODA_DRAWENTIRE) return;
BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
GetClientRect( wndPtr->hwndSelf, &rc);
if (TWEAK_WineLook == WIN31_LOOK) {
HPEN hPrevPen = SelectObject( hDC,
GetSysColorPen(COLOR_WINDOWFRAME));
HBRUSH hPrevBrush = SelectObject( hDC,
GetStockObject(NULL_BRUSH) );
Rectangle( hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1 );
SelectObject( hDC, hPrevBrush );
SelectObject( hDC, hPrevPen );
} else {
TEXTMETRIC tm;
rcFrame = rc;
if (infoPtr->hFont)
SelectObject (hDC, infoPtr->hFont);
GetTextMetricsA (hDC, &tm);
rcFrame.top += (tm.tmHeight / 2) - 1;
DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT);
}
if (wndPtr->text)
{
if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
if (wndPtr->dwStyle & WS_DISABLED)
SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
rc.left += 10;
DrawTextA( hDC, wndPtr->text, -1, &rc, DT_SINGLELINE | DT_NOCLIP );
}
}
/**********************************************************************
* User Button Functions
*/
static void UB_Paint( WND *wndPtr, HDC hDC, WORD action )
{
RECT rc;
HBRUSH hBrush;
BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
if (action == ODA_SELECT) return;
GetClientRect( wndPtr->hwndSelf, &rc);
if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
hBrush = GetControlBrush( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
FillRect( hDC, &rc, hBrush );
if ((action == ODA_FOCUS) ||
((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
DrawFocusRect( hDC, &rc );
}
/**********************************************************************
* Ownerdrawn Button Functions
*/
static void OB_Paint( WND *wndPtr, HDC hDC, WORD action )
{
BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
DRAWITEMSTRUCT dis;
dis.CtlType = ODT_BUTTON;
dis.CtlID = wndPtr->wIDmenu;
dis.itemID = 0;
dis.itemAction = action;
dis.itemState = ((infoPtr->state & BUTTON_HASFOCUS) ? ODS_FOCUS : 0) |
((infoPtr->state & BUTTON_HIGHLIGHTED) ? ODS_SELECTED : 0) |
((wndPtr->dwStyle & WS_DISABLED) ? ODS_DISABLED : 0);
dis.hwndItem = wndPtr->hwndSelf;
dis.hDC = hDC;
dis.itemData = 0;
GetClientRect( wndPtr->hwndSelf, &dis.rcItem );
SendMessageA( GetParent(wndPtr->hwndSelf), WM_DRAWITEM,
wndPtr->wIDmenu, (LPARAM)&dis );
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,242 @@
/*
* Icontitle window class.
*
* Copyright 1997 Alex Korobka
*/
#include <windows.h>
#include <user32/widgets.h>
#include <user32/sysmetr.h>
#include <user32/win.h>
#include <user32/heapdup.h>
#define WM_ISACTIVEICON 0x0035
static LPCSTR emptyTitleText = "<...>";
WINBOOL bMultiLineTitle;
HFONT hIconTitleFont;
/***********************************************************************
* ICONTITLE_Init
*/
WINBOOL ICONTITLE_Init(void)
{
LOGFONT logFont;
SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &bMultiLineTitle, 0 );
hIconTitleFont = CreateFontIndirectA( &logFont );
return (hIconTitleFont) ? TRUE : FALSE;
}
/***********************************************************************
* ICONTITLE_Create
*/
HWND ICONTITLE_Create( WND* wnd )
{
WND* wndPtr;
HWND hWnd;
if( wnd->dwStyle & WS_CHILD )
hWnd = CreateWindowExA( 0, ICONTITLE_CLASS_ATOM, NULL,
WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 1, 1,
wnd->parent->hwndSelf, 0, wnd->hInstance, NULL );
else
hWnd = CreateWindowExA( 0, ICONTITLE_CLASS_ATOM, NULL,
WS_CLIPSIBLINGS, 0, 0, 1, 1,
wnd->hwndSelf, 0, wnd->hInstance, NULL );
wndPtr = WIN_FindWndPtr( hWnd );
if( wndPtr )
{
wndPtr->owner = wnd; /* MDI depends on this */
wndPtr->dwStyle &= ~(WS_CAPTION | WS_BORDER);
if( wnd->dwStyle & WS_DISABLED ) wndPtr->dwStyle |= WS_DISABLED;
return hWnd;
}
return 0;
}
/***********************************************************************
* ICONTITLE_GetTitlePos
*/
WINBOOL ICONTITLE_GetTitlePos( WND* wnd, LPRECT lpRect )
{
LPSTR str;
int length = lstrlenA( wnd->owner->text );
if( length )
{
str = HeapAlloc( GetProcessHeap(), 0, length + 1 );
lstrcpyA( str, wnd->owner->text );
while( str[length - 1] == ' ' ) /* remove trailing spaces */
{
str[--length] = '\0';
if( !length )
{
HeapFree( GetProcessHeap(), 0, str );
break;
}
}
}
if( !length )
{
str = (LPSTR)emptyTitleText;
length = lstrlenA( str );
}
if( str )
{
HDC hDC = GetDC( wnd->hwndSelf );
if( hDC )
{
HFONT hPrevFont = SelectObject( hDC, hIconTitleFont );
SetRect( lpRect, 0, 0, sysMetrics[SM_CXICONSPACING] -
SYSMETRICS_CXBORDER * 2, SYSMETRICS_CYBORDER * 2 );
DrawTextA( hDC, str, length, lpRect, DT_CALCRECT |
DT_CENTER | DT_NOPREFIX | DT_WORDBREAK |
(( bMultiLineTitle ) ? 0 : DT_SINGLELINE) );
SelectObject( hDC, hPrevFont );
ReleaseDC( wnd->hwndSelf, hDC );
lpRect->right += 4 * SYSMETRICS_CXBORDER - lpRect->left;
lpRect->left = wnd->owner->rectWindow.left + SYSMETRICS_CXICON / 2 -
(lpRect->right - lpRect->left) / 2;
lpRect->bottom -= lpRect->top;
lpRect->top = wnd->owner->rectWindow.top + SYSMETRICS_CYICON;
}
if( str != emptyTitleText ) HeapFree( GetProcessHeap(), 0, str );
return ( hDC ) ? TRUE : FALSE;
}
return FALSE;
}
/***********************************************************************
* ICONTITLE_Paint
*/
WINBOOL ICONTITLE_Paint( WND* wnd, HDC hDC, WINBOOL bActive )
{
HFONT hPrevFont;
HBRUSH hBrush = 0;
COLORREF textColor = 0;
if( bActive )
{
hBrush = GetSysColorBrush(COLOR_ACTIVECAPTION);
textColor = GetSysColor(COLOR_CAPTIONTEXT);
}
else
{
if( wnd->dwStyle & WS_CHILD )
{
hBrush = wnd->parent->class->hbrBackground;
if( hBrush )
{
INT level;
LOGBRUSH logBrush;
GetObjectA( hBrush, sizeof(logBrush), &logBrush );
level = GetRValue(logBrush.lbColor) +
GetGValue(logBrush.lbColor) +
GetBValue(logBrush.lbColor);
if( level < (0x7F * 3) )
textColor = RGB( 0xFF, 0xFF, 0xFF );
}
else
hBrush = GetStockObject( WHITE_BRUSH );
}
else
{
hBrush = GetStockObject( BLACK_BRUSH );
textColor = RGB( 0xFF, 0xFF, 0xFF );
}
}
FillWindow( wnd->parent->hwndSelf, wnd->hwndSelf, hDC, hBrush );
hPrevFont = SelectObject( hDC, hIconTitleFont );
if( hPrevFont )
{
RECT rect;
INT length;
char buffer[80];
rect.left = rect.top = 0;
rect.right = wnd->rectWindow.right - wnd->rectWindow.left;
rect.bottom = wnd->rectWindow.bottom - wnd->rectWindow.top;
length = GetWindowTextA( wnd->owner->hwndSelf, buffer, 80 );
SetTextColor( hDC, textColor );
SetBkMode( hDC, TRANSPARENT );
DrawTextA( hDC, buffer, length, &rect, DT_CENTER | DT_NOPREFIX |
DT_WORDBREAK | ((bMultiLineTitle) ? 0 : DT_SINGLELINE) );
SelectObject( hDC, hPrevFont );
}
return ( hPrevFont ) ? TRUE : FALSE;
}
/***********************************************************************
* IconTitleWndProc
*/
LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam )
{
WND *wnd = WIN_FindWndPtr( hWnd );
switch( msg )
{
case WM_NCHITTEST:
return HTCAPTION;
case WM_NCMOUSEMOVE:
case WM_NCLBUTTONDBLCLK:
return SendMessageA( wnd->owner->hwndSelf, msg, wParam, lParam );
case WM_ACTIVATE:
if( wParam ) SetActiveWindow( wnd->owner->hwndSelf );
/* fall through */
case WM_CLOSE:
return 0;
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 );
}
return 0;
case WM_ERASEBKGND:
if( wnd )
{
WND* iconWnd = wnd->owner;
if( iconWnd->dwStyle & WS_CHILD )
lParam = SendMessageA( iconWnd->hwndSelf, WM_ISACTIVEICON, 0, 0 );
else
lParam = (iconWnd->hwndSelf == GetActiveWindow());
if( ICONTITLE_Paint( wnd, (HDC)wParam, (WINBOOL)lParam ) )
ValidateRect( hWnd, NULL );
return 1;
}
}
return DefWindowProcA( hWnd, msg, wParam, lParam );
}

File diff suppressed because it is too large Load diff

View file

@ -14,20 +14,20 @@
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <user32/win.h>
//#include <user32/debug.h>
#include <user32/debug.h>
#include <user32/resource.h>
#include <user32/sysmetr.h>
#include <user32/menu.h>
#include <user32/syscolor.h>
#include<stdio.h>
#define DPRINT printf
/**********************************************************************
@ -49,7 +49,7 @@ HMENU STDCALL CreateMenu(void)
menu->hWnd = 0;
menu->items = NULL;
menu->FocusedItem = NO_SELECTED_ITEM;
//TRACE(menu, "return %04x\n", hMenu );
DPRINT( "return %04x\n", hMenu );
return hMenu;
}
@ -254,10 +254,10 @@ WINBOOL STDCALL DrawMenuBar( HWND hWnd )
*/
HMENU STDCALL LoadMenuA( HINSTANCE instance, LPCSTR name )
{
// instance should be a module handle GetModuleHandle(NULL)
HRSRC hrsrc = FindResourceA( instance, name, (LPCSTR)RT_MENU );
HRSRC hrsrc = FindResourceA( GetModuleHandle(NULL), name, (LPCSTR)RT_MENU );
if (!hrsrc) return 0;
return LoadMenuIndirectA( (LPCVOID)LoadResource( instance, hrsrc ));
return LoadMenuIndirectA( (LPCVOID)LoadResource( GetModuleHandle(NULL), hrsrc ));
}
@ -267,19 +267,61 @@ HMENU STDCALL LoadMenuA( HINSTANCE instance, LPCSTR name )
HMENU STDCALL LoadMenuW( HINSTANCE hInstance, LPCWSTR name )
{
HRSRC hrsrc = FindResourceW( hInstance, name, (LPCWSTR)RT_MENU );
if (!hrsrc)
return 0;
return LoadMenuIndirectW( (LPCVOID)LoadResource( hInstance, hrsrc ));
HRSRC hrsrc = FindResourceW( GetModuleHandle(NULL), name, (LPCSTR)RT_MENU );
if (!hrsrc) return 0;
return LoadMenuIndirectW( (LPCVOID)LoadResource( GetModuleHandle(NULL), hrsrc ));
}
/*
A menu template consists of a MENUITEMTEMPLATEHEADER structure
followed by one or more contiguous MENUITEMTEMPLATE structures.
In Windows 95, an extended menu template consists of a
MENUEX_TEMPLATE_HEADER structure followed by one or more
contiguous MENUEX_TEMPLATE_ITEM structures.
typedef struct {
WORD mtOption;
WORD mtID;
WCHAR mtString[1];
typedef struct {
WORD wVersion;
WORD wOffset;
DWORD dwHelpId;
} MENUEX_TEMPLATE_HEADER;
typedef struct {
DWORD dwType;
DWORD dwState;
UINT uId;
BYTE bResInfo;
WCHAR szText[1];
DWORD dwHelpId;
} MENUEX_TEMPLATE_ITEM;
typedef struct tagMENUITEMINFO {
UINT cbSize;
UINT fMask;
UINT fType;
UINT fState;
UINT wID;
HMENU hSubMenu;
HBITMAP hbmpChecked;
HBITMAP hbmpUnchecked;
DWORD dwItemData;
LPTSTR dwTypeData;
UINT cch;
} MENUITEMINFO, *LPMENUITEMINFO;
typedef MENUITEMINFO CONST *LPCMENUITEMINFO;
typedef struct {
WORD mtOption;
WORD mtID;
WCHAR mtString[1];
} MENUITEMTEMPLATE;
typedef struct {
WORD versionNumber;
WORD offset;
} MENUITEMTEMPLATEHEADER;
typedef VOID MENUTEMPLATE, *LPMENUTEMPLATE;
*/
/**********************************************************************
@ -986,8 +1028,7 @@ INT STDCALL GetMenuStringA( HMENU hMenu, UINT wItemID,
MENUITEM *item;
int i;
int len;
//TRACE(menu, "menu=%04x item=%04x ptr=%p len=%d flags=%04x\n",
// hMenu, wItemID, str, nMaxSiz, wFlags );
DPRINT( "menu=%04x item=%04x ptr=%p len=%d flags=%04x\n", hMenu, wItemID, str, nMaxSiz, wFlags );
if (!str || !nMaxSiz)
return 0;
str[0] = '\0';
@ -1012,8 +1053,7 @@ INT STDCALL GetMenuStringW( HMENU hMenu, UINT wItemID,
{
MENUITEM *item;
//TRACE(menu, "menu=%04x item=%04x ptr=%p len=%d flags=%04x\n",
// hMenu, wItemID, str, nMaxSiz, wFlags );
DPRINT( "menu=%04x item=%04x ptr=%p len=%d flags=%04x\n", hMenu, wItemID, str, nMaxSiz, wFlags );
if (!str || !nMaxSiz)
return 0;
str[0] = '\0';
@ -1030,8 +1070,8 @@ WINBOOL STDCALL HiliteMenuItem( HWND hWnd, HMENU hMenu, UINT wItemID,
UINT wHilite )
{
LPPOPUPMENU menu;
// DPRINT("menu (%04x, %04x, %04x, %04x);\n",
// hWnd, hMenu, wItemID, wHilite);
DPRINT("menu (%04x, %04x, %04x, %04x);\n", hWnd, hMenu, wItemID, wHilite);
if (!MENU_FindItem( &hMenu, &wItemID, wHilite )) return FALSE;
if (!(menu = (LPPOPUPMENU) (hMenu))) return FALSE;
if (menu->FocusedItem == wItemID) return TRUE;
@ -1269,7 +1309,6 @@ STDCALL
GetMenuCheckMarkDimensions(VOID)
{
return MAKELONG(GetSystemMetrics(SM_CXMENUCHECK), GetSystemMetrics(SM_CYMENUCHECK) );
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,509 @@
/*
* Static control
*
* Copyright David W. Metcalfe, 1993
*
*/
#include <windows.h>
#include <user32/win.h>
#include <user32/static.h>
#include <user32/debug.h>
#include <user32/syscolor.h>
#include <user32/nc.h>
#include <user32/defwnd.h>
/* Static Control Styles */
//#define SS_ETCHEDHORZ 0x00000010L
//#define SS_ETCHEDVERT 0x00000011L
//#define SS_ETCHEDFRAME 0x00000012L
#define SS_TYPEMASK 0x0000001FL
//#define SS_NOPREFIX 0x00000080L
//#define SS_NOTIFY 0x00000100L
//#define SS_CENTERIMAGE 0x00000200L
//#define SS_RIGHTJUST 0x00000400L
//#define SS_REALSIZEIMAGE 0x00000800L
//#define SS_SUNKEN 0x00001000L
/* Static Control Messages */
//#define STM_SETICON 0x0170
//#define STM_GETICON 0x0171
//#define STM_SETIMAGE 0x0172
//#define STM_GETIMAGE 0x0173
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 COLORREF color_windowframe, color_background, color_window;
typedef void (*pfPaint)( WND *, HDC );
static pfPaint staticPaintFunc[SS_TYPEMASK+1] =
{
STATIC_PaintTextfn, /* SS_LEFT */
STATIC_PaintTextfn, /* SS_CENTER */
STATIC_PaintTextfn, /* SS_RIGHT */
STATIC_PaintIconfn, /* SS_ICON */
STATIC_PaintRectfn, /* SS_BLACKRECT */
STATIC_PaintRectfn, /* SS_GRAYRECT */
STATIC_PaintRectfn, /* SS_WHITERECT */
STATIC_PaintRectfn, /* SS_BLACKFRAME */
STATIC_PaintRectfn, /* SS_GRAYFRAME */
STATIC_PaintRectfn, /* SS_WHITEFRAME */
NULL, /* Not defined */
STATIC_PaintTextfn, /* SS_SIMPLE */
STATIC_PaintTextfn, /* SS_LEFTNOWORDWRAP */
NULL, /* SS_OWNERDRAW */
STATIC_PaintBitmapfn, /* SS_BITMAP */
NULL, /* SS_ENHMETAFILE */
STATIC_PaintEtchedfn, /* SS_ETCHEDHORIZ */
STATIC_PaintEtchedfn, /* SS_ETCHEDVERT */
STATIC_PaintEtchedfn, /* SS_ETCHEDFRAME */
};
HICON STATIC_LoadIcon(WND *wndPtr,const void *name )
{
HICON hIcon;
if ( wndPtr->class->bUnicode ) {
hIcon = LoadIconW(wndPtr->hInstance,(LPCWSTR)name);
}
else
hIcon = LoadIconA(wndPtr->hInstance,(LPCSTR)name);
return hIcon;
}
/***********************************************************************
* STATIC_SetIcon
*
* Set the icon for an SS_ICON control.
*/
HICON STATIC_SetIcon( WND *wndPtr, HICON hicon )
{
HICON prevIcon;
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
ICONINFO iconinfo;
BITMAP info;
if ( !GetIconInfo(hicon, &iconinfo ) )
return NULL;
if ( iconinfo.hbmColor )
GetObject(iconinfo.hbmColor, sizeof(BITMAP),&info);
else
GetObject(iconinfo.hbmMask, sizeof(BITMAP),&info);
if ((wndPtr->dwStyle & SS_TYPEMASK) != SS_ICON) return 0;
prevIcon = infoPtr->hIcon;
infoPtr->hIcon = hicon;
if (hicon)
{
SetWindowPos( wndPtr->hwndSelf, 0, 0, 0, info.bmWidth, info.bmHeight,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
}
return prevIcon;
}
HBITMAP STATIC_LoadBitmap(WND *wndPtr,const void *name )
{
HBITMAP hBitmap;
if ( wndPtr->class->bUnicode ) {
hBitmap = LoadBitmapW(wndPtr->hInstance,(LPCWSTR)name);
}
else
hBitmap = LoadBitmapA(wndPtr->hInstance,(LPCSTR)name);
return hBitmap;
}
/***********************************************************************
* STATIC_SetBitmap
*
* Set the bitmap for an SS_BITMAP control.
*/
HICON STATIC_SetBitmap( WND *wndPtr, HICON hicon )
{
HICON prevIcon;
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
BITMAP info;
if ( hicon == NULL )
return NULL;
GetObject(hicon, sizeof(BITMAP),&info);
if ((wndPtr->dwStyle & SS_TYPEMASK) != SS_BITMAP) return 0;
prevIcon = infoPtr->hIcon;
infoPtr->hIcon = hicon;
if (hicon)
{
SetWindowPos( wndPtr->hwndSelf, 0, 0, 0, info.bmWidth, info.bmHeight,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
}
return prevIcon;
}
/***********************************************************************
* StaticWndProc
*/
LRESULT WINAPI StaticWndProc( HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam )
{
LRESULT lResult = 0;
WND *wndPtr = WIN_FindWndPtr(hWnd);
LONG style = wndPtr->dwStyle & SS_TYPEMASK;
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
switch (uMsg)
{
case WM_NCCREATE: {
CREATESTRUCT *cs = (CREATESTRUCT *)lParam;
if ((TWEAK_WineLook > WIN31_LOOK) && (wndPtr->dwStyle & SS_SUNKEN))
wndPtr->dwExStyle |= WS_EX_STATICEDGE;
if (style == SS_ICON)
{
if (cs->lpszName) {
STATIC_SetIcon( wndPtr,STATIC_LoadIcon(wndPtr,cs->lpszName));
}
return 1;
}
if (style == SS_BITMAP)
{
if (cs->lpszName) {
STATIC_SetBitmap( wndPtr,STATIC_LoadBitmap(wndPtr,cs->lpszName));
}
return 1;
}
if ( wndPtr->class->bUnicode )
return DefWindowProcW( hWnd, uMsg, wParam, lParam );
else
return DefWindowProcA( hWnd, uMsg, wParam, lParam );
}
case WM_CREATE:
if (style < 0L || style > SS_TYPEMASK)
{
DPRINT( "Unknown style 0x%02lx\n", style );
lResult = -1L;
break;
}
/* initialise colours */
color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
color_background = GetSysColor(COLOR_BACKGROUND);
color_window = GetSysColor(COLOR_WINDOW);
break;
case WM_NCDESTROY:
if (style == SS_ICON) {
/*
* FIXME
* DestroyIcon( STATIC_SetIcon( wndPtr, 0 ) );
*
* We don't want to do this yet because DestroyIcon is broken. If the icon
* had already been loaded by the application the last thing we want to do is
* GlobalFree the handle.
*/
} else {
if ( wndPtr->class->bUnicode )
lResult = DefWindowProcW( hWnd, uMsg, wParam, lParam );
else
lResult = DefWindowProcA( hWnd, uMsg, wParam, lParam );
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint( hWnd, &ps );
if (staticPaintFunc[style])
(staticPaintFunc[style])( wndPtr, ps.hdc );
EndPaint( hWnd, &ps );
}
break;
case WM_ENABLE:
InvalidateRect( hWnd, NULL, FALSE );
break;
case WM_SYSCOLORCHANGE:
color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
color_background = GetSysColor(COLOR_BACKGROUND);
color_window = GetSysColor(COLOR_WINDOW);
InvalidateRect( hWnd, NULL, TRUE );
break;
case WM_SETTEXT:
if (style == SS_ICON)
{
if (lParam) {
STATIC_SetIcon( wndPtr,STATIC_LoadIcon(wndPtr,(const void *)lParam));
}
}
else if (style == SS_BITMAP)
{
if (lParam) {
STATIC_SetBitmap( wndPtr,STATIC_LoadBitmap(wndPtr,(const void *)lParam));
}
}
else {
DEFWND_SetText( wndPtr, (const void *)lParam );
}
InvalidateRect( hWnd, NULL, FALSE );
UpdateWindow( hWnd );
break;
case WM_SETFONT:
if (style == SS_ICON) return 0;
if (style == SS_BITMAP) return 0;
infoPtr->hFont = (HFONT)wParam;
if (LOWORD(lParam))
{
InvalidateRect( hWnd, NULL, FALSE );
UpdateWindow( hWnd );
}
break;
case WM_GETFONT:
return infoPtr->hFont;
case WM_NCHITTEST:
return HTTRANSPARENT;
case WM_GETDLGCODE:
return DLGC_STATIC;
case STM_GETIMAGE:
case STM_GETICON:
return infoPtr->hIcon;
case STM_SETIMAGE:
/* FIXME: handle wParam */
lResult = STATIC_SetBitmap( wndPtr, (HBITMAP)lParam );
InvalidateRect( hWnd, NULL, FALSE );
UpdateWindow( hWnd );
break;
case STM_SETICON:
lResult = STATIC_SetIcon( wndPtr, (HICON)wParam );
InvalidateRect( hWnd, NULL, FALSE );
UpdateWindow( hWnd );
break;
default:
if ( wndPtr->class->bUnicode )
lResult = DefWindowProcW( hWnd, uMsg, wParam, lParam );
else
lResult = DefWindowProcA( hWnd, uMsg, wParam, lParam );
break;
}
return lResult;
}
static void STATIC_PaintTextfn( WND *wndPtr, HDC hdc )
{
RECT rc;
HBRUSH hBrush;
WORD wFormat;
LONG style = wndPtr->dwStyle;
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
GetClientRect( wndPtr->hwndSelf, &rc);
switch (style & SS_TYPEMASK)
{
case SS_LEFT:
wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
break;
case SS_CENTER:
wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
break;
case SS_RIGHT:
wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
break;
case SS_SIMPLE:
wFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOCLIP;
break;
case SS_LEFTNOWORDWRAP:
wFormat = DT_LEFT | DT_SINGLELINE | DT_EXPANDTABS | DT_VCENTER | DT_NOCLIP;
break;
default:
return;
}
if (style & SS_NOPREFIX)
wFormat |= DT_NOPREFIX;
if (infoPtr->hFont) SelectObject( hdc, infoPtr->hFont );
hBrush = MSG_SendMessage( wndPtr->parent, WM_CTLCOLORSTATIC,
(WPARAM)hdc,(LPARAM) wndPtr->hwndSelf );
if (!hBrush) hBrush = GetStockObject(WHITE_BRUSH);
FillRect( hdc, &rc, hBrush );
if (wndPtr->text) {
if ( wndPtr->class->bUnicode ) {
DrawTextW( hdc, wndPtr->text, -1, &rc, wFormat );
}
else {
DrawTextA( hdc, wndPtr->text, -1, &rc, wFormat );
}
}
}
static void STATIC_PaintRectfn( WND *wndPtr, HDC hdc )
{
RECT rc;
HBRUSH hBrush;
GetClientRect( wndPtr->hwndSelf, &rc);
switch (wndPtr->dwStyle & SS_TYPEMASK)
{
case SS_BLACKRECT:
hBrush = CreateSolidBrush(color_windowframe);
FillRect( hdc, &rc, hBrush );
break;
case SS_GRAYRECT:
hBrush = CreateSolidBrush(color_background);
FillRect( hdc, &rc, hBrush );
break;
case SS_WHITERECT:
hBrush = CreateSolidBrush(color_window);
FillRect( hdc, &rc, hBrush );
break;
case SS_BLACKFRAME:
hBrush = CreateSolidBrush(color_windowframe);
FrameRect( hdc, &rc, hBrush );
break;
case SS_GRAYFRAME:
hBrush = CreateSolidBrush(color_background);
FrameRect( hdc, &rc, hBrush );
break;
case SS_WHITEFRAME:
hBrush = CreateSolidBrush(color_window);
FrameRect( hdc, &rc, hBrush );
break;
default:
return;
}
DeleteObject( hBrush );
}
static void STATIC_PaintIconfn( WND *wndPtr, HDC hdc )
{
RECT rc;
HBRUSH hbrush;
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
GetClientRect( wndPtr->hwndSelf, &rc );
hbrush = MSG_SendMessage( wndPtr->parent, WM_CTLCOLORSTATIC,
(WPARAM)hdc, (LPARAM)wndPtr->hwndSelf );
FillRect( hdc, &rc, hbrush );
if (infoPtr->hIcon) DrawIcon( hdc, rc.left, rc.top, infoPtr->hIcon );
}
static void STATIC_PaintBitmapfn(WND *wndPtr, HDC hdc )
{
RECT rc;
HBRUSH hbrush;
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
HDC hMemDC;
HBITMAP oldbitmap;
GetClientRect( wndPtr->hwndSelf, &rc );
hbrush = MSG_SendMessage( wndPtr->parent, WM_CTLCOLORSTATIC,
(WPARAM)hdc,(LPARAM) wndPtr->hwndSelf );
FillRect( hdc, &rc, hbrush );
if (infoPtr->hIcon) {
BITMAP bmp;
GetObject( infoPtr->hIcon, sizeof(BITMAP),&bmp);
if (!(hMemDC = CreateCompatibleDC( hdc ))) return;
oldbitmap = SelectObject(hMemDC,infoPtr->hIcon);
BitBlt(hdc,bmp.bmWidth,bmp.bmHeight,bmp.bmWidth,bmp.bmHeight,hMemDC,0,0,SRCCOPY);
// BitBlt(hdc,bmp.size.cx,bmp.size.cy,bmp.bmWidth,bmp.bmHeight,hMemDC,0,0,SRCCOPY);
DeleteDC(hMemDC);
}
}
static void STATIC_PaintEtchedfn( WND *wndPtr, HDC hdc )
{
RECT rc;
HBRUSH hbrush;
HPEN hpen;
if (TWEAK_WineLook == WIN31_LOOK)
return;
GetClientRect( wndPtr->hwndSelf, &rc );
hbrush = MSG_SendMessage( wndPtr->parent, WM_CTLCOLORSTATIC,
(WPARAM)hdc, (LPARAM)wndPtr->hwndSelf );
FillRect( hdc, &rc, hbrush );
switch (wndPtr->dwStyle & SS_TYPEMASK)
{
case SS_ETCHEDHORZ:
hpen = SelectObject (hdc, GetSysColorPen (COLOR_3DSHADOW));
MoveToEx (hdc, rc.left, rc.bottom / 2 - 1, NULL);
LineTo (hdc, rc.right - 1, rc.bottom / 2 - 1);
SelectObject (hdc, GetSysColorPen (COLOR_3DHIGHLIGHT));
MoveToEx (hdc, rc.left, rc.bottom / 2, NULL);
LineTo (hdc, rc.right, rc.bottom / 2);
LineTo (hdc, rc.right, rc.bottom / 2 - 1);
SelectObject (hdc, hpen);
break;
case SS_ETCHEDVERT:
hpen = SelectObject (hdc, GetSysColorPen (COLOR_3DSHADOW));
MoveToEx (hdc, rc.right / 2 - 1, rc.top, NULL);
LineTo (hdc, rc.right / 2 - 1, rc.bottom - 1);
SelectObject (hdc, GetSysColorPen (COLOR_3DHIGHLIGHT));
MoveToEx (hdc, rc.right / 2, rc.top, NULL);
LineTo (hdc, rc.right / 2, rc.bottom);
LineTo (hdc, rc.right / 2 -1 , rc.bottom);
SelectObject (hdc, hpen);
break;
case SS_ETCHEDFRAME:
DrawEdge (hdc, &rc, EDGE_ETCHED, BF_RECT);
break;
}
}

View file

@ -0,0 +1,112 @@
/*
* Windows widgets (built-in window classes)
*
* Copyright 1993 Alexandre Julliard
*/
#define UNICODE
#include <windows.h>
#include <user32/widgets.h>
#include <user32/win.h>
#include <user32/button.h>
#include <user32/scroll.h>
#include <user32/static.h>
#include <user32/mdi.h>
#include <user32/dialog.h>
#include <user32/heapdup.h>
/* Built-in classes */
#define DLGWINDOWEXTRA sizeof(DIALOGINFO)
static WNDCLASS WIDGETS_BuiltinClasses[BIC_NB_CLASSES+1] =
{
/* BIC_BUTTON */
{ CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
ButtonWndProc, 0, sizeof(BUTTONINFO), 0, 0,
(HCURSOR)IDC_ARROW, 0, 0, BUTTON_CLASS_NAME },
/* BIC_EDIT */
{ CS_GLOBALCLASS | CS_DBLCLKS /*| CS_PARENTDC*/,
EditWndProc, 0, sizeof(void *), 0, 0,
(HCURSOR)IDC_IBEAM, 0, 0, EDIT_CLASS_NAME },
/* BIC_LISTBOX */
{ CS_GLOBALCLASS | CS_DBLCLKS /*| CS_PARENTDC*/,
ListBoxWndProc, 0, sizeof(void *), 0, 0,
(HCURSOR)IDC_ARROW, 0, 0, LISTBOX_CLASS_NAME },
/* BIC_COMBO */
{ CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
ComboWndProc, 0, sizeof(void *), 0, 0,
(HCURSOR)IDC_ARROW, 0, 0, COMBOBOX_CLASS_NAME },
/* BIC_COMBOLB */
{ CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS, ComboLBWndProc,
0, sizeof(void *), 0, 0, (HCURSOR)IDC_ARROW, 0, 0,COMBOLBOX_CLASS_NAME},
/* BIC_POPUPMENU */
// { CS_GLOBALCLASS | CS_SAVEBITS, PopupMenuWndProc, 0, sizeof(HMENU),
// 0, 0, (HCURSOR)IDC_ARROW, NULL_BRUSH, 0, POPUPMENU_CLASS_NAME },
/* BIC_STATIC */
{ CS_GLOBALCLASS | CS_PARENTDC, StaticWndProc,
0, sizeof(STATICINFO), 0, 0, (HCURSOR)IDC_ARROW, 0, 0, STATIC_CLASS_NAME },
/* BIC_SCROLL */
{ CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
ScrollBarWndProc, 0, sizeof(SCROLLBAR_INFO), 0, 0,
(HCURSOR)IDC_ARROW, 0, 0, SCROLLBAR_CLASS_NAME},
/* BIC_MDICLIENT */
// { CS_GLOBALCLASS, MDIClientWndProc,
// 0, sizeof(MDICLIENTINFO), 0, 0, 0, LTGRAY_BRUSH, 0, "MDIClient" },
/* BIC_DESKTOP */
// { CS_GLOBALCLASS, DesktopWndProc, 0, sizeof(DESKTOPINFO),
// 0, 0, (HCURSOR)IDC_ARROW, 0, 0, DESKTOP_CLASS_NAME },
/* BIC_DIALOG */
{ CS_GLOBALCLASS | CS_SAVEBITS, DefDlgProc, 100, 100,
0, 0, (HCURSOR)IDC_ARROW, 0, 0, DIALOG_CLASS_NAMEW },
/* BIC_ICONTITLE */
{ CS_GLOBALCLASS, IconTitleWndProc, 0, 0,
0, 0, (HCURSOR)IDC_ARROW, 0, 0, ICONTITLE_CLASS_NAME },
/* BIC_DIALOG Ascii */
{ CS_GLOBALCLASS, DefDlgProcA, 100, 100,
0, 0, (HCURSOR)IDC_ARROW, 0, 0, (LPWSTR)DIALOG_CLASS_NAME_A }
};
static ATOM bicAtomTable[BIC_NB_CLASSES+1];
/***********************************************************************
* WIDGETS_Init
*
* Initialize the built-in window classes.
*/
WINBOOL WIDGETS_Init(void)
{
int i;
WNDCLASS *cls = WIDGETS_BuiltinClasses;
/* Create builtin classes */
for (i = 0; i < BIC_NB_CLASSES; i++)
{
cls[i].hCursor = LoadCursorW( 0, (LPCWSTR)cls[i].hCursor );
if (!(bicAtomTable[i] = RegisterClassW( &cls[i] ))) return FALSE;
}
cls[i].hCursor = LoadCursorW( 0, (LPCWSTR)cls[i].hCursor );
if (!(bicAtomTable[i] = RegisterClassA( &cls[i] ))) return FALSE;
return TRUE;
}
/***********************************************************************
* WIDGETS_IsControl
*
* Check whether pWnd is a built-in control or not.
*/
WINBOOL WIDGETS_IsControl( WND* pWnd, BUILTIN_CLASS cls )
{
if( cls >= BIC_NB_CLASSES )
return FALSE;
return (pWnd->class->atomName == bicAtomTable[cls]);
}

View file

@ -1,6 +1,37 @@
#include <windows.h>
INT STDCALL FrameRect( HDC hdc, const RECT *rect, HBRUSH hbrush )
{
HBRUSH prevBrush;
//int left, top, right, bottom;
if ( hdc == NULL )
return 0;
//left = XLPTODP( dc, rect->left );
//top = YLPTODP( dc, rect->top );
//right = XLPTODP( dc, rect->right );
//bottom = YLPTODP( dc, rect->bottom );
//if ( (right <= left) || (bottom <= top) ) return 0;
if (!(prevBrush = SelectObject( hdc, hbrush ))) return 0;
PatBlt( hdc, rect->left, rect->top, 1,
rect->bottom - rect->top, PATCOPY );
PatBlt( hdc, rect->right - 1, rect->top, 1,
rect->bottom - rect->top, PATCOPY );
PatBlt( hdc, rect->left, rect->top,
rect->right - rect->left, 1, PATCOPY );
PatBlt( hdc, rect->left, rect->bottom - 1,
rect->right - rect->left, 1, PATCOPY );
SelectObject( hdc, prevBrush );
return 1;
}
INT STDCALL FillRect( HDC hdc, const RECT *rect, HBRUSH hbrush )
{
HBRUSH prevBrush;

View file

@ -1,7 +1,9 @@
#include <windows.h>
#include <user32/static.h>
HICON LoadStandardIcon(UINT IconId);
HICON
STDCALL
@ -27,8 +29,42 @@ CreateIcon(
HICON
STDCALL
CreateIconIndirect(
PICONINFO piconinfo)
PICONINFO lpIconInfo)
{
BITMAP bmpXor,bmpAnd;
HICON hObj;
int sizeXor,sizeAnd;
GetObject(lpIconInfo->hbmColor,sizeof(BITMAP),&bmpXor);
GetObject(lpIconInfo->hbmMask,sizeof(BITMAP),&bmpAnd);
sizeXor = bmpXor.bmHeight * bmpXor.bmWidthBytes;
sizeAnd = bmpAnd.bmHeight * bmpAnd.bmWidthBytes;
hObj = GlobalAlloc( GMEM_MOVEABLE,
sizeof(ICONINFO) + sizeXor + sizeAnd );
if (hObj)
{
ICONINFO *info;
info = (ICONINFO *)( hObj );
info->xHotspot = lpIconInfo->xHotspot;
info->yHotspot = lpIconInfo->yHotspot;
//info->nWidth = bmpXor.bmWidth;
//info->nHeight = bmpXor.bmHeight;
//info->nWidthBytes = bmpXor.bmWidthBytes;
//info->bPlanes = bmpXor.bmPlanes;
//info->bBitsPerPixel = bmpXor.bmBitsPixel;
/* Transfer the bitmap bits to the CURSORICONINFO structure */
GetBitmapBits( lpIconInfo->hbmMask ,sizeAnd,(char*)(info + 1) );
GetBitmapBits( lpIconInfo->hbmColor,sizeXor,(char*)(info + 1) +sizeAnd);
}
return hObj;
}
@ -53,14 +89,79 @@ GetIconInfo(
HICON LoadIconA(HINSTANCE hInstance,LPCSTR lpIconName )
{
return CreateIcon(hInstance, GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
0,0,NULL,NULL);
HRSRC hrsrc;
ICONINFO *IconInfo;
if ( hInstance == NULL ) {
return LoadStandardIcon((UINT)lpIconName);
}
//RT_GROUP_ICON
hrsrc = FindResourceExA(hInstance,RT_GROUP_ICON, lpIconName, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));
if ( hrsrc == NULL )
return NULL;
IconInfo = (ICONINFO *)LoadResource(hInstance, hrsrc);
if ( IconInfo != NULL || IconInfo->fIcon == FALSE )
return NULL;
return CreateIconIndirect(IconInfo);
}
HICON LoadIconW(HINSTANCE hInstance,LPCWSTR lpIconName )
{
return CreateIcon(hInstance, GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
0,0,NULL,NULL);
HRSRC hrsrc;
ICONINFO *IconInfo;
if ( hInstance == NULL ) {
return LoadStandardIcon((UINT)lpIconName);
}
hrsrc = FindResourceW(hInstance,lpIconName,RT_GROUP_ICON);
if ( hrsrc == NULL )
return NULL;
IconInfo = (ICONINFO *)LoadResource(hInstance, hrsrc);
if ( IconInfo != NULL || IconInfo->fIcon == FALSE )
return NULL;
return CreateIconIndirect(IconInfo);
}
HICON LoadStandardIcon(UINT IconId)
{
HMODULE hModule = LoadLibraryA("user32.dll");
switch (IconId )
{
case IDI_APPLICATION:
IconId = 100;
return LoadIconW(hModule,(LPWSTR)IconId);
break;
case IDI_ASTERISK:
//
IconId = 103;
return LoadIconW(hModule,(LPWSTR)IconId);
break;
case IDI_EXCLAMATION:
IconId = 101;
return LoadIconW(hModule,(LPWSTR)IconId);
break;
case IDI_HAND:
//
return LoadIconW(hModule,(LPWSTR)MAKEINTRESOURCE(104));
break;
case IDI_QUESTION:
IconId = 102;
return LoadIconW(hModule,(LPWSTR)IconId);
break;
case IDI_WINLOGO:
IconId = 105;
return LoadIconW(hModule,(LPWSTR)IconId);
break;
default:
return NULL;
break;
}
return NULL;
}

View file

@ -8,12 +8,10 @@
#include <windows.h>
//#include <user32/syscolor.h>
#include <user32/syscolor.h>
#include <user32/nc.h>
void SYSCOLOR_SetColor( int index, COLORREF color );
void SYSCOLOR_Init(void);
static const char * const DefSysColors[] =
{
@ -149,7 +147,7 @@ HBRUSH STDCALL GetSysColorBrush( INT index )
* Windows. However, it is a natural complement for GetSysColorBrush
* in the Win API and is needed quite a bit inside Wine.
*/
HPEN STDCALL GetSysColorPen( INT index )
HPEN GetSysColorPen( INT index )
{
/* We can assert here, because this function is internal to Wine */
//assert (0 <= index && index < NUM_SYS_COLORS);

View file

@ -1,4 +1,5 @@
#include <windows.h>
#include <user32/text.h>
int
@ -25,4 +26,48 @@ DrawTextW(
dtp.iTabLength = 0;
return TEXT_DrawTextEx(hDC,(void *)lpString,nCount,lpRect,uFormat, &dtp,TRUE);
}
}
/***********************************************************************
* GetTabbedTextExtentA (USER32.293)
*/
DWORD
STDCALL
GetTabbedTextExtentA(HDC hDC, LPCSTR lpString, int nCount, int nTabPositions,
LPINT lpnTabStopPositions)
{
return TEXT_TabbedTextOutA( hDC, 0, 0, lpString, nCount, nTabPositions,
lpnTabStopPositions,0, FALSE );
}
DWORD
STDCALL
GetTabbedTextExtentW(HDC hDC, LPCWSTR lpString, int nCount, int nTabPositions,
LPINT lpnTabStopPositions)
{
return TEXT_TabbedTextOutW( hDC, 0, 0, lpString, nCount, nTabPositions,
lpnTabStopPositions, 0, FALSE );
}
LONG
STDCALL
TabbedTextOutA( HDC hDC, int X, int Y, LPCSTR lpString,
int nCount, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin)
{
return TEXT_TabbedTextOutA( hDC, X, Y, lpString, nCount, nTabPositions,
lpnTabStopPositions, nTabOrigin, TRUE );
}
LONG
STDCALL
TabbedTextOutW( HDC hDC, int X, int Y, LPCWSTR lpString,
int nCount, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin)
{
return TEXT_TabbedTextOutW( hDC, 0, 0, lpString, nCount, nTabPositions,
lpnTabStopPositions, nTabOrigin, TRUE );
}

View file

@ -14,6 +14,7 @@
#include <user32/dce.h>
#include <user32/sysmetr.h>
#include <user32/paint.h>
#include <user32/defwnd.h>
#include <user32/debug.h>
@ -65,11 +66,22 @@ void DEFWND_HandleWindowPosChanged( WND *wndPtr, UINT flags )
*
* Set the window text.
*/
void DEFWND_SetText( WND *wndPtr,const void *text )
{
if ( wndPtr->class->bUnicode )
DEFWND_SetTextW( wndPtr, (LPCWSTR) text );
else
DEFWND_SetTextA( wndPtr, (LPCSTR) text );
}
void DEFWND_SetTextA( WND *wndPtr, LPCSTR text )
{
if (!text) text = "";
if (wndPtr->text) HeapFree( GetProcessHeap(), 0, wndPtr->text );
wndPtr->text = (void *)HEAP_strdupA( GetProcessHeap(), 0, text );
wndPtr->text = (void *)HEAP_strdupA( GetProcessHeap(), 0, text );
NC_HandleNCPaint( wndPtr->hwndSelf , (HRGN)1 ); /* Repaint caption */
}
@ -77,7 +89,8 @@ void DEFWND_SetTextW( WND *wndPtr, LPCWSTR text )
{
if (!text) text = L"";
if (wndPtr->text) HeapFree( GetProcessHeap(), 0, wndPtr->text );
wndPtr->text = (void *)HEAP_strdupW( GetProcessHeap(), 0, text );
wndPtr->text = (void *)HEAP_strdupW( GetProcessHeap(), 0, text );
NC_HandleNCPaint( wndPtr->hwndSelf , (HRGN)1 ); /* Repaint caption */
}
/***********************************************************************
@ -125,7 +138,7 @@ void DEFWND_SetRedraw( WND* wndPtr, WPARAM wParam )
{
if( !bVisible )
{
wndPtr->dwStyle |= WS_VISIBLE;
//wndPtr->dwStyle |= WS_VISIBLE;
DCE_InvalidateDCE( wndPtr, &wndPtr->rectWindow );
}
}
@ -136,7 +149,7 @@ void DEFWND_SetRedraw( WND* wndPtr, WPARAM wParam )
PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, wParam, 0 );
DCE_InvalidateDCE( wndPtr, &wndPtr->rectWindow );
wndPtr->dwStyle &= ~WS_VISIBLE;
// wndPtr->dwStyle &= ~WS_VISIBLE;
}
}
@ -171,8 +184,8 @@ LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
if ((wndPtr->flags & WIN_ISWIN) || (TWEAK_WineLook > WIN31_LOOK))
{
ClientToScreen(wndPtr->hwndSelf, (LPPOINT)&lParam);
SendMessageA( wndPtr->hwndSelf, WM_CONTEXTMENU,
wndPtr->hwndSelf, lParam);
MSG_SendMessage( wndPtr, WM_CONTEXTMENU,
(WPARAM)wndPtr->hwndSelf,(LPARAM) lParam);
}
break;

File diff suppressed because it is too large Load diff

View file

@ -72,6 +72,7 @@ int lpstrncpyA( LPSTR ptr1,LPSTR ptr2, int n)
if ( ptr1[i] == 0 )
break;
}
return i;
}
int lpstrncpyW( LPWSTR ptr1,LPWSTR ptr2, int n)
{
@ -81,6 +82,7 @@ int lpstrncpyW( LPWSTR ptr1,LPWSTR ptr2, int n)
if ( ptr1[i] == 0 )
break;
}
return i;
}
LPSTR HEAP_strdupA(HANDLE hHeap,DWORD dwFlags,LPCSTR ptr)
@ -100,4 +102,14 @@ LPWSTR HEAP_strdupW(HANDLE hHeap,DWORD dwFlags,LPCWSTR ptr)
lstrcpyW(lpszString,ptr);
return lpszString;
}
int HEAP_memset( void *d,int c ,int count)
{
return memset(d,c,count);
}
int HEAP_memcpy( void *d,void *s,int c)
{
return memcpy(d,s,c);
}

View file

@ -1,15 +1,16 @@
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <user32/win.h>
//#include <user32/debug.h>
#include <user32/debug.h>
#include <user32/resource.h>
#include <user32/sysmetr.h>
#include <user32/syscolor.h>
#include <user32/menu.h>
#include <user32/nc.h>
#include <stdlib.h>
#include <user32/heapdup.h>
#include <wchar.h>
#include <stdlib.h>
//#include <stdlib.h>
typedef struct tagMDINEXTMENU
{
@ -48,9 +49,6 @@ UINT uSubPWndLevel = 0;
WINBOOL fEndMenu = FALSE;
#include<stdio.h>
#define DPRINT printf
/***********************************************************************
* debug_print_menuitem
@ -684,7 +682,7 @@ void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop, HWND hwndOwner )
*
* Calculate the size of the menu bar.
*/
static void MENU_MenuBarCalcSize( HDC hdc, LPRECT lprect,
void MENU_MenuBarCalcSize( HDC hdc, LPRECT lprect,
LPPOPUPMENU lppop, HWND hwndOwner )
{
MENUITEM *lpitem;
@ -1451,7 +1449,7 @@ WINBOOL MENU_PatchResidentPopup( HQUEUE checkQueue, WND* checkWnd )
}
menu->items = newItems;
menu->nItems++;
memset( &newItems[pos], 0, sizeof(*newItems) );
HEAP_memset( &newItems[pos], 0, sizeof(*newItems) );
return &newItems[pos];
}

View file

@ -4,10 +4,10 @@
* Copyright 1993, 1994 Alexandre Julliard
*/
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/time.h>
//#include <sys/time.h>
#include <sys/types.h>
#include <windows.h>
#include <user32/msg.h>
@ -16,6 +16,7 @@
#include <user32/debug.h>
#include <user32/winpos.h>
#include <user32/queue.h>
#include <user32/heapdup.h>
@ -158,16 +159,16 @@ DWORD MSG_TranslateMouseMsg( HWND hTopWnd, DWORD filter,
if (HOOK_IsHooked( WH_MOUSE ))
{
MOUSEHOOKSTRUCT *hook = malloc(sizeof(MOUSEHOOKSTRUCT));
MOUSEHOOKSTRUCT *hook = HeapAlloc(GetProcessHeap(),0,sizeof(MOUSEHOOKSTRUCT));
if( hook )
{
hook->pt = screen_pt;
hook->hwnd = hWnd;
hook->wHitTestCode = hittest;
hook->dwExtraInfo = 0;
ret = HOOK_CallHooksA( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE,
message, (LPARAM)(hook) );
free(hook);
ret = HOOK_CallHooks( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE,
message, (LPARAM)(hook), pWnd->class->bUnicode );
HeapFree(GetProcessHeap(),0,hook);
}
if( ret ) return MAKELONG((INT)SYSQ_MSG_SKIP, hittest);
}
@ -523,24 +524,47 @@ WINBOOL MSG_PeekHardwareMsg( MSG *msg, HWND hwnd, DWORD filter,
return FALSE;
}
/***********************************************************************
* MSG_SendMessage
*
* Implementation of an inter-task SendMessage.
*/
LRESULT MSG_SendMessage( HQUEUE hDestQueue, HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam, WORD flags )
LRESULT MSG_SendMessageInterTask( HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam, WINBOOL bUnicode)
{
WND *wndPtr;
WND **list, **ppWnd;
INT prevSMRL = debugSMRL;
QSMCTRL qCtrl = { 0, 1};
MESSAGEQUEUE *queue, *destQ;
if (!(queue = (MESSAGEQUEUE*)GlobalLock( GetFastQueue() ))) return 0;
if (!(destQ = (MESSAGEQUEUE*)GlobalLock( hDestQueue ))) return 0;
if (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST)
{
if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
return TRUE;
for (ppWnd = list; *ppWnd; ppWnd++)
{
wndPtr = *ppWnd;
//if (!WIN_IsWindow(wndPtr))
//continue;
if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
MSG_SendMessageInterTask( wndPtr->hwndSelf, msg, wParam, lParam, bUnicode );
}
HeapFree( GetProcessHeap(), 0, list );
return TRUE;
}
if (
// should turn queue and destQ around
if (!(queue = (MESSAGEQUEUE*)GlobalLock( GetFastQueue() ))) return 0;
if (!(destQ = (MESSAGEQUEUE*)GlobalLock( wndPtr->hmemTaskQ ))) return 0;
//if (
//IsTaskLocked() ||
!IsWindow(hwnd)) return 0;
//!IsWindow(hwnd)) return 0;
debugSMRL+=4;
DPRINT("%*sSM: %s [%04x] (%04x -> %04x)\n",
@ -552,6 +576,9 @@ LRESULT MSG_SendMessage( HQUEUE hDestQueue, HWND hwnd, UINT msg,
QUEUE_WaitBits( QS_SMPARAMSFREE );
}
/* resume sending */
queue->hWnd = hwnd;
@ -563,7 +590,7 @@ LRESULT MSG_SendMessage( HQUEUE hDestQueue, HWND hwnd, UINT msg,
destQ->hSendingTask = GetFastQueue();
QUEUE_ClearWakeBit( queue, QS_SMPARAMSFREE );
queue->flags = (queue->flags & ~(QUEUE_SM_ASCII|QUEUE_SM_UNICODE)) | flags;
// queue->flags = (queue->flags & ~(QUEUE_SM_ASCII|QUEUE_SM_UNICODE)) | flags;
DPRINT("%*ssm: smResultInit = %08x\n", prevSMRL, "", (unsigned)&qCtrl);
@ -610,6 +637,52 @@ LRESULT MSG_SendMessage( HQUEUE hDestQueue, HWND hwnd, UINT msg,
WINBOOL MSG_PeekMessage( LPMSG msg, HWND hwnd, WORD first, WORD last,
WORD flags, WINBOOL peek )
{
#if 0
case MOUSE_EVENT:
MouseEvent = &Buffer.Event;
if ( MouseEvent->dwEventFlags == MOUSE_MOVED ) {
msg->hwnd = hwnd;
msg->message = WM_MOUSEMOVE;
msg->wParam = MouseEvent->dwControlKeyState;
msg->lParam =
MAKELONG(MouseEvent->dwMousePosition.X,MouseEvent->dwMousePosition.Y);
}
else if ( MouseEvent->dwEventFlags == DOUBLE_CLICK ) {
msg->hwnd = hwnd;
msg->message = WM_MBUTTONDBLCLK;
msg->wParam = MouseEvent->dwControlKeyState;
msg->lParam =
MAKELONG(MouseEvent->dwMousePosition.X,MouseEvent->dwMousePosition.Y);
}
else {
if (MouseEvent->dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED ) {
msg->hwnd = hwnd;
msg->message = WM_MBUTTONDOWN ;
msg->wParam = MouseEvent->dwControlKeyState;
msg->lParam =
MAKELONG(MouseEvent->dwMousePosition.X,MouseEvent->dwMousePosition.Y);
}
else {
msg->hwnd = hwnd;
msg->message = WM_MBUTTONUP ;
msg->wParam = MouseEvent->dwControlKeyState;
msg->lParam =
MAKELONG(MouseEvent->dwMousePosition.X,MouseEvent->dwMousePosition.Y);
}
}
break;
#endif
msg->hwnd = hwnd;
msg->message = WM_MBUTTONDBLCLK;
msg->wParam = 0;
msg->lParam = MAKELONG(200,200);
return TRUE;
#if 0
int pos, mask;
MESSAGEQUEUE *msgQueue;
HQUEUE hQueue;
@ -769,6 +842,9 @@ WINBOOL MSG_PeekMessage( LPMSG msg, HWND hwnd, WORD first, WORD last,
}
if (peek) return TRUE;
else return (msg->message != WM_QUIT);
#endif
}
/***********************************************************************
@ -1040,6 +1116,29 @@ WINBOOL MSG_DoTranslateMessage( UINT message, HWND hwnd,
}
LRESULT MSG_SendMessage( WND *wndPtr, UINT msg, WPARAM wParam, LPARAM lParam )
{
LRESULT ret;
if ( wndPtr == NULL )
return 0;
// if (QUEUE_IsExitingQueue(wndPtr->hmemTaskQ))
// return 0; /* Don't send anything if the task is dying */
if ( wndPtr->class->bUnicode )
ret = CallWindowProcW( (WNDPROC)wndPtr->winproc,
wndPtr->hwndSelf, msg, wParam, lParam );
else
ret = CallWindowProcA( (WNDPROC)wndPtr->winproc,
wndPtr->hwndSelf, msg, wParam, lParam );
return ret;
}
HTASK GetCurrentTask(void)
{
return (HTASK)-2;
@ -1054,7 +1153,7 @@ HQUEUE GetThreadQueue( DWORD thread )
{
if ( init == 0 ) {
init = 1;
memset(&Queue,0,sizeof(MESSAGEQUEUE));
HEAP_memset(&Queue,0,sizeof(MESSAGEQUEUE));
}
return hThreadQ;
}

View file

@ -1,8 +1,11 @@
#include <windows.h>
#include <stdlib.h>
#include <user32/nc.h>
#include <user32/syscolor.h>
#include <user32/debug.h>
// GetBitmapDimensionEx in NC_DrawMaxButton95 returns TRUE on invalid bitmap
static HBITMAP hbitmapClose = 0;
static HBITMAP hbitmapCloseD = 0;
static HBITMAP hbitmapMinimize = 0;
@ -126,6 +129,7 @@ NC_AdjustRectOuter95 (LPRECT rect, DWORD style, WINBOOL menu, DWORD exStyle)
/* Decide if the window will be managed (see CreateWindowEx) */
// Options.managed &&
if (!( !(style & WS_CHILD) &&
((style & (WS_DLGFRAME | WS_THICKFRAME)) ||
(exStyle & WS_EX_DLGMODALFRAME))))
@ -136,10 +140,10 @@ NC_AdjustRectOuter95 (LPRECT rect, DWORD style, WINBOOL menu, DWORD exStyle)
{
if (HAS_SIZEFRAME(style))
InflateRect( rect, SYSMETRICS_CXFRAME, SYSMETRICS_CYFRAME );
#if 0
if (style & WS_BORDER)
InflateRect( rect, SYSMETRICS_CXBORDER, SYSMETRICS_CYBORDER);
#endif
}
if ((style & WS_CAPTION) == WS_CAPTION)
@ -151,10 +155,12 @@ NC_AdjustRectOuter95 (LPRECT rect, DWORD style, WINBOOL menu, DWORD exStyle)
}
} else {
if (HAS_SIZEFRAME(style))
InflateRect( rect, SYSMETRICS_CXFRAME, SYSMETRICS_CYFRAME );
#if 0
if (style & WS_BORDER)
InflateRect( rect, SYSMETRICS_CXBORDER, SYSMETRICS_CYBORDER);
#endif
if ((style & WS_CAPTION) == WS_CAPTION)
{
@ -326,13 +332,13 @@ NC_GetInsideRect95 (HWND hwnd, RECT *rect)
InflateRect( rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER );*/
}
if (wndPtr->dwStyle & WS_CHILD) {
// if (wndPtr->dwStyle & WS_CHILD) {
if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
InflateRect(rect, -SYSMETRICS_CXEDGE, -SYSMETRICS_CYEDGE);
if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
InflateRect(rect, -SYSMETRICS_CXBORDER, -SYSMETRICS_CYBORDER);
}
// }
return;
}
@ -827,13 +833,22 @@ static void NC_DrawMaxButton95(
WND *wndPtr = WIN_FindWndPtr( hwnd );
SIZE bmsz;
HBITMAP bm;
BITMAP bmp;
HDC hdcMem;
if( !(wndPtr->flags & WIN_MANAGED) &&
if( !(wndPtr->flags & WIN_MANAGED) ) {
GetBitmapDimensionEx((bm = IsZoomed(hwnd) ?
(down ? hbitmapRestoreD : hbitmapRestore ) :
(down ? hbitmapMaximizeD : hbitmapMaximize)),
&bmsz)) {
(down ? hbitmapRestoreD : hbitmapRestore ) :
(down ? hbitmapMaximizeD : hbitmapMaximize)),
&bmsz);
if ( bmsz.cx == 0 || bmsz.cy == 0 ) {
GetObject(bm, sizeof(BITMAP), &bmp);
bmsz.cx = bmp.bmWidth;
bmsz.cy = bmp.bmHeight;
DPRINT("WARN GetBitmapDimensionEx returned 0 size ");
}
NC_GetInsideRect95( hwnd, &rect );
@ -1169,7 +1184,7 @@ static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd,
*
*****************************************************************************/
static void NC_DrawCaption95(
void NC_DrawCaption95(
HDC hdc,
RECT *rect,
HWND hwnd,
@ -1181,6 +1196,7 @@ static void NC_DrawCaption95(
WND *wndPtr = WIN_FindWndPtr( hwnd );
char buffer[256];
HPEN hPrevPen;
int txt;
if (wndPtr->flags & WIN_MANAGED) return;
@ -1188,7 +1204,7 @@ static void NC_DrawCaption95(
MoveToEx( hdc, r.left, r.bottom - 1, NULL );
LineTo( hdc, r.right, r.bottom - 1 );
SelectObject( hdc, hPrevPen );
r.bottom-2;
// r.bottom - 2;
FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION :
@ -1221,8 +1237,14 @@ static void NC_DrawCaption95(
NC_DrawMinButton95( hwnd, hdc, FALSE );
r.right -= SYSMETRICS_CXSIZE + 1;
}
if ( wndPtr->class->bUnicode )
txt = GetWindowTextW( hwnd, buffer, sizeof(buffer) );
else
txt = GetWindowTextA( hwnd, buffer, sizeof(buffer) );
if (GetWindowTextA( hwnd, buffer, sizeof(buffer) )) {
if (txt) {
NONCLIENTMETRICS nclm;
HFONT hFont, hOldFont;
nclm.cbSize = sizeof(NONCLIENTMETRICS);
@ -1236,7 +1258,11 @@ static void NC_DrawCaption95(
else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
SetBkMode( hdc, TRANSPARENT );
r.left += 2;
DrawTextA( hdc, buffer, -1, &r,
if ( wndPtr->class->bUnicode )
DrawTextW( hdc, buffer, -1, &r,
DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
else
DrawTextA( hdc, buffer, -1, &r,
DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
DeleteObject(SelectObject (hdc, hOldFont));
}
@ -1378,10 +1404,10 @@ void NC_DoNCPaint95(
if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ))) return;
if (ExcludeVisRect( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
wndPtr->rectClient.top-wndPtr->rectWindow.top,
wndPtr->rectClient.right-wndPtr->rectWindow.left,
wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
if (ExcludeVisRect( hdc, wndPtr->rectClient.left -wndPtr->rectWindow.left,
wndPtr->rectClient.top -wndPtr->rectWindow.top,
wndPtr->rectClient.right -wndPtr->rectWindow.left,
wndPtr->rectClient.bottom -wndPtr->rectWindow.top )
== NULLREGION)
{
ReleaseDC( hwnd, hdc );
@ -1495,10 +1521,10 @@ LONG NC_HandleNCActivate( WND *wndPtr, WPARAM wParam )
{
WORD wStateChange;
if( wParam ) wStateChange = !(wndPtr->flags & WIN_NCACTIVATED);
else wStateChange = wndPtr->flags & WIN_NCACTIVATED;
// if( wParam ) wStateChange = !(wndPtr->flags & WIN_NCACTIVATED);
// else wStateChange = wndPtr->flags & WIN_NCACTIVATED;
if( wStateChange )
// if( wStateChange )
{
if (wParam) wndPtr->flags |= WIN_NCACTIVATED;
else wndPtr->flags &= ~WIN_NCACTIVATED;

View file

@ -15,6 +15,7 @@
/* Last CTLCOLOR id */
//#define CTLCOLOR_MAX CTLCOLOR_STATIC
HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType );
/***********************************************************************
@ -45,28 +46,21 @@ WINBOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate,
if (!hwnd) hwnd = GetDesktopWindow();
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
#ifdef OPTIMIZE
if (!WIN_IsWindowDrawable( wndPtr, !(flags & RDW_FRAME) ) )
return TRUE; /* No redraw needed */
#endif
bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
if (rectUpdate)
{
DPRINT( "%04x %d,%d-%d,%d %04x flags=%04x\n",
hwnd, rectUpdate->left, rectUpdate->top,
rectUpdate->right, rectUpdate->bottom, hrgnUpdate, flags );
}
else
{
DPRINT( "%04x NULL %04x flags=%04x\n", hwnd, hrgnUpdate, flags);
}
GetClientRect( hwnd, &rectClient );
if (flags & RDW_INVALIDATE) /* Invalidate */
{
int rgnNotEmpty = COMPLEXREGION;
if (wndPtr->hrgnUpdate > 1) /* Is there already an update region? */
if (wndPtr->hrgnUpdate > (HRGN)1) /* Is there already an update region? */
{
if ((hrgn = hrgnUpdate) == 0)
hrgn = CreateRectRgnIndirect( rectUpdate ? rectUpdate :
@ -116,7 +110,7 @@ WINBOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate,
else if (flags & RDW_VALIDATE) /* Validate */
{
/* We need an update region in order to validate anything */
if (wndPtr->hrgnUpdate > 1)
if (wndPtr->hrgnUpdate > (HRGN)1)
{
if (!hrgnUpdate && !rectUpdate)
{
@ -148,13 +142,13 @@ WINBOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate,
if (flags & RDW_INTERNALPAINT)
{
if ( wndPtr->hrgnUpdate <= 1 && !(wndPtr->flags & WIN_INTERNAL_PAINT))
if ( wndPtr->hrgnUpdate <= (HRGN)1 && !(wndPtr->flags & WIN_INTERNAL_PAINT))
QUEUE_IncPaintCount( wndPtr->hmemTaskQ );
wndPtr->flags |= WIN_INTERNAL_PAINT;
}
else if (flags & RDW_NOINTERNALPAINT)
{
if ( wndPtr->hrgnUpdate <= 1 && (wndPtr->flags & WIN_INTERNAL_PAINT))
if ( wndPtr->hrgnUpdate <= (HRGN)1 && (wndPtr->flags & WIN_INTERNAL_PAINT))
QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
wndPtr->flags &= ~WIN_INTERNAL_PAINT;
}
@ -168,10 +162,10 @@ WINBOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate,
}
else if (flags & RDW_ERASENOW)
{
if (wndPtr->flags & WIN_NEEDS_NCPAINT)
//if (wndPtr->flags & WIN_NEEDS_NCPAINT)
WIN_UpdateNCArea( wndPtr, FALSE);
if (wndPtr->flags & WIN_NEEDS_ERASEBKGND)
//if (wndPtr->flags & WIN_NEEDS_ERASEBKGND)
{
HDC hdc = GetDCEx( hwnd, wndPtr->hrgnUpdate,
DCX_INTERSECTRGN | DCX_USESTYLE |
@ -249,3 +243,36 @@ WINBOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate,
return TRUE;
}
/***********************************************************************
* GetControlBrush Not A Win32 API
*/
HBRUSH GetControlBrush( HWND hwnd, HDC hdc, UINT ctlType )
{
WND* wndPtr = WIN_FindWndPtr( hwnd );
if((ctlType <= CTLCOLOR_MAX) && wndPtr )
{
WND* parent;
if( wndPtr->dwStyle & WS_POPUP ) parent = wndPtr->owner;
else parent = wndPtr->parent;
if( !parent ) parent = wndPtr;
return (HBRUSH)PAINT_GetControlBrush( parent->hwndSelf, hwnd, hdc, ctlType );
}
return (HBRUSH)0;
}
/***********************************************************************
* PAINT_GetControlBrush
*/
HBRUSH PAINT_GetControlBrush( HWND hParent, HWND hWnd, HDC hDC, UINT ctlType )
{
LOGBRUSH LogBrush;
HBRUSH bkgBrush = (HBRUSH)SendMessageA( hParent, WM_CTLCOLORMSGBOX + ctlType,
(WPARAM)hDC, (LPARAM)hWnd );
if( !GetObject(bkgBrush,sizeof(LOGBRUSH),&LogBrush) )
bkgBrush = DEFWND_ControlColor( hDC, ctlType );
return bkgBrush;
}

View file

@ -10,6 +10,7 @@
#include <user32/scroll.h>
#include <user32/msg.h>
#include <user32/win.h>
#include <user32/caret.h>
#include <user32/debug.h>
#define MAKEINTRESOURCEA(x) "x"
@ -1065,4 +1066,33 @@ done:
/* Return current position */
return infoPtr->CurVal;
}
/*************************************************************************
* SCROLL_FixCaret
*/
WINBOOL SCROLL_FixCaret(HWND hWnd, LPRECT lprc, UINT flags)
{
HWND hCaret = CARET_GetHwnd();
if( hCaret )
{
RECT rc;
CARET_GetRect( &rc );
if( hCaret == hWnd ||
(flags & SW_SCROLLCHILDREN && IsChild(hWnd, hCaret)) )
{
POINT pt;
pt.x = rc.left; pt.y = rc.top;
MapWindowPoints( hCaret, hWnd, (LPPOINT)&rc, 2 );
if( IntersectRect(lprc, lprc, &rc) )
{
HideCaret(0);
lprc->left = pt.x; lprc->top = pt.y;
return TRUE;
}
}
}
return FALSE;
}

View file

@ -6,9 +6,9 @@
*/
#include <windows.h>
#include <user32/syscolor.h>
#include <user32/debug.h>
HPEN STDCALL GetSysColorPen( INT index );
static const WORD wPattern_AA55[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555,
0xaaaa, 0x5555, 0xaaaa, 0x5555 };
@ -18,11 +18,7 @@ static const WORD wPattern_AA55[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555,
* UITOOLS_DrawRectEdge()
*/
/* DrawEdge() flags */
#define BDR_RAISEDOUTER 0x0001
#define BDR_SUNKENOUTER 0x0002
#define BDR_RAISEDINNER 0x0004
#define BDR_SUNKENINNER 0x0008
#define BDR_OUTER 0x0003
#define BDR_INNER 0x000c

View file

@ -9,6 +9,8 @@
#include <user32/dce.h>
#include <user32/caret.h>
#include <user32/debug.h>
#include <user32/heapdup.h>
#include <user32/dialog.h>
WND *rootWnd;
//////////////////////////////////////////////////////////////////////////////////
@ -93,7 +95,7 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom)
? MENU_GetSysMenu( hWnd, 0 ) : 0;
if (classPtr->cbWndExtra)
memset( wndPtr->wExtra, 0, classPtr->cbWndExtra);
HEAP_memset( wndPtr->wExtra, 0, classPtr->cbWndExtra);
/* Call the WH_CBT hook */
@ -107,7 +109,7 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom)
cbtc.lpcs = cs;
cbtc.hwndInsertAfter = hWndLinkAfter;
ret = HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, hWnd, (LPARAM)&cbtc);
ret = HOOK_CallHooks(WH_CBT, HCBT_CREATEWND, (INT)hWnd, (LPARAM)&cbtc, classPtr->bUnicode);
if (ret)
{
@ -232,21 +234,14 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom)
maxPos.x = wndPtr->rectWindow.left;
maxPos.y = wndPtr->rectWindow.top;
if ( classPtr->bUnicode == TRUE ) {
if( SendMessageW( hWnd, WM_NCCREATE, 0, (LPARAM)cs) == 0)
{
if( MSG_SendMessage( wndPtr, WM_NCCREATE, 0, (LPARAM)cs) == 0)
{
/* Abort window creation */
WIN_DestroyWindow( wndPtr );
return NULL;
}
} else {
if( SendMessageA( hWnd, WM_NCCREATE, 0, (LPARAM)cs) == 0)
{
/* Abort window creation */
WIN_DestroyWindow( wndPtr );
return NULL;
}
WIN_DestroyWindow( wndPtr );
return NULL;
}
/* Insert the window in the linked list */
@ -258,7 +253,7 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom)
maxPos.y - wndPtr->rectWindow.top);
if( (SendMessageA( hWnd, WM_CREATE, 0, (LPARAM)cs )) == -1 )
if( (MSG_SendMessage( wndPtr, WM_CREATE, 0, (LPARAM)cs)) == -1 )
{
WIN_UnlinkWindow( hWnd );
WIN_DestroyWindow( wndPtr );
@ -272,12 +267,12 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom)
if (((wndPtr->rectClient.right-wndPtr->rectClient.left) <0)
||((wndPtr->rectClient.bottom-wndPtr->rectClient.top)<0))
SendMessageA( hWnd, WM_SIZE, SIZE_RESTORED,
MSG_SendMessage( wndPtr, WM_SIZE, SIZE_RESTORED,
MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
wndPtr->rectClient.bottom-wndPtr->rectClient.top));
SendMessageA( hWnd, WM_MOVE, 0,
MSG_SendMessage( wndPtr, WM_MOVE, 0,
MAKELONG( wndPtr->rectClient.left,
wndPtr->rectClient.top ) );
wndPtr->rectClient.top) );
}
/* Show the window, maximizing or minimizing if needed */
@ -299,7 +294,7 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom)
{
/* Notify the parent window only */
SendMessageA( wndPtr->parent->hwndSelf, WM_PARENTNOTIFY,
MSG_SendMessage( wndPtr->parent, WM_PARENTNOTIFY,
MAKEWPARAM(WM_CREATE, wndPtr->wIDmenu), (LPARAM)hWnd );
if( !IsWindow(hWnd) ) return 0;
}
@ -310,7 +305,7 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom)
/* Call WH_SHELL hook */
if (!(wndPtr->dwStyle & WS_CHILD) && !wndPtr->owner)
HOOK_CallHooksW( WH_SHELL, HSHELL_WINDOWCREATED, hWnd, 0L );
HOOK_CallHooks( WH_SHELL, HSHELL_WINDOWCREATED, (INT)hWnd, 0L, classPtr->bUnicode);
return hWnd;
@ -318,6 +313,12 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom)
}
WINBOOL WIN_IsWindow(HANDLE hWnd)
{
if (WIN_FindWndPtr( hWnd ) == NULL) return FALSE;
return TRUE;
}
/***********************************************************************
* WIN_FindWinToRepaint
*
@ -446,7 +447,7 @@ LONG WIN_SetWindowLong( HWND hwnd, INT offset, LONG newval )
/* Special case for dialog window procedure */
if ((offset == DWL_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG))
{
retval = ptr;
retval = (LONG)ptr;
*ptr = newval;
return (LONG)retval;
}
@ -454,12 +455,12 @@ LONG WIN_SetWindowLong( HWND hwnd, INT offset, LONG newval )
else switch(offset)
{
case GWL_ID:
ptr = (DWORD*)&wndPtr->wIDmenu;
ptr = (LONG*)&wndPtr->wIDmenu;
break;
case GWL_HINSTANCE:
return SetWindowWord( hwnd, offset, newval );
return (LONG)SetWindowWord( hwnd, offset, newval );
case GWL_WNDPROC:
retval = wndPtr->winproc;
retval = (LONG)wndPtr->winproc;
wndPtr->winproc = (WNDPROC)newval;
return retval;
case GWL_STYLE:
@ -467,24 +468,22 @@ LONG WIN_SetWindowLong( HWND hwnd, INT offset, LONG newval )
newval &= ~(WS_VISIBLE | WS_CHILD); /* Some bits can't be changed this way */
style.styleNew = newval | (style.styleOld & (WS_VISIBLE | WS_CHILD));
//if (wndPtr->flags & WIN_ISWIN32)
SendMessageA(hwnd,WM_STYLECHANGING,GWL_STYLE,(LPARAM)&style);
MSG_SendMessage(wndPtr,WM_STYLECHANGING,GWL_STYLE,(LPARAM)&style);
wndPtr->dwStyle = style.styleNew;
//if (wndPtr->flags & WIN_ISWIN32)
SendMessageA(hwnd,WM_STYLECHANGED,GWL_STYLE,(LPARAM)&style);
MSG_SendMessage(wndPtr,WM_STYLECHANGED,GWL_STYLE,(LPARAM)&style);
return style.styleOld;
case GWL_USERDATA:
ptr = &wndPtr->userdata;
ptr = (LONG *)&wndPtr->userdata;
break;
case GWL_EXSTYLE:
style.styleOld = wndPtr->dwExStyle;
style.styleNew = newval;
//if (wndPtr->flags & WIN_ISWIN32)
SendMessageA(hwnd,WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&style);
wndPtr->dwExStyle = newval;
//if (wndPtr->flags & WIN_ISWIN32)
SendMessageA(hwnd,WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&style);
MSG_SendMessage(wndPtr,WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&style);
wndPtr->dwExStyle = newval;
MSG_SendMessage(wndPtr,WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&style);
return style.styleOld;
default:
@ -511,19 +510,20 @@ WINBOOL WIN_DestroyWindow( WND* wndPtr )
HWND hWnd;
WND *pWnd;
if ( wndPtr == NULL )
return FALSE;
hWnd = wndPtr->hwndSelf;
#ifdef CONFIG_IPC
if (main_block)
DDE_DestroyWindow(wndPtr->hwndSelf);
#endif /* CONFIG_IPC */
/* free child windows */
while ((pWnd = wndPtr->child))
wndPtr->child = WIN_DestroyWindow( pWnd );
if ( !WIN_DestroyWindow( pWnd ) )
break;
SendMessageA( wndPtr->hwndSelf, WM_NCDESTROY, 0, 0);
MSG_SendMessage( wndPtr, WM_NCDESTROY, 0, 0);
/* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
@ -570,9 +570,9 @@ WINBOOL WIN_DestroyWindow( WND* wndPtr )
if (!(wndPtr->dwStyle & WS_CHILD))
if (wndPtr->wIDmenu) DestroyMenu( (HMENU)wndPtr->wIDmenu );
if (wndPtr->hSysMenu) DestroyMenu( wndPtr->hSysMenu );
//wndPtr->pDriver->pDestroyWindow( wndPtr );
//DeleteDC(wndPtr->dc) /* Always do this to catch orphaned DCs */
// DeleteDC(wndPtr->dc) /* Always do this to catch orphaned DCs */
wndPtr->winproc = NULL;
wndPtr->hwndSelf = NULL;
@ -779,10 +779,7 @@ WINBOOL WIN_LinkWindow( HWND hWnd, HWND hWndInsertAfter )
void WIN_UpdateNCArea(WND* wnd, BOOL bUpdate)
{
POINT pt = {0, 0};
HRGN hClip = 1;
DPRINT("hwnd %04x, hrgnUpdate %04x\n",
wnd->hwndSelf, wnd->hrgnUpdate );
HRGN hClip = (HRGN)1;
/* desktop window doesn't have nonclient area */
if(wnd == WIN_GetDesktop())
@ -791,7 +788,7 @@ void WIN_UpdateNCArea(WND* wnd, BOOL bUpdate)
return;
}
if( wnd->hrgnUpdate > 1 )
if( wnd->hrgnUpdate > (HRGN)1 )
{
ClientToScreen(wnd->hwndSelf, &pt);
@ -799,7 +796,7 @@ void WIN_UpdateNCArea(WND* wnd, BOOL bUpdate)
if (!CombineRgn( hClip, wnd->hrgnUpdate, 0, RGN_COPY ))
{
DeleteObject(hClip);
hClip = 1;
hClip = (HRGN)1;
}
else
OffsetRgn( hClip, pt.x, pt.y );
@ -815,7 +812,7 @@ void WIN_UpdateNCArea(WND* wnd, BOOL bUpdate)
hrgn, RGN_AND) == NULLREGION))
{
DeleteObject( wnd->hrgnUpdate );
wnd->hrgnUpdate = 1;
wnd->hrgnUpdate = (HRGN)1;
}
DeleteObject( hrgn );
@ -824,17 +821,19 @@ void WIN_UpdateNCArea(WND* wnd, BOOL bUpdate)
wnd->flags &= ~WIN_NEEDS_NCPAINT;
#ifdef OPTIMIZE
if ((wnd->hwndSelf == GetActiveWindow()) &&
!(wnd->flags & WIN_NCACTIVATED))
{
wnd->flags |= WIN_NCACTIVATED;
if( hClip > 1) DeleteObject( hClip );
hClip = 1;
if( hClip > (HRGN)1) DeleteObject( hClip );
hClip = (HRGN)1;
}
#endif
if (hClip) SendMessage( wnd->hwndSelf, WM_NCPAINT, hClip, 0L );
if (hClip) MSG_SendMessage( wnd, WM_NCPAINT, (WPARAM)hClip, 0L );
if (hClip > 1) DeleteObject( hClip );
if (hClip > (HRGN)1) DeleteObject( hClip );
}
/***********************************************************************
@ -888,9 +887,9 @@ void WIN_SendDestroyMsg( WND* pWnd )
WIN_CheckFocus(pWnd);
if( CARET_GetHwnd() == pWnd->hwndSelf ) DestroyCaret();
// CLIPBOARD_GetDriver()->pResetOwner( pWnd, TRUE );
SendMessageA( pWnd->hwndSelf, WM_DESTROY, 0, 0);
MSG_SendMessage( pWnd, WM_DESTROY, 0, 0);
if( IsWindow(pWnd->hwndSelf) )
{
@ -907,6 +906,26 @@ void WIN_SendDestroyMsg( WND* pWnd )
}
/***********************************************************************
* IsDialogMessage (USER32.90)
*/
WINBOOL STDCALL WIN_IsDialogMessage( HWND hwndDlg, LPMSG msg )
{
WINBOOL ret, translate, dispatch;
INT dlgCode;
if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd ))
return FALSE;
dlgCode = SendMessage( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg);
ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
msg->wParam, msg->lParam,
&translate, &dispatch, dlgCode );
if (translate) TranslateMessage( msg );
if (dispatch) DispatchMessage( msg );
return ret;
}

View file

@ -1,25 +1,36 @@
all: user32.exe
INTERNAL_OBJECTS = internal/property.o internal/menu.o internal/heapdup.o internal/nc.o\
internal/scroll.o internal/win.o internal/dce.o internal/msg.o internal/queue.o\
internal/win.o internal/dce.o internal/msg.o internal/queue.o\
internal/signal.o internal/event.o internal/timer.o internal/region.o\
internal/text.o internal/defwnd.o internal/paint.o internal/uitools.o
internal/text.o internal/defwnd.o internal/paint.o internal/uitools.o\
internal/dialog.o
MISC_OBJECTS = misc/sprintf.o misc/dllmain.o misc/string.o misc/sysmetr.o\
misc/main.o misc/bitmap.o misc/cursor.o misc/vk.o
WINDOWS_OBJECTS = windows/wndproc.o windows/win.o windows/hook.o windows/spy.o\
windows/queue.o windows/winpos.o windows/class.o windows/menu.o windows/dc.o\
windows/queue.o windows/winpos.o windows/class.o windows/dc.o\
windows/timer.o windows/rect.o windows/msg.o windows/input.o windows/property.o\
windows/focus.o windows/paint.o
windows/focus.o windows/paint.o windows/msgbox.o windows/dialog.o\
windows/scroll.o windows/defdlg.o
GRAPHICS_OBJECTS = graphics/rect.o graphics/caret.o graphics/text.o graphics/syscol.o graphics/fill.o\
graphics/draw.o graphics/icon.o
RESOURCE_OBJECTS = resources/sysres.o
CONTROLS_OBJECTS = controls/button.o controls/combo.o controls/edit.o controls/icontitle.o controls/listbox.o\
controls/widgets.o controls/menu.o controls/scroll.o controls/static.o
OBJECTS = $(MISC_OBJECTS) $(INTERNAL_OBJECTS) $(GRAPHICS_OBJECTS) $(RESOURCE_OBJECTS) $(WINDOWS_OBJECTS)
RESOURCE_OBJECTS = resources/sysres.o
RESOURCE_OBJECT = user32.coff
OBJECTS = $(MISC_OBJECTS) $(INTERNAL_OBJECTS) $(GRAPHICS_OBJECTS) $(RESOURCE_OBJECTS) $(RESOURCE_OBJECT)\
$(CONTROLS_OBJECTS) $(WINDOWS_OBJECTS)
user32.coff: user32.rc ../../include/reactos/resource.h
windres user32.rc user32.coff
user32.exe: $(OBJECTS)
$(LD) $(OBJECTS) F:/gnu/cygnus/cygwin-b20/H-i586-cygwin32/i586-cygwin32/lib/crt1.o ./libgdi32.a ./libkernel32.a ./libcrtdll.a -o user32.exe

View file

@ -84,3 +84,6 @@ HBITMAP BITMAP_LoadBitmapW(HINSTANCE instance,LPCWSTR name,
return hbitmap;
#endif
}

View file

@ -1,9 +1,12 @@
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK WindowFunc(HWND,UINT,WPARAM, LPARAM);
char szName[] = "Hallo";
int _CRT_fmode = 0;
int _CRT_glob = 0;
@ -13,24 +16,34 @@ int __main(int argc, char **argv)
}
int i;
int main(int argc, char **argv)
{
WIDGETS_Init();
#if 0
HWND hwnd;
HWND User32hWnd;
HMENU hmenu;
MSG msg;
WNDCLASSEX wc1;
HINSTANCE hInst = 0;
int nWinMode = SW_SHOW;
unsigned short *test;
RECT rect;
HANDLE hMod, hrsrc;
RECT rect, cl;
wc1.hInstance = hInst;
wc1.lpszClassName = szName;
wc1.lpfnWndProc = WindowFunc;
wc1.style = 0;
wc1.cbSize = sizeof(WNDCLASSEX);
wc1.hIcon = NULL;
wc1.hIconSm = NULL;
wc1.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wc1.hIconSm = LoadIcon(NULL,IDI_WINLOGO);;
wc1.hCursor = NULL;
wc1.lpszMenuName = NULL;
@ -38,21 +51,30 @@ int main(int argc, char **argv)
wc1.cbClsExtra = 0;
wc1.cbWndExtra = 0;
wc1.hbrBackground = NULL;
wc1.hbrBackground = GetStockObject(WHITE_BRUSH);
if ( !RegisterClassEx(&wc1)) return 0;
hmenu = CreateMenu();
hwnd = CreateWindowEx(0, szName, "test", WS_OVERLAPPEDWINDOW,
hwnd = CreateWindowEx
(0, szName, "test2", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
NULL,hmenu,hInst, NULL);
NULL,NULL,hInst, NULL);
MessageBox(NULL,"Hallo","Hallo",MB_OK);
ShowWindow(hwnd,nWinMode);
UpdateWindow(hwnd);
#endif
MessageBox(NULL,"xxx","yyyy",MB_OK);
#if 0
GetWindowRect(hwnd,&rect);
GetClientRect(hwnd,&cl);
SetWindowText(hwnd,"Hallo");
printf("%d\n",(rect.left - rect.right) - (cl.left - cl.right));
SetWindowText(hwnd,"Hallo3");
DrawMenuBar(hwnd);
// SendMessage( hwnd, WM_MOVE, 0,MAKELONG(0,0));
@ -64,10 +86,11 @@ int main(int argc, char **argv)
}
Sleep(10000);
return msg.wParam;
#endif
}
//printf("hallo\n");

View file

@ -9,5 +9,7 @@
LPCVOID SYSRES_GetResPtr( int id )
{
// return SYSRES_Resources[Options.language][id]->data;
return NULL;
}

View file

@ -4,8 +4,8 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
VS_VERSION_INFO VERSIONINFO
FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
FILEVERSION 0,0,13,RES_UINT_FILE_VERSION
PRODUCTVERSION 0,0,13,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -22,7 +22,7 @@ BEGIN
BEGIN
VALUE "CompanyName", RES_STR_COMPANY_NAME
VALUE "FileDescription", "ReactOS User API Client Dll\0"
VALUE "FileVersion", RES_STR_FILE_VERSION
VALUE "FileVersion", "post 0.0.13\0"
VALUE "InternalName", "user32\0"
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
VALUE "OriginalFilename", "user32.dll\0"
@ -36,3 +36,23 @@ BEGIN
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
MSGBOX DIALOG DISCARDABLE 100, 80, 216, 168
STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
FONT 8, "MS Sans Serif"
BEGIN
ICON "", 1088, 9, 20, 16, 16, WS_CHILD | WS_VISIBLE
LTEXT "", 100, 32, 4, 176, 48, WS_CHILD | WS_VISIBLE | WS_GROUP
PUSHBUTTON "&OK", 1, 16, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Cancel", 2, 64, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Abort", 3, 112, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Retry", 4, 160, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Ignore", 5, 208, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Yes", 6, 256, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&No", 7, 304, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
END

View file

@ -1,10 +1,19 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/user32/windows/class.c
* PURPOSE: Registers a window class
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/05/99: Created
*/
#include <windows.h>
#include <user32/class.h>
#include <user32/win.h>
#include <user32/dce.h>
#include <user32/heapdup.h>
CLASS *rootClass;
ATOM STDCALL RegisterClassA(const WNDCLASS* wc)
@ -80,7 +89,7 @@ ATOM STDCALL RegisterClassExA(const WNDCLASSEX* wc)
if (classExtra)
memset( classPtr->wExtra, 0, classExtra );
HEAP_memset( classPtr->wExtra, 0, classExtra );
if (!classPtr) {
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
@ -136,7 +145,7 @@ ATOM STDCALL RegisterClassExW( const WNDCLASSEX* wc )
CLASS *classPtr;
INT classExtra, winExtra;
int i, len;
int len;
if ( wc == NULL || wc->cbSize != sizeof(WNDCLASSEX)) {
SetLastError(ERROR_INVALID_DATA);
return FALSE;
@ -165,7 +174,7 @@ ATOM STDCALL RegisterClassExW( const WNDCLASSEX* wc )
if (classExtra)
memset( classPtr->wExtra, 0, classExtra );
HEAP_memset( classPtr->wExtra, 0, classExtra );
if (!classPtr) {
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
@ -189,13 +198,17 @@ ATOM STDCALL RegisterClassExW( const WNDCLASSEX* wc )
classPtr->dce = (wc->style & CS_CLASSDC) ?
CreateDC( "DISPLAY", NULL,NULL,NULL ) : NULL;
len = lstrlenW((LPWSTR)wc->lpszMenuName);
classPtr->menuName = HeapAlloc(GetProcessHeap(),0,(len+1)*2);
lstrcpyW((LPWSTR)classPtr->menuName, (LPWSTR)wc->lpszMenuName);
if ( wc->lpszMenuName != NULL ) {
len = lstrlenW(wc->lpszMenuName);
classPtr->menuName = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(len+1));
lstrcpyW(classPtr->menuName,wc->lpszMenuName);
}
else
classPtr->menuName = NULL;
len = lstrlenW((LPWSTR)wc->lpszClassName);
classPtr->className = HeapAlloc(GetProcessHeap(),0,(len+1)*2);
classPtr->className = HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
lstrcpyW((LPWSTR)classPtr->className,(LPWSTR) wc->lpszClassName );
classPtr->next = rootClass;
@ -283,7 +296,7 @@ WINBOOL GetClassInfoExW( HINSTANCE hInstance, LPCWSTR lpClassName, LPWNDCLASSE
if ( HIWORD(lpClassName) != 0 )
a = FindAtomW(lpClassName);
else
a = lpClassName;
a = (ATOM)lpClassName;
classPtr = CLASS_FindClassByAtom( a, hInstance );
if ( classPtr == NULL )
@ -408,7 +421,7 @@ WORD STDCALL GetClassWord( HWND hWnd, INT nIndex )
if (nIndex >= 0)
{
if (nIndex <= wndPtr->class->cbClsExtra - sizeof(WORD))
return (WORD)((char *)wndPtr->class->wExtra) + nIndex;
return (WORD)(wndPtr->class->wExtra + nIndex);
}
else switch(nIndex)
{

View file

@ -0,0 +1,374 @@
/*
* Default dialog procedure
*
* Copyright 1993, 1996 Alexandre Julliard
*
*/
#include <windows.h>
#include <user32/widgets.h>
#include <user32/dialog.h>
#include <user32/win.h>
/***********************************************************************
* DEFDLG_SetFocus
*
* Set the focus to a control of the dialog, selecting the text if
* the control is an edit dialog.
*/
static void DEFDLG_SetFocus( HWND hwndDlg, HWND hwndCtrl )
{
HWND hwndPrev = GetFocus();
if (IsChild( hwndDlg, hwndPrev ))
{
if (SendMessage( hwndPrev, WM_GETDLGCODE, 0, 0 ) & DLGC_HASSETSEL)
SendMessage( hwndPrev, EM_SETSEL, TRUE, MAKELONG( -1, 0 ) );
}
if (SendMessage( hwndCtrl, WM_GETDLGCODE, 0, 0 ) & DLGC_HASSETSEL)
SendMessage( hwndCtrl, EM_SETSEL, FALSE, MAKELONG( 0, -1 ) );
SetFocus( hwndCtrl );
}
/***********************************************************************
* DEFDLG_SaveFocus
*/
static BOOL DEFDLG_SaveFocus( HWND hwnd, DIALOGINFO *infoPtr )
{
HWND hwndFocus = GetFocus();
if (!hwndFocus || !IsChild( hwnd, hwndFocus )) return FALSE;
infoPtr->hwndFocus = hwndFocus;
/* Remove default button */
return TRUE;
}
/***********************************************************************
* DEFDLG_RestoreFocus
*/
static BOOL DEFDLG_RestoreFocus( HWND hwnd, DIALOGINFO *infoPtr )
{
if (!infoPtr->hwndFocus || IsIconic(hwnd)) return FALSE;
if (!IsWindow( infoPtr->hwndFocus )) return FALSE;
DEFDLG_SetFocus( hwnd, infoPtr->hwndFocus );
/* This used to set infoPtr->hwndFocus to NULL for no apparent reason,
sometimes losing focus when receiving WM_SETFOCUS messages. */
return TRUE;
}
/***********************************************************************
* DEFDLG_FindDefButton
*
* Find the current default push-button.
*/
static HWND DEFDLG_FindDefButton( HWND hwndDlg )
{
HWND hwndChild = GetWindow( hwndDlg, GW_CHILD );
while (hwndChild)
{
if (SendMessage( hwndChild, WM_GETDLGCODE, 0, 0 ) & DLGC_DEFPUSHBUTTON)
break;
hwndChild = GetWindow( hwndChild, GW_HWNDNEXT );
}
return hwndChild;
}
/***********************************************************************
* DEFDLG_SetDefButton
*
* Set the new default button to be hwndNew.
*/
static BOOL DEFDLG_SetDefButton( HWND hwndDlg, DIALOGINFO *dlgInfo,
HWND hwndNew )
{
if (hwndNew &&
!(SendMessage(hwndNew, WM_GETDLGCODE, 0, 0 ) & DLGC_UNDEFPUSHBUTTON))
return FALSE; /* Destination is not a push button */
if (dlgInfo->idResult) /* There's already a default pushbutton */
{
HWND hwndOld = GetDlgItem( hwndDlg, dlgInfo->idResult );
if (SendMessageA( hwndOld, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
SendMessageA( hwndOld, BM_SETSTYLE, BS_PUSHBUTTON, TRUE );
}
if (hwndNew)
{
SendMessageA( hwndNew, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
dlgInfo->idResult = GetDlgCtrlID( hwndNew );
}
else dlgInfo->idResult = 0;
return TRUE;
}
/***********************************************************************
* DEFDLG_Proc
*
* Implementation of DefDlgProc(). Only handle messages that need special
* handling for dialogs.
*/
LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam, DIALOGINFO *dlgInfo )
{
switch(msg)
{
case WM_ERASEBKGND:
FillWindow( hwnd, hwnd, (HDC)wParam, (HBRUSH)CTLCOLOR_DLG );
return 1;
case WM_NCDESTROY:
/* Free dialog heap (if created) */
if (dlgInfo->hDialogHeap)
{
GlobalUnlock(dlgInfo->hDialogHeap);
GlobalFree(dlgInfo->hDialogHeap);
dlgInfo->hDialogHeap = 0;
}
/* Delete font */
if (dlgInfo->hUserFont)
{
DeleteObject( dlgInfo->hUserFont );
dlgInfo->hUserFont = 0;
}
/* Delete menu */
if (dlgInfo->hMenu)
{
DestroyMenu( dlgInfo->hMenu );
dlgInfo->hMenu = 0;
}
/* Delete window procedure */
//WINPROC_FreeProc( dlgInfo->dlgProc, WIN_PROC_WINDOW );
dlgInfo->dlgProc = NULL;
dlgInfo->flags |= DF_END; /* just in case */
/* Window clean-up */
return DefWindowProcA( hwnd, msg, wParam, lParam );
case WM_SHOWWINDOW:
if (!wParam) DEFDLG_SaveFocus( hwnd, dlgInfo );
return DefWindowProcA( hwnd, msg, wParam, lParam );
case WM_ACTIVATE:
if (wParam) DEFDLG_RestoreFocus( hwnd, dlgInfo );
else DEFDLG_SaveFocus( hwnd, dlgInfo );
return 0;
case WM_SETFOCUS:
DEFDLG_RestoreFocus( hwnd, dlgInfo );
return 0;
case DM_SETDEFID:
if (dlgInfo->flags & DF_END) return 1;
DEFDLG_SetDefButton( hwnd, dlgInfo,
wParam ? GetDlgItem( hwnd, wParam ) : 0 );
return 1;
case DM_GETDEFID:
{
HWND hwndDefId;
if (dlgInfo->flags & DF_END) return 0;
if (dlgInfo->idResult)
return MAKELONG( dlgInfo->idResult, DC_HASDEFID );
if ((hwndDefId = DEFDLG_FindDefButton( hwnd )))
return MAKELONG( GetDlgCtrlID( hwndDefId ), DC_HASDEFID);
}
return 0;
case WM_NEXTDLGCTL:
{
HWND hwndDest = (HWND)wParam;
if (!lParam)
hwndDest = GetNextDlgTabItem(hwnd, GetFocus(), wParam);
if (hwndDest) DEFDLG_SetFocus( hwnd, hwndDest );
DEFDLG_SetDefButton( hwnd, dlgInfo, hwndDest );
}
return 0;
case WM_ENTERMENULOOP:
case WM_LBUTTONDOWN:
case WM_NCLBUTTONDOWN:
{
HWND hwndFocus = GetFocus();
if (hwndFocus)
{
WND *wnd = WIN_FindWndPtr( hwndFocus );
if( wnd )
{
/* always make combo box hide its listbox control */
if( WIDGETS_IsControl( wnd, BIC_COMBO ) )
SendMessageA( hwndFocus, CB_SHOWDROPDOWN,
FALSE, 0 );
else if( WIDGETS_IsControl( wnd, BIC_EDIT ) &&
WIDGETS_IsControl( wnd->parent,
BIC_COMBO ))
SendMessageA( wnd->parent->hwndSelf,
CB_SHOWDROPDOWN, FALSE, 0 );
}
}
}
return DefWindowProcA( hwnd, msg, wParam, lParam );
case WM_GETFONT:
return dlgInfo->hUserFont;
case WM_CLOSE:
PostMessageA( hwnd, WM_COMMAND, IDCANCEL,
(LPARAM)GetDlgItem( hwnd, IDCANCEL ) );
return 0;
}
return 0;
}
/***********************************************************************
* DEFDLG_Epilog
*/
LRESULT DEFDLG_Epilog(DIALOGINFO* dlgInfo, UINT msg, BOOL fResult)
{
/* see SDK 3.1 */
if ((msg >= WM_CTLCOLORMSGBOX && msg <= WM_CTLCOLORSTATIC) ||
msg == WM_CTLCOLOR || msg == WM_COMPAREITEM ||
msg == WM_VKEYTOITEM || msg == WM_CHARTOITEM ||
msg == WM_QUERYDRAGICON || msg == WM_INITDIALOG)
return fResult;
return dlgInfo->msgResult;
}
/***********************************************************************
* DefDlgProcA (USER.120)
*/
LRESULT WINAPI DefDlgProcA( HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam )
{
DIALOGINFO * dlgInfo;
BOOL result = FALSE;
WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return 0;
dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
dlgInfo->msgResult = 0;
if (dlgInfo->dlgProc) { /* Call dialog procedure */
result = CallWindowProcA( (WNDPROC)dlgInfo->dlgProc,
hwnd, msg, wParam, lParam );
/* Check if window was destroyed by dialog procedure */
if (dlgInfo->flags & DF_END && !(dlgInfo->flags & DF_ENDING)) {
dlgInfo->flags |= DF_ENDING;
DestroyWindow( hwnd );
}
}
if (!result && IsWindow(hwnd))
{
/* callback didn't process this message */
switch(msg)
{
case WM_ERASEBKGND:
case WM_SHOWWINDOW:
case WM_ACTIVATE:
case WM_SETFOCUS:
case DM_SETDEFID:
case DM_GETDEFID:
case WM_NEXTDLGCTL:
case WM_GETFONT:
case WM_CLOSE:
case WM_NCDESTROY:
case WM_ENTERMENULOOP:
case WM_LBUTTONDOWN:
case WM_NCLBUTTONDOWN:
return DEFDLG_Proc( (HWND)hwnd, msg,
(WPARAM)wParam, lParam, dlgInfo );
case WM_INITDIALOG:
case WM_VKEYTOITEM:
case WM_COMPAREITEM:
case WM_CHARTOITEM:
break;
default:
return DefWindowProcA( hwnd, msg, wParam, lParam );
}
}
return DEFDLG_Epilog(dlgInfo, msg, result);
}
/***********************************************************************
* DefDlgProcW (USER.121)
*/
LRESULT WINAPI DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam )
{
DIALOGINFO * dlgInfo;
BOOL result = FALSE;
WND * wndPtr = WIN_FindWndPtr( hwnd );
if (!wndPtr) return 0;
dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
dlgInfo->msgResult = 0;
if (dlgInfo->dlgProc) { /* Call dialog procedure */
result = CallWindowProcW( (WNDPROC)dlgInfo->dlgProc,
hwnd, msg, wParam, lParam );
/* Check if window was destroyed by dialog procedure */
if (dlgInfo->flags & DF_END && !(dlgInfo->flags & DF_ENDING)) {
dlgInfo->flags |= DF_ENDING;
DestroyWindow( hwnd );
}
}
if (!result && IsWindow(hwnd))
{
/* callback didn't process this message */
switch(msg)
{
case WM_ERASEBKGND:
case WM_SHOWWINDOW:
case WM_ACTIVATE:
case WM_SETFOCUS:
case DM_SETDEFID:
case DM_GETDEFID:
case WM_NEXTDLGCTL:
case WM_GETFONT:
case WM_CLOSE:
case WM_NCDESTROY:
case WM_ENTERMENULOOP:
case WM_LBUTTONDOWN:
case WM_NCLBUTTONDOWN:
return DEFDLG_Proc( (HWND)hwnd, msg,
(WPARAM)wParam, lParam, dlgInfo );
case WM_INITDIALOG:
case WM_VKEYTOITEM:
case WM_COMPAREITEM:
case WM_CHARTOITEM:
break;
default:
return DefWindowProcW( hwnd, msg, wParam, lParam );
}
}
return DEFDLG_Epilog(dlgInfo, msg, result);
}

File diff suppressed because it is too large Load diff

View file

@ -287,12 +287,12 @@ LRESULT HOOK_CallHook( HHOOK hook, INT fromtype, INT code,
WPARAM wParam, LPARAM lParam )
{
// MESSAGEQUEUE *queue;
HANDLE prevHook;
//HANDLE prevHook;
HOOKDATA *data = (HOOKDATA *)(hook);
LRESULT ret;
WPARAM wParamOrig = wParam;
LPARAM lParamOrig = lParam;
//WPARAM wParamOrig = wParam;
//LPARAM lParamOrig = lParam;
// HOOK_MapFunc MapFunc;
// HOOK_UnMapFunc UnMapFunc;
@ -337,7 +337,16 @@ WINBOOL HOOK_IsHooked( INT id )
return HOOK_GetHook( id, GetThreadQueue(0) ) != 0;
}
LRESULT HOOK_CallHooks( INT id, INT code, WPARAM wParam,
LPARAM lParam ,WINBOOL bUnicode)
{
if ( bUnicode == TRUE )
return HOOK_CallHooksW( id, code, wParam,lParam );
else
return HOOK_CallHooksA( id, code, wParam,lParam );
return 0;
}
/***********************************************************************
* HOOK_CallHooksA

View file

@ -251,101 +251,51 @@ WINBOOL STDCALL PostMessageW( HWND hwnd, UINT message, WPARAM wParam,
LRESULT STDCALL SendMessageA( HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam )
{
WND * wndPtr;
WND **list, **ppWnd;
LRESULT ret;
WND *wndPtr;
if (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST)
{
if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
return TRUE;
for (ppWnd = list; *ppWnd; ppWnd++)
{
wndPtr = *ppWnd;
if (!IsWindow(wndPtr->hwndSelf)) continue;
if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
SendMessageA( wndPtr->hwndSelf, msg, wParam, lParam );
}
HeapFree( GetProcessHeap(), 0, list );
return TRUE;
return MSG_SendMessageInterTask(hwnd,msg,wParam,lParam,FALSE);
}
if (!(wndPtr = WIN_FindWndPtr( hwnd )))
{
DPRINT( "invalid hwnd %08x\n", hwnd );
return 0;
}
if (HOOK_IsHooked( WH_CALLWNDPROC ))
MSG_CallWndProcHook( (LPMSG)&hwnd, FALSE);
if (!(wndPtr = WIN_FindWndPtr( hwnd )))
{
DPRINT( "invalid hwnd %08x\n", hwnd );
return 0;
}
if (QUEUE_IsExitingQueue(wndPtr->hmemTaskQ))
return 0; /* Don't send anything if the task is dying */
SPY_EnterMessage( SPY_SENDMESSAGE, hwnd, msg, wParam, lParam );
if (wndPtr->hmemTaskQ != GetFastQueue())
ret = MSG_SendMessage( wndPtr->hmemTaskQ, hwnd, msg, wParam, lParam,
QUEUE_SM_ASCII );
else
ret = CallWindowProcA( (WNDPROC)wndPtr->winproc,
hwnd, msg, wParam, lParam );
SPY_ExitMessage( SPY_RESULT_OK, hwnd, msg, ret );
return ret;
return MSG_SendMessage(wndPtr,msg,wParam,lParam,FALSE);
}
LRESULT STDCALL SendMessageW(
HWND hwnd, /* Window to send message to. If HWND_BROADCAST,
the message will be sent to all top-level windows. */
UINT msg, /* message */
WPARAM wParam, /* message parameter */
LPARAM lParam /* additional message parameter */
) {
WND * wndPtr;
WND **list, **ppWnd;
LRESULT ret;
LRESULT STDCALL SendMessageW( HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam )
{
WND *wndPtr;
if (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST)
{
if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
return TRUE;
for (ppWnd = list; *ppWnd; ppWnd++)
{
wndPtr = *ppWnd;
if (!IsWindow(wndPtr->hwndSelf)) continue;
if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
SendMessageW( wndPtr->hwndSelf, msg, wParam, lParam );
}
HeapFree( GetProcessHeap(), 0, list );
return TRUE;
return MSG_SendMessageInterTask(hwnd,msg,wParam,lParam,TRUE);
}
if (HOOK_IsHooked( WH_CALLWNDPROC ))
MSG_CallWndProcHook( (LPMSG)&hwnd, TRUE);
if (!(wndPtr = WIN_FindWndPtr( hwnd )))
{
DPRINT( "invalid hwnd %08x\n", hwnd );
return 0;
}
if (QUEUE_IsExitingQueue(wndPtr->hmemTaskQ))
return 0; /* Don't send anything if the task is dying */
SPY_EnterMessage( SPY_SENDMESSAGE, hwnd, msg, wParam, lParam );
if (HOOK_IsHooked( WH_CALLWNDPROC ))
MSG_CallWndProcHook( (LPMSG)&hwnd, FALSE);
if (wndPtr->hmemTaskQ != GetFastQueue())
ret = MSG_SendMessage( wndPtr->hmemTaskQ, hwnd, msg, wParam, lParam,
QUEUE_SM_ASCII | QUEUE_SM_UNICODE );
else
ret = CallWindowProcW( (WNDPROC)wndPtr->winproc,
hwnd, msg, wParam, lParam );
SPY_ExitMessage( SPY_RESULT_OK, hwnd, msg, ret );
return ret;
return MSG_SendMessage(wndPtr,msg,wParam,lParam,TRUE);
}
/***********************************************************************

View file

@ -1,6 +1,7 @@
#define UNICODE
#include <windows.h>
#include <user32/win.h>
#include <user32/nc.h>
#include <user32/resource.h>
@ -9,8 +10,12 @@
#define MB_DEFMASK 0x00000F00
LRESULT CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam );
WPARAM wParam, LPARAM lParam, WINBOOL bUnicode );
LRESULT CALLBACK MSGBOX_DlgProcA( HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam );
LRESULT CALLBACK MSGBOX_DlgProcW( HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam );
// FIXME ?????????
/* Static text */
@ -47,7 +52,8 @@ INT STDCALL MessageBoxExA( HWND hWnd, LPCSTR text, LPCSTR title,
UINT type, WORD langid )
{
MSGBOXPARAMS mbox;
HANDLE hrsrc;
HANDLE hDlgTemplate;
if (title == NULL)
title="Error";
if (text == NULL)
@ -56,9 +62,13 @@ INT STDCALL MessageBoxExA( HWND hWnd, LPCSTR text, LPCSTR title,
mbox.lpszCaption = title;
mbox.lpszText = text;
mbox.dwStyle = type;
return DialogBoxIndirectParamA( WIN_GetWindowInstance(hWnd),
SYSRES_GetResPtr( SYSRES_DIALOG_MSGBOX ),
hWnd, MSGBOX_DlgProc, (LPARAM)&mbox );
hrsrc = FindResourceA( NULL, "MSGBOX", RT_DIALOG );
if (!hrsrc) return 0;
hDlgTemplate = LockResource(LoadResource(NULL,hrsrc));
return DialogBoxIndirectParamA( NULL, hDlgTemplate,
hWnd, MSGBOX_DlgProcA, (LPARAM)&mbox );
}
/**************************************************************************
@ -68,7 +78,8 @@ INT STDCALL MessageBoxExW( HWND hWnd, LPCWSTR text, LPCWSTR title,
UINT type, WORD langid )
{
MSGBOXPARAMS mbox;
HANDLE hrsrc;
HANDLE hDlgTemplate;
if (title == NULL)
title=L"Error";
if (text == NULL)
@ -77,9 +88,14 @@ INT STDCALL MessageBoxExW( HWND hWnd, LPCWSTR text, LPCWSTR title,
mbox.lpszCaption = title;
mbox.lpszText = text;
mbox.dwStyle = type;
return DialogBoxIndirectParamW( WIN_GetWindowInstance(hWnd),
SYSRES_GetResPtr( SYSRES_DIALOG_MSGBOX ),
hWnd, MSGBOX_DlgProc, (LPARAM)&mbox );
hrsrc = FindResourceW( NULL, L"MSGBOX", RT_DIALOG );
if (!hrsrc) return 0;
hDlgTemplate = LockResource(LoadResource(NULL,hrsrc));
return DialogBoxIndirectParamW( NULL,
hDlgTemplate,
hWnd, MSGBOX_DlgProcW, (LPARAM)&mbox );
}
@ -89,10 +105,13 @@ INT STDCALL MessageBoxExW( HWND hWnd, LPCWSTR text, LPCWSTR title,
*/
INT STDCALL MessageBoxIndirectA( LPMSGBOXPARAMS msgbox )
{
HANDLE hrsrc = FindResourceA( NULL, "MSGBOX", RT_DIALOG );
HANDLE hDlgTemplate;
if (!hrsrc) return 0;
hDlgTemplate = LockResource(LoadResource(NULL,hrsrc));
return DialogBoxIndirectParamA( msgbox->hInstance,
SYSRES_GetResPtr( SYSRES_DIALOG_MSGBOX ),
msgbox->hwndOwner, MSGBOX_DlgProc,
hDlgTemplate,
msgbox->hwndOwner, MSGBOX_DlgProcA,
(LPARAM)msgbox );
}
@ -102,9 +121,13 @@ INT STDCALL MessageBoxIndirectA( LPMSGBOXPARAMS msgbox )
INT STDCALL MessageBoxIndirectW( LPMSGBOXPARAMS msgbox )
{
HANDLE hrsrc = FindResourceW( NULL, L"MSGBOX", RT_DIALOG );
HANDLE hDlgTemplate;
if (!hrsrc) return 0;
hDlgTemplate = LockResource(LoadResource(NULL,hrsrc));
return DialogBoxIndirectParamW( msgbox->hInstance,
SYSRES_GetResPtr( SYSRES_DIALOG_MSGBOX ),
msgbox->hwndOwner, MSGBOX_DlgProc,
hDlgTemplate,
msgbox->hwndOwner, MSGBOX_DlgProcW,
(LPARAM)msgbox );
}
@ -113,8 +136,19 @@ INT STDCALL MessageBoxIndirectW( LPMSGBOXPARAMS msgbox )
*
* Dialog procedure for message boxes.
*/
LRESULT CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message,
LRESULT CALLBACK MSGBOX_DlgProcA( HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam )
{
return MSGBOX_DlgProc(hwnd,message,wParam,lParam,FALSE);
}
LRESULT CALLBACK MSGBOX_DlgProcW( HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam )
{
return MSGBOX_DlgProc(hwnd,message,wParam,lParam,TRUE);
}
LRESULT CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam, WINBOOL bUnicode )
{
static HFONT hFont = 0;
LPMSGBOXPARAMS lpmb;
@ -126,144 +160,162 @@ LRESULT CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message,
int i, buttons, bwidth, bheight, theight, wwidth, bpos;
int borheight, iheight, tiheight;
NONCLIENTMETRICS nclm;
switch(message) {
case WM_INITDIALOG:
lpmb = (LPMSGBOXPARAMS)lParam;
nclm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
hFont = CreateFontIndirect(&nclm.lfMessageFont);
/* set button font */
for (i=1; i < 8; i++)
SendDlgItemMessageW (hwnd, i, WM_SETFONT, (WPARAM)hFont, 0);
/* set text font */
SendDlgItemMessageW (hwnd, 100, WM_SETFONT, (WPARAM)hFont, 0);
if (TWEAK_WineLook >= WIN95_LOOK) {
NONCLIENTMETRICS nclm;
INT i;
nclm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
hFont = CreateFontIndirect (&nclm.lfMessageFont);
/* set button font */
for (i=1; i < 8; i++)
SendDlgItemMessage (hwnd, i, WM_SETFONT, (WPARAM)hFont, 0);
/* set text font */
SendDlgItemMessage (hwnd, 100, WM_SETFONT, (WPARAM)hFont, 0);
}
if (lpmb->lpszCaption)
SetWindowTextW(hwnd, lpmb->lpszCaption);
SetWindowTextW(GetDlgItem(hwnd, 100), lpmb->lpszText);
if ( bUnicode == TRUE ) {
if (lpmb->lpszCaption)
SetWindowTextW(hwnd, (LPCWSTR)lpmb->lpszCaption);
SetWindowTextW(GetDlgItem(hwnd, 100),(LPWSTR) lpmb->lpszText);
} else {
if (lpmb->lpszCaption)
SetWindowTextA(hwnd, lpmb->lpszCaption);
SetWindowTextA(GetDlgItem(hwnd, 100), lpmb->lpszText);
}
/* Hide not selected buttons */
switch(lpmb->dwStyle & MB_TYPEMASK) {
case MB_OK:
ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE);
/* fall through */
case MB_OKCANCEL:
ShowWindow(GetDlgItem(hwnd, 3), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 4), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 5), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 6), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 7), SW_HIDE);
break;
case MB_ABORTRETRYIGNORE:
ShowWindow(GetDlgItem(hwnd, 1), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 6), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 7), SW_HIDE);
break;
case MB_YESNO:
ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE);
/* fall through */
case MB_YESNOCANCEL:
ShowWindow(GetDlgItem(hwnd, 1), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 3), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 4), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 5), SW_HIDE);
break;
}
/* Set the icon */
switch(lpmb->dwStyle & MB_ICONMASK) {
case MB_ICONEXCLAMATION:
SendDlgItemMessage(hwnd, stc1, STM_SETICON,
(WPARAM)LoadIcon(0, IDI_EXCLAMATION), 0);
break;
case MB_ICONQUESTION:
SendDlgItemMessage(hwnd, stc1, STM_SETICON,
case MB_OK:
ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE);
/* fall through */
case MB_OKCANCEL:
ShowWindow(GetDlgItem(hwnd, 3), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 4), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 5), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 6), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 7), SW_HIDE);
break;
case MB_ABORTRETRYIGNORE:
ShowWindow(GetDlgItem(hwnd, 1), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 6), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 7), SW_HIDE);
break;
case MB_YESNO:
ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE);
/* fall through */
case MB_YESNOCANCEL:
ShowWindow(GetDlgItem(hwnd, 1), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 3), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 4), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 5), SW_HIDE);
break;
}
/* Set the icon */
switch(lpmb->dwStyle & MB_ICONMASK) {
case MB_ICONEXCLAMATION:
SendDlgItemMessage(hwnd, stc1, STM_SETICON,
(WPARAM)LoadIcon(0, IDI_EXCLAMATION), 0);
break;
case MB_ICONQUESTION:
SendDlgItemMessage(hwnd, stc1, STM_SETICON,
(WPARAM)LoadIcon(0, IDI_QUESTION), 0);
break;
case MB_ICONASTERISK:
SendDlgItemMessage(hwnd, stc1, STM_SETICON,
break;
case MB_ICONASTERISK:
SendDlgItemMessage(hwnd, stc1, STM_SETICON,
(WPARAM)LoadIcon(0, IDI_ASTERISK), 0);
break;
case MB_ICONHAND:
default:
SendDlgItemMessage(hwnd, stc1, STM_SETICON,
break;
case MB_ICONHAND:
default:
SendDlgItemMessage(hwnd, stc1, STM_SETICON,
(WPARAM)LoadIcon(0, IDI_HAND), 0);
break;
}
break;
}
/* Position everything */
GetWindowRect(hwnd, &rect);
borheight = rect.bottom - rect.top;
wwidth = rect.right - rect.left;
GetClientRect(hwnd, &rect);
borheight -= rect.bottom - rect.top;
/* Position everything */
GetWindowRect(hwnd, &rect);
borheight = rect.bottom - rect.top;
wwidth = rect.right - rect.left;
GetClientRect(hwnd, &rect);
borheight -= rect.bottom - rect.top;
/* Get the icon height */
GetWindowRect(GetDlgItem(hwnd, 1088), &rect);
iheight = rect.bottom - rect.top;
/* Get the icon height */
GetWindowRect(GetDlgItem(hwnd, 1088), &rect);
iheight = rect.bottom - rect.top;
/* Get the number of visible buttons and their width */
GetWindowRect(GetDlgItem(hwnd, 2), &rect);
bheight = rect.bottom - rect.top;
bwidth = rect.left;
GetWindowRect(GetDlgItem(hwnd, 1), &rect);
bwidth -= rect.left;
for (buttons = 0, i = 1; i < 8; i++)
{
hItem = GetDlgItem(hwnd, i);
if (GetWindowLongW(hItem, GWL_STYLE) & WS_VISIBLE)
buttons++;
}
/* Get the number of visible buttons and their width */
GetWindowRect(GetDlgItem(hwnd, 2), &rect);
bheight = rect.bottom - rect.top;
bwidth = rect.left;
GetWindowRect(GetDlgItem(hwnd, 1), &rect);
bwidth -= rect.left;
for (buttons = 0, i = 1; i < 8; i++)
{
hItem = GetDlgItem(hwnd, i);
if (GetWindowLong(hItem, GWL_STYLE) & WS_VISIBLE)
buttons++;
}
/* Get the text size */
hItem = GetDlgItem(hwnd, 100);
GetWindowRect(hItem, &textrect);
MapWindowPoints(0, hwnd, (LPPOINT)&textrect, 2);
/* Get the text size */
hItem = GetDlgItem(hwnd, 100);
GetWindowRect(hItem, &textrect);
MapWindowPoints(0, hwnd, (LPPOINT)&textrect, 2);
GetClientRect(hItem, &rect);
hdc = GetDC(hItem);
lRet = DrawTextW( hdc, lpmb->lpszText, -1, &rect,
GetClientRect(hItem, &rect);
hdc = GetDC(hItem);
if ( bUnicode )
lRet = DrawTextW( hdc, (LPCWSTR)lpmb->lpszText, -1, &rect,
DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT);
theight = rect.bottom - rect.top;
tiheight = 16 + max(iheight, theight);
ReleaseDC(hItem, hdc);
else
lRet = DrawTextA( hdc, lpmb->lpszText, -1, &rect,
DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT);
theight = rect.bottom - rect.top;
tiheight = 16 + max(iheight, theight);
ReleaseDC(hItem, hdc);
/* Position the text */
SetWindowPos(hItem, 0, textrect.left, (tiheight - theight) / 2,
/* Position the text */
SetWindowPos(hItem, 0, textrect.left, (tiheight - theight) / 2,
rect.right - rect.left, theight,
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
/* Position the icon */
hItem = GetDlgItem(hwnd, 1088);
GetWindowRect(hItem, &rect);
MapWindowPoints(0, hwnd, (LPPOINT)&rect, 2);
SetWindowPos(hItem, 0, rect.left, (tiheight - iheight) / 2, 0, 0,
/* Position the icon */
hItem = GetDlgItem(hwnd, 1088);
GetWindowRect(hItem, &rect);
MapWindowPoints(0, hwnd, (LPPOINT)&rect, 2);
SetWindowPos(hItem, 0, rect.left, (tiheight - iheight) / 2, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
/* Resize the window */
SetWindowPos(hwnd, 0, 0, 0, wwidth, 8 + tiheight + bheight + borheight,
SetWindowPos(hwnd, 0, 0, 0, wwidth, 8 + tiheight + bheight + borheight,
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
/* Position the buttons */
bpos = (wwidth - bwidth * buttons) / 2;
GetWindowRect(GetDlgItem(hwnd, 1), &rect);
for (buttons = i = 0; i < 7; i++) {
/* some arithmetic to get the right order for YesNoCancel windows */
hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1);
if (GetWindowLongW(hItem, GWL_STYLE) & WS_VISIBLE) {
if (buttons++ == ((lpmb->dwStyle & MB_DEFMASK) >> 8)) {
SetFocus(hItem);
SendMessageW( hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
}
SetWindowPos(hItem, 0, bpos, tiheight, 0, 0,
SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW);
bpos += bwidth;
}
}
return 0;
break;
bpos = (wwidth - bwidth * buttons) / 2;
GetWindowRect(GetDlgItem(hwnd, 1), &rect);
for (buttons = i = 0; i < 7; i++) {
/* some arithmetic to get the right order for YesNoCancel windows */
hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1);
if (GetWindowLong(hItem, GWL_STYLE) & WS_VISIBLE) {
if (buttons++ == ((lpmb->dwStyle & MB_DEFMASK) >> 8)) {
SetFocus(hItem);
SendMessage( hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
}
SetWindowPos(hItem, 0, bpos, tiheight, 0, 0,
SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW);
bpos += bwidth;
}
}
return 0;
break;
case WM_COMMAND:
switch (wParam)

View file

@ -0,0 +1,312 @@
/*
* Scroll windows and DCs
*
* Copyright David W. Metcalfe, 1993
* Alex Korobka 1995,1996
*
*
*/
#include <stdlib.h>
#include <windows.h>
#include <user32/class.h>
#include <user32/win.h>
#include <user32/dce.h>
#include <user32/sysmetr.h>
#include <user32/caret.h>
#include <user32/debug.h>
/*************************************************************************
* ScrollWindow (USER.450)
*
* FIXME: verify clipping region calculations
*/
WINBOOL STDCALL ScrollWindow( HWND hwnd, INT dx, INT dy,
const RECT *rect, const RECT *clipRect )
{
HDC hdc;
HRGN hrgnUpdate,hrgnClip;
RECT rc, cliprc;
HWND hCaretWnd = CARET_GetHwnd();
WND* wndScroll = WIN_FindWndPtr( hwnd );
if ( !wndScroll || !WIN_IsWindowDrawable( wndScroll, TRUE ) ) return TRUE;
if ( !rect ) /* do not clip children */
{
GetClientRect(hwnd, &rc);
hrgnClip = CreateRectRgnIndirect( &rc );
if ((hCaretWnd == hwnd) || IsChild(hwnd,hCaretWnd))
HideCaret(hCaretWnd);
else hCaretWnd = 0;
hdc = GetDCEx(hwnd, hrgnClip, DCX_CACHE | DCX_CLIPSIBLINGS);
DeleteObject( hrgnClip );
}
else /* clip children */
{
CopyRect(&rc, rect);
if (hCaretWnd == hwnd) HideCaret(hCaretWnd);
else hCaretWnd = 0;
hdc = GetDCEx( hwnd, 0, DCX_CACHE | DCX_USESTYLE );
}
if (clipRect == NULL)
GetClientRect(hwnd, &cliprc);
else
CopyRect(&cliprc, clipRect);
hrgnUpdate = CreateRectRgn( 0, 0, 0, 0 );
ScrollDC( hdc, dx, dy, &rc, &cliprc, hrgnUpdate, NULL );
ReleaseDC(hwnd, hdc);
if( !rect ) /* move child windows and update region */
{
WND* wndPtr;
if( wndScroll->hrgnUpdate > 1 )
OffsetRgn( wndScroll->hrgnUpdate, dx, dy );
for (wndPtr = wndScroll->child; wndPtr; wndPtr = wndPtr->next)
SetWindowPos(wndPtr->hwndSelf, 0, wndPtr->rectWindow.left + dx,
wndPtr->rectWindow.top + dy, 0,0, SWP_NOZORDER |
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOREDRAW |
SWP_DEFERERASE );
}
PAINT_RedrawWindow( hwnd, NULL, hrgnUpdate, RDW_ALLCHILDREN |
RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW, RDW_C_USEHRGN );
DeleteObject( hrgnUpdate );
if( hCaretWnd )
{
POINT pt;
GetCaretPos(&pt);
pt.x += dx; pt.y += dy;
SetCaretPos(pt.x, pt.y);
ShowCaret(hCaretWnd);
}
return TRUE;
}
/*************************************************************************
* ScrollDC (USER.449)
*
* Both 'rc' and 'prLClip' are in logical units but update info is
* returned in device coordinates.
*/
WINBOOL STDCALL ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc,
const RECT *prLClip, HRGN hrgnUpdate,
LPRECT rcUpdate )
{
#if 0
RECT rClip;
POINT src, dest;
INT ldx, ldy;
if (!hdc ) return FALSE;
/* compute device clipping region */
if ( rc )
rClip = *rc;
else /* maybe we should just return FALSE? */
GetClipBox( hdc, &rClip );
if (prLClip)
IntersectRect(&rClip,&rClip,prLClip);
if( rClip.left >= rClip.right || rClip.top >= rClip.bottom )
{
return FALSE;
}
SaveVisRgn( hdc );
IntersectVisRect( hdc, rClip.left, rClip.top,
rClip.right, rClip.bottom );
/* translate coordinates */
ldx = dx * dc->wndExtX / dc->vportExtX;
ldy = dy * dc->wndExtY / dc->vportExtY;
if (dx > 0)
dest.x = (src.x = rClip.left) + ldx;
else
src.x = (dest.x = rClip.left) - ldx;
if (dy > 0)
dest.y = (src.y = rClip.top) + ldy;
else
src.y = (dest.y = rClip.top) - ldy;
/* copy bits */
if( rClip.right - rClip.left > ldx &&
rClip.bottom - rClip.top > ldy )
{
ldx = rClip.right - rClip.left - ldx;
ldy = rClip.bottom - rClip.top - ldy;
if (!BitBlt( hdc, dest.x, dest.y, ldx, ldy,
hdc, src.x, src.y, SRCCOPY))
{
return FALSE;
}
}
/* restore clipping region */
RestoreVisRgn( hdc );
/* compute update areas */
if ( (hrgnUpdate || rcUpdate) && dc->w.hVisRgn )
{
HRGN hrgn = (hrgnUpdate) ? hrgnUpdate : CreateRectRgn( 0,0,0,0 );
HRGN hrgnClip;
LPtoDP( hdc, (LPPOINT)&rClip, 2 );
OffsetRect( &rClip, dc->w.DCOrgX, dc->w.DCOrgY );
hrgnClip = CreateRectRgnIndirect( &rClip );
CombineRgn( hrgn, dc->w.hVisRgn, hrgnClip, RGN_AND );
OffsetRgn( hrgn, dx, dy );
CombineRgn( hrgn, dc->w.hVisRgn, hrgn, RGN_DIFF );
CombineRgn( hrgn, hrgn, hrgnClip, RGN_AND );
OffsetRgn( hrgn, -dc->w.DCOrgX, -dc->w.DCOrgY );
if( rcUpdate ) GetRgnBox( hrgnUpdate, rcUpdate );
if (!hrgnUpdate) DeleteObject( hrgn );
DeleteObject( hrgnClip );
}
#endif
return TRUE;
}
/*************************************************************************
* ScrollWindowEx (USER.451)
*
* NOTE: Use this function instead of ScrollWindow
*/
INT STDCALL ScrollWindowEx( HWND hwnd, INT dx, INT dy,
const RECT *rect, const RECT *clipRect,
HRGN hrgnUpdate, LPRECT rcUpdate,
UINT flags )
{
INT retVal = NULLREGION;
WINBOOL bCaret = FALSE, bOwnRgn = TRUE;
RECT rc, cliprc;
WND* wnd = WIN_FindWndPtr( hwnd );
if( !wnd || !WIN_IsWindowDrawable( wnd, TRUE )) return ERROR;
if (rect == NULL) GetClientRect(hwnd, &rc);
else rc = *rect;
if (clipRect) IntersectRect(&cliprc,&rc,clipRect);
else cliprc = rc;
if (!IsRectEmpty(&cliprc) && (dx || dy))
{
HDC hDC;
WINBOOL bUpdate = (rcUpdate || hrgnUpdate || flags & (SW_INVALIDATE | SW_ERASE));
HRGN hrgnClip = CreateRectRgnIndirect(&cliprc);
rc = cliprc;
bCaret = SCROLL_FixCaret(hwnd, &rc, flags);
if( hrgnUpdate ) bOwnRgn = FALSE;
else if( bUpdate ) hrgnUpdate = CreateRectRgn( 0, 0, 0, 0 );
hDC = GetDCEx( hwnd, hrgnClip, DCX_CACHE | DCX_USESTYLE |
((flags & SW_SCROLLCHILDREN) ? DCX_NOCLIPCHILDREN : 0) );
if( hDC != NULL)
{
#if 0
if( dc->w.hVisRgn && bUpdate )
{
OffsetRgn( hrgnClip, dc->w.DCOrgX, dc->w.DCOrgY );
CombineRgn( hrgnUpdate, dc->w.hVisRgn, hrgnClip, RGN_AND );
OffsetRgn( hrgnUpdate, dx, dy );
CombineRgn( hrgnUpdate, dc->w.hVisRgn, hrgnUpdate, RGN_DIFF );
CombineRgn( hrgnUpdate, hrgnUpdate, hrgnClip, RGN_AND );
OffsetRgn( hrgnUpdate, -dc->w.DCOrgX, -dc->w.DCOrgY );
if( rcUpdate ) GetRgnBox( hrgnUpdate, rcUpdate );
}
#endif
ReleaseDC(hwnd, hDC);
}
if( wnd->hrgnUpdate > 1 )
{
if( rect || clipRect )
{
if( (CombineRgn( hrgnClip, hrgnClip,
wnd->hrgnUpdate, RGN_AND ) != NULLREGION) )
{
CombineRgn( wnd->hrgnUpdate, wnd->hrgnUpdate, hrgnClip, RGN_DIFF );
OffsetRgn( hrgnClip, dx, dy );
CombineRgn( wnd->hrgnUpdate, wnd->hrgnUpdate, hrgnClip, RGN_OR );
}
}
else
OffsetRgn( wnd->hrgnUpdate, dx, dy );
}
if( flags & SW_SCROLLCHILDREN )
{
RECT r;
WND* w;
for( w = wnd->child; w; w = w->next )
{
if( !clipRect || IntersectRect(&w->rectWindow, &r, &cliprc) )
SetWindowPos(w->hwndSelf, 0, w->rectWindow.left + dx,
w->rectWindow.top + dy, 0,0, SWP_NOZORDER |
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOREDRAW |
SWP_DEFERERASE );
}
}
if( flags & (SW_INVALIDATE | SW_ERASE) )
PAINT_RedrawWindow( hwnd, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE |
((flags & SW_ERASE) ? RDW_ERASENOW : 0) | ((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0 ), 0 );
if( bCaret )
{
SetCaretPos( rc.left + dx, rc.top + dy );
ShowCaret(0);
}
if( bOwnRgn && hrgnUpdate ) DeleteObject( hrgnUpdate );
DeleteObject( hrgnClip );
}
return retVal;
}

View file

@ -5,9 +5,11 @@
#include <user32/winpos.h>
#include <user32/hook.h>
#include <user32/property.h>
#include <user32/paint.h>
#include <user32/debug.h>
// change style on WS_OVERLAPPEDWINDOW
#undef CreateWindowA
HWND STDCALL CreateWindowA(LPCSTR lpClassName, LPCSTR lpWindowName,
@ -51,17 +53,11 @@ HWND STDCALL CreateWindowExA( DWORD exStyle, LPCSTR lpClassName,
//if(exStyle & WS_EX_MDICHILD)
// return MDI_CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, data);
#if 0
while ((*lpWindowName)!=0 && i < MAX_PATH)
{
WindowNameW[i] = *lpWindowName;
lpWindowName++;
i++;
}
WindowNameW[i] = 0;
#endif
if ( style == WS_OVERLAPPEDWINDOW )
style |= (WS_OVERLAPPED| WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX |WS_MAXIMIZEBOX );
/* Create the window */
@ -91,8 +87,6 @@ HWND STDCALL CreateWindowExW( DWORD exStyle, LPCWSTR lpClassName,
HWND parent, HMENU menu,
HINSTANCE hInstance, LPVOID data )
{
// WCHAR WindowNameW[MAX_PATH];
// WCHAR ClassNameW[MAX_PATH];
CLASS *p;
DWORD status;
CREATESTRUCTW cs;
@ -103,7 +97,8 @@ HWND STDCALL CreateWindowExW( DWORD exStyle, LPCWSTR lpClassName,
if ( p == NULL )
return NULL;
if ( style == WS_OVERLAPPEDWINDOW )
style |= (WS_OVERLAPPED| WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX |WS_MAXIMIZEBOX );
/* Create the window */
@ -133,22 +128,25 @@ WINBOOL STDCALL DestroyWindow( HWND hwnd )
{
WND * wndPtr;
DPRINT( "(%04x)\n", hwnd);
/* Initialization */
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
//if (wndPtr == pWndDesktop) return FALSE; /* Can't destroy desktop */
if ( hwnd == NULL )
return FALSE;
/* Call hooks */
if( HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, hwnd, 0L) )
if( HOOK_CallHooks( WH_CBT, HCBT_DESTROYWND, hwnd, 0L, wndPtr->class->bUnicode ) )
return FALSE;
if (!(wndPtr->dwStyle & WS_CHILD) && !wndPtr->owner)
{
HOOK_CallHooksA( WH_SHELL, HSHELL_WINDOWDESTROYED, hwnd, 0L );
HOOK_CallHooks( WH_SHELL, HSHELL_WINDOWDESTROYED, hwnd, 0L, wndPtr->class->bUnicode );
/* FIXME: clean up palette - see "Internals" p.352 */
}
@ -156,12 +154,13 @@ WINBOOL STDCALL DestroyWindow( HWND hwnd )
if( wndPtr->dwStyle & WS_CHILD && !(wndPtr->dwExStyle & WS_EX_NOPARENTNOTIFY) )
{
/* Notify the parent window only */
SendMessageA( wndPtr->parent->hwndSelf, WM_PARENTNOTIFY,
if ( wndPtr->parent != NULL )
SendMessageA( wndPtr->parent->hwndSelf, WM_PARENTNOTIFY,
MAKEWPARAM(WM_DESTROY, wndPtr->wIDmenu), (LPARAM)hwnd );
if( !IsWindow(hwnd) ) return TRUE;
}
// CLIPBOARD_GetDriver()->pResetOwner( wndPtr, FALSE ); /* before the window is unmapped */
/* Hide the window */
@ -182,7 +181,10 @@ WINBOOL STDCALL DestroyWindow( HWND hwnd )
for (;;)
{
WND *siblingPtr = wndPtr->parent->child; /* First sibling */
WND *siblingPtr = NULL;
if ( wndPtr->parent != NULL )
siblingPtr = wndPtr->parent->child; /* First sibling */
while (siblingPtr)
{
if (siblingPtr->owner == wndPtr)
@ -571,20 +573,22 @@ WINBOOL STDCALL IsWindowVisible( HWND hwnd )
/***********************************************************************
* ShowWindow32 (USER32.534)
* ShowWindow (USER32.534)
*/
WINBOOL STDCALL ShowWindow( HWND hwnd, INT cmd )
{
WND* wndPtr = WIN_FindWndPtr( hwnd );
WINBOOL wasVisible, showFlag;
WINBOOL wasVisible = FALSE, showFlag;
RECT newPos = {0, 0, 0, 0};
int swp = 0;
if (!wndPtr) return FALSE;
// DPRINT("hwnd=%04x, cmd=%d\n", hwnd, cmd);
#ifdef OPTIMIZATION
wasVisible = (wndPtr->dwStyle & WS_VISIBLE) != 0;
#endif
switch(cmd)
{
@ -680,6 +684,51 @@ WINBOOL STDCALL ShowWindow( HWND hwnd, INT cmd )
// SendMessage(hwnd, WM_NCACTIVATE,TRUE,0);
// SendMessage(hwnd, WM_NCPAINT,CreateRectRgn(100,100,100, 100) ,0);
return wasVisible;
}
/*******************************************************************
* FlashWindow (USER32.202)
*/
WINBOOL STDCALL FlashWindow( HWND hWnd, WINBOOL bInvert )
{
WND *wndPtr = WIN_FindWndPtr(hWnd);
if (!wndPtr) return FALSE;
if (wndPtr->dwStyle & WS_MINIMIZE)
{
if (bInvert && !(wndPtr->flags & WIN_NCACTIVATED))
{
HDC hDC = GetDC(hWnd);
if (!SendMessage( hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0 ))
wndPtr->flags |= WIN_NEEDS_ERASEBKGND;
ReleaseDC( hWnd, hDC );
wndPtr->flags |= WIN_NCACTIVATED;
}
else
{
PAINT_RedrawWindow( hWnd, 0, 0, RDW_INVALIDATE | RDW_ERASE |
RDW_UPDATENOW | RDW_FRAME, 0 );
wndPtr->flags &= ~WIN_NCACTIVATED;
}
return TRUE;
}
else
{
WPARAM wparam;
if (bInvert) wparam = !(wndPtr->flags & WIN_NCACTIVATED);
else wparam = (hWnd == GetActiveWindow());
SendMessage( hWnd, WM_NCACTIVATE, wparam, (LPARAM)0 );
return wparam;
}
}

View file

@ -175,15 +175,13 @@ HWND SetActiveWindow(HWND hWnd )
WINBOOL
STDCALL
SetWindowPos(
HWND hWnd,
HWND hWndInsertAfter ,
int X,
int Y,
int cx,
int cy,
HWND hWnd, HWND hWndInsertAfter ,
int X, int Y,
int cx, int cy,
UINT flags)
{
WINDOWPOS winpos;
WINDOWPOS winpos;
WND * wndPtr;
RECT newWindowRect, newClientRect, oldWindowRect;
HRGN visRgn = 0;
@ -192,13 +190,22 @@ SetWindowPos(
UINT uFlags;
WINBOOL resync = FALSE;
DPRINT("hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
hWnd, X, Y, X+cx, Y+cy, flags);
/* Check window handle */
if (hWnd == GetDesktopWindow()) return FALSE;
if (hWnd == GetActiveWindow() ) flags |= SWP_NOACTIVATE; /* Already active */
/* Check dimensions */
if (cx <= 0) cx = 1;
if (cy <= 0) cy = 1;
if (!(wndPtr = WIN_FindWndPtr( hWnd ))) return FALSE;
#if OPTIMIZATION
if(wndPtr->dwStyle & WS_VISIBLE)
flags &= ~SWP_SHOWWINDOW;
else
@ -208,38 +215,30 @@ SetWindowPos(
if (!(flags & SWP_SHOWWINDOW)) flags |= SWP_NOREDRAW;
}
/* Check for windows that may not be resized
FIXME: this should be done only for Windows 3.0 programs
if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
flags |= SWP_NOSIZE | SWP_NOMOVE;
*/
/* Check dimensions */
if (cx <= 0) cx = 1;
if (cy <= 0) cy = 1;
/* Check flags */
if (hWnd == hwndActive) flags |= SWP_NOACTIVATE; /* Already active */
if ((wndPtr->rectWindow.right - wndPtr->rectWindow.left == cx) &&
(wndPtr->rectWindow.bottom - wndPtr->rectWindow.top == cy))
flags |= SWP_NOSIZE; /* Already the right size */
if ((wndPtr->rectWindow.left == X) && (wndPtr->rectWindow.top == Y))
flags |= SWP_NOMOVE; /* Already the right position */
#endif
/* Check hWndInsertAfter */
if (!(flags & (SWP_NOZORDER | SWP_NOACTIVATE)))
{
/* Ignore TOPMOST flags when activating a window */
/* _and_ moving it in Z order. */
if ((hWndInsertAfter == HWND_TOPMOST) ||
(hWndInsertAfter == HWND_NOTOPMOST))
if ((hWndInsertAfter == HWND_TOPMOST) || (hWndInsertAfter == HWND_NOTOPMOST))
hWndInsertAfter = HWND_TOP;
}
/* TOPMOST not supported yet */
if ((hWndInsertAfter == HWND_TOPMOST) ||
(hWndInsertAfter == HWND_NOTOPMOST)) hWndInsertAfter = HWND_TOP;
if ((hWndInsertAfter == HWND_TOPMOST) || (hWndInsertAfter == HWND_NOTOPMOST))
hWndInsertAfter = HWND_TOP;
/* hWndInsertAfter must be a sibling of the window */
if ((hWndInsertAfter != HWND_TOP) && (hWndInsertAfter != HWND_BOTTOM))
@ -274,7 +273,7 @@ SetWindowPos(
/* Send WM_WINDOWPOSCHANGING message */
if (!(winpos.flags & SWP_NOSENDCHANGING))
SendMessageA( hWnd, WM_WINDOWPOSCHANGING, 0, (LPARAM)&winpos );
MSG_SendMessage( wndPtr, WM_WINDOWPOSCHANGING, 0, (LPARAM)&winpos );
/* Calculate new position and size */
@ -414,10 +413,11 @@ SetWindowPos(
if (!(flags & SWP_NOREDRAW))
if (!(flags & SWP_NOREDRAW) && wndPtr->parent != NULL )
PAINT_RedrawWindow( wndPtr->parent->hwndSelf, &oldWindowRect,
0, RDW_INVALIDATE | RDW_ALLCHILDREN |
RDW_ERASE | RDW_ERASENOW, 0 );
uFlags |= SMC_NOPARENTERASE;
@ -468,6 +468,7 @@ SetWindowPos(
/***********************************************************************
* WINPOS_CreateInternalPosAtom
*/
@ -491,14 +492,14 @@ void WINPOS_CheckInternalPos( HWND hwnd )
if( hwnd == hwndActive )
{
hwndActive = 0;
//WARN(win, "\tattempt to activate destroyed window!\n");
DPRINT("\tattempt to activate destroyed window!\n");
}
if( lpPos )
{
if( IsWindow(lpPos->hwndIconTitle) )
DestroyWindow( lpPos->hwndIconTitle );
HeapFree( GetProcessHeap(), 0, lpPos );
//if( IsWindow(lpPos->hwndIconTitle) )
// DestroyWindow( lpPos->hwndIconTitle );
//HeapFree( GetProcessHeap(), 0, lpPos );
}
}
@ -512,7 +513,18 @@ static POINT WINPOS_FindIconPos( WND* wndPtr, POINT pt )
RECT rectParent;
short x, y, xspacing, yspacing;
GetClientRect( wndPtr->parent->hwndSelf, &rectParent );
if ( wndPtr->parent != NULL ) {
GetClientRect( wndPtr->parent->hwndSelf, &rectParent );
}
else {
rectParent.left = 0;
rectParent.right = SYSMETRICS_CXFULLSCREEN;
rectParent.top = 0;
rectParent.right = SYSMETRICS_CYFULLSCREEN;
}
if ((pt.x >= rectParent.left) && (pt.x + SYSMETRICS_CXICON < rectParent.right) &&
(pt.y >= rectParent.top) && (pt.y + SYSMETRICS_CYICON < rectParent.bottom))
return pt; /* The icon already has a suitable position */
@ -526,7 +538,9 @@ static POINT WINPOS_FindIconPos( WND* wndPtr, POINT pt )
for (x = rectParent.left; x <= rectParent.right-xspacing; x += xspacing)
{
/* Check if another icon already occupies this spot */
WND *childPtr = wndPtr->parent->child;
WND *childPtr = NULL;
if ( wndPtr->parent )
childPtr = wndPtr->parent->child;
while (childPtr)
{
if ((childPtr->dwStyle & WS_MINIMIZE) && (childPtr != wndPtr))
@ -712,6 +726,7 @@ LPINTERNALPOS WINPOS_InitInternalPos( WND* wnd, POINT pt,
*(UINT*)&lpPos->ptIconPos = *(UINT*)&lpPos->ptMaxPos = 0xFFFFFFFF;
}
if( wnd->dwStyle & WS_MINIMIZE )
memcpy( &lpPos->ptIconPos, &pt,sizeof(POINT) );
else if( wnd->dwStyle & WS_MAXIMIZE )
@ -824,7 +839,7 @@ void WINPOS_GetMinMaxInfo( WND *wndPtr, POINT *maxSize, POINT *maxPos,
MinMax.ptMaxPosition.y = -yinc;
}
SendMessageA( wndPtr->hwndSelf, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
MSG_SendMessage( wndPtr, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
/* Some sanity checks */
@ -857,25 +872,19 @@ UINT WINPOS_MinMaximize( WND* wndPtr, UINT cmd, LPRECT lpRect )
//DPRINT("0x%04x %u\n", wndPtr->hwndSelf, cmd );
if ( wndPtr->class->bUnicode ) {
if (HOOK_CallHooksW(WH_CBT, HCBT_MINMAX, (INT)wndPtr->hwndSelf, cmd)) {
swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
return swpFlags;
}
}
else {
if (HOOK_CallHooksA(WH_CBT, HCBT_MINMAX, (INT)wndPtr->hwndSelf, cmd)) {
swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
return swpFlags;
}
if (HOOK_CallHooks(WH_CBT, HCBT_MINMAX, (INT)wndPtr->hwndSelf, cmd, wndPtr->class->bUnicode )) {
swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
return swpFlags;
}
if (lpPos)
{
if( wndPtr->dwStyle & WS_MINIMIZE )
{
if( !SendMessageA( wndPtr->hwndSelf, WM_QUERYOPEN, 0, 0L ) )
if( !MSG_SendMessage( wndPtr->hwndSelf, WM_QUERYOPEN, 0, 0L ) )
return (SWP_NOSIZE | SWP_NOMOVE);
swpFlags |= SWP_NOCOPYBITS;
}
@ -1000,7 +1009,156 @@ WINBOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT *wndpl,
*/
WINBOOL WINPOS_SetActiveWindow( HWND hWnd, WINBOOL fMouse, WINBOOL fChangeFocus)
{
return FALSE;
CBTACTIVATESTRUCT* cbtStruct;
WND* wndPtr, *wndTemp;
//HQUEUE hOldActiveQueue, hNewActiveQueue;
WORD wIconized = 0;
/* paranoid checks */
if( hWnd == GetDesktopWindow || hWnd == hwndActive ) return 0;
/* if (wndPtr && (GetFastQueue() != wndPtr->hmemTaskQ))
* return 0;
*/
wndPtr = WIN_FindWndPtr(hWnd);
//hOldActiveQueue = (pActiveQueue)?pActiveQueue->self : 0;
if( (wndTemp = WIN_FindWndPtr(hwndActive)) )
wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
#if 0
/* call CBT hook chain */
if ((cbtStruct = SEGPTR_NEW(CBTACTIVATESTRUCT16)))
{
LRESULT wRet;
cbtStruct->fMouse = fMouse;
cbtStruct->hWndActive = hwndActive;
wRet = HOOK_CallHooks16( WH_CBT, HCBT_ACTIVATE, (WPARAM16)hWnd,
(LPARAM)SEGPTR_GET(cbtStruct) );
SEGPTR_FREE(cbtStruct);
if (wRet) return wRet;
}
#endif
/* set prev active wnd to current active wnd and send notification */
if ((hwndPrevActive = hwndActive) && IsWindow(hwndPrevActive))
{
if (!SendMessageA( hwndPrevActive, WM_NCACTIVATE, FALSE, 0 ))
{
//if (GetSysModalWindow16() != hWnd) return 0;
/* disregard refusal if hWnd is sysmodal */
}
SendMessageA( hwndPrevActive, WM_ACTIVATE,
MAKEWPARAM( WA_INACTIVE, wIconized ),
(LPARAM)hWnd );
/* check if something happened during message processing */
if( hwndPrevActive != hwndActive ) return 0;
}
/* set active wnd */
hwndActive = hWnd;
/* send palette messages */
if (hWnd && SendMessage( hWnd, WM_QUERYNEWPALETTE, 0, 0L))
SendMessage((HWND)-1, WM_PALETTEISCHANGING, (WPARAM)hWnd, 0L );
/* if prev wnd is minimized redraw icon title */
if( IsIconic( hwndPrevActive ) ) WINPOS_RedrawIconTitle(hwndPrevActive);
#if DESKTOP
/* managed windows will get ConfigureNotify event */
if (wndPtr && !(wndPtr->dwStyle & WS_CHILD) && !(wndPtr->flags & WIN_MANAGED))
{
/* check Z-order and bring hWnd to the top */
for (wndTemp = WIN_GetDesktop()->child; wndTemp; wndTemp = wndTemp->next)
if (wndTemp->dwStyle & WS_VISIBLE) break;
if( wndTemp != wndPtr )
SetWindowPos(hWnd, HWND_TOP, 0,0,0,0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE );
if (!IsWindow(hWnd)) return 0;
}
#endif
#if 0
hNewActiveQueue = wndPtr ? wndPtr->hmemTaskQ : 0;
/* send WM_ACTIVATEAPP if necessary */
if (hOldActiveQueue != hNewActiveQueue)
{
WND **list, **ppWnd;
if ((list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
{
for (ppWnd = list; *ppWnd; ppWnd++)
{
if (!IsWindow( (*ppWnd)->hwndSelf )) continue;
if ((*ppWnd)->hmemTaskQ == hOldActiveQueue)
SendMessage16( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP,
0, QUEUE_GetQueueTask(hNewActiveQueue) );
}
HeapFree( SystemHeap, 0, list );
}
pActiveQueue = (hNewActiveQueue)
? (MESSAGEQUEUE*) GlobalLock16(hNewActiveQueue) : NULL;
if ((list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
{
for (ppWnd = list; *ppWnd; ppWnd++)
{
if (!IsWindow( (*ppWnd)->hwndSelf )) continue;
if ((*ppWnd)->hmemTaskQ == hNewActiveQueue)
SendMessage( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP,
1, QUEUE_GetQueueTask( hOldActiveQueue ) );
}
HeapFree( SystemHeap, 0, list );
}
if (!IsWindow(hWnd)) return 0;
}
#endif
if (hWnd)
{
/* walk up to the first unowned window */
wndTemp = wndPtr;
while (wndTemp->owner) wndTemp = wndTemp->owner;
/* and set last active owned popup */
wndTemp->hwndLastActive = hWnd;
wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
SendMessageA( hWnd, WM_NCACTIVATE, TRUE, 0 );
SendMessageA( hWnd, WM_ACTIVATE,
MAKEWPARAM( (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE, wIconized),
(LPARAM)hwndPrevActive );
if( !IsWindow(hWnd) ) return 0;
}
#if 0
/* change focus if possible */
if( fChangeFocus && GetFocus() )
if( WIN_GetTopParent(GetFocus()) != hwndActive )
FOCUS_SwitchFocus( GetFocus(),
(wndPtr && (wndPtr->dwStyle & WS_MINIMIZE))?
0:
hwndActive
);
#endif
/* if active wnd is minimized redraw icon title */
if( IsIconic(hwndActive) ) WINPOS_RedrawIconTitle(hwndActive);
return (hWnd == hwndActive);
}
/*******************************************************************
@ -1060,7 +1218,7 @@ WINBOOL WINPOS_ChangeActiveWindow( HWND hWnd, WINBOOL mouseMsg )
/* child windows get WM_CHILDACTIVATE message */
if( (wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD )
return SendMessageA(hWnd, WM_CHILDACTIVATE, 0, 0L);
return MSG_SendMessage(wndPtr, WM_CHILDACTIVATE, 0, 0L);
/* owned popups imply owner activation - not sure */
if ((wndPtr->dwStyle & WS_POPUP) && wndPtr->owner &&
@ -1076,10 +1234,11 @@ WINBOOL WINPOS_ChangeActiveWindow( HWND hWnd, WINBOOL mouseMsg )
if( !WINPOS_SetActiveWindow(hWnd ,mouseMsg ,TRUE) )
return FALSE;
#if DESKTOP
/* switch desktop queue to current active */
if( wndPtr->parent == WIN_GetDesktop())
WIN_GetDesktop()->hmemTaskQ = wndPtr->hmemTaskQ;
#endif
return TRUE;
}
@ -1397,8 +1556,7 @@ UINT WINPOS_SizeMoveClean( WND* Wnd, HRGN oldVisRgn,
// REMOVED DCX_KEEPCLIPRGN
hDC = GetDCEx( Wnd->parent->hwndSelf, oldVisRgn,
DCX_INTERSECTRGN |
DCX_CACHE | DCX_CLIPSIBLINGS);
DCX_INTERSECTRGN | DCX_CACHE | DCX_CLIPSIBLINGS);
BitBlt( hDC, xto, yto, width, height, hDC, xfrom, yfrom, SRCCOPY );
ReleaseDC( Wnd->parent->hwndSelf, hDC);
@ -1422,3 +1580,15 @@ UINT WINPOS_SizeMoveClean( WND* Wnd, HRGN oldVisRgn,
return uFlags;
}
/***********************************************************************
* MoveWindow (USER32.399)
*/
WINBOOL STDCALL MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
WINBOOL repaint )
{
int flags = SWP_NOZORDER | SWP_NOACTIVATE;
if (!repaint) flags |= SWP_NOREDRAW;
return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
}