/*
|
/*
|
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
|
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
|
*
|
*
|
* DefWindowProc implementation for Micro-Windows
|
* DefWindowProc implementation for Micro-Windows
|
* This file should ideally only include windows.h, and be built
|
* This file should ideally only include windows.h, and be built
|
* on top of regular win32 api calls. For speed, however,
|
* on top of regular win32 api calls. For speed, however,
|
* certain knowledge of the internal hwnd is known...
|
* certain knowledge of the internal hwnd is known...
|
*/
|
*/
|
#include "windows.h"
|
#include "windows.h"
|
#include "wintern.h"
|
#include "wintern.h"
|
#include "device.h"
|
#include "device.h"
|
#include "wintools.h" /* Draw3dBox, etc*/
|
#include "wintools.h" /* Draw3dBox, etc*/
|
#include <string.h>
|
#include <string.h>
|
|
|
/* desktop wallpaper image*/
|
/* desktop wallpaper image*/
|
static PMWIMAGEHDR pImageWallpaper = NULL;
|
static PMWIMAGEHDR pImageWallpaper = NULL;
|
|
|
/* local routines*/
|
/* local routines*/
|
static void GetCloseBoxRect(HWND hwnd, LPRECT lprc);
|
static void GetCloseBoxRect(HWND hwnd, LPRECT lprc);
|
static void DrawXORFrame(HWND hwnd,int x, int y, BOOL bDrawCurrent);
|
static void DrawXORFrame(HWND hwnd,int x, int y, BOOL bDrawCurrent);
|
static RECT lastrc;
|
static RECT lastrc;
|
|
|
BOOL
|
BOOL
|
MwSetDesktopWallpaper(PMWIMAGEHDR pImage)
|
MwSetDesktopWallpaper(PMWIMAGEHDR pImage)
|
{
|
{
|
pImageWallpaper = pImage;
|
pImageWallpaper = pImage;
|
InvalidateRect(rootwp, NULL, TRUE);
|
InvalidateRect(rootwp, NULL, TRUE);
|
return TRUE;
|
return TRUE;
|
}
|
}
|
|
|
/* needed only for XORMOVE repaint algorithm*/
|
/* needed only for XORMOVE repaint algorithm*/
|
static void
|
static void
|
DrawXORFrame(HWND hwnd,int x, int y, BOOL bDrawCurrent)
|
DrawXORFrame(HWND hwnd,int x, int y, BOOL bDrawCurrent)
|
{
|
{
|
HDC hdc;
|
HDC hdc;
|
RECT rc;
|
RECT rc;
|
|
|
hdc = GetDCEx(NULL, NULL, DCX_WINDOW|DCX_EXCLUDEUPDATE);
|
hdc = GetDCEx(NULL, NULL, DCX_WINDOW|DCX_EXCLUDEUPDATE);
|
SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
SelectObject(hdc, GetStockObject(WHITE_PEN));
|
SelectObject(hdc, GetStockObject(WHITE_PEN));
|
GdSetMode(MWMODE_XOR);
|
GdSetMode(MWMODE_XOR);
|
if(!IsRectEmpty(&lastrc))
|
if(!IsRectEmpty(&lastrc))
|
Rectangle(hdc, lastrc.left, lastrc.top, lastrc.right,
|
Rectangle(hdc, lastrc.left, lastrc.top, lastrc.right,
|
lastrc.bottom);
|
lastrc.bottom);
|
GetWindowRect(hwnd, &rc);
|
GetWindowRect(hwnd, &rc);
|
SetRect(&lastrc, rc.left+x, rc.top+y, rc.right+x, rc.bottom+y);
|
SetRect(&lastrc, rc.left+x, rc.top+y, rc.right+x, rc.bottom+y);
|
if(bDrawCurrent)
|
if(bDrawCurrent)
|
Rectangle(hdc, lastrc.left, lastrc.top, lastrc.right,
|
Rectangle(hdc, lastrc.left, lastrc.top, lastrc.right,
|
lastrc.bottom);
|
lastrc.bottom);
|
ReleaseDC(NULL, hdc);
|
ReleaseDC(NULL, hdc);
|
GdSetMode(MWMODE_COPY);
|
GdSetMode(MWMODE_COPY);
|
}
|
}
|
|
|
/*
|
/*
|
* This procedure implements the messages passed by the window
|
* This procedure implements the messages passed by the window
|
* manager for default processing on behalf of the window.
|
* manager for default processing on behalf of the window.
|
*/
|
*/
|
LRESULT WINAPI
|
LRESULT WINAPI
|
DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
{
|
{
|
HDC hdc;
|
HDC hdc;
|
RECT rc;
|
RECT rc;
|
DWORD dwStyle;
|
DWORD dwStyle;
|
HBRUSH hbr;
|
HBRUSH hbr;
|
HPEN hpen, holdpen;
|
HPEN hpen, holdpen;
|
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
POINT curpt;
|
POINT curpt;
|
int x, y;
|
int x, y;
|
HWND wp;
|
HWND wp;
|
HWND oldActive;
|
HWND oldActive;
|
COLORREF crCaption;
|
COLORREF crCaption;
|
LPNCCALCSIZE_PARAMS lpnc;
|
LPNCCALCSIZE_PARAMS lpnc;
|
CHAR szTitle[64];
|
CHAR szTitle[64];
|
static POINT startpt;
|
static POINT startpt;
|
|
|
switch(msg) {
|
switch(msg) {
|
case WM_NCCALCSIZE:
|
case WM_NCCALCSIZE:
|
/* calculate client rect from passed window rect in rgrc[0]*/
|
/* calculate client rect from passed window rect in rgrc[0]*/
|
lpnc = (LPNCCALCSIZE_PARAMS)lParam;
|
lpnc = (LPNCCALCSIZE_PARAMS)lParam;
|
dwStyle = GetWindowLong(hwnd, GWL_STYLE);
|
dwStyle = GetWindowLong(hwnd, GWL_STYLE);
|
if(dwStyle & WS_BORDER) {
|
if(dwStyle & WS_BORDER) {
|
if((dwStyle & WS_CAPTION) == WS_CAPTION) {
|
if((dwStyle & WS_CAPTION) == WS_CAPTION) {
|
InflateRect(&lpnc->rgrc[0],
|
InflateRect(&lpnc->rgrc[0],
|
-mwSYSMETRICS_CXFRAME,
|
-mwSYSMETRICS_CXFRAME,
|
-mwSYSMETRICS_CYFRAME);
|
-mwSYSMETRICS_CYFRAME);
|
lpnc->rgrc[0].top += mwSYSMETRICS_CYCAPTION + 1;
|
lpnc->rgrc[0].top += mwSYSMETRICS_CYCAPTION + 1;
|
} else
|
} else
|
InflateRect(&lpnc->rgrc[0], -1, -1);
|
InflateRect(&lpnc->rgrc[0], -1, -1);
|
}
|
}
|
break;
|
break;
|
|
|
case WM_NCPAINT:
|
case WM_NCPAINT:
|
/* repaint all non-client area*/
|
/* repaint all non-client area*/
|
dwStyle = GetWindowLong(hwnd, GWL_STYLE);
|
dwStyle = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
if(dwStyle & WS_BORDER) {
|
if(dwStyle & WS_BORDER) {
|
hdc = GetWindowDC(hwnd);
|
hdc = GetWindowDC(hwnd);
|
GetWindowRect(hwnd, &rc);
|
GetWindowRect(hwnd, &rc);
|
|
|
if((dwStyle & WS_CAPTION) == WS_CAPTION) {
|
if((dwStyle & WS_CAPTION) == WS_CAPTION) {
|
/* draw 2-line 3d border around window*/
|
/* draw 2-line 3d border around window*/
|
Draw3dOutset(hdc, rc.left, rc.top,
|
Draw3dOutset(hdc, rc.left, rc.top,
|
rc.right-rc.left, rc.bottom-rc.top);
|
rc.right-rc.left, rc.bottom-rc.top);
|
InflateRect(&rc, -2, -2);
|
InflateRect(&rc, -2, -2);
|
|
|
/* draw 1-line inset inside border*/
|
/* draw 1-line inset inside border*/
|
hpen = CreatePen(PS_SOLID, 1,
|
hpen = CreatePen(PS_SOLID, 1,
|
GetSysColor(COLOR_BTNFACE));
|
GetSysColor(COLOR_BTNFACE));
|
holdpen = SelectObject(hdc, hpen);
|
holdpen = SelectObject(hdc, hpen);
|
SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
Rectangle(hdc, rc.left, rc.top, rc.right,
|
Rectangle(hdc, rc.left, rc.top, rc.right,
|
rc.bottom);
|
rc.bottom);
|
InflateRect(&rc, -1, -1);
|
InflateRect(&rc, -1, -1);
|
|
|
/* fill caption*/
|
/* fill caption*/
|
rc.bottom = rc.top + mwSYSMETRICS_CYCAPTION;
|
rc.bottom = rc.top + mwSYSMETRICS_CYCAPTION;
|
crCaption = GetActiveWindow()==hwnd?
|
crCaption = GetActiveWindow()==hwnd?
|
GetSysColor(COLOR_ACTIVECAPTION):
|
GetSysColor(COLOR_ACTIVECAPTION):
|
GetSysColor(COLOR_INACTIVECAPTION);
|
GetSysColor(COLOR_INACTIVECAPTION);
|
hbr = CreateSolidBrush(crCaption);
|
hbr = CreateSolidBrush(crCaption);
|
FillRect(hdc, &rc, hbr);
|
FillRect(hdc, &rc, hbr);
|
DeleteObject(hbr);
|
DeleteObject(hbr);
|
|
|
/* draw 1 line under caption*/
|
/* draw 1 line under caption*/
|
MoveToEx(hdc, rc.left, rc.bottom, NULL);
|
MoveToEx(hdc, rc.left, rc.bottom, NULL);
|
LineTo(hdc, rc.right, rc.bottom);
|
LineTo(hdc, rc.right, rc.bottom);
|
DeleteObject(SelectObject(hdc, holdpen));
|
DeleteObject(SelectObject(hdc, holdpen));
|
|
|
/* draw caption text*/
|
/* draw caption text*/
|
if(GetWindowText(hwnd, szTitle,
|
if(GetWindowText(hwnd, szTitle,
|
sizeof(szTitle))) {
|
sizeof(szTitle))) {
|
SetBkMode(hdc, TRANSPARENT);
|
SetBkMode(hdc, TRANSPARENT);
|
/* set background color even though
|
/* set background color even though
|
* transparent in case GdArea is used
|
* transparent in case GdArea is used
|
* to draw text which compares
|
* to draw text which compares
|
* gr_foreground != gr_background
|
* gr_foreground != gr_background
|
* when transparent...
|
* when transparent...
|
*/
|
*/
|
SetBkColor(hdc, crCaption);
|
SetBkColor(hdc, crCaption);
|
SetTextColor(hdc,
|
SetTextColor(hdc,
|
GetActiveWindow()==hwnd?
|
GetActiveWindow()==hwnd?
|
GetSysColor(COLOR_CAPTIONTEXT):
|
GetSysColor(COLOR_CAPTIONTEXT):
|
GetSysColor(COLOR_INACTIVECAPTIONTEXT));
|
GetSysColor(COLOR_INACTIVECAPTIONTEXT));
|
SelectObject(hdc,
|
SelectObject(hdc,
|
GetStockObject(DEFAULT_GUI_FONT));
|
GetStockObject(DEFAULT_GUI_FONT));
|
GetWindowRect(hwnd, &rc);
|
GetWindowRect(hwnd, &rc);
|
TextOut(hdc, rc.left+4, rc.top+2,
|
TextOut(hdc, rc.left+4, rc.top+2,
|
szTitle, strlen(szTitle));
|
szTitle, strlen(szTitle));
|
}
|
}
|
|
|
/* draw close box*/
|
/* draw close box*/
|
GetCloseBoxRect(hwnd, &rc);
|
GetCloseBoxRect(hwnd, &rc);
|
/*DrawDIB(hdc, rc.right-XSIZE_CLOSEBOX-3,
|
/*DrawDIB(hdc, rc.right-XSIZE_CLOSEBOX-3,
|
rc.top+3, &image_close4);*/
|
rc.top+3, &image_close4);*/
|
Draw3dBox(hdc, rc.left, rc.top,
|
Draw3dBox(hdc, rc.left, rc.top,
|
rc.right-rc.left, rc.bottom-rc.top,
|
rc.right-rc.left, rc.bottom-rc.top,
|
GetSysColor(COLOR_BTNHIGHLIGHT),
|
GetSysColor(COLOR_BTNHIGHLIGHT),
|
GetSysColor(COLOR_WINDOWFRAME));
|
GetSysColor(COLOR_WINDOWFRAME));
|
InflateRect(&rc, -1, -1);
|
InflateRect(&rc, -1, -1);
|
hbr = CreateSolidBrush(
|
hbr = CreateSolidBrush(
|
GetSysColor(COLOR_BTNFACE));
|
GetSysColor(COLOR_BTNFACE));
|
FillRect(hdc, &rc, hbr);
|
FillRect(hdc, &rc, hbr);
|
DeleteObject(hbr);
|
DeleteObject(hbr);
|
|
|
InflateRect(&rc, -1, -1);
|
InflateRect(&rc, -1, -1);
|
MoveToEx(hdc, rc.left, rc.top, NULL);
|
MoveToEx(hdc, rc.left, rc.top, NULL);
|
LineTo(hdc, rc.right-1, rc.bottom-1);
|
LineTo(hdc, rc.right-1, rc.bottom-1);
|
MoveToEx(hdc, rc.left, rc.bottom-1, NULL);
|
MoveToEx(hdc, rc.left, rc.bottom-1, NULL);
|
LineTo(hdc, rc.right-1, rc.top);
|
LineTo(hdc, rc.right-1, rc.top);
|
} else {
|
} else {
|
SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
Rectangle(hdc, rc.left, rc.top, rc.right,
|
Rectangle(hdc, rc.left, rc.top, rc.right,
|
rc.bottom);
|
rc.bottom);
|
}
|
}
|
ReleaseDC(hwnd, hdc);
|
ReleaseDC(hwnd, hdc);
|
}
|
}
|
break;
|
break;
|
|
|
case WM_NCHITTEST:
|
case WM_NCHITTEST:
|
/* if system is dragging a window, always return caption*/
|
/* if system is dragging a window, always return caption*/
|
if(dragwp)
|
if(dragwp)
|
return HTCAPTION;
|
return HTCAPTION;
|
|
|
/* Determine what part of the window the mouse is over*/
|
/* Determine what part of the window the mouse is over*/
|
POINTSTOPOINT(curpt, lParam);
|
POINTSTOPOINT(curpt, lParam);
|
|
|
if(PtInRect(&hwnd->clirect, curpt))
|
if(PtInRect(&hwnd->clirect, curpt))
|
return HTCLIENT;
|
return HTCLIENT;
|
|
|
if(PtInRect(&hwnd->vscroll.rc, curpt))
|
if(PtInRect(&hwnd->vscroll.rc, curpt))
|
return HTVSCROLL;
|
return HTVSCROLL;
|
if(PtInRect(&hwnd->hscroll.rc, curpt))
|
if(PtInRect(&hwnd->hscroll.rc, curpt))
|
return HTHSCROLL;
|
return HTHSCROLL;
|
|
|
dwStyle = GetWindowLong(hwnd, GWL_STYLE);
|
dwStyle = GetWindowLong(hwnd, GWL_STYLE);
|
if((dwStyle & WS_CAPTION) == WS_CAPTION) {
|
if((dwStyle & WS_CAPTION) == WS_CAPTION) {
|
GetCloseBoxRect(hwnd, &rc);
|
GetCloseBoxRect(hwnd, &rc);
|
if(PtInRect(&rc, curpt))
|
if(PtInRect(&rc, curpt))
|
return HTCLOSE;
|
return HTCLOSE;
|
|
|
GetWindowRect(hwnd, &rc);
|
GetWindowRect(hwnd, &rc);
|
InflateRect(&rc, -2, -2);
|
InflateRect(&rc, -2, -2);
|
rc.bottom = rc.top + mwSYSMETRICS_CYCAPTION;
|
rc.bottom = rc.top + mwSYSMETRICS_CYCAPTION;
|
if(PtInRect(&rc, curpt))
|
if(PtInRect(&rc, curpt))
|
return HTCAPTION;
|
return HTCAPTION;
|
|
|
GetWindowRect(hwnd, &rc);
|
GetWindowRect(hwnd, &rc);
|
InflateRect(&rc, -2, -2);
|
InflateRect(&rc, -2, -2);
|
rc.top += mwSYSMETRICS_CYCAPTION;
|
rc.top += mwSYSMETRICS_CYCAPTION;
|
if(PtInRect(&rc, curpt))
|
if(PtInRect(&rc, curpt))
|
return HTCLIENT;
|
return HTCLIENT;
|
|
|
return HTBORDER;
|
return HTBORDER;
|
}
|
}
|
return HTNOWHERE;
|
return HTNOWHERE;
|
|
|
case WM_NCLBUTTONDOWN:
|
case WM_NCLBUTTONDOWN:
|
/* Handle default actions for mouse down on window*/
|
/* Handle default actions for mouse down on window*/
|
if(wParam == HTCLOSE) {
|
if(wParam == HTCLOSE) {
|
SendMessage(hwnd, WM_CLOSE, 0, 0L);
|
SendMessage(hwnd, WM_CLOSE, 0, 0L);
|
break;
|
break;
|
}
|
}
|
|
|
/* set focus on mouse down, repaint if necessary*/
|
/* set focus on mouse down, repaint if necessary*/
|
oldActive = GetActiveWindow();
|
oldActive = GetActiveWindow();
|
if(wParam == HTCLIENT || wParam == HTVSCROLL ||
|
if(wParam == HTCLIENT || wParam == HTVSCROLL ||
|
wParam == HTHSCROLL)
|
wParam == HTHSCROLL)
|
/* activate and raise window if in client area*/
|
/* activate and raise window if in client area*/
|
/* kaffe port requires this commented out*/
|
/* kaffe port requires this commented out*/
|
SetForegroundWindow(hwnd);
|
SetForegroundWindow(hwnd);
|
else {
|
else {
|
/* otherwise just change focus window, same z order*/
|
/* otherwise just change focus window, same z order*/
|
/* this will activate it's top level parent*/
|
/* this will activate it's top level parent*/
|
SetFocus(hwnd);
|
SetFocus(hwnd);
|
}
|
}
|
/* repaint captions now because of activation change*/
|
/* repaint captions now because of activation change*/
|
UpdateWindow(oldActive);
|
UpdateWindow(oldActive);
|
UpdateWindow(hwnd);
|
UpdateWindow(hwnd);
|
|
|
if(wParam == HTVSCROLL || wParam == HTHSCROLL) {
|
if(wParam == HTVSCROLL || wParam == HTHSCROLL) {
|
MwHandleNCMessageScrollbar(hwnd, msg, wParam, lParam);
|
MwHandleNCMessageScrollbar(hwnd, msg, wParam, lParam);
|
break;
|
break;
|
}
|
}
|
|
|
/* start window drag if in caption area*/
|
/* start window drag if in caption area*/
|
if(wParam == HTCAPTION && hwnd != rootwp) {
|
if(wParam == HTCAPTION && hwnd != rootwp) {
|
POINTSTOPOINT(startpt, lParam);
|
POINTSTOPOINT(startpt, lParam);
|
if(!(GetWindowLong(hwnd, GWL_STYLE) & WS_MAXIMIZE))
|
if(!(GetWindowLong(hwnd, GWL_STYLE) & WS_MAXIMIZE))
|
dragwp = hwnd;
|
dragwp = hwnd;
|
SetRectEmpty(&lastrc); /* XORMOVE only*/
|
SetRectEmpty(&lastrc); /* XORMOVE only*/
|
}
|
}
|
break;
|
break;
|
|
|
case WM_NCMOUSEMOVE:
|
case WM_NCMOUSEMOVE:
|
if(wParam == HTVSCROLL || wParam == HTHSCROLL) {
|
if(wParam == HTVSCROLL || wParam == HTHSCROLL) {
|
MwHandleNCMessageScrollbar(hwnd, msg, wParam, lParam);
|
MwHandleNCMessageScrollbar(hwnd, msg, wParam, lParam);
|
break;
|
break;
|
}
|
}
|
|
|
/* drag window with mousemove after mousedown*/
|
/* drag window with mousemove after mousedown*/
|
if(dragwp == hwnd) {
|
if(dragwp == hwnd) {
|
POINTSTOPOINT(curpt, lParam);
|
POINTSTOPOINT(curpt, lParam);
|
x = curpt.x - startpt.x;
|
x = curpt.x - startpt.x;
|
y = curpt.y - startpt.y;
|
y = curpt.y - startpt.y;
|
|
|
if(mwERASEMOVE) {
|
if(mwERASEMOVE) {
|
GetWindowRect(hwnd, &rc);
|
GetWindowRect(hwnd, &rc);
|
MoveWindow(hwnd, rc.left+x, rc.top+y,
|
MoveWindow(hwnd, rc.left+x, rc.top+y,
|
rc.right-rc.left, rc.bottom-rc.top,
|
rc.right-rc.left, rc.bottom-rc.top,
|
TRUE);
|
TRUE);
|
startpt = curpt;
|
startpt = curpt;
|
} else
|
} else
|
DrawXORFrame(hwnd, x, y, TRUE);
|
DrawXORFrame(hwnd, x, y, TRUE);
|
}
|
}
|
break;
|
break;
|
|
|
case WM_NCLBUTTONUP:
|
case WM_NCLBUTTONUP:
|
/* stop window drag*/
|
/* stop window drag*/
|
if(dragwp == hwnd) {
|
if(dragwp == hwnd) {
|
dragwp = NULL;
|
dragwp = NULL;
|
|
|
if(mwERASEMOVE) {
|
if(mwERASEMOVE) {
|
/*
|
/*
|
* User stopped moving window, repaint
|
* User stopped moving window, repaint
|
* windows previously queued for painting.
|
* windows previously queued for painting.
|
*/
|
*/
|
for(wp=listwp; wp; wp=wp->next)
|
for(wp=listwp; wp; wp=wp->next)
|
if(wp->gotPaintMsg == PAINT_DELAYPAINT)
|
if(wp->gotPaintMsg == PAINT_DELAYPAINT)
|
wp->gotPaintMsg = PAINT_NEEDSPAINT;
|
wp->gotPaintMsg = PAINT_NEEDSPAINT;
|
} else {
|
} else {
|
POINTSTOPOINT(curpt, lParam);
|
POINTSTOPOINT(curpt, lParam);
|
x = curpt.x - startpt.x;
|
x = curpt.x - startpt.x;
|
y = curpt.y - startpt.y;
|
y = curpt.y - startpt.y;
|
DrawXORFrame(hwnd, x, y, FALSE);
|
DrawXORFrame(hwnd, x, y, FALSE);
|
GetWindowRect(hwnd, &rc);
|
GetWindowRect(hwnd, &rc);
|
MoveWindow(hwnd, rc.left+x, rc.top+y,
|
MoveWindow(hwnd, rc.left+x, rc.top+y,
|
rc.right-rc.left, rc.bottom-rc.top, TRUE);
|
rc.right-rc.left, rc.bottom-rc.top, TRUE);
|
}
|
}
|
}
|
}
|
|
|
if(wParam == HTVSCROLL || wParam == HTHSCROLL) {
|
if(wParam == HTVSCROLL || wParam == HTHSCROLL) {
|
MwHandleNCMessageScrollbar(hwnd, msg, wParam, lParam);
|
MwHandleNCMessageScrollbar(hwnd, msg, wParam, lParam);
|
break;
|
break;
|
}
|
}
|
break;
|
break;
|
|
|
case WM_NCLBUTTONDBLCLK:
|
case WM_NCLBUTTONDBLCLK:
|
if(wParam == HTVSCROLL || wParam == HTHSCROLL) {
|
if(wParam == HTVSCROLL || wParam == HTHSCROLL) {
|
MwHandleNCMessageScrollbar(hwnd, msg, wParam, lParam);
|
MwHandleNCMessageScrollbar(hwnd, msg, wParam, lParam);
|
break;
|
break;
|
}
|
}
|
|
|
/* maximize/restore processing*/
|
/* maximize/restore processing*/
|
if(wParam != HTCAPTION)
|
if(wParam != HTCAPTION)
|
break;
|
break;
|
|
|
if((hwnd->style & WS_CAPTION) == WS_CAPTION) {
|
if((hwnd->style & WS_CAPTION) == WS_CAPTION) {
|
if(hwnd->style & WS_MAXIMIZE) {
|
if(hwnd->style & WS_MAXIMIZE) {
|
rc = hwnd->restorerc;
|
rc = hwnd->restorerc;
|
MoveWindow(hwnd, rc.left, rc.top,
|
MoveWindow(hwnd, rc.left, rc.top,
|
rc.right-rc.left, rc.bottom-rc.top,
|
rc.right-rc.left, rc.bottom-rc.top,
|
TRUE);
|
TRUE);
|
hwnd->style &= ~WS_MAXIMIZE;
|
hwnd->style &= ~WS_MAXIMIZE;
|
} else {
|
} else {
|
hwnd->restorerc = hwnd->winrect;
|
hwnd->restorerc = hwnd->winrect;
|
GetWindowRect(rootwp, &rc);
|
GetWindowRect(rootwp, &rc);
|
MoveWindow(hwnd, -mwSYSMETRICS_CXFRAME,
|
MoveWindow(hwnd, -mwSYSMETRICS_CXFRAME,
|
-mwSYSMETRICS_CYFRAME,
|
-mwSYSMETRICS_CYFRAME,
|
rc.right+2*mwSYSMETRICS_CXFRAME,
|
rc.right+2*mwSYSMETRICS_CXFRAME,
|
rc.bottom+2*mwSYSMETRICS_CYFRAME, TRUE);
|
rc.bottom+2*mwSYSMETRICS_CYFRAME, TRUE);
|
hwnd->style |= WS_MAXIMIZE;
|
hwnd->style |= WS_MAXIMIZE;
|
}
|
}
|
}
|
}
|
break;
|
break;
|
|
|
case WM_GETTEXTLENGTH:
|
case WM_GETTEXTLENGTH:
|
/* Get window text length. This routine requires
|
/* Get window text length. This routine requires
|
* knowledge of the internal window structure
|
* knowledge of the internal window structure
|
*/
|
*/
|
return strlen(hwnd->szTitle);
|
return strlen(hwnd->szTitle);
|
|
|
case WM_GETTEXT:
|
case WM_GETTEXT:
|
/* Get window text. This routine requires
|
/* Get window text. This routine requires
|
* knowledge of the internal window structure
|
* knowledge of the internal window structure
|
*/
|
*/
|
return strzcpy((LPSTR)lParam, hwnd->szTitle, wParam);
|
return strzcpy((LPSTR)lParam, hwnd->szTitle, wParam);
|
|
|
case WM_SETTEXT:
|
case WM_SETTEXT:
|
/* Set window text. This routine requires
|
/* Set window text. This routine requires
|
* knowledge of the internal window structure.
|
* knowledge of the internal window structure.
|
* Note that setting text doesn't invalidate the window.
|
* Note that setting text doesn't invalidate the window.
|
*/
|
*/
|
strzcpy(hwnd->szTitle, (LPSTR)lParam, sizeof(hwnd->szTitle));
|
strzcpy(hwnd->szTitle, (LPSTR)lParam, sizeof(hwnd->szTitle));
|
return TRUE;
|
return TRUE;
|
|
|
case WM_CLOSE:
|
case WM_CLOSE:
|
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
if(hwnd == rootwp)
|
if(hwnd == rootwp)
|
PostQuitMessage(0);
|
PostQuitMessage(0);
|
break;
|
break;
|
|
|
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
/* erase background with class background brush*/
|
/* erase background with class background brush*/
|
hbr = (HBRUSH)GetClassLong(hwnd, GCL_HBRBACKGROUND);
|
hbr = (HBRUSH)GetClassLong(hwnd, GCL_HBRBACKGROUND);
|
if(!hbr)
|
if(!hbr)
|
return 0;
|
return 0;
|
/* don't exclude update region*/
|
/* don't exclude update region*/
|
hdc = GetDCEx(hwnd, NULL, DCX_DEFAULTCLIP);
|
hdc = GetDCEx(hwnd, NULL, DCX_DEFAULTCLIP);
|
FillRect(hdc, NULL, hbr);
|
FillRect(hdc, NULL, hbr);
|
ReleaseDC(hwnd, hdc);
|
ReleaseDC(hwnd, hdc);
|
return 1;
|
return 1;
|
|
|
case WM_PAINT:
|
case WM_PAINT:
|
/* required to send erasebkgnd for desktop window*/
|
/* required to send erasebkgnd for desktop window*/
|
hdc = BeginPaint(hwnd, &ps);
|
hdc = BeginPaint(hwnd, &ps);
|
|
|
/* draw desktop wallpaper*/
|
/* draw desktop wallpaper*/
|
if(hwnd == rootwp && pImageWallpaper) {
|
if(hwnd == rootwp && pImageWallpaper) {
|
GetWindowRect(hwnd, &rc);
|
GetWindowRect(hwnd, &rc);
|
DrawDIB(hdc,
|
DrawDIB(hdc,
|
(rc.right-rc.left-pImageWallpaper->width)/2,
|
(rc.right-rc.left-pImageWallpaper->width)/2,
|
(rc.bottom-rc.top-pImageWallpaper->height)/2,
|
(rc.bottom-rc.top-pImageWallpaper->height)/2,
|
pImageWallpaper);
|
pImageWallpaper);
|
}
|
}
|
|
|
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
break;
|
break;
|
}
|
}
|
return 0;
|
return 0;
|
}
|
}
|
|
|
static void
|
static void
|
GetCloseBoxRect(HWND hwnd, LPRECT lprc)
|
GetCloseBoxRect(HWND hwnd, LPRECT lprc)
|
{
|
{
|
#define XSIZE_CLOSEBOX 9
|
#define XSIZE_CLOSEBOX 9
|
#define YSIZE_CLOSEBOX 9
|
#define YSIZE_CLOSEBOX 9
|
GetWindowRect(hwnd, lprc);
|
GetWindowRect(hwnd, lprc);
|
lprc->left = lprc->right - XSIZE_CLOSEBOX - 5;
|
lprc->left = lprc->right - XSIZE_CLOSEBOX - 5;
|
lprc->top = lprc->top + 5;
|
lprc->top = lprc->top + 5;
|
lprc->right = lprc->left + XSIZE_CLOSEBOX;
|
lprc->right = lprc->left + XSIZE_CLOSEBOX;
|
lprc->bottom = lprc->top + YSIZE_CLOSEBOX;
|
lprc->bottom = lprc->top + YSIZE_CLOSEBOX;
|
}
|
}
|
|
|