Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv14355/port/src/cbits/Win32 Modified Files: ColorDialog.c FileDialog.c FontDialog.c Frame.c Message.c Timer.c Util.c Window.c Log Message: The internal implementation is rewritten. The new feature is that we have FrameWindow for both SDI and MDI. This simplify the implementation of the entire backend. Index: ColorDialog.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ColorDialog.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ColorDialog.c 14 Mar 2003 18:38:43 -0000 1.1 --- ColorDialog.c 29 Mar 2003 08:12:18 -0000 1.2 *************** *** 1,3 **** --- 1,4 ---- #include "ColorDialog.h" + #include "Internals.h" static COLORREF std_colors[] = *************** *** 9,13 **** cc.lStructSize = sizeof(cc); ! cc.hwndOwner = GetActiveWindow(); cc.hInstance = NULL; cc.rgbResult = 0; --- 10,14 ---- cc.lStructSize = sizeof(cc); ! cc.hwndOwner = ghWndFrame; cc.hInstance = NULL; cc.rgbResult = 0; Index: FileDialog.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/FileDialog.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FileDialog.c 23 Jan 2003 20:19:32 -0000 1.2 --- FileDialog.c 29 Mar 2003 08:12:18 -0000 1.3 *************** *** 26,30 **** char title[17] = "Select Directory\0"; ! bi.hwndOwner = GetActiveWindow (); bi.pidlRoot = NULL; bi.pszDisplayName = buffer; --- 26,30 ---- char title[17] = "Select Directory\0"; ! bi.hwndOwner = ghWndFrame; bi.pidlRoot = NULL; bi.pszDisplayName = buffer; *************** *** 54,58 **** ofn.lStructSize = sizeof (OPENFILENAME); ! ofn.hwndOwner = GetActiveWindow (); ofn.hInstance = NULL; ofn.lpstrFilter = NULL; --- 54,58 ---- ofn.lStructSize = sizeof (OPENFILENAME); ! ofn.hwndOwner = ghWndFrame; ofn.hInstance = NULL; ofn.lpstrFilter = NULL; *************** *** 92,96 **** ofn.lStructSize = sizeof (OPENFILENAME); ! ofn.hwndOwner = GetActiveWindow (); ofn.lpstrFilter = NULL; ofn.lpstrCustomFilter = NULL; --- 92,96 ---- ofn.lStructSize = sizeof (OPENFILENAME); ! ofn.hwndOwner = ghWndFrame; ofn.lpstrFilter = NULL; ofn.lpstrCustomFilter = NULL; Index: FontDialog.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/FontDialog.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FontDialog.c 16 Mar 2003 23:48:14 -0000 1.1 --- FontDialog.c 29 Mar 2003 08:12:18 -0000 1.2 *************** *** 1,3 **** --- 1,4 ---- #include "FontDialog.h" + #include "Internals.h" BOOL osRunFontDialog(char **fname, int *fsize, int *fweight, int *fstyle, BOOL *funderline, BOOL *fstrikeout) *************** *** 7,11 **** cf.lStructSize = sizeof(cf); ! cf.hwndOwner = GetActiveWindow(); cf.hDC = NULL; cf.lpLogFont = &lf; --- 8,12 ---- cf.lStructSize = sizeof(cf); ! cf.hwndOwner = ghWndFrame; cf.hDC = NULL; cf.lpLogFont = &lf; Index: Frame.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Frame.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Frame.c 26 Mar 2003 08:45:54 -0000 1.2 --- Frame.c 29 Mar 2003 08:12:19 -0000 1.3 *************** *** 1,9 **** #include "Types.h" #include "Internals.h" #include "Handlers_stub.h" #define OSMenuIDEnd 500 ! LRESULT CALLBACK HMDIFrameFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { --- 1,13 ---- #include "Types.h" + #include "Window.h" #include "Internals.h" #include "Handlers_stub.h" #define OSMenuIDEnd 500 ! ! LRESULT CALLBACK HFrameSharedFunction(int DocumentInterface, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + FrameData *pData = (FrameData *) GetWindowLong(hWnd,GWL_USERDATA); + switch (uMsg) { *************** *** 11,14 **** --- 15,101 ---- handleProcessDismiss(); return 0; + case WM_DESTROY: + handleProcessDestroy(); + DeleteObject(pData->hControlFont); + free(pData->lpszAppName); + free(pData); + PostQuitMessage(0); + break; + case WM_CREATE: + { + int nLen; + LOGFONT lf; + HFONT hControlFont; + + // Globally, we create a logical font that is used in all controls. + lf.lfHeight = -8; + lf.lfWidth = 0; + lf.lfWeight = 400; + lf.lfItalic = FALSE; + lf.lfUnderline = FALSE; + lf.lfStrikeOut = FALSE; + lf.lfEscapement = 0; + lf.lfOrientation = 0; + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfOutPrecision = OUT_DEFAULT_PRECIS; + lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; + lf.lfQuality = DEFAULT_QUALITY; + lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; + strcpy(lf.lfFaceName, "MS Sans Serif"); + hControlFont = CreateFontIndirect (&lf); + + if (!hControlFont) + return -1; + + pData = (FrameData *) malloc(sizeof(FrameData)); + if (!pData) + { + DeleteObject(hControlFont); + return -1; + } + + pData->hClientWnd = NULL; + pData->DocumentInterface = DocumentInterface; + pData->hControlFont = hControlFont; + pData->lpszAppName = NULL; + + nLen = GetWindowTextLength(hWnd); + if (nLen > 0) + { + pData->lpszAppName = malloc(nLen+1); + if (!pData->lpszAppName) + { + free(pData); + DeleteObject(hControlFont); + return -1; + } + GetWindowText(hWnd,pData->lpszAppName,nLen); + } + + SetWindowLong(hWnd,GWL_USERDATA,(LONG) pData); + } + break; + case WM_SIZE: + { + int nWidth = LOWORD(lParam); + int nHeight = HIWORD(lParam); + SetWindowPos(pData->hClientWnd,NULL,0,0,nWidth,nHeight,SWP_NOZORDER); + } + break; + } + + if (DocumentInterface == 1) + return DefWindowProc (hWnd, uMsg, wParam, lParam); + else + return DefFrameProc (hWnd, pData->hClientWnd, uMsg, wParam, lParam); + }; + + LRESULT CALLBACK HMDIFrameFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) + { + LRESULT result = HFrameSharedFunction(2, hWnd, uMsg, wParam, lParam); + FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); + + switch (uMsg) + { case WM_CREATE: { *************** *** 33,37 **** clientcreate.idFirstChild = OSMenuIDEnd+5; // Window ids must be generated from OSMenuIDEnd+5 ! ghWndClient = CreateWindow ("MDICLIENT", // The MDICLIENT window class NULL, // The window name MDIS_ALLCHILDSTYLES | WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, --- 120,124 ---- clientcreate.idFirstChild = OSMenuIDEnd+5; // Window ids must be generated from OSMenuIDEnd+5 ! pData->hClientWnd = CreateWindow ("MDICLIENT", // The MDICLIENT window class NULL, // The window name MDIS_ALLCHILDSTYLES | WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, *************** *** 43,57 **** (LPVOID) &clientcreate // The CLIENTCREATESTRUCT ); ! if (!ghWndClient) return -1; - - gActiveObjects++; - } - break; - case WM_SIZE: - { - int nWidth = LOWORD(lParam); - int nHeight = HIWORD(lParam); - SetWindowPos(GetWindow(hWnd,GW_CHILD),NULL,0,0,nWidth,nHeight,SWP_NOZORDER); } break; --- 130,135 ---- (LPVOID) &clientcreate // The CLIENTCREATESTRUCT ); ! if (!pData->hClientWnd) return -1; } break; *************** *** 64,85 **** { case (OSMenuIDEnd+1): ! SendMessage (GetWindow(hWnd,GW_CHILD),WM_MDIICONARRANGE,0,0); break; case (OSMenuIDEnd+2): ! SendMessage (GetWindow(hWnd,GW_CHILD),WM_MDITILE,(WPARAM) MDITILE_VERTICAL,0); break; case (OSMenuIDEnd+3): ! SendMessage (GetWindow(hWnd,GW_CHILD),WM_MDITILE,(WPARAM) MDITILE_HORIZONTAL,0); break; case (OSMenuIDEnd+4): ! SendMessage (GetWindow(hWnd,GW_CHILD),WM_MDICASCADE,0,0); break; } break; - case WM_DESTROY: - gActiveObjects--; - break; } ! return DefFrameProc (hWnd, GetWindow(hWnd,GW_CHILD), uMsg, wParam, lParam); ! }; \ No newline at end of file --- 142,189 ---- { case (OSMenuIDEnd+1): ! SendMessage (pData->hClientWnd,WM_MDIICONARRANGE,0,0); break; case (OSMenuIDEnd+2): ! SendMessage (pData->hClientWnd,WM_MDITILE,(WPARAM) MDITILE_VERTICAL,0); break; case (OSMenuIDEnd+3): ! SendMessage (pData->hClientWnd,WM_MDITILE,(WPARAM) MDITILE_HORIZONTAL,0); break; case (OSMenuIDEnd+4): ! SendMessage (pData->hClientWnd,WM_MDICASCADE,0,0); break; } break; } ! return result; ! }; ! ! LRESULT CALLBACK HSDIFrameFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ! { ! LRESULT result = HFrameSharedFunction(1, hWnd, uMsg, wParam, lParam); ! FrameData *pFrameData = (FrameData *) GetWindowLong(hWnd,GWL_USERDATA); ! ! switch (uMsg) ! { ! case WM_ACTIVATE: ! if (pFrameData->hClientWnd) ! { ! if (wParam == WA_INACTIVE) ! { ! if (gInKey) ! handleWindowKeyboard(pFrameData->hClientWnd, evKeyLost, gCurChar, GetModifiers()); ! gInKey = FALSE; ! gCurChar = 0; ! handleWindowDeactivate(pFrameData->hClientWnd); ! } ! else ! { ! handleWindowActivate(pFrameData->hClientWnd); ! } ! } ! break; ! } ! ! return result; ! }; Index: Message.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Message.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Message.c 14 Mar 2003 17:14:56 -0000 1.2 --- Message.c 29 Mar 2003 08:12:19 -0000 1.3 *************** *** 4,33 **** void osMessageAlert(char *szText) { ! MessageBox(GetActiveWindow(), szText, gAppName, MB_OK | MB_ICONINFORMATION); }; BOOL osMessageConfirm(char *szText) { ! return (MessageBox(GetActiveWindow(), szText, gAppName, MB_OKCANCEL | MB_ICONINFORMATION) == IDOK); }; void osMessageWarning(char *szText) { ! MessageBox(GetActiveWindow(), szText, gAppName, MB_OK | MB_ICONWARNING); }; BOOL osMessageQuestion(char *szText) { ! return (MessageBox(GetActiveWindow(), szText, gAppName, MB_YESNO | MB_ICONQUESTION) == IDYES); }; BOOL osMessageError(char *szText) { ! return (MessageBox(GetActiveWindow(), szText, gAppName, MB_OKCANCEL | MB_ICONERROR) == IDOK); }; int osMessageCancelQuestion(char *szText) { ! switch (MessageBox(GetActiveWindow(), szText, gAppName, MB_YESNO | MB_ICONQUESTION)) { case IDNO: return 0; --- 4,39 ---- void osMessageAlert(char *szText) { ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! MessageBox(ghWndFrame, szText, pFrameData->lpszAppName, MB_OK | MB_ICONINFORMATION); }; BOOL osMessageConfirm(char *szText) { ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! return (MessageBox(ghWndFrame, szText, pFrameData->lpszAppName, MB_OKCANCEL | MB_ICONINFORMATION) == IDOK); }; void osMessageWarning(char *szText) { ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! MessageBox(ghWndFrame, szText, pFrameData->lpszAppName, MB_OK | MB_ICONWARNING); }; BOOL osMessageQuestion(char *szText) { ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! return (MessageBox(ghWndFrame, szText, pFrameData->lpszAppName, MB_YESNO | MB_ICONQUESTION) == IDYES); }; BOOL osMessageError(char *szText) { ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! return (MessageBox(ghWndFrame, szText, pFrameData->lpszAppName, MB_OKCANCEL | MB_ICONERROR) == IDOK); }; int osMessageCancelQuestion(char *szText) { ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! switch (MessageBox(ghWndFrame, szText, pFrameData->lpszAppName, MB_YESNO | MB_ICONQUESTION)) { case IDNO: return 0; *************** *** 39,43 **** int osMessageConfirmSave(char *szText) { ! switch (MessageBox(GetActiveWindow(), szText, gAppName, MB_YESNO | MB_ICONQUESTION)) { case IDNO: return 0; --- 45,50 ---- int osMessageConfirmSave(char *szText) { ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! switch (MessageBox(ghWndFrame, szText, pFrameData->lpszAppName, MB_YESNO | MB_ICONQUESTION)) { case IDNO: return 0; Index: Timer.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Timer.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Timer.c 26 Mar 2003 02:19:57 -0000 1.3 --- Timer.c 29 Mar 2003 08:12:19 -0000 1.4 *************** *** 56,60 **** timer->enabled = TRUE; timer->id = (msecs > 0) ? SetTimer(ghTimerWnd, (WPARAM) timer, msecs, NULL) : 0; - gActiveObjects++; return timer; } --- 56,59 ---- *************** *** 67,71 **** KillTimer(ghTimerWnd,timer->id); rfree(timer); - gActiveObjects--; } } --- 66,69 ---- Index: Util.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Util.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Util.c 26 Mar 2003 15:39:48 -0000 1.9 --- Util.c 29 Mar 2003 08:12:19 -0000 1.10 *************** *** 4,7 **** --- 4,8 ---- #include "Types.h" #include "Window.h" + #include "Internals.h" #include "Handlers_stub.h" *************** *** 9,18 **** HMODULE ghModule = NULL; ! HFONT ghControlFont = NULL; ! HWND ghWndFrame; ! HWND ghWndClient; ! int gActiveObjects; ! int gDocumentInterface; ! char *gAppName; void *rmalloc (DWORD bytes) --- 10,14 ---- HMODULE ghModule = NULL; ! HWND ghWndFrame = NULL; void *rmalloc (DWORD bytes) *************** *** 34,41 **** } ! extern LRESULT CALLBACK HWindowFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); ! extern LRESULT CALLBACK HDialogFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); extern LRESULT CALLBACK HMDIFrameFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); extern LRESULT CALLBACK HMDIWindowFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static ATOM classDialog = 0; --- 30,38 ---- } ! extern LRESULT CALLBACK HSDIFrameFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); ! extern LRESULT CALLBACK HSDIWindowFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); extern LRESULT CALLBACK HMDIFrameFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); extern LRESULT CALLBACK HMDIWindowFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + extern LRESULT CALLBACK HDialogFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static ATOM classDialog = 0; *************** *** 53,71 **** */ ! void osInit(char *AppName, int DocumentInterface) { if (!ghModule) { WNDCLASS wc; - LOGFONT lf; INITCOMMONCONTROLSEX icc; ghModule = GetModuleHandle(NULL); ! /* DAAN: create two different classes for dialogs and windows so ! that we can call the appropiate default window message handler ! for each window kind */ wc.style = CS_DBLCLKS; ! wc.lpfnWndProc = HWindowFunction; wc.cbClsExtra = 0; wc.cbWndExtra = 0; --- 50,77 ---- */ ! void osInit(char *szAppName, int DocumentInterface) { if (!ghModule) { WNDCLASS wc; INITCOMMONCONTROLSEX icc; ghModule = GetModuleHandle(NULL); ! // Window class for SDIFrame ! wc.style = CS_DBLCLKS; ! wc.lpfnWndProc = HSDIFrameFunction; ! wc.cbClsExtra = 0; ! wc.cbWndExtra = 0; ! wc.hInstance = ghModule; ! wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); ! wc.hCursor = LoadCursor (NULL, IDC_ARROW); ! wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1); // For best results (Petzold) ! wc.lpszMenuName = NULL; ! wc.lpszClassName = "HSDIFRAME"; ! RegisterClass(&wc); ! wc.style = CS_DBLCLKS; ! wc.lpfnWndProc = HSDIWindowFunction; wc.cbClsExtra = 0; wc.cbWndExtra = 0; *************** *** 75,81 **** wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); wc.lpszMenuName = NULL; ! wc.lpszClassName = "HWINDOW"; classWindow = RegisterClass(&wc); wc.style = CS_DBLCLKS; wc.lpfnWndProc = HDialogFunction; --- 81,88 ---- wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); wc.lpszMenuName = NULL; ! wc.lpszClassName = "HSDIWINDOW"; classWindow = RegisterClass(&wc); + // Window class for Dialogs wc.style = CS_DBLCLKS; wc.lpfnWndProc = HDialogFunction; *************** *** 100,104 **** wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1); // For best results (Petzold) wc.lpszMenuName = NULL; ! wc.lpszClassName = "HFRAME"; RegisterClass(&wc); --- 107,111 ---- wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1); // For best results (Petzold) wc.lpszMenuName = NULL; ! wc.lpszClassName = "HMDIFRAME"; RegisterClass(&wc); *************** *** 116,149 **** RegisterClass(&wc); - // Globally, we create a logical font that is used in all controls. - lf.lfHeight = -8; - lf.lfWidth = 0; - lf.lfWeight = 400; - lf.lfItalic = FALSE; - lf.lfUnderline = FALSE; - lf.lfStrikeOut = FALSE; - lf.lfEscapement = 0; - lf.lfOrientation = 0; - lf.lfCharSet = DEFAULT_CHARSET; - lf.lfOutPrecision = OUT_DEFAULT_PRECIS; - lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf.lfQuality = DEFAULT_QUALITY; - lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - strcpy(lf.lfFaceName, "MS Sans Serif"); - ghControlFont = CreateFontIndirect (&lf); - icc.dwSize = sizeof(icc); icc.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&icc); ! gActiveObjects = 0; ! gAppName = strdup(AppName); ! gDocumentInterface = DocumentInterface; ! ! if (gDocumentInterface == 2) { ! ghWndClient = NULL; ! ghWndFrame = CreateWindow ( "HFRAME", ! AppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT, --- 123,147 ---- RegisterClass(&wc); icc.dwSize = sizeof(icc); icc.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&icc); ! if (DocumentInterface == 1) { ! ghWndFrame = CreateWindow ( "HSDIFRAME", ! szAppName, ! WS_OVERLAPPEDWINDOW, ! CW_USEDEFAULT,CW_USEDEFAULT, ! CW_USEDEFAULT,CW_USEDEFAULT, ! NULL, ! NULL, ! (HANDLE) ghModule, ! NULL ! ); ! } ! else ! { ! ghWndFrame = CreateWindow ( "HMDIFRAME", ! szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT, *************** *** 154,160 **** NULL ); - ShowWindow(ghWndFrame,SW_MAXIMIZE); - UpdateWindow(ghWndFrame); } } }; --- 152,159 ---- NULL ); } + + ShowWindow(ghWndFrame,SW_NORMAL); + UpdateWindow(ghWndFrame); } }; *************** *** 163,166 **** --- 162,166 ---- { HWND hParent; + FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); if (!hWnd) *************** *** 170,177 **** } ! SendMessage(hWnd, WM_SETFONT, (WPARAM)ghControlFont, MAKELPARAM (TRUE,0)); hParent = GetParent(hWnd); - if (hParent && !osGetWindowEnabled(hParent)) EnableWindow(hWnd, FALSE); --- 170,176 ---- } ! SendMessage(hWnd, WM_SETFONT, (WPARAM)pFrameData->hControlFont, MAKELPARAM (TRUE,0)); hParent = GetParent(hWnd); if (hParent && !osGetWindowEnabled(hParent)) EnableWindow(hWnd, FALSE); *************** *** 186,217 **** MSG msg; ! while (gActiveObjects > 0) { ! handleMenusUpdate(); ! ! while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0) ! { ! TranslateMessage(&msg); ! DispatchMessage(&msg); ! ! if (gActiveObjects <= 0) ! return; ! }; ! ! if (gActiveObjects <= 0) ! return; ! ! if (GetMessage(&msg, NULL, 0, 0) != 0) ! { ! TranslateMessage(&msg); ! DispatchMessage(&msg); ! } } - handleProcessDestroy(); - doneGdiPlus(); - - free(gAppName); }; --- 185,195 ---- MSG msg; ! while (GetMessage(&msg, NULL, 0, 0) != 0) { ! TranslateMessage(&msg); ! DispatchMessage(&msg); } doneGdiPlus(); }; *************** *** 220,231 **** void osQuit() { ! if (gDocumentInterface == 2) ! { ! DestroyWindow(ghWndFrame); ! } ! ! if (gActiveObjects > 0) ! { ! printf("WARNING: There are still have active objects\n"); ! } } --- 198,201 ---- void osQuit() { ! DestroyWindow(ghWndFrame); } Index: Window.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Window.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Window.c 27 Mar 2003 14:05:03 -0000 1.16 --- Window.c 29 Mar 2003 08:12:19 -0000 1.17 *************** *** 28,32 **** } WindowData; ! static unsigned int GetModifiers() { return (( GetAsyncKeyState (VK_SHIFT) ? shiftBIT : 0) | --- 28,32 ---- } WindowData; ! unsigned int GetModifiers() { return (( GetAsyncKeyState (VK_SHIFT) ? shiftBIT : 0) | *************** *** 78,83 **** } ! static BOOL gInKey = FALSE; ! static BOOL gCurChar = 0; int CheckVirtualKeyCode (int keycode) --- 78,83 ---- } ! BOOL gInKey = FALSE; ! BOOL gCurChar = 0; int CheckVirtualKeyCode (int keycode) *************** *** 182,187 **** pData->hTooltip = NULL; SetWindowLong(hWnd,GWL_USERDATA,(LONG) pData); - - gActiveObjects++; } break; --- 182,185 ---- *************** *** 190,193 **** --- 188,192 ---- return 0; case WM_DESTROY: + handleWindowDestroy(hWnd); if (pData->hBackBrush) { *************** *** 196,201 **** } ! handleWindowDestroy(hWnd); ! gActiveObjects--; break; case WM_COMMAND: --- 195,199 ---- } ! free(pData); break; case WM_COMMAND: *************** *** 708,732 **** ! LRESULT CALLBACK HWindowFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_LBUTTONDOWN: SetActiveWindow(hWnd); break; ! case WM_ACTIVATE: ! if (wParam == WA_INACTIVE) ! { ! if (gInKey) ! handleWindowKeyboard(hWnd, evKeyLost, gCurChar, GetModifiers()); ! gInKey = FALSE; ! gCurChar = 0; ! handleWindowDeactivate(hWnd); ! } ! else ! { ! handleWindowActivate(hWnd); ! } ! break; } --- 706,752 ---- ! LRESULT CALLBACK HSDIWindowFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); + switch (uMsg) { + case WM_SETTEXT: + { + char *s = (char *) lParam; + + printf("WM_SETTEXT %p %d\n", s, *s); + + if (pFrameData->lpszAppName) + { + if (s && *s) + { + char *title; + int nTextLen; + + s = (char *) lParam; + nTextLen = strlen(s); + title = rmalloc(strlen(pFrameData->lpszAppName)+nTextLen+6); + + strcpy(title, pFrameData->lpszAppName); + strcat(title, " - ["); + strcat(title, s); + strcat(title, "]"); + SetWindowText(ghWndFrame, title); + } + else + SetWindowText(ghWndFrame, pFrameData->lpszAppName); + } + else + SetWindowText(ghWndFrame, s); + } + break; case WM_LBUTTONDOWN: SetActiveWindow(hWnd); break; ! case WM_DESTROY: ! pFrameData->hClientWnd = NULL; ! SetWindowText(ghWndFrame, pFrameData->lpszAppName); ! break; } *************** *** 748,751 **** --- 768,773 ---- LRESULT CALLBACK HMDIWindowFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); + switch (uMsg) { *************** *** 757,763 **** s = (char *) lParam; nTextLen = strlen(s); ! title = rmalloc(strlen(gAppName)+nTextLen+6); ! strcpy(title, gAppName); strcat(title, " - ["); strcat(title, s); --- 779,785 ---- s = (char *) lParam; nTextLen = strlen(s); ! title = rmalloc(strlen(pFrameData->lpszAppName)+nTextLen+6); ! strcpy(title, pFrameData->lpszAppName); strcat(title, " - ["); strcat(title, s); *************** *** 772,778 **** nTextLen = GetWindowTextLength(hWnd); ! title = rmalloc(strlen(gAppName)+nTextLen+6); ! strcpy(title, gAppName); strcat(title, " - ["); GetWindowText(hWnd, title+strlen(title), nTextLen+1); --- 794,800 ---- nTextLen = GetWindowTextLength(hWnd); ! title = rmalloc(strlen(pFrameData->lpszAppName)+nTextLen+6); ! strcpy(title, pFrameData->lpszAppName); strcat(title, " - ["); GetWindowText(hWnd, title+strlen(title), nTextLen+1); *************** *** 788,797 **** break; case WM_DESTROY: ! SetWindowText(ghWndFrame, gAppName); ! SendMessage(ghWndClient, WM_MDIREFRESHMENU, 0, 0); DrawMenuBar(ghWndFrame); break; case WM_LBUTTONDOWN: ! SendMessage(ghWndClient,WM_MDIACTIVATE,(WPARAM) hWnd,0); break; }; --- 810,819 ---- break; case WM_DESTROY: ! SetWindowText(ghWndFrame, pFrameData->lpszAppName); ! SendMessage(pFrameData->hClientWnd, WM_MDIREFRESHMENU, 0, 0); DrawMenuBar(ghWndFrame); break; case WM_LBUTTONDOWN: ! SendMessage(pFrameData->hClientWnd,WM_MDIACTIVATE,(WPARAM) hWnd,0); break; }; *************** *** 818,835 **** { HWND hWnd; ! switch (gDocumentInterface) { case 1: // SDI hWnd = CreateWindow( ! "HWINDOW", ! gAppName, ! WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, ! CW_USEDEFAULT,0,0,0, NULL, NULL, ghModule, NULL ); break; case 2: // MDI --- 840,861 ---- { HWND hWnd; + RECT rect; + FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! switch (pFrameData->DocumentInterface) { case 1: // SDI + GetClientRect(ghWndFrame, &rect); hWnd = CreateWindow( ! "HSDIWINDOW", NULL, + WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL, + 0,0,rect.right-rect.left,rect.bottom-rect.top, + ghWndFrame, NULL, ghModule, NULL ); + pFrameData->hClientWnd = hWnd; break; case 2: // MDI *************** *** 839,843 **** /* fill the MDICREATESTRUCT record */ mdicreate.szClass = "HMDIWINDOW"; ! mdicreate.szTitle = gAppName; mdicreate.hOwner = ghModule; mdicreate.x = 0; --- 865,869 ---- /* fill the MDICREATESTRUCT record */ mdicreate.szClass = "HMDIWINDOW"; ! mdicreate.szTitle = NULL; mdicreate.hOwner = ghModule; mdicreate.x = 0; *************** *** 849,853 **** /* create the window */ ! hWnd = (HWND) SendMessage (ghWndClient,WM_MDICREATE,0,(LPARAM) &mdicreate); } break; --- 875,879 ---- /* create the window */ ! hWnd = (HWND) SendMessage (pFrameData->hClientWnd,WM_MDICREATE,0,(LPARAM) &mdicreate); } break; *************** *** 933,942 **** void osSetWindowViewSize(WindowHandle window, int w, int h) { RECT crect, wrect; ! GetClientRect(window,&crect); ! GetWindowRect(window,&wrect); ! SetWindowPos(window,NULL,wrect.left,wrect.top, (wrect.right-wrect.left) + (w - (crect.right-crect.left)), (wrect.bottom-wrect.top) + (h - (crect.bottom - crect.top)), --- 959,972 ---- 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); ! GetWindowRect(hTargetWnd,&wrect); ! ! SetWindowPos(hTargetWnd,NULL,wrect.left,wrect.top, (wrect.right-wrect.left) + (w - (crect.right-crect.left)), (wrect.bottom-wrect.top) + (h - (crect.bottom - crect.top)), *************** *** 1330,1336 **** } ! void osSetWindowRect(WindowHandle ctrl, int x0, int y0, int x1, int y1) { ! SetWindowPos(ctrl,HWND_TOP,x0,y0,abs(x1-x0),abs(y1-y0),SWP_SHOWWINDOW); } --- 1360,1367 ---- } ! 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); } |