From: <kr_...@us...> - 2003-04-26 20:03:11
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv15534/port/src/cbits/Win32 Modified Files: Window.c Log Message: Complete implementation for modal and modeless dialogs Index: Window.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Window.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Window.c 23 Apr 2003 21:48:54 -0000 1.25 --- Window.c 26 Apr 2003 20:03:08 -0000 1.26 *************** *** 117,152 **** } ! static HWND checkMousePosition(HWND hWnd, POINT *pos) { ! RECT rect; ! POINT upLeft; ! POINT downRight; ! HWND hCtrl = GetTopWindow(hWnd); ! ! while (hCtrl) ! { ! if (IsWindowEnabled(hCtrl)) ! { ! GetWindowRect(hCtrl,&rect); ! upLeft.x = rect.left; ! upLeft.y = rect.top; ! ScreenToClient(hWnd,&upLeft); ! downRight.x = rect.right; ! downRight.y = rect.bottom; ! ScreenToClient(hWnd,&downRight); ! if (pos->x >= upLeft.x && ! pos->x <= downRight.x && ! pos->y >= upLeft.y && ! pos->y <= downRight.y) ! { ! return hCtrl; ! } ! } ! ! hCtrl = GetNextWindow(hCtrl,GW_HWNDNEXT); ! } ! return NULL; } --- 117,135 ---- } ! static HWND checkMousePosition(HWND hWnd, POINT pos) { ! HWND hCtrl; ! ! hCtrl = ChildWindowFromPointEx(hWnd, pos, CWP_SKIPINVISIBLE | CWP_SKIPDISABLED | CWP_SKIPTRANSPARENT); ! if (hCtrl == hWnd) hCtrl = NULL; ! if (hCtrl == NULL) ! { ! ClientToScreen(hWnd, &pos); ! hCtrl = WindowFromPoint(pos); ! if (hCtrl == hWnd) hCtrl = NULL; ! } ! return hCtrl; } *************** *** 537,541 **** pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, &pos); if (hCtrl) { --- 520,524 ---- pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, pos); if (hCtrl) { *************** *** 562,566 **** pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, &pos); if (hCtrl) { --- 545,549 ---- pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, pos); if (hCtrl) { *************** *** 605,609 **** ReleaseCapture(); ! hCtrl = checkMousePosition(hWnd, &pos); if (hCtrl) { --- 588,592 ---- ReleaseCapture(); ! hCtrl = checkMousePosition(hWnd, pos); if (hCtrl) { *************** *** 624,628 **** pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, &pos); if (hCtrl) { --- 607,611 ---- pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, pos); if (hCtrl) { *************** *** 647,651 **** pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, &pos); if (hCtrl) { --- 630,634 ---- pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, pos); if (hCtrl) { *************** *** 806,809 **** --- 789,799 ---- switch (uMsg) { + case WM_CLOSE: + { + HWND hOwner = GetWindow(hWnd, GW_OWNER); + EnableWindow(hOwner, TRUE); + SetActiveWindow(hOwner); + } + break; case WM_LBUTTONDOWN: SetActiveWindow(hWnd); *************** *** 811,815 **** } ! return HWindowSharedFunction(DefDlgProc, hWnd, uMsg, wParam, lParam ); } --- 801,805 ---- } ! return HWindowSharedFunction(DefDlgProc, hWnd, uMsg, wParam, lParam); } *************** *** 904,911 **** WORD dlgtemplate[60]; DWORD lStyle; - HWND hDlg; // start to fill in the dlgtemplate information. Addressing by WORDs ! lStyle = WS_CAPTION | DS_SETFONT | WS_SYSMENU | WS_OVERLAPPEDWINDOW; p = dlgtemplate; --- 894,900 ---- WORD dlgtemplate[60]; DWORD lStyle; // start to fill in the dlgtemplate information. Addressing by WORDs ! lStyle = WS_CAPTION | DS_SETFONT | WS_SYSMENU | WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL; p = dlgtemplate; *************** *** 926,932 **** s = "MS Sans Serif"; do { *p++ = (WORD) *s; } while (*s++); ! hDlg = CreateDialogIndirectParam (ghModule, (LPCDLGTEMPLATE) dlgtemplate, parent, (DLGPROC) NULL, (LPARAM) 0); ! ! return hDlg; }; --- 915,921 ---- s = "MS Sans Serif"; do { *p++ = (WORD) *s; } while (*s++); ! if (!parent) parent = ghWndFrame; ! ! return CreateDialogIndirectParam (ghModule, (LPCDLGTEMPLATE) dlgtemplate, parent, (DLGPROC) NULL, (LPARAM) 0); }; *************** *** 974,982 **** void osSetWindowViewSize(WindowHandle window, int w, int h) { HWND hTargetWnd; RECT crect, wrect; - FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! hTargetWnd = (pFrameData->DocumentInterface == 1) ? ghWndFrame : window; GetClientRect(hTargetWnd,&crect); --- 963,972 ---- void osSetWindowViewSize(WindowHandle window, int w, int h) { + char buffer[20]; HWND hTargetWnd; RECT crect, wrect; ! GetClassName(window,buffer,sizeof(buffer)); ! hTargetWnd = (_stricmp(buffer, "HSDIWINDOW") == 0) ? ghWndFrame : window; GetClientRect(hTargetWnd,&crect); *************** *** 1072,1088 **** } ! void osRunWindow(WindowHandle window) { MSG msg; ! WindowHandle parent = GetWindow(window,GW_OWNER); ! ! EnableWindow(parent,FALSE); ! ShowWindow(window, SW_SHOW); while (IsWindow(window) && GetMessage(&msg, NULL, 0, 0) != 0) { ! TranslateMessage(&msg); ! DispatchMessage(&msg); }; - EnableWindow(parent,TRUE); } --- 1062,1077 ---- } ! void osRunDialog(WindowHandle window) { MSG msg; ! ! SetActiveWindow(window); ! EnableWindow(GetWindow(window, GW_OWNER), FALSE); ! while (IsWindow(window) && GetMessage(&msg, NULL, 0, 0) != 0) { ! TranslateMessage(&msg); ! DispatchMessage(&msg); }; } *************** *** 1383,1388 **** void osSetWindowRect(WindowHandle window, int x0, int y0, int x1, int y1) { ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! SetWindowPos((pFrameData->DocumentInterface == 1) ? ghWndFrame : window,NULL,x0,y0,abs(x1-x0),abs(y1-y0),SWP_NOZORDER); } --- 1372,1382 ---- void osSetWindowRect(WindowHandle window, int x0, int y0, int x1, int y1) { ! char buffer[20]; ! HWND hTargetWnd; ! ! GetClassName(window,buffer,sizeof(buffer)); ! hTargetWnd = (_stricmp(buffer, "HSDIWINDOW") == 0) ? ghWndFrame : window; ! ! SetWindowPos(hTargetWnd,NULL,x0,y0,abs(x1-x0),abs(y1-y0),SWP_NOZORDER); } |