- Timestamp:
- Sep 4, 1999, 9:42:30 PM (26 years ago)
- Location:
- trunk/src/user32/new
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/controls.cpp
r760 r821 1 /* $Id: controls.cpp,v 1.1 0 1999-08-31 17:14:51sandervl Exp $ */1 /* $Id: controls.cpp,v 1.11 1999-09-04 19:42:27 sandervl Exp $ */ 2 2 /* File: controls.cpp -- Win32 common controls 3 3 * … … 16 16 #include "combo.H" //listbox,combo,edit 17 17 #include "win32wmdiclient.h" 18 #include "win32dlg.h" 18 19 19 20 /* registration */ … … 66 67 dprintf(("Register MDICLIENT class")); 67 68 if (!MDICLIENT_Register()) dprintf(("failed!!!")); 69 70 dprintf(("Register DIALOG class")); 71 if (!DIALOG_Register()) dprintf(("failed!!!")); 68 72 } 69 73 … … 93 97 dprintf(("Unregister MDICLIENT class")); 94 98 if (!MDICLIENT_Unregister()) dprintf(("failed!!!")); 99 100 dprintf(("Unregister DIALOG class")); 101 if (!DIALOG_Unregister()) dprintf(("failed!!!")); 95 102 } 96 103 -
trunk/src/user32/new/defwndproc.cpp
r760 r821 1 /* $Id: defwndproc.cpp,v 1. 7 1999-08-31 17:14:51sandervl Exp $ */1 /* $Id: defwndproc.cpp,v 1.8 1999-09-04 19:42:27 sandervl Exp $ */ 2 2 3 3 /* … … 17 17 #include "win32wnd.h" 18 18 #include "win32wmdichild.h" 19 #include "win32dlg.h" 19 20 20 21 #ifdef DEBUG … … 52 53 LRESULT WIN32API DefDlgProcA(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) 53 54 { 54 #ifdef DEBUG 55 //// WriteLog("*DDP*"); 56 #endif 57 switch(Msg) { 58 case WM_SETREDRAW: //Open32 does not set the visible flag 59 if(wParam) 60 SetWindowLongA (hwnd, GWL_STYLE, GetWindowLongA (hwnd, GWL_STYLE) | WS_VISIBLE); 61 else 62 SetWindowLongA (hwnd, GWL_STYLE, GetWindowLongA (hwnd, GWL_STYLE) & ~WS_VISIBLE); 63 return O32_DefDlgProc(hwnd, Msg, wParam, lParam); 64 case WM_NCCREATE://SvL: YAOFM (yet another open32 feature missing) 65 return(TRUE); 66 case WM_CTLCOLORMSGBOX: 67 case WM_CTLCOLOREDIT: 68 case WM_CTLCOLORLISTBOX: 69 case WM_CTLCOLORBTN: 70 case WM_CTLCOLORDLG: 71 case WM_CTLCOLORSTATIC: 72 case WM_CTLCOLORSCROLLBAR: 73 SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); 74 SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); 75 return GetSysColorBrush(COLOR_BTNFACE); 55 Win32Dialog *dialog; 76 56 77 case WM_PARENTNOTIFY: //Open32 doesn't like receiving those!! 78 dprintf(("DefWndProc: WM_PARENTNOTIFY for %x", hwnd)); 57 dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd); 58 if(!dialog || dialog->IsWindow()) { 59 dprintf(("DefDlgProcA, window %x not found", hwnd)); 79 60 return 0; 80 81 default:82 return O32_DefDlgProc(hwnd, Msg, wParam, lParam);83 61 } 62 return dialog->DefDlgProcA(Msg, wParam, lParam); 84 63 } 85 64 //****************************************************************************** 86 //NOTE: Unicode msg translation!87 65 //****************************************************************************** 88 66 LRESULT WIN32API DefDlgProcW(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) 89 67 { 90 #ifdef DEBUG 91 //// WriteLog("*DDPW*"); 92 #endif 93 switch(Msg) { 94 case WM_SETREDRAW: //Open32 does not set the visible flag 95 if(wParam) 96 SetWindowLongA (hwnd, GWL_STYLE, GetWindowLongA (hwnd, GWL_STYLE) | WS_VISIBLE); 97 else 98 SetWindowLongA (hwnd, GWL_STYLE, GetWindowLongA (hwnd, GWL_STYLE) & ~WS_VISIBLE); 99 return O32_DefDlgProc(hwnd, Msg, wParam, lParam); 100 case WM_NCCREATE://SvL: YAOFM (yet another open32 feature missing) 101 return(TRUE); 102 case WM_CTLCOLORMSGBOX: 103 case WM_CTLCOLOREDIT: 104 case WM_CTLCOLORLISTBOX: 105 case WM_CTLCOLORBTN: 106 case WM_CTLCOLORDLG: 107 case WM_CTLCOLORSTATIC: 108 case WM_CTLCOLORSCROLLBAR: 109 SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); 110 SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); 111 return GetSysColorBrush(COLOR_BTNFACE); 68 Win32Dialog *dialog; 112 69 113 case WM_PARENTNOTIFY: //Open32 doesn't like receiving those!! 114 dprintf(("DefWndProc: WM_PARENTNOTIFY for %x", hwnd)); 70 dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd); 71 if(!dialog || dialog->IsWindow()) { 72 dprintf(("DefDlgProcW, window %x not found", hwnd)); 115 73 return 0; 116 117 default:118 return O32_DefDlgProc(hwnd, Msg, wParam, lParam);119 74 } 75 return dialog->DefDlgProcW(Msg, wParam, lParam); 120 76 } 121 77 //****************************************************************************** -
trunk/src/user32/new/dialog.cpp
r780 r821 1 /* $Id: dialog.cpp,v 1. 7 1999-09-01 19:12:20 phallerExp $ */1 /* $Id: dialog.cpp,v 1.8 1999-09-04 19:42:27 sandervl Exp $ */ 2 2 3 3 /* 4 4 * Win32 dialog API functions for OS/2 5 5 * 6 * Copyright 199 8 Sander van Leeuwen6 * Copyright 1999 Sander van Leeuwen (Wine port & OS/2 adaption) 7 7 * 8 * 9 * Based on Wine code (990815; windows\dialog.c) 10 * 11 * Copyright 1993, 1994, 1996 Alexandre Julliard 8 12 * 9 13 * Project Odin Software License can be found in LICENSE.TXT … … 11 15 */ 12 16 #include <os2win.h> 13 #include <nameid.h> 14 #include "user32.h" 15 #include "wndproc.h" 16 #include "wndclass.h" 17 #include "win32wbase.h" 18 #include "win32dlg.h" 17 19 18 20 //****************************************************************************** 19 21 //****************************************************************************** 20 HWND WIN32API CreateDialogParamA(HINSTANCE h inst, LPCSTR lpszTemplate,21 22 22 HWND WIN32API CreateDialogParamA(HINSTANCE hInst, LPCSTR lpszTemplate, 23 HWND hwndOwner, DLGPROC dlgproc, 24 LPARAM lParamInit) 23 25 { 24 HWND rc;26 HANDLE hrsrc = FindResourceA( hInst, lpszTemplate, RT_DIALOGA ); 25 27 26 if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id 27 #ifdef DEBUG 28 WriteLog("OS2CreateDialogParamA %s\n", lpszTemplate); 29 #endif 30 lpszTemplate = (LPCSTR)ConvertNameId(hinst, (char *)lpszTemplate); 31 } 32 #ifdef DEBUG 33 else WriteLog("OS2CreateDialogParamA %d\n", (int)lpszTemplate); 34 #endif 28 if (!hrsrc) 29 return 0; 35 30 36 return(rc); 31 return CreateDialogIndirectParamA(hInst, (DLGTEMPLATE*)LoadResource(hInst, hrsrc), 32 hwndOwner, dlgproc, lParamInit); 37 33 } 38 34 //****************************************************************************** 39 35 //****************************************************************************** 40 HWND WIN32API CreateDialogParamW(HINSTANCE h inst, LPCWSTR lpszTemplate,41 42 36 HWND WIN32API CreateDialogParamW(HINSTANCE hInst, LPCWSTR lpszTemplate, 37 HWND hwndOwner, DLGPROC dlgproc, 38 LPARAM lParamInit) 43 39 { 44 HWND rc;40 HANDLE hrsrc = FindResourceW( hInst, lpszTemplate, RT_DIALOGW ); 45 41 46 if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id 47 char *astring = UnicodeToAsciiString((LPWSTR)lpszTemplate); 48 #ifdef DEBUG 49 WriteLog("OS2CreateDialogParamW %s\n", astring); 50 #endif 51 lpszTemplate = (LPWSTR)ConvertNameId(hinst, astring); 52 FreeAsciiString(astring); 53 } 54 #ifdef DEBUG 55 else WriteLog("OS2CreateDialogParamW %d\n", (int)lpszTemplate); 56 #endif 42 if (!hrsrc) 43 return 0; 57 44 58 return(rc); 45 return CreateDialogIndirectParamW(hInst, (DLGTEMPLATE*)LoadResource(hInst, hrsrc), 46 hwndOwner, dlgproc, lParamInit); 59 47 } 60 48 //****************************************************************************** 61 49 //****************************************************************************** 62 HWND WIN32API CreateDialogIndirectParamA(HINSTANCE h inst,63 64 65 50 HWND WIN32API CreateDialogIndirectParamA(HINSTANCE hInst, 51 DLGTEMPLATE *dlgtemplate, 52 HWND hwndParent, DLGPROC dlgproc, 53 LPARAM lParamInit) 66 54 { 67 HWND hwnd;55 Win32Dialog *dialog; 68 56 69 return(0); 57 dprintf(("CreateDialogIndirectParamA: %x %x %x %x %x", hInst, dlgtemplate, hwndParent, dlgproc, lParamInit)); 58 59 if (!dlgtemplate) return 0; 60 61 dialog = new Win32Dialog(hInst, (LPCSTR)dlgtemplate, hwndParent, dlgproc, lParamInit, FALSE); 62 63 if(dialog == NULL) 64 { 65 dprintf(("Win32Dialog creation failed!!")); 66 return 0; 67 } 68 if(GetLastError() != 0) 69 { 70 dprintf(("Win32Dialog error found!!")); 71 delete dialog; 72 return 0; 73 } 74 return dialog->getWindowHandle(); 70 75 } 71 76 //****************************************************************************** 72 77 //****************************************************************************** 73 HWND WIN32API CreateDialogIndirectParamW(HINSTANCE h inst,74 75 76 78 HWND WIN32API CreateDialogIndirectParamW(HINSTANCE hInst, 79 DLGTEMPLATE *dlgtemplate, 80 HWND hwndParent, DLGPROC dlgproc, 81 LPARAM lParamInit) 77 82 { 78 HWND hwnd;83 Win32Dialog *dialog; 79 84 80 return(0); 85 dprintf(("CreateDialogIndirectParamW: %x %x %x %x %x", hInst, dlgtemplate, hwndParent, dlgproc, lParamInit)); 86 87 if (!dlgtemplate) return 0; 88 89 dialog = new Win32Dialog(hInst, (LPCSTR)dlgtemplate, hwndParent, dlgproc, lParamInit, TRUE); 90 91 if(dialog == NULL) 92 { 93 dprintf(("Win32Dialog creation failed!!")); 94 return 0; 95 } 96 if(GetLastError() != 0) 97 { 98 dprintf(("Win32Dialog error found!!")); 99 delete dialog; 100 return 0; 101 } 102 return dialog->getWindowHandle(); 81 103 } 82 104 //****************************************************************************** 83 105 //****************************************************************************** 84 INT WIN32API DialogBoxIndirectParamA(HINSTANCE h inst,85 86 87 106 INT WIN32API DialogBoxIndirectParamA(HINSTANCE hInst, 107 DLGTEMPLATE *dlgtemplate, 108 HWND hwndParent, DLGPROC dlgproc, 109 LPARAM lParamInit) 88 110 { 89 return(0); 111 HWND hwnd = CreateDialogIndirectParamA(hInst, dlgtemplate, hwndParent, dlgproc, 112 lParamInit); 113 //TODO: 114 if (hwnd) return 1; //return DIALOG_DoDialogBox( hwnd, owner ); 115 return -1; 90 116 } 91 117 //****************************************************************************** 92 118 //****************************************************************************** 93 INT WIN32API DialogBoxIndirectParamW(HINSTANCE hinst, 94 DLGTEMPLATE *dlgtemplate, 95 HWND hwndParent, DLGPROC dlgproc, 96 LPARAM lParamInit) 119 INT WIN32API DialogBoxIndirectParamW(HINSTANCE hInst, DLGTEMPLATE *dlgtemplate, 120 HWND hwndParent, DLGPROC dlgproc, 121 LPARAM lParamInit) 97 122 { 98 return(0); 123 HWND hwnd = CreateDialogIndirectParamW(hInst, dlgtemplate, hwndParent, dlgproc, 124 lParamInit); 125 //TODO: 126 if (hwnd) return 1; //return DIALOG_DoDialogBox( hwnd, owner ); 127 return -1; 99 128 } 100 129 //****************************************************************************** 101 130 //****************************************************************************** 102 int WIN32API DialogBoxParamA(HINSTANCE h inst, LPCSTR lpszTemplate, HWND hwndOwner,103 DLGPROC dlgprc, LPARAM lParamInit)131 int WIN32API DialogBoxParamA(HINSTANCE hInst, LPCSTR lpszTemplate, HWND hwndOwner, 132 DLGPROC dlgproc, LPARAM lParamInit) 104 133 { 105 int rc; 106 107 if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id 108 dprintf(("DialogBoxParam %s\n", lpszTemplate)); 109 lpszTemplate = (LPCSTR)ConvertNameId(hinst, (char *)lpszTemplate); 110 } 111 else { 112 dprintf(("DialogBoxParam %d\n", (int)lpszTemplate)); 113 } 114 115 return(0); 134 HWND hwnd = CreateDialogParamA( hInst, lpszTemplate, hwndOwner, dlgproc, lParamInit); 135 //TODO: 136 if (hwnd) return 1; //return DIALOG_DoDialogBox( hwnd, owner ); 137 return -1; 116 138 } 117 139 //****************************************************************************** 118 140 //****************************************************************************** 119 int WIN32API DialogBoxParamW(HINSTANCE arg1, LPCWSTR arg2, HWND arg3,120 DLGPROC arg4, LPARAM arg5)141 int WIN32API DialogBoxParamW(HINSTANCE hInst, LPCWSTR lpszTemplate, HWND hwndOwner, 142 DLGPROC dlgproc, LPARAM lParamInit) 121 143 { 122 int rc; 123 char *astring = NULL; 124 125 126 if((int)arg2 >> 16 != 0) { 127 astring = UnicodeToAsciiString((LPWSTR)arg2); 128 } 129 else astring = (char *)arg2; 130 dprintf(("OS2DialogBoxParamW\n")); 131 132 if((int)astring >> 16 != 0) FreeAsciiString(astring); 133 134 dprintf(("OS2DialogBoxIndirectParamA returned %d\n", rc)); 135 136 return(0); 144 HWND hwnd = CreateDialogParamW( hInst, lpszTemplate, hwndOwner, dlgproc, lParamInit); 145 //TODO: 146 if (hwnd) return 1; //return DIALOG_DoDialogBox( hwnd, owner ); 147 return -1; 137 148 } 138 149 //****************************************************************************** -
trunk/src/user32/new/makefile
r819 r821 1 # $Id: makefile,v 1.4 1 1999-09-04 17:56:40 dengertExp $1 # $Id: makefile,v 1.42 1999-09-04 19:42:27 sandervl Exp $ 2 2 3 3 # … … 67 67 dde.obj: dde.cpp 68 68 hook.obj: hook.cpp hooks.h 69 defwndproc.obj: defwndproc.cpp syscolor.h win32wmdiclient.h win32wbase.h win32wnd.h 69 defwndproc.obj: defwndproc.cpp syscolor.h win32wmdiclient.h win32wbase.h win32wnd.h win32dlg.h 70 70 hooks.obj: hooks.cpp hooks.h 71 71 initterm.obj: initterm.cpp $(PDWIN32_INCLUDE)\spy.h pmwindow.h heapshared.h … … 76 76 spy.obj: spy.cpp $(PDWIN32_INCLUDE)\spy.h 77 77 78 controls.obj: controls.cpp $(PDWIN32_INCLUDE)\win\controls.h win32wmdiclient.h 78 controls.obj: controls.cpp $(PDWIN32_INCLUDE)\win\controls.h win32wmdiclient.h win32dlg.h 79 79 button.obj: button.cpp $(PDWIN32_INCLUDE)\win\button.h 80 80 static.obj: static.cpp $(PDWIN32_INCLUDE)\win\static.h -
trunk/src/user32/new/oslibres.cpp
r753 r821 1 /* $Id: oslibres.cpp,v 1. 7 1999-08-31 14:38:08 sandervl Exp $ */1 /* $Id: oslibres.cpp,v 1.8 1999-09-04 19:42:28 sandervl Exp $ */ 2 2 /* 3 3 * Window API wrappers for OS/2 … … 45 45 } 46 46 //****************************************************************************** 47 //TODO: handle single icons48 47 //****************************************************************************** 49 48 HANDLE OSLibWinCreateIcon(PVOID iconbitmap) … … 70 69 bafh = (BITMAPARRAYFILEHEADER2 *)bfhBW; //for calculation bitmap offset 71 70 } 72 hps = WinGetPS(HWND_DESKTOP); 71 hps = WinGetScreenPS(HWND_DESKTOP); 72 73 73 hbmColor = GpiCreateBitmap(hps, &bfhColor->bmp2, CBM_INIT, 74 74 (char *)bafh + bfhColor->offBits, … … 118 118 } 119 119 //skip xor/and mask 120 hps = WinGet PS(HWND_DESKTOP);120 hps = WinGetScreenPS(HWND_DESKTOP); 121 121 hbmColor = GpiCreateBitmap(hps, &bfh->bmp2, CBM_INIT, 122 122 (char *)bfh + bfh->offBits, -
trunk/src/user32/new/user32.cpp
r808 r821 1 /* $Id: user32.cpp,v 1.1 7 1999-09-03 15:09:44sandervl Exp $ */1 /* $Id: user32.cpp,v 1.18 1999-09-04 19:42:28 sandervl Exp $ */ 2 2 3 3 /* … … 1188 1188 } 1189 1189 //****************************************************************************** 1190 /* Not support by Open32 (not included are the new win9x parameters): 1191 case SPI_GETFASTTASKSWITCH: 1192 case SPI_GETGRIDGRANULARITY: 1193 case SPI_GETICONTITLELOGFONT: 1194 case SPI_GETICONTITLEWRAP: 1195 case SPI_GETMENUDROPALIGNMENT: 1196 case SPI_ICONHORIZONTALSPACING: 1197 case SPI_ICONVERTICALSPACING: 1198 case SPI_LANGDRIVER: 1199 case SPI_SETFASTTASKSWITCH: 1200 case SPI_SETGRIDGRANULARITY: 1201 case SPI_SETICONTITLELOGFONT: 1202 case SPI_SETICONTITLEWRAP: 1203 case SPI_SETMENUDROPALIGNMENT: 1204 case SPI_GETSCREENSAVEACTIVE: 1205 case SPI_GETSCREENSAVETIMEOUT: 1206 case SPI_SETDESKPATTERN: 1207 case SPI_SETDESKWALLPAPER: 1208 case SPI_SETSCREENSAVEACTIVE: 1209 case SPI_SETSCREENSAVETIMEOUT: 1210 */ 1190 1211 //****************************************************************************** 1191 1212 BOOL WIN32API SystemParametersInfoA(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni) … … 1225 1246 break; 1226 1247 case SPI_GETICONTITLELOGFONT: 1248 { 1249 LPLOGFONTA lpLogFont = (LPLOGFONTA)pvParam; 1250 1251 /* from now on we always have an alias for MS Sans Serif */ 1252 strcpy(lpLogFont->lfFaceName, "MS Sans Serif"); 1253 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 8); 1254 lpLogFont->lfWidth = 0; 1255 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0; 1256 lpLogFont->lfWeight = FW_NORMAL; 1257 lpLogFont->lfItalic = FALSE; 1258 lpLogFont->lfStrikeOut = FALSE; 1259 lpLogFont->lfUnderline = FALSE; 1260 lpLogFont->lfCharSet = ANSI_CHARSET; 1261 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS; 1262 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS; 1263 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS; 1227 1264 break; 1228 1265 } 1229 1266 case SPI_GETBORDER: 1230 1267 *(INT *)pvParam = GetSystemMetrics( SM_CXFRAME ); … … 1283 1320 pvParamA = &clientMetricsA; 1284 1321 break; 1322 case SPI_GETICONTITLELOGFONT: 1323 { 1324 LPLOGFONTW lpLogFont = (LPLOGFONTW)pvParam; 1325 1326 /* from now on we always have an alias for MS Sans Serif */ 1327 lstrcpyW(lpLogFont->lfFaceName, (LPCWSTR)L"MS Sans Serif"); 1328 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 8); 1329 lpLogFont->lfWidth = 0; 1330 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0; 1331 lpLogFont->lfWeight = FW_NORMAL; 1332 lpLogFont->lfItalic = FALSE; 1333 lpLogFont->lfStrikeOut = FALSE; 1334 lpLogFont->lfUnderline = FALSE; 1335 lpLogFont->lfCharSet = ANSI_CHARSET; 1336 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS; 1337 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS; 1338 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS; 1339 return TRUE; 1340 } 1285 1341 default: 1286 1342 pvParamA = pvParam; -
trunk/src/user32/new/win32dlg.cpp
r741 r821 1 /* $Id: win32dlg.cpp,v 1. 2 1999-08-30 11:59:53sandervl Exp $ */1 /* $Id: win32dlg.cpp,v 1.3 1999-09-04 19:42:28 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Dialog Code for OS/2 4 4 * 5 * 6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl) 7 * 5 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl) (Wine port & OS/2 adaption) 6 * 7 * Based on Wine code (990815; windows\dialog.c) 8 * 9 * Copyright 1993, 1994, 1996 Alexandre Julliard 8 10 * 9 11 * Project Odin Software License can be found in LICENSE.TXT … … 11 13 */ 12 14 #include <os2win.h> 15 #include <windowsx.h> 13 16 #include <stdlib.h> 14 17 #include <string.h> … … 18 21 //****************************************************************************** 19 22 //****************************************************************************** 20 Win32Dialog::Win32Dialog() : Win32BaseWindow(OBJTYPE_DIALOG) 21 { 23 Win32Dialog::Win32Dialog(HINSTANCE hInst, LPCSTR dlgTemplate, HWND owner, 24 DLGPROC dlgProc, LPARAM param, BOOL isUnicode) 25 : Win32BaseWindow(OBJTYPE_DIALOG) 26 { 27 RECT rect; 28 WORD style; 29 ATOM classAtom; 30 31 this->isUnicode = isUnicode; 32 hUserFont = 0; 33 hMenu = 0; 34 hwndFocus = 0; 35 Win32DlgProc = 0; 36 msgResult = 0; 37 userDlgData = 0; 38 idResult = 0; 39 dialogFlags = 0; 40 memset(&dlgInfo, 0, sizeof(dlgInfo)); 41 42 if(fInitialized == FALSE) { 43 if(DIALOG_Init() == FALSE) { 44 dprintf(("DIALOG_Init FAILED!")); 45 DebugInt3(); 46 SetLastError(ERROR_GEN_FAILURE); 47 return; 48 } 49 fInitialized = TRUE; 50 } 51 xUnit = xBaseUnit; 52 yUnit = yBaseUnit; 53 54 /* Parse dialog template */ 55 dlgTemplate = parseTemplate(dlgTemplate, &dlgInfo); 56 57 /* Load menu */ 58 if (dlgInfo.menuName) 59 { 60 hMenu = LoadMenuW( hInst, (LPCWSTR)dlgInfo.menuName ); 61 } 62 63 /* Create custom font if needed */ 64 if (dlgInfo.style & DS_SETFONT) 65 { 66 /* The font height must be negative as it is a point size */ 67 /* (see CreateFont() documentation in the Windows SDK). */ 68 hUserFont = CreateFontW(dlgInfo.pointSize, 0, 0, 0, 69 dlgInfo.weight, dlgInfo.italic, FALSE, 70 FALSE, DEFAULT_CHARSET, 0, 0, PROOF_QUALITY, 71 FF_DONTCARE, (LPCWSTR)dlgInfo.faceName ); 72 if (hUserFont) 73 { 74 SIZE charSize; 75 getCharSize(hUserFont,&charSize); 76 xBaseUnit = charSize.cx; 77 yBaseUnit = charSize.cy; 78 } 79 } 80 81 /* Create dialog main window */ 82 rect.left = rect.top = 0; 83 rect.right = dlgInfo.cx * xUnit / 4; 84 rect.bottom = dlgInfo.cy * yUnit / 8; 85 if (dlgInfo.style & DS_MODALFRAME) 86 dlgInfo.exStyle |= WS_EX_DLGMODALFRAME; 87 88 AdjustWindowRectEx( &rect, dlgInfo.style, hMenu ? TRUE : FALSE , dlgInfo.exStyle ); 89 rect.right -= rect.left; 90 rect.bottom -= rect.top; 91 92 if ((INT16)dlgInfo.x == CW_USEDEFAULT16) 93 { 94 rect.left = rect.top = CW_USEDEFAULT; 95 } 96 else 97 { 98 if (dlgInfo.style & DS_CENTER) 99 { 100 rect.left = (GetSystemMetrics(SM_CXSCREEN) - rect.right) / 2; 101 rect.top = (GetSystemMetrics(SM_CYSCREEN) - rect.bottom) / 2; 102 } 103 else 104 { 105 rect.left += dlgInfo.x * xUnit / 4; 106 rect.top += dlgInfo.y * yUnit / 8; 107 } 108 if ( !(dlgInfo.style & WS_CHILD) ) 109 { 110 INT dX, dY; 111 112 if( !(dlgInfo.style & DS_ABSALIGN) ) 113 ClientToScreen(owner, (POINT *)&rect ); 114 115 /* try to fit it into the desktop */ 116 117 if( (dX = rect.left + rect.right + GetSystemMetrics(SM_CXDLGFRAME) 118 - GetSystemMetrics(SM_CXSCREEN)) > 0 ) rect.left -= dX; 119 if( (dY = rect.top + rect.bottom + GetSystemMetrics(SM_CYDLGFRAME) 120 - GetSystemMetrics(SM_CYSCREEN)) > 0 ) rect.top -= dY; 121 if( rect.left < 0 ) rect.left = 0; 122 if( rect.top < 0 ) rect.top = 0; 123 } 124 } 125 126 /* Create the dialog window */ 127 128 /* Find the class atom */ 129 if (HIWORD(dlgInfo.className)) 130 { 131 classAtom = (ATOM)LOWORD(dlgInfo.className); 132 } 133 else 134 if(!(classAtom = GlobalFindAtomA(dlgInfo.className))) 135 { 136 SetLastError(ERROR_INVALID_PARAMETER); 137 return; 138 } 139 CREATESTRUCTA cs; 140 cs.lpCreateParams = NULL; 141 cs.hInstance = hInst; 142 cs.hMenu = hMenu; 143 cs.hwndParent = owner; 144 cs.x = rect.left; 145 cs.y = rect.top; 146 cs.cx = rect.right; 147 cs.cy = rect.bottom; 148 cs.style = dlgInfo.style & ~WS_VISIBLE; 149 cs.lpszName = dlgInfo.caption; 150 cs.lpszClass = dlgInfo.className; 151 cs.dwExStyle = dlgInfo.exStyle; 152 153 CreateWindowExA(&cs, classAtom); 154 155 if (!getWindowHandle()) 156 { 157 if (hUserFont) DeleteObject( hUserFont ); 158 if (hMenu) DestroyMenu( hMenu ); 159 return; 160 } 161 fIsDialog = TRUE; 162 163 //TODO: 164 // wndPtr->helpContext = helpId; 165 Win32DlgProc = dlgProc; 166 167 if (hUserFont) 168 SendMessageA(WM_SETFONT, (WPARAM)hUserFont, 0 ); 169 170 /* Create controls */ 171 if (createControls(dlgTemplate, hInst)) 172 { 173 /* Send initialisation messages and set focus */ 174 hwndFocus = GetNextDlgTabItem( getWindowHandle(), 0, FALSE ); 175 176 if (::SendMessageA(hwndFocus, WM_INITDIALOG, (WPARAM)hwndFocus, param )) 177 SetFocus( hwndFocus ); 178 179 if (dlgInfo.style & WS_VISIBLE && !(getStyle() & WS_VISIBLE)) 180 { 181 ShowWindow( SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */ 182 ::UpdateWindow( getWindowHandle() ); 183 } 184 return; 185 } 186 DestroyWindow(); 22 187 } 23 188 //****************************************************************************** … … 25 190 Win32Dialog::~Win32Dialog() 26 191 { 27 192 if (hUserFont) DeleteObject( hUserFont ); 193 if (hMenu) DestroyMenu( hMenu ); 194 195 } 196 /*********************************************************************** 197 * DIALOG_Init 198 * 199 * Initialisation of the dialog manager. 200 */ 201 BOOL Win32Dialog::DIALOG_Init(void) 202 { 203 HDC hdc; 204 SIZE size; 205 206 /* Calculate the dialog base units */ 207 if (!(hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL ))) return FALSE; 208 if (!getCharSizeFromDC( hdc, 0, &size )) return FALSE; 209 DeleteDC( hdc ); 210 xBaseUnit = size.cx; 211 yBaseUnit = size.cy; 212 213 return TRUE; 214 } 215 /*********************************************************************** 216 * DIALOG_GetCharSizeFromDC 217 * 218 * 219 * Calculates the *true* average size of English characters in the 220 * specified font as oppposed to the one returned by GetTextMetrics. 221 */ 222 BOOL Win32Dialog::getCharSizeFromDC( HDC hDC, HFONT hUserFont, SIZE * pSize ) 223 { 224 BOOL Success = FALSE; 225 HFONT hUserFontPrev = 0; 226 pSize->cx = xBaseUnit; 227 pSize->cy = yBaseUnit; 228 229 if ( hDC ) 230 { 231 /* select the font */ 232 TEXTMETRICA tm; 233 memset(&tm,0,sizeof(tm)); 234 if (hUserFont) hUserFontPrev = SelectFont(hDC,hUserFont); 235 if (GetTextMetricsA(hDC,&tm)) 236 { 237 pSize->cx = tm.tmAveCharWidth; 238 pSize->cy = tm.tmHeight; 239 240 /* if variable width font */ 241 if (tm.tmPitchAndFamily & TMPF_FIXED_PITCH) 242 { 243 SIZE total; 244 static const char szAvgChars[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 245 246 /* Calculate a true average as opposed to the one returned 247 * by tmAveCharWidth. This works better when dealing with 248 * proportional spaced fonts and (more important) that's 249 * how Microsoft's dialog creation code calculates the size 250 * of the font 251 */ 252 if (GetTextExtentPointA(hDC,szAvgChars,sizeof(szAvgChars),&total)) 253 { 254 /* round up */ 255 pSize->cx = ((2*total.cx/sizeof(szAvgChars)) + 1)/2; 256 Success = TRUE; 257 } 258 } 259 else 260 { 261 Success = TRUE; 262 } 263 } 264 265 /* select the original font */ 266 if (hUserFontPrev) SelectFont(hDC,hUserFontPrev); 267 } 268 return (Success); 269 } 270 /*********************************************************************** 271 * DIALOG_GetCharSize 272 * 273 * 274 * Calculates the *true* average size of English characters in the 275 * specified font as oppposed to the one returned by GetTextMetrics. 276 * A convenient variant of DIALOG_GetCharSizeFromDC. 277 */ 278 BOOL Win32Dialog::getCharSize( HFONT hUserFont, SIZE * pSize ) 279 { 280 HDC hDC = GetDC(0); 281 BOOL Success = getCharSizeFromDC( hDC, hUserFont, pSize ); 282 ReleaseDC(0, hDC); 283 return Success; 284 } 285 /*********************************************************************** 286 * DIALOG_ParseTemplate32 287 * 288 * Fill a DLG_TEMPLATE structure from the dialog template, and return 289 * a pointer to the first control. 290 */ 291 LPCSTR Win32Dialog::parseTemplate( LPCSTR dlgtemplate, DLG_TEMPLATE * result ) 292 { 293 const WORD *p = (const WORD *)dlgtemplate; 294 295 result->style = GET_DWORD(p); p += 2; 296 if (result->style == 0xffff0001) /* DIALOGEX resource */ 297 { 298 result->dialogEx = TRUE; 299 result->helpId = GET_DWORD(p); p += 2; 300 result->exStyle = GET_DWORD(p); p += 2; 301 result->style = GET_DWORD(p); p += 2; 302 } 303 else 304 { 305 result->dialogEx = FALSE; 306 result->helpId = 0; 307 result->exStyle = GET_DWORD(p); p += 2; 308 } 309 result->nbItems = GET_WORD(p); p++; 310 result->x = GET_WORD(p); p++; 311 result->y = GET_WORD(p); p++; 312 result->cx = GET_WORD(p); p++; 313 result->cy = GET_WORD(p); p++; 314 315 /* Get the menu name */ 316 317 switch(GET_WORD(p)) 318 { 319 case 0x0000: 320 result->menuName = NULL; 321 p++; 322 break; 323 case 0xffff: 324 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 ); 325 p += 2; 326 break; 327 default: 328 result->menuName = (LPCSTR)p; 329 p += lstrlenW( (LPCWSTR)p ) + 1; 330 break; 331 } 332 333 /* Get the class name */ 334 switch(GET_WORD(p)) 335 { 336 case 0x0000: 337 result->className = (LPCSTR)DIALOG_CLASS_ATOM; 338 p++; 339 break; 340 case 0xffff: 341 result->className = (LPCSTR)(UINT)GET_WORD( p + 1 ); 342 p += 2; 343 break; 344 default: 345 result->className = (LPCSTR)p; 346 p += lstrlenW( (LPCWSTR)p ) + 1; 347 break; 348 } 349 350 /* Get the window caption */ 351 352 result->caption = (LPCSTR)p; 353 p += lstrlenW( (LPCWSTR)p ) + 1; 354 355 /* Get the font name */ 356 357 if (result->style & DS_SETFONT) 358 { 359 result->pointSize = GET_WORD(p); 360 p++; 361 if (result->dialogEx) 362 { 363 result->weight = GET_WORD(p); p++; 364 result->italic = LOBYTE(GET_WORD(p)); p++; 365 } 366 else 367 { 368 result->weight = FW_DONTCARE; 369 result->italic = FALSE; 370 } 371 result->faceName = (LPCSTR)p; 372 p += lstrlenW( (LPCWSTR)p ) + 1; 373 } 374 375 /* First control is on dword boundary */ 376 return (LPCSTR)((((int)p) + 3) & ~3); 377 } 378 /*********************************************************************** 379 * DIALOG_GetControl32 380 * 381 * Return the class and text of the control pointed to by ptr, 382 * fill the header structure and return a pointer to the next control. 383 */ 384 WORD *Win32Dialog::getControl(const WORD *p, DLG_CONTROL_INFO *info, BOOL dialogEx) 385 { 386 if (dialogEx) 387 { 388 info->helpId = GET_DWORD(p); p += 2; 389 info->exStyle = GET_DWORD(p); p += 2; 390 info->style = GET_DWORD(p); p += 2; 391 } 392 else 393 { 394 info->helpId = 0; 395 info->style = GET_DWORD(p); p += 2; 396 info->exStyle = GET_DWORD(p); p += 2; 397 } 398 info->x = GET_WORD(p); p++; 399 info->y = GET_WORD(p); p++; 400 info->cx = GET_WORD(p); p++; 401 info->cy = GET_WORD(p); p++; 402 403 if (dialogEx) 404 { 405 /* id is a DWORD for DIALOGEX */ 406 info->id = GET_DWORD(p); 407 p += 2; 408 } 409 else 410 { 411 info->id = GET_WORD(p); 412 p++; 413 } 414 415 if (GET_WORD(p) == 0xffff) 416 { 417 static const WCHAR class_names[6][10] = 418 { 419 { 'B','u','t','t','o','n', }, /* 0x80 */ 420 { 'E','d','i','t', }, /* 0x81 */ 421 { 'S','t','a','t','i','c', }, /* 0x82 */ 422 { 'L','i','s','t','B','o','x', }, /* 0x83 */ 423 { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */ 424 { 'C','o','m','b','o','B','o','x', } /* 0x85 */ 425 }; 426 WORD id = GET_WORD(p+1); 427 if ((id >= 0x80) && (id <= 0x85)) 428 info->className = (LPCSTR)class_names[id - 0x80]; 429 else 430 { 431 info->className = NULL; 432 dprintf(("Unknown built-in class id %04x\n", id )); 433 } 434 p += 2; 435 } 436 else 437 { 438 info->className = (LPCSTR)p; 439 p += lstrlenW( (LPCWSTR)p ) + 1; 440 } 441 442 if (GET_WORD(p) == 0xffff) /* Is it an integer id? */ 443 { 444 info->windowName = (LPCSTR)(UINT)GET_WORD(p + 1); 445 p += 2; 446 } 447 else 448 { 449 info->windowName = (LPCSTR)p; 450 p += lstrlenW( (LPCWSTR)p ) + 1; 451 } 452 453 if (GET_WORD(p)) 454 { 455 info->data = (LPVOID)(p + 1); 456 p += GET_WORD(p) / sizeof(WORD); 457 } 458 else info->data = NULL; 459 p++; 460 461 /* Next control is on dword boundary */ 462 return (WORD *)((((int)p) + 3) & ~3); 463 } 464 465 466 /*********************************************************************** 467 * DIALOG_CreateControls 468 * 469 * Create the control windows for a dialog. 470 */ 471 BOOL Win32Dialog::createControls(LPCSTR dlgtemplate, HINSTANCE hInst) 472 { 473 DLG_CONTROL_INFO info; 474 HWND hwndCtrl, hwndDefButton = 0; 475 INT items = dlgInfo.nbItems; 476 477 while (items--) 478 { 479 dlgtemplate = (LPCSTR)getControl( (WORD *)dlgtemplate, &info, dlgInfo.dialogEx ); 480 481 hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY, 482 (LPCWSTR)info.className, 483 (LPCWSTR)info.windowName, 484 info.style | WS_CHILD, 485 info.x * xUnit / 4, 486 info.y * yUnit / 8, 487 info.cx * xUnit / 4, 488 info.cy * yUnit / 8, 489 getWindowHandle(), (HMENU)info.id, 490 hInst, info.data ); 491 492 if (!hwndCtrl) return FALSE; 493 494 /* Send initialisation messages to the control */ 495 if (hUserFont) ::SendMessageA( hwndCtrl, WM_SETFONT, (WPARAM)hUserFont, 0 ); 496 497 if (::SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON) 498 { 499 /* If there's already a default push-button, set it back */ 500 /* to normal and use this one instead. */ 501 if (hwndDefButton) 502 ::SendMessageA( hwndDefButton, BM_SETSTYLE, 503 BS_PUSHBUTTON,FALSE ); 504 hwndDefButton = hwndCtrl; 505 idResult = ::GetWindowWord( hwndCtrl, GWW_ID ); 506 } 507 } 508 return TRUE; 509 } 510 /*********************************************************************** 511 * DEFDLG_Proc 512 * 513 * Implementation of DefDlgProc(). Only handle messages that need special 514 * handling for dialogs. 515 */ 516 LRESULT Win32Dialog::DefDlg_Proc(UINT msg, WPARAM wParam, LPARAM lParam) 517 { 518 switch(msg) 519 { 520 case WM_ERASEBKGND: 521 { 522 RECT rect; 523 int rc; 524 /* Since WM_ERASEBKGND may receive either a window dc or a */ 525 /* client dc, the area to be erased has to be retrieved from */ 526 /* the device context. */ 527 rc = GetClipBox( (HDC)wParam, &rect ); 528 if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION)) 529 FillRect( (HDC)wParam, &rect, windowClass->getBackgroundBrush()); 530 return 1; 531 } 532 case WM_NCDESTROY: 533 /* Free dialog heap (if created) */ 534 #if 0 535 if (dlgInfo->hDialogHeap) 536 { 537 GlobalUnlock16(dlgInfo->hDialogHeap); 538 GlobalFree16(dlgInfo->hDialogHeap); 539 dlgInfo->hDialogHeap = 0; 540 } 541 #endif 542 /* Delete font */ 543 if (hUserFont) 544 { 545 DeleteObject( hUserFont ); 546 hUserFont = 0; 547 } 548 549 /* Delete menu */ 550 if (hMenu) 551 { 552 DestroyMenu( hMenu ); 553 hMenu = 0; 554 } 555 556 /* Delete window procedure */ 557 Win32DlgProc = 0; 558 dialogFlags |= DF_END; /* just in case */ 559 560 /* Window clean-up */ 561 return DefWindowProcA(msg, wParam, lParam ); 562 563 case WM_SHOWWINDOW: 564 if (!wParam) saveFocus(); 565 return DefWindowProcA(msg, wParam, lParam ); 566 567 case WM_ACTIVATE: 568 if (wParam) { 569 restoreFocus(); 570 } 571 else saveFocus(); 572 return 0; 573 574 case WM_SETFOCUS: 575 restoreFocus(); 576 return 0; 577 578 case DM_SETDEFID: 579 if (dialogFlags & DF_END) 580 return 1; 581 582 setDefButton(wParam ? GetDlgItem( getWindowHandle(), wParam ) : 0 ); 583 return 1; 584 585 case DM_GETDEFID: 586 { 587 HWND hwndDefId; 588 if (dialogFlags & DF_END) return 0; 589 if (idResult) 590 return MAKELONG( idResult, DC_HASDEFID ); 591 if ((hwndDefId = findDefButton())) 592 return MAKELONG( GetDlgCtrlID( hwndDefId ), DC_HASDEFID); 593 594 return 0; 595 } 596 597 case WM_NEXTDLGCTL: 598 { 599 HWND hwndDest = (HWND)wParam; 600 if (!lParam) 601 hwndDest = GetNextDlgTabItem(getWindowHandle(), GetFocus(), wParam); 602 if (hwndDest) setFocus( hwndDest ); 603 setDefButton( hwndDest ); 604 return 0; 605 } 606 607 case WM_ENTERMENULOOP: 608 case WM_LBUTTONDOWN: 609 case WM_NCLBUTTONDOWN: 610 { 611 HWND hwndCurFocus = GetFocus(); 612 if (hwndCurFocus) 613 { 614 #if 0 615 WND *wnd = WIN_FindWndPtr( hwndFocus ); 616 617 if( wnd ) 618 { 619 /* always make combo box hide its listbox control */ 620 if( WIDGETS_IsControl( wnd, BIC32_COMBO ) ) 621 SendMessageA( hwndFocus, CB_SHOWDROPDOWN, FALSE, 0 ); 622 else 623 if( WIDGETS_IsControl( wnd, BIC32_EDIT ) && 624 WIDGETS_IsControl( wnd->parent, BIC32_COMBO )) 625 SendMessageA(CB_SHOWDROPDOWN, FALSE, 0 ); 626 } 627 #endif 628 } 629 return DefWindowProcA( msg, wParam, lParam ); 630 } 631 632 case WM_GETFONT: 633 return hUserFont; 634 635 case WM_CLOSE: 636 PostMessageA(WM_COMMAND, IDCANCEL, (LPARAM)GetDlgItem( getWindowHandle(), IDCANCEL ) ); 637 return 0; 638 639 case WM_NOTIFYFORMAT: 640 return DefWindowProcA(msg, wParam, lParam ); 641 } 642 return 0; 643 } 644 //****************************************************************************** 645 //****************************************************************************** 646 LRESULT Win32Dialog::DefDlgProcA(UINT Msg, WPARAM wParam, LPARAM lParam) 647 { 648 BOOL result = FALSE; 649 650 msgResult = 0; 651 652 if (Win32DlgProc) { /* Call dialog procedure */ 653 result = Win32DlgProc(getWindowHandle(), Msg, wParam, lParam); 654 } 655 656 if (!result && IsWindow()) 657 { 658 /* callback didn't process this message */ 659 switch(Msg) 660 { 661 case WM_ERASEBKGND: 662 case WM_SHOWWINDOW: 663 case WM_ACTIVATE: 664 case WM_SETFOCUS: 665 case DM_SETDEFID: 666 case DM_GETDEFID: 667 case WM_NEXTDLGCTL: 668 case WM_GETFONT: 669 case WM_CLOSE: 670 case WM_NCDESTROY: 671 case WM_ENTERMENULOOP: 672 case WM_LBUTTONDOWN: 673 case WM_NCLBUTTONDOWN: 674 return DefDlg_Proc(Msg, (WPARAM)wParam, lParam); 675 676 case WM_INITDIALOG: 677 case WM_VKEYTOITEM: 678 case WM_COMPAREITEM: 679 case WM_CHARTOITEM: 680 break; 681 682 default: 683 return DefWindowProcA(Msg, wParam, lParam ); 684 } 685 } 686 return DefDlg_Epilog(Msg, result); 687 } 688 //****************************************************************************** 689 //****************************************************************************** 690 LRESULT Win32Dialog::DefDlgProcW(UINT Msg, WPARAM wParam, LPARAM lParam) 691 { 692 BOOL result = FALSE; 693 694 msgResult = 0; 695 696 if (Win32DlgProc) { /* Call dialog procedure */ 697 result = Win32DlgProc(getWindowHandle(), Msg, wParam, lParam); 698 } 699 700 if (!result && IsWindow()) 701 { 702 /* callback didn't process this message */ 703 switch(Msg) 704 { 705 case WM_ERASEBKGND: 706 case WM_SHOWWINDOW: 707 case WM_ACTIVATE: 708 case WM_SETFOCUS: 709 case DM_SETDEFID: 710 case DM_GETDEFID: 711 case WM_NEXTDLGCTL: 712 case WM_GETFONT: 713 case WM_CLOSE: 714 case WM_NCDESTROY: 715 case WM_ENTERMENULOOP: 716 case WM_LBUTTONDOWN: 717 case WM_NCLBUTTONDOWN: 718 return DefDlg_Proc(Msg, (WPARAM)wParam, lParam); 719 720 case WM_INITDIALOG: 721 case WM_VKEYTOITEM: 722 case WM_COMPAREITEM: 723 case WM_CHARTOITEM: 724 break; 725 726 default: 727 return DefWindowProcW(Msg, wParam, lParam ); 728 } 729 } 730 return DefDlg_Epilog(Msg, result); 731 } 732 /*********************************************************************** 733 * DEFDLG_Epilog 734 */ 735 LRESULT Win32Dialog::DefDlg_Epilog(UINT msg, BOOL fResult) 736 { 737 /* see SDK 3.1 */ 738 if ((msg >= WM_CTLCOLORMSGBOX && msg <= WM_CTLCOLORSTATIC) || 739 msg == WM_CTLCOLOR || msg == WM_COMPAREITEM || 740 msg == WM_VKEYTOITEM || msg == WM_CHARTOITEM || 741 msg == WM_QUERYDRAGICON || msg == WM_INITDIALOG) 742 return fResult; 743 744 return msgResult; 745 } 746 /*********************************************************************** 747 * DEFDLG_SetFocus 748 * 749 * Set the focus to a control of the dialog, selecting the text if 750 * the control is an edit dialog. 751 */ 752 void Win32Dialog::setFocus(HWND hwndCtrl ) 753 { 754 HWND hwndPrev = GetFocus(); 755 756 if (IsChild( hwndPrev )) 757 { 758 if (::SendMessageA( hwndPrev, WM_GETDLGCODE, 0, 0 ) & DLGC_HASSETSEL) 759 ::SendMessageA( hwndPrev, EM_SETSEL, TRUE, MAKELONG( -1, 0 ) ); 760 } 761 if (::SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0 ) & DLGC_HASSETSEL) 762 ::SendMessageA(hwndCtrl, EM_SETSEL, FALSE, MAKELONG( 0, -1 ) ); 763 SetFocus( hwndCtrl ); 764 } 765 766 767 /*********************************************************************** 768 * DEFDLG_SaveFocus 769 */ 770 BOOL Win32Dialog::saveFocus() 771 { 772 HWND hwndCurrentFocus = GetFocus(); 773 774 if (!hwndCurrentFocus || !IsChild( hwndCurrentFocus )) return FALSE; 775 776 hwndFocus = hwndCurrentFocus; 777 /* Remove default button */ 778 return TRUE; 779 } 780 781 782 /*********************************************************************** 783 * DEFDLG_RestoreFocus 784 */ 785 BOOL Win32Dialog::restoreFocus() 786 { 787 if (!hwndFocus || IsIconic()) return FALSE; 788 789 if (!::IsWindow( hwndFocus )) return FALSE; 790 791 /* Don't set the focus back to controls if EndDialog is already called.*/ 792 if (!(dialogFlags & DF_END)) 793 setFocus(hwndFocus); 794 795 /* This used to set infoPtr->hwndFocus to NULL for no apparent reason, 796 sometimes losing focus when receiving WM_SETFOCUS messages. */ 797 return TRUE; 798 } 799 800 801 /*********************************************************************** 802 * DEFDLG_FindDefButton 803 * 804 * Find the current default push-button. 805 */ 806 HWND Win32Dialog::findDefButton() 807 { 808 HWND hwndChild = GetWindow( GW_CHILD ); 809 while (hwndChild) 810 { 811 if (::SendMessageA( hwndChild, WM_GETDLGCODE, 0, 0 ) & DLGC_DEFPUSHBUTTON) 812 break; 813 hwndChild = ::GetWindow( hwndChild, GW_HWNDNEXT ); 814 } 815 return hwndChild; 816 } 817 818 819 /*********************************************************************** 820 * DEFDLG_SetDefButton 821 * 822 * Set the new default button to be hwndNew. 823 */ 824 BOOL Win32Dialog::setDefButton(HWND hwndNew ) 825 { 826 if (hwndNew && 827 !(::SendMessageA(hwndNew, WM_GETDLGCODE, 0, 0 ) & DLGC_UNDEFPUSHBUTTON)) 828 return FALSE; /* Destination is not a push button */ 829 830 if (idResult) /* There's already a default pushbutton */ 831 { 832 HWND hwndOld = GetDlgItem( getWindowHandle(), idResult ); 833 if (::SendMessageA( hwndOld, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON) 834 ::SendMessageA( hwndOld, BM_SETSTYLE, BS_PUSHBUTTON, TRUE ); 835 } 836 if (hwndNew) 837 { 838 ::SendMessageA( hwndNew, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE ); 839 idResult = GetDlgCtrlID( hwndNew ); 840 } 841 else idResult = 0; 842 return TRUE; 28 843 } 29 844 //****************************************************************************** … … 76 891 //****************************************************************************** 77 892 //****************************************************************************** 893 BOOL DIALOG_Register() 894 { 895 WNDCLASSA wndClass; 896 897 if (GlobalFindAtomA(DIALOG_CLASS_NAME)) return FALSE; 898 899 ZeroMemory(&wndClass,sizeof(WNDCLASSA)); 900 wndClass.style = CS_GLOBALCLASS | CS_SAVEBITS; 901 wndClass.lpfnWndProc = (WNDPROC)DefDlgProcA; 902 wndClass.cbClsExtra = 0; 903 wndClass.cbWndExtra = 0; 904 wndClass.hCursor = (HCURSOR)IDC_ARROWA; 905 wndClass.hbrBackground = LTGRAY_BRUSH; 906 wndClass.lpszClassName = DIALOG_CLASS_NAME; 907 908 return RegisterClassA(&wndClass); 909 } 910 //****************************************************************************** 911 //****************************************************************************** 912 BOOL DIALOG_Unregister() 913 { 914 if (GlobalFindAtomA(DIALOG_CLASS_NAME)) 915 return UnregisterClassA(DIALOG_CLASS_NAME,(HINSTANCE)NULL); 916 else return FALSE; 917 } 918 //****************************************************************************** 919 //****************************************************************************** 920 BOOL Win32Dialog::fInitialized = FALSE; 921 int Win32Dialog::xBaseUnit = 0; 922 int Win32Dialog::yBaseUnit = 0; -
trunk/src/user32/new/win32dlg.h
r741 r821 1 /* $Id: win32dlg.h,v 1. 3 1999-08-30 11:59:53sandervl Exp $ */1 /* $Id: win32dlg.h,v 1.4 1999-09-04 19:42:29 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Dialog Code for OS/2 … … 17 17 #ifdef __cplusplus 18 18 19 #define DF_END 0x0001 20 21 /* Dialog control information */ 22 typedef struct 23 { 24 DWORD style; 25 DWORD exStyle; 26 DWORD helpId; 27 INT x; 28 INT y; 29 INT cx; 30 INT cy; 31 UINT id; 32 LPCSTR className; 33 LPCSTR windowName; 34 LPVOID data; 35 } DLG_CONTROL_INFO; 36 37 /* Dialog template */ 38 typedef struct 39 { 40 DWORD style; 41 DWORD exStyle; 42 DWORD helpId; 43 UINT nbItems; 44 INT x; 45 INT y; 46 INT cx; 47 INT cy; 48 LPCSTR menuName; 49 LPCSTR className; 50 LPCSTR caption; 51 WORD pointSize; 52 WORD weight; 53 BOOL italic; 54 LPCSTR faceName; 55 BOOL dialogEx; 56 } DLG_TEMPLATE; 57 19 58 class Win32Dialog : public Win32BaseWindow 20 59 { 21 60 public: 22 Win32Dialog(); 61 Win32Dialog(HINSTANCE hInst, LPCSTR dlgTemplate, HWND owner, 62 DLGPROC dlgProc, LPARAM param, BOOL isUnicode); 63 23 64 virtual ~Win32Dialog(); 65 66 LRESULT DefDlgProcA(UINT Msg, WPARAM wParam, LPARAM lParam); 67 LRESULT DefDlgProcW(UINT Msg, WPARAM wParam, LPARAM lParam); 68 69 LRESULT DefDlg_Epilog(UINT msg, BOOL fResult); 24 70 25 71 virtual ULONG MsgOS2Create(HWND hwndOS2, ULONG initParam); … … 29 75 30 76 protected: 77 BOOL DIALOG_Init(void); 78 BOOL getCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize ); 79 BOOL getCharSize( HFONT hFont, SIZE * pSize); 80 LPCSTR parseTemplate( LPCSTR dlgtemplate, DLG_TEMPLATE *result); 81 WORD *getControl(const WORD *p, DLG_CONTROL_INFO *info, BOOL dialogEx); 82 BOOL createControls(LPCSTR dlgtemplate, HINSTANCE hInst); 83 84 LRESULT DefDlg_Proc(UINT msg, WPARAM wParam, LPARAM lParam); 85 BOOL setDefButton(HWND hwndNew ); 86 HWND findDefButton(); 87 BOOL saveFocus(); 88 BOOL restoreFocus(); 89 void setFocus(HWND hwndCtrl ); 90 31 91 // values normally contained in the standard dialog words 32 92 DLGPROC Win32DlgProc; //DWL_WNDPROC … … 34 94 ULONG userDlgData; //DWL_USER 35 95 96 DLG_TEMPLATE dlgInfo; 97 WORD xUnit; 98 WORD yUnit; 99 HWND hwndFocus; 100 HFONT hUserFont; 101 HMENU hMenu; 102 DWORD idResult; 103 DWORD dialogFlags; 104 36 105 private: 106 static BOOL fInitialized; 107 static int xBaseUnit; 108 static int yBaseUnit; 37 109 }; 38 110 111 /* Built-in class names (see _Undocumented_Windows_ p.418) */ 112 #define DIALOG_CLASS_NAME "#32770" /* Dialog */ 113 #define DIALOG_CLASS_ATOM 32770 /* Dialog */ 114 115 BOOL DIALOG_Register(); 116 BOOL DIALOG_Unregister(); 39 117 40 118 #endif //__cplusplus -
trunk/src/user32/new/win32wbase.cpp
r819 r821 1 /* $Id: win32wbase.cpp,v 1. 6 1999-09-04 17:56:41 dengertExp $ */1 /* $Id: win32wbase.cpp,v 1.7 1999-09-04 19:42:29 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 75 75 fCreated = FALSE; 76 76 fFirstShow = TRUE; 77 fIsDialog = FALSE; 77 78 78 79 windowNameA = NULL; -
trunk/src/user32/new/win32wbase.h
r819 r821 1 /* $Id: win32wbase.h,v 1. 4 1999-09-04 17:56:41 dengertExp $ */1 /* $Id: win32wbase.h,v 1.5 1999-09-04 19:42:29 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 148 148 BOOL CloseWindow(); 149 149 static HWND GetActiveWindow(); 150 BOOL IsWindow(); 150 //Window handle has already been verified, so just return true 151 BOOL IsWindow() { return TRUE; }; 151 152 BOOL IsWindowEnabled(); 152 153 BOOL IsWindowVisible(); … … 154 155 155 156 BOOL GetWindowRect(PRECT pRect); 156 int GetWindowTextLength A();157 int GetWindowText A(LPSTR lpsz, int cch);157 int GetWindowTextLength(); 158 int GetWindowText(LPSTR lpsz, int cch); 158 159 BOOL SetWindowText(LPSTR lpsz); 159 160 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0); … … 198 199 199 200 protected: 201 #ifndef OS2_INCLUDED 202 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom); 203 #endif 200 204 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam); 201 205 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam); … … 227 231 BOOL fCreated; 228 232 BOOL fFirstShow; 233 BOOL fIsDialog; 229 234 230 235 Win32BaseWindow *owner; … … 250 255 private: 251 256 #ifndef OS2_INCLUDED 252 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);253 254 257 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack ); 255 258 -
trunk/src/user32/new/win32wmdichild.cpp
r808 r821 1 /* $Id: win32wmdichild.cpp,v 1. 3 1999-09-03 15:09:46sandervl Exp $ */1 /* $Id: win32wmdichild.cpp,v 1.4 1999-09-04 19:42:29 sandervl Exp $ */ 2 2 /* 3 3 * Win32 MDI Child Window Class for OS/2 … … 335 335 #if 0 336 336 MDI_AugmentFrameMenu( ci, w->parent, hwnd ); 337 #endif 337 338 client->updateFrameText(MDI_REPAINTFRAME, NULL ); 338 #endif339 339 } 340 340 } -
trunk/src/user32/new/win32wmdiclient.cpp
r808 r821 1 /* $Id: win32wmdiclient.cpp,v 1. 4 1999-09-03 15:09:46sandervl Exp $ */1 /* $Id: win32wmdiclient.cpp,v 1.5 1999-09-04 19:42:29 sandervl Exp $ */ 2 2 /* 3 3 * Win32 MDI Client Window Class for OS/2 … … 819 819 820 820 ZeroMemory(&wndClass,sizeof(WNDCLASSA)); 821 wndClass.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW | CS_PARENTDC | CS_DBLCLKS;821 wndClass.style = CS_GLOBALCLASS; 822 822 wndClass.lpfnWndProc = (WNDPROC)MDIClientWndProc; 823 823 wndClass.cbClsExtra = 0; 824 824 wndClass.cbWndExtra = 0; 825 825 wndClass.hCursor = 0; 826 wndClass.hbrBackground = (HBRUSH) 0;826 wndClass.hbrBackground = (HBRUSH)LTGRAY_BRUSH; 827 827 wndClass.lpszClassName = MDICLIENTCLASSNAMEA; 828 828 -
trunk/src/user32/new/window.cpp
r760 r821 1 /* $Id: window.cpp,v 1.2 1 1999-08-31 17:14:52sandervl Exp $ */1 /* $Id: window.cpp,v 1.22 1999-09-04 19:42:30 sandervl Exp $ */ 2 2 /* 3 3 * Win32 window apis for OS/2 … … 558 558 } 559 559 dprintf(("GetWindowTextLength %x", hwnd)); 560 return window->GetWindowTextLength A();560 return window->GetWindowTextLength(); 561 561 } 562 562 //****************************************************************************** … … 565 565 { 566 566 Win32BaseWindow *window; 567 int rc; 567 568 568 569 window = Win32BaseWindow::GetWindowFromHandle(hwnd); … … 571 572 return 0; 572 573 } 573 dprintf(("GetWindowTextA %x", hwnd)); 574 return window->GetWindowTextA(lpsz, cch); 574 rc = window->GetWindowText(lpsz, cch); 575 dprintf(("GetWindowTextA %x %s", hwnd, lpsz)); 576 return rc; 575 577 } 576 578 //****************************************************************************** … … 585 587 int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch) 586 588 { 587 char title[128]; 588 int rc; 589 590 rc = O32_GetWindowText(hwnd, title, sizeof(title)); 591 #ifdef DEBUG 592 WriteLog("USER32: GetWindowTextW returned %s\n", title); 593 #endif 594 if(rc > cch) { 595 title[cch-1] = 0; 596 rc = cch; 597 } 598 AsciiToUnicode(title, lpsz); 599 return(rc); 589 Win32BaseWindow *window; 590 591 window = Win32BaseWindow::GetWindowFromHandle(hwnd); 592 if(!window) { 593 dprintf(("GetWindowTextW, window %x not found", hwnd)); 594 return 0; 595 } 596 dprintf(("GetWindowTextW %x", hwnd)); 597 return window->GetWindowText((LPSTR)lpsz, cch); 600 598 } 601 599 //****************************************************************************** … … 615 613 //****************************************************************************** 616 614 //****************************************************************************** 617 BOOL WIN32API SetWindowTextW( HWND arg1, LPCWSTR arg2) 618 { 619 char *astring = UnicodeToAsciiString((LPWSTR)arg2); 620 BOOL rc; 621 622 rc = SetWindowTextA(arg1, (LPCSTR)astring); 623 dprintf(("USER32: SetWindowTextW %X %s returned %d\n", arg1, astring, rc)); 624 FreeAsciiString(astring); 625 return(rc); 615 BOOL WIN32API SetWindowTextW( HWND hwnd, LPCWSTR lpsz) 616 { 617 Win32BaseWindow *window; 618 619 window = Win32BaseWindow::GetWindowFromHandle(hwnd); 620 if(!window) { 621 dprintf(("SetWindowTextA, window %x not found", hwnd)); 622 return 0; 623 } 624 dprintf(("SetWindowTextW %x", hwnd)); 625 return window->SetWindowText((LPSTR)lpsz); 626 626 } 627 627 /*******************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.