Some enhancements, and removal of C++ constructs.

This commit is contained in:
Ove Kaaven 1999-07-03 12:04:35 +00:00 committed by Alexandre Julliard
parent f48db82876
commit 0a7816f92e
1 changed files with 112 additions and 47 deletions

View File

@ -10,10 +10,11 @@
/* checks to include */ /* checks to include */
#define LOGGING /* can be undefined under Wine and use -debugmsg +message instead */ #define LOGGING /* can be undefined under Wine and use -debugmsg +message instead */
#define MAIN_STYLE WS_OVERLAPPEDWINDOW #define MAIN_STYLE WS_OVERLAPPEDWINDOW|WS_HSCROLL
#define MAIN_EXSTYLE 0
#undef TEST_DESTROY_MAIN #undef TEST_DESTROY_MAIN
#undef SHOW_SUB #define SHOW_SUB
#define TEST_DIALOG #undef TEST_DIALOG
#define RESIZE_DIALOG #define RESIZE_DIALOG
#undef TEST_SUBDIALOG #undef TEST_SUBDIALOG
#undef TEST_COMMCTL #undef TEST_COMMCTL
@ -108,8 +109,10 @@ MSG(WM_NCMOUSEMOVE)
MSG(WM_PAINT) MSG(WM_PAINT)
MSG(WM_LBUTTONDOWN) MSG(WM_LBUTTONDOWN)
MSG(WM_LBUTTONUP) MSG(WM_LBUTTONUP)
MSG(WM_LBUTTONDBLCLK)
MSG(WM_NCLBUTTONDOWN) MSG(WM_NCLBUTTONDOWN)
MSG(WM_NCLBUTTONUP) MSG(WM_NCLBUTTONUP)
MSG(WM_NCLBUTTONDBLCLK)
MSG(WM_KEYDOWN) MSG(WM_KEYDOWN)
MSG(WM_KEYUP) MSG(WM_KEYUP)
@ -138,6 +141,10 @@ MSG(WM_INITDIALOG)
MSG(WM_GETDLGCODE) MSG(WM_GETDLGCODE)
MSG(WM_ENTERIDLE) MSG(WM_ENTERIDLE)
/* scroll bars */
MSG(WM_HSCROLL)
MSG(WM_VSCROLL)
/* getting these from Wine but not from Windows */ /* getting these from Wine but not from Windows */
MSG2(WM_SETVISIBLE,0x0009) /* unheard of in BC++ 4.52 */ MSG2(WM_SETVISIBLE,0x0009) /* unheard of in BC++ 4.52 */
#ifdef WIN32 #ifdef WIN32
@ -175,7 +182,7 @@ char*MsgName(UINT msg,HWND hWnd)
return buffer; return buffer;
} }
char*WndName(HWND hWnd,int state=State) char*WndName(HWND hWnd,int state)
{ {
static char buffer[16]; static char buffer[16];
if (!hWnd) return "0000"; if (!hWnd) return "0000";
@ -220,18 +227,17 @@ void Logf(const char*fmt,...)
void LogChildOrder(HWND hWnd) void LogChildOrder(HWND hWnd)
{ {
HWND hWndChild = GetWindow(hWnd,GW_CHILD); HWND hWndChild = GetWindow(hWnd,GW_CHILD);
char*name;
static char buffer[256]; static char buffer[256];
strcpy(buffer,"child list:"); strcpy(buffer,"child list:");
while (hWndChild) { while (hWndChild) {
strcat(strcat(buffer," "),WndName(hWndChild)); strcat(strcat(buffer," "),WndName(hWndChild,State));
hWndChild=GetWindow(hWndChild,GW_HWNDNEXT); hWndChild=GetWindow(hWndChild,GW_HWNDNEXT);
} }
Log(buffer); Log(buffer);
} }
void LogMessage(int state,HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam,char*name=NULL) void LogMessage(int state,HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam,char*name)
{ {
static char buffer[256]; static char buffer[256];
DWORD tick=GetTickCount()-StartTime; DWORD tick=GetTickCount()-StartTime;
@ -242,20 +248,20 @@ void LogMessage(int state,HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam,char*na
case WM_KILLFOCUS: case WM_KILLFOCUS:
case WM_SETCURSOR: case WM_SETCURSOR:
Logf("%04d[%s(%d):%s]%s(%s,%08x)",tick,StateName[state],Rec, Logf("%04d[%s(%d):%s]%s(%s,%08x)",tick,StateName[state],Rec,
name,msgname,WndName((HWND)wParam),lParam); name,msgname,WndName((HWND)wParam,State),lParam);
break; break;
#ifdef WIN32 #ifdef WIN32
case WM_ENTERIDLE: case WM_ENTERIDLE:
case WM_CTLCOLORBTN: case WM_CTLCOLORBTN:
case WM_CTLCOLORDLG: case WM_CTLCOLORDLG:
Logf("%04d[%s(%d):%s]%s(%08x,%s)",tick,StateName[state],Rec, Logf("%04d[%s(%d):%s]%s(%08x,%s)",tick,StateName[state],Rec,
name,msgname,wParam,WndName((HWND)lParam)); name,msgname,wParam,WndName((HWND)lParam,State));
break; break;
#else #else
case WM_ENTERIDLE: case WM_ENTERIDLE:
case WM_CTLCOLOR: case WM_CTLCOLOR:
Logf("%04d[%s(%d):%s]%s(%08x,%04x:%s)",tick,StateName[state],Rec, Logf("%04d[%s(%d):%s]%s(%08x,%04x:%s)",tick,StateName[state],Rec,
name,msgname,wParam,HIWORD(lParam),WndName((HWND)LOWORD(lParam))); name,msgname,wParam,HIWORD(lParam),WndName((HWND)LOWORD(lParam),State));
break; break;
#endif #endif
case WM_WINDOWPOSCHANGING: case WM_WINDOWPOSCHANGING:
@ -263,33 +269,92 @@ void LogMessage(int state,HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam,char*na
{ {
WINDOWPOS*pos=(WINDOWPOS*)lParam; WINDOWPOS*pos=(WINDOWPOS*)lParam;
#ifdef WIN32 #ifdef WIN32
Logf("%04d[%s(%d):%s]%s(%08x,%p)",tick,StateName[state],Rec, Logf("%04d[%s(%d):%s]%s(%08x,%p)",tick,StateName[state],Rec,
name,msgname,wParam,pos); name,msgname,wParam,pos);
#else #else
Logf("%04d[%s(%d):%s]%s(%04x,%p)",tick,StateName[state],Rec, Logf("%04d[%s(%d):%s]%s(%04x,%p)",tick,StateName[state],Rec,
name,msgname,wParam,pos); name,msgname,wParam,pos);
#endif #endif
strcpy(buffer,"FLAGS:"); strcpy(buffer,"FLAGS:");
if (pos->flags&SWP_DRAWFRAME) strcat(buffer," DRAWFRAME"); if (pos->flags&SWP_DRAWFRAME) strcat(buffer," DRAWFRAME");
if (pos->flags&SWP_HIDEWINDOW) strcat(buffer," HIDEWINDOW"); if (pos->flags&SWP_HIDEWINDOW) strcat(buffer," HIDEWINDOW");
if (pos->flags&SWP_NOACTIVATE) strcat(buffer," NOACTIVATE"); if (pos->flags&SWP_NOACTIVATE) strcat(buffer," NOACTIVATE");
if (pos->flags&SWP_NOCOPYBITS) strcat(buffer," NOCOPYBITS"); if (pos->flags&SWP_NOCOPYBITS) strcat(buffer," NOCOPYBITS");
if (pos->flags&SWP_NOMOVE) strcat(buffer," NOMOVE"); if (pos->flags&SWP_NOMOVE) strcat(buffer," NOMOVE");
if (pos->flags&SWP_NOOWNERZORDER) strcat(buffer," NOOWNERZORDER"); if (pos->flags&SWP_NOOWNERZORDER) strcat(buffer," NOOWNERZORDER");
if (pos->flags&SWP_NOSIZE) strcat(buffer," NOSIZE"); if (pos->flags&SWP_NOSIZE) strcat(buffer," NOSIZE");
if (pos->flags&SWP_NOREDRAW) strcat(buffer," NOREDRAW"); if (pos->flags&SWP_NOREDRAW) strcat(buffer," NOREDRAW");
if (pos->flags&SWP_NOZORDER) strcat(buffer," NOZORDER"); if (pos->flags&SWP_NOZORDER) strcat(buffer," NOZORDER");
if (pos->flags&SWP_SHOWWINDOW) strcat(buffer," SHOWWINDOW"); if (pos->flags&SWP_SHOWWINDOW) strcat(buffer," SHOWWINDOW");
Log(buffer); Log(buffer);
} }
break; break;
default: case WM_SYSCOMMAND:
{
char*cmd=NULL;
switch (wParam&0xFFF0) {
#define CASE(x) case SC_##x: cmd=#x; break;
CASE(CLOSE)
CASE(DEFAULT)
CASE(HOTKEY)
CASE(HSCROLL)
CASE(KEYMENU)
CASE(MAXIMIZE)
CASE(MINIMIZE)
CASE(MOUSEMENU)
CASE(MOVE)
CASE(NEXTWINDOW)
CASE(PREVWINDOW)
CASE(RESTORE)
CASE(SCREENSAVE)
CASE(SIZE)
CASE(TASKLIST)
CASE(VSCROLL)
#undef CASE
}
if (cmd) {
Logf("%04d[%s(%d):%s]%s(%s+%x,%08x)",tick,StateName[state],Rec,
name,msgname,cmd,wParam&0xF,lParam);
} else goto GENERIC_MSG;
}
break;
case WM_HSCROLL:
case WM_VSCROLL:
{
char*cmd=NULL;
switch (LOWORD(wParam)) {
#define CASE(x) case SB_##x: cmd=#x; break;
#define CASE2(h,v) case SB_##h: if (msg==WM_HSCROLL) cmd=#h; else cmd=#v; break;
CASE(BOTTOM)
CASE(ENDSCROLL)
CASE2(LINELEFT,LINEUP)
CASE2(LINERIGHT,LINEDOWN)
CASE2(PAGELEFT,PAGEUP)
CASE2(PAGERIGHT,PAGEDOWN)
CASE(THUMBPOSITION)
CASE(THUMBTRACK)
CASE(TOP)
#undef CASE
}
if (cmd) {
#ifdef WIN32 #ifdef WIN32
Logf("%04d[%s(%d):%s]%s(%08x,%08x)",tick,StateName[state],Rec, Logf("%04d[%s(%d):%s]%s(%s,%04x,%s)",tick,StateName[state],Rec,
name,msgname,wParam,lParam); name,msgname,cmd,HIWORD(wParam),WndName((HWND)lParam,State));
#else #else
Logf("%04d[%s(%d):%s]%s(%04x,%08x)",tick,StateName[state],Rec, Logf("%04d[%s(%d):%s]%s(%04x,%04x,%s)",tick,StateName[state],Rec,
name,msgname,wParam,lParam); name,msgname,cmd,LOWORD(lParam),WndName((HWND)HIWORD(lParam),State));
#endif
} else goto GENERIC_MSG;
}
break;
default:
GENERIC_MSG:
#ifdef WIN32
Logf("%04d[%s(%d):%s]%s(%08x,%08x)",tick,StateName[state],Rec,
name,msgname,wParam,lParam);
#else
Logf("%04d[%s(%d):%s]%s(%04x,%08x)",tick,StateName[state],Rec,
name,msgname,wParam,lParam);
#endif #endif
} }
} }
@ -306,17 +371,17 @@ void Paint(HWND hWnd)
EndPaint(hWnd,&ps); EndPaint(hWnd,&ps);
} }
void FillPattern(HWND hWnd,HDC pdc=0) void FillPattern(HWND hWnd,HDC pdc)
{ {
HDC dc=pdc?pdc:GetDC(hWnd); HDC dc=pdc?pdc:GetDC(hWnd);
HBRUSH oldbrush; HBRUSH oldbrush;
RECT rect; RECT rect;
if (!dc) { if (!dc) {
Logf("failed to acquire DC for window %s",WndName(hWnd)); Logf("failed to acquire DC for window %s",WndName(hWnd,State));
return; return;
} else { } else {
Logf("acquired DC for %s window %s, painting", Logf("acquired DC for %s window %s, painting",
IsWindowVisible(hWnd)?"visible":"invisible",WndName(hWnd)); IsWindowVisible(hWnd)?"visible":"invisible",WndName(hWnd,State));
} }
GetClientRect(hWnd,&rect); GetClientRect(hWnd,&rect);
oldbrush=SelectObject(dc,GetStockObject(LTGRAY_BRUSH)); oldbrush=SelectObject(dc,GetStockObject(LTGRAY_BRUSH));
@ -346,7 +411,7 @@ LRESULT FAR CALLBACK _export MainWindowProc(HWND hWnd, UINT msg, WPARAM wParam,
int OldState=State; int OldState=State;
State=STATE_RECURS; Rec++; State=STATE_RECURS; Rec++;
if (!Clicked) LogMessage(OldState,hWnd,msg,wParam,lParam); if (!Clicked) LogMessage(OldState,hWnd,msg,wParam,lParam,NULL);
switch (msg) { switch (msg) {
case WM_NCHITTEST: case WM_NCHITTEST:
lResult=DefWindowProc(hWnd,msg,wParam,lParam); lResult=DefWindowProc(hWnd,msg,wParam,lParam);
@ -390,7 +455,7 @@ LRESULT FAR CALLBACK _export SubWindowProc(HWND hWnd, UINT msg, WPARAM wParam, L
int OldState=State; int OldState=State;
State=STATE_RECURS; Rec++; State=STATE_RECURS; Rec++;
if (!Clicked) LogMessage(OldState,hWnd,msg,wParam,lParam); if (!Clicked) LogMessage(OldState,hWnd,msg,wParam,lParam,NULL);
switch (msg) { switch (msg) {
case WM_PAINT: case WM_PAINT:
Paint(hWnd); Paint(hWnd);
@ -419,7 +484,7 @@ LRESULT FAR CALLBACK _export SubClassWindowProc(HWND hWnd, UINT msg, WPARAM wPar
State=STATE_RECURS; Rec++; State=STATE_RECURS; Rec++;
if (!Clicked) { if (!Clicked) {
LogMessage(OldState,hWnd,msg,wParam,lParam); LogMessage(OldState,hWnd,msg,wParam,lParam,NULL);
if (But!=-1) { if (But!=-1) {
lResult=CallWindowProc((FARPROC)wndButton[But],hWnd,msg,wParam,lParam); lResult=CallWindowProc((FARPROC)wndButton[But],hWnd,msg,wParam,lParam);
if (msg==WM_LBUTTONUP) { if (msg==WM_LBUTTONUP) {
@ -526,7 +591,7 @@ BOOL FAR CALLBACK _export SubDialogProc(HWND hWndDlg, UINT msg, WPARAM wParam, L
int But=-1; int But=-1;
State=STATE_RECURS; Rec++; State=STATE_RECURS; Rec++;
if (!Clicked) LogMessage(OldState,hWndDlg,msg,wParam,lParam); if (!Clicked) LogMessage(OldState,hWndDlg,msg,wParam,lParam,NULL);
switch (msg) { switch (msg) {
case WM_INITDIALOG: case WM_INITDIALOG:
hSubDlg = hWndDlg; hSubDlg = hWndDlg;
@ -588,8 +653,8 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
} }
State=STATE_CREATE; State=STATE_CREATE;
hMainWnd = CreateWindow(wclassname,winname,MAIN_STYLE, hMainWnd = CreateWindowEx(MAIN_EXSTYLE,wclassname,winname,MAIN_STYLE,
CW_USEDEFAULT,0,400,300,0,0,hInst,0); CW_USEDEFAULT,0,400,300,0,0,hInst,0);
if (!hMainWnd) return 0; if (!hMainWnd) return 0;
State=STATE_SHOW; State=STATE_SHOW;
ShowWindow(hMainWnd,nCmdShow); ShowWindow(hMainWnd,nCmdShow);
@ -604,8 +669,8 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
State=STATE_DIRECT; State=STATE_DIRECT;
} }
State=STATE_CREATE; State=STATE_CREATE;
hMainWnd = CreateWindow(wclassname,winname,MAIN_STYLE, hMainWnd = CreateWindowEx(MAIN_EXSTYLE,wclassname,winname,MAIN_STYLE,
CW_USEDEFAULT,0,400,300,0,0,hInst,0); CW_USEDEFAULT,0,400,300,0,0,hInst,0);
if (!hMainWnd) return 0; if (!hMainWnd) return 0;
State=STATE_SHOW; State=STATE_SHOW;
ShowWindow(hMainWnd,nCmdShow); ShowWindow(hMainWnd,nCmdShow);
@ -615,7 +680,7 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
// UpdateWindow(hMainWnd); // UpdateWindow(hMainWnd);
Ready=TRUE; Ready=TRUE;
/* fill client area with a pattern */ /* fill client area with a pattern */
FillPattern(hMainWnd); FillPattern(hMainWnd,0);
/* create subwindow */ /* create subwindow */
State=STATE_CREATE; State=STATE_CREATE;
GetClientRect(hMainWnd,&rect); GetClientRect(hMainWnd,&rect);
@ -649,14 +714,14 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
/* the button should now be invisible */ /* the button should now be invisible */
Logf("but1 visible=%d",IsWindowVisible(hButton[0])); Logf("but1 visible=%d",IsWindowVisible(hButton[0]));
/* see if we can draw on them */ /* see if we can draw on them */
FillPattern(hButton[0]); FillPattern(hButton[0],0);
#ifdef SHOW_SUB #ifdef SHOW_SUB
State=STATE_SHOW; State=STATE_SHOW;
ShowWindow(hSubWnd,SW_SHOWNORMAL); ShowWindow(hSubWnd,SW_SHOWNORMAL);
State=STATE_UPDATE; State=STATE_UPDATE;
UpdateWindow(hSubWnd); UpdateWindow(hSubWnd);
FillPattern(hSubWnd); FillPattern(hSubWnd,0);
// InvalidateRect(hMainWnd,NULL,TRUE); // InvalidateRect(hMainWnd,NULL,TRUE);
Logf("but1 visible=%d",IsWindowVisible(hButton[0])); Logf("but1 visible=%d",IsWindowVisible(hButton[0]));
#endif #endif