Tue Jan 4 13:01:33 1994 David Metcalfe <david@prism.demon.co.uk> * [window/caret.c] Modified code to use system timer. Jan 9, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [windows/win.c] Windows create if required new XLIB MenuBar & CaptionBar. * [windows/defwnd.c] WM_CALCSIZE Move & Resize caption, menubar & scrollbars. (I'm not sure it's the good place for it, but it work...) * [loader/resource.c] optimize in FindResourceByNumber, make lseek() if next type ... * [controls/scroll.c] scrollbar buttons are now using system resources bitmaps. * [controls/caption.c] - new file ... captionbar showing title, close button with SysMenu, and other buttons using system resources bitmaps. * [controls/menu.c] New functions: SetMenuItemBitmaps() with 'glues', Make new version of LoadMenu() & ParseMenu(), ( put #define USE_POPUPMENU ). Implementation of MenuBar functions. * [sysres.dll] New bitmaps for system such OBM_CLOSE, OBM_MINIMIZE, OBM_UPARROWI. New SYSMENU menu, it don't work yet ! :-(( Tue Jan 11 05:27:45 1994 julliard@di.epfl.ch (Alexandre Julliard * [memory/atom.c] Fixed a bug that could cause atoms to be case-sensitive. * [misc/rect.c] Bug fix in SubtractRect(). * [objects/clipping.c] Bug fix when setting the clip mask to an empty region. * [windows/dce.c] Bug fix in ReleaseDC(). * [windows/dialog.c] Call AdjustWindowRectEx() before creating the dialog window. Added support for DS_MODALFRAME style. * [windows/event.c] Cleaned up event handling and removed old Xt stuff. Moved double-click handling to windows/message.c * [windows/focus.c] Bug fix: only set the X focus when the window is viewable. * [windows/graphics.c] Rewritten DrawReliefRect() to use brush instead of pen, and to use the system colors. * [windows/message.c] Implemented WM_NCHITTEST message sending, and non-client mouse messages. Cleaned up double-click handling, and removed the Xt code. * [windows/nonclient.c] (New file) Implemented AdjustWindowRect(). Implemented WM_NCCALCSIZE, WM_NCHITTEST and WM_NCPAINT handling. * [windows/painting.c] Added sending of the WM_NCPAINT message in BeginPaint(). * [windows/sysmetrics.c] [include/sysmetrics.h] (New files) Implemented system metrics. * [windows/win.c] Bug fix in setting the parent and owner in CreateWindow(). Removed the Xt code. * [windows/winpos.c] Added sending of the WM_NCPAINT message in SetWindowPos(). Removed the Xt code.
211 lines
5.1 KiB
C
211 lines
5.1 KiB
C
/*
|
|
* Default window procedure
|
|
*
|
|
* Copyright 1993 Alexandre Julliard
|
|
*/
|
|
|
|
static char Copyright[] = "Copyright Alexandre Julliard, 1993";
|
|
|
|
|
|
#include "windows.h"
|
|
#include "win.h"
|
|
#include "class.h"
|
|
#include "user.h"
|
|
|
|
extern Display * display;
|
|
|
|
extern LONG NC_HandleNCPaint( HWND hwnd, HRGN hrgn );
|
|
extern LONG NC_HandleNCCalcSize( HWND hwnd, NCCALCSIZE_PARAMS *params );
|
|
extern LONG NC_HandleNCHitTest( HWND hwnd, POINT pt );
|
|
extern LONG NC_HandleNCMouseMsg(HWND hwnd, WORD msg, WORD wParam, LONG lParam);
|
|
|
|
|
|
/***********************************************************************
|
|
* DefWindowProc (USER.107)
|
|
*/
|
|
LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam )
|
|
{
|
|
CLASS * classPtr;
|
|
LPSTR textPtr;
|
|
int len;
|
|
int tempwidth, tempheight;
|
|
WND * wndPtr = WIN_FindWndPtr( hwnd );
|
|
|
|
#ifdef DEBUG_MESSAGE
|
|
printf( "DefWindowProc: %d %d %d %08x\n", hwnd, msg, wParam, lParam );
|
|
#endif
|
|
|
|
switch(msg)
|
|
{
|
|
case WM_NCCREATE:
|
|
{
|
|
CREATESTRUCT * createStruct = (CREATESTRUCT *)lParam;
|
|
if (createStruct->lpszName)
|
|
{
|
|
/* Allocate space for window text */
|
|
wndPtr->hText = USER_HEAP_ALLOC(GMEM_MOVEABLE,
|
|
strlen(createStruct->lpszName) + 2);
|
|
textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
|
|
strcpy(textPtr, createStruct->lpszName);
|
|
*(textPtr + strlen(createStruct->lpszName) + 1) = '\0';
|
|
/* for use by edit control */
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
case WM_NCCALCSIZE:
|
|
return NC_HandleNCCalcSize( hwnd, (NCCALCSIZE_PARAMS *)lParam );
|
|
|
|
case WM_NCPAINT:
|
|
return NC_HandleNCPaint( hwnd, (HRGN)wParam );
|
|
|
|
case WM_NCHITTEST:
|
|
return NC_HandleNCHitTest( hwnd, MAKEPOINT(lParam) );
|
|
|
|
case WM_NCLBUTTONDOWN:
|
|
case WM_NCLBUTTONUP:
|
|
case WM_NCLBUTTONDBLCLK:
|
|
case WM_NCMOUSEMOVE:
|
|
return NC_HandleNCMouseMsg( hwnd, msg, wParam, lParam );
|
|
|
|
case WM_NCDESTROY:
|
|
{
|
|
if (wndPtr->hText) USER_HEAP_FREE(wndPtr->hText);
|
|
wndPtr->hText = 0;
|
|
return 0;
|
|
}
|
|
|
|
case WM_PAINT:
|
|
{
|
|
PAINTSTRUCT paintstruct;
|
|
BeginPaint( hwnd, &paintstruct );
|
|
EndPaint( hwnd, &paintstruct );
|
|
return 0;
|
|
}
|
|
|
|
case WM_CLOSE:
|
|
DestroyWindow( hwnd );
|
|
return 0;
|
|
|
|
case WM_WINDOWPOSCHANGED:
|
|
{
|
|
WINDOWPOS * winPos = (WINDOWPOS *)lParam;
|
|
if (!(winPos->flags & SWP_NOMOVE))
|
|
SendMessage( hwnd, WM_MOVE, 0,
|
|
MAKELONG( wndPtr->rectClient.left,
|
|
wndPtr->rectClient.top ));
|
|
if (!(winPos->flags & SWP_NOSIZE))
|
|
SendMessage( hwnd, WM_SIZE, SIZE_RESTORED,
|
|
MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
|
|
wndPtr->rectClient.bottom-wndPtr->rectClient.top));
|
|
return 0;
|
|
}
|
|
|
|
case WM_ERASEBKGND:
|
|
case WM_ICONERASEBKGND:
|
|
{
|
|
if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return 1;
|
|
if (!classPtr->wc.hbrBackground) return 1;
|
|
FillWindow( GetParent(hwnd), hwnd, (HDC)wParam,
|
|
classPtr->wc.hbrBackground );
|
|
return 0;
|
|
}
|
|
|
|
case WM_GETDLGCODE:
|
|
return 0;
|
|
|
|
case WM_CTLCOLOR:
|
|
{
|
|
if (HIWORD(lParam) == CTLCOLOR_SCROLLBAR)
|
|
{
|
|
SetBkColor( (HDC)wParam, RGB(255, 255, 255) );
|
|
SetTextColor( (HDC)wParam, RGB(0, 0, 0) );
|
|
/* hbr = sysClrObjects.hbrScrollbar;
|
|
UnrealizeObject(hbr); */
|
|
return GetStockObject(LTGRAY_BRUSH);
|
|
}
|
|
else
|
|
{
|
|
SetBkColor( (HDC)wParam, GetSysColor(COLOR_WINDOW) );
|
|
SetTextColor( (HDC)wParam, GetSysColor(COLOR_WINDOWTEXT) );
|
|
/* hbr = sysClrObjects.hbrWindow; */
|
|
return GetStockObject(WHITE_BRUSH);
|
|
}
|
|
}
|
|
|
|
case WM_GETTEXT:
|
|
{
|
|
if (wParam)
|
|
{
|
|
if (wndPtr->hText)
|
|
{
|
|
textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
|
|
if ((int)wParam > (len = strlen(textPtr)))
|
|
{
|
|
strcpy((char *)lParam, textPtr);
|
|
return (DWORD)len;
|
|
}
|
|
}
|
|
lParam = (DWORD)NULL;
|
|
}
|
|
return (0L);
|
|
}
|
|
|
|
case WM_GETTEXTLENGTH:
|
|
{
|
|
if (wndPtr->hText)
|
|
{
|
|
textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
|
|
return (DWORD)strlen(textPtr);
|
|
}
|
|
return (0L);
|
|
}
|
|
|
|
case WM_SETTEXT:
|
|
{
|
|
if (wndPtr->hText)
|
|
USER_HEAP_FREE(wndPtr->hText);
|
|
|
|
wndPtr->hText = USER_HEAP_ALLOC(GMEM_MOVEABLE,
|
|
strlen((LPSTR)lParam) + 1);
|
|
textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
|
|
strcpy(textPtr, (LPSTR)lParam);
|
|
XStoreName( display, wndPtr->window, textPtr );
|
|
return (0L);
|
|
}
|
|
case WM_SETCURSOR:
|
|
if (wndPtr->hCursor != (HCURSOR)NULL)
|
|
SetCursor(wndPtr->hCursor);
|
|
return 0L;
|
|
case WM_SYSCOMMAND:
|
|
switch (wParam)
|
|
{
|
|
case SC_CLOSE:
|
|
ShowWindow(hwnd, SW_MINIMIZE);
|
|
printf("defdwndproc WM_SYSCOMMAND SC_CLOSE !\n");
|
|
return SendMessage( hwnd, WM_CLOSE, 0, 0 );
|
|
case SC_RESTORE:
|
|
ShowWindow(hwnd, SW_RESTORE);
|
|
break;
|
|
case SC_MINIMIZE:
|
|
ShowWindow(hwnd, SW_MINIMIZE);
|
|
printf("defdwndproc WM_SYSCOMMAND SC_MINIMIZE !\n");
|
|
break;
|
|
case SC_MAXIMIZE:
|
|
ShowWindow(hwnd, SW_MAXIMIZE);
|
|
break;
|
|
}
|
|
break;
|
|
case WM_SYSKEYDOWN:
|
|
if (wParam == VK_MENU) {
|
|
printf("VK_MENU Pressed // hMenu=%04X !\n", GetMenu(hwnd));
|
|
}
|
|
break;
|
|
case WM_SYSKEYUP:
|
|
if (wParam == VK_MENU) {
|
|
printf("VK_MENU Released // hMenu=%04X !\n", GetMenu(hwnd));
|
|
}
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|