| 1 | /* $Id: dialog.cpp,v 1.2 1999-09-12 00:26:27 bird Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * PE2LX dialog conversion code | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl) | 
|---|
| 7 | * Copyright 1998 Patrick Haller | 
|---|
| 8 | * Copyright 1998 Peter Fitzsimmons | 
|---|
| 9 | * | 
|---|
| 10 | * | 
|---|
| 11 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 12 | * | 
|---|
| 13 | */ | 
|---|
| 14 | #ifndef DIALOG_USER32 | 
|---|
| 15 | #include <stdarg.h> | 
|---|
| 16 | #define INCL_WINMLE | 
|---|
| 17 | #define INCL_DOSNLS | 
|---|
| 18 | #include "pe2lx.h" | 
|---|
| 19 | #include "dialog.h" | 
|---|
| 20 | #include "sprintf.h" | 
|---|
| 21 |  | 
|---|
| 22 | static void *ConvertDialogEx(LXHeaderSuper &OS2Exe, int id, WINDLGTEMPLATEEX *dhdr, int size, PULONG pulSize, int cp); | 
|---|
| 23 |  | 
|---|
| 24 | #else | 
|---|
| 25 |  | 
|---|
| 26 | #define INCL_DOSFILEMGR          /* File Manager values      */ | 
|---|
| 27 | #define INCL_DOSERRORS           /* DOS Error values         */ | 
|---|
| 28 | #define INCL_DOSPROCESS          /* DOS Process values       */ | 
|---|
| 29 | #define INCL_DOSMISC             /* DOS Miscellanous values  */ | 
|---|
| 30 | #define INCL_WIN | 
|---|
| 31 | #include <os2.h> | 
|---|
| 32 | #include <stdio.h> | 
|---|
| 33 | #include <string.h> | 
|---|
| 34 | #include <stdlib.h> | 
|---|
| 35 | #include <string.h> | 
|---|
| 36 | #include <assert.h> | 
|---|
| 37 |  | 
|---|
| 38 | #define DWORD   ULONG | 
|---|
| 39 | #define LPVOID  VOID * | 
|---|
| 40 | #define WORD    USHORT | 
|---|
| 41 | #define WCHAR   USHORT | 
|---|
| 42 | #define HANDLE  ULONG | 
|---|
| 43 | #define LPWSTR  WCHAR * | 
|---|
| 44 |  | 
|---|
| 45 | #include "misc.h" | 
|---|
| 46 | #include "unicode.h" | 
|---|
| 47 | #include "nameid.h" | 
|---|
| 48 | #include "dlgconvert.h" | 
|---|
| 49 | #include "..\pe2lx\dialog.h" | 
|---|
| 50 |  | 
|---|
| 51 | DLGTEMPLATE *ConvertWin32DlgTemplateEx(WINDLGTEMPLATEEX *dhdr); | 
|---|
| 52 | #endif | 
|---|
| 53 |  | 
|---|
| 54 | #ifndef BS_TEXT /*PLF Sun  97-06-22 03:07:13  not in watcom's os/2 header */ | 
|---|
| 55 | #define BS_TEXT                 0x0010 | 
|---|
| 56 | #endif | 
|---|
| 57 |  | 
|---|
| 58 | #define DEFAULT_DLGFONT "9.WarpSans" | 
|---|
| 59 |  | 
|---|
| 60 | static int  ConvertClassAndStyle(int winclass, int style, USHORT *os2class, BOOL *fIconBmp); | 
|---|
| 61 | static int  ConvertDlgStyle(int style); | 
|---|
| 62 | static int  ConvertDlgItemStyle(int style); | 
|---|
| 63 | static BOOL ConvertCaption(ULONG style, char *caption); | 
|---|
| 64 | static BOOL ConvertFont(char *font, PRESPARAMS *dlgpparam, int fsize); | 
|---|
| 65 |  | 
|---|
| 66 | #ifndef DIALOG_USER32 | 
|---|
| 67 | BOOL ShowDialog(LXHeaderSuper &OS2Exe, int id, DialogBoxHeader *dhdr, int size, int cp) | 
|---|
| 68 | { | 
|---|
| 69 | DLGTEMPLATE *dlgt; | 
|---|
| 70 | ULONG ulSize; | 
|---|
| 71 | int rc = FALSE; | 
|---|
| 72 |  | 
|---|
| 73 | ltassert((ULONG)dhdr > MINPTR && (ULONG)dhdr+size < MAXPTR); | 
|---|
| 74 |  | 
|---|
| 75 | //First save original win32 resource | 
|---|
| 76 | ltassert(OS2Exe.StoreWin32Resource(id, RT_DIALOG, size, (char *)dhdr)); | 
|---|
| 77 |  | 
|---|
| 78 | dlgt = (DLGTEMPLATE*)ConvertDialog(OS2Exe, id, dhdr, size, (PULONG)SSToDS(&ulSize), cp); | 
|---|
| 79 | if (dlgt != NULL) | 
|---|
| 80 | { | 
|---|
| 81 | //calculate dialog box length | 
|---|
| 82 | rc = OS2Exe.StoreResource(id, RT_DIALOG, ulSize, (char *)dlgt); | 
|---|
| 83 | free(dlgt); | 
|---|
| 84 | } | 
|---|
| 85 | else | 
|---|
| 86 | cout << "ShowDialog: Convertsion failed" << endl; | 
|---|
| 87 |  | 
|---|
| 88 | return rc; | 
|---|
| 89 | } | 
|---|
| 90 | #else | 
|---|
| 91 | //****************************************************************************** | 
|---|
| 92 | //Dialog conversion: (win32 -> OS/2) | 
|---|
| 93 | //****************************************************************************** | 
|---|
| 94 | void DeleteWin32DlgTemplate(DLGTEMPLATE *os2dlg) | 
|---|
| 95 | { | 
|---|
| 96 | free(os2dlg); | 
|---|
| 97 | } | 
|---|
| 98 | #endif | 
|---|
| 99 |  | 
|---|
| 100 | //****************************************************************************** | 
|---|
| 101 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 
|---|
| 102 | //ConvertDialogEx is identical except for the different dialog(item) structures | 
|---|
| 103 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 
|---|
| 104 | //****************************************************************************** | 
|---|
| 105 | #ifndef DIALOG_USER32 | 
|---|
| 106 | void *ConvertDialog(LXHeaderSuper &OS2Exe, int id, DialogBoxHeader *dhdr, int size, PULONG pulSize, int cp) | 
|---|
| 107 | #else | 
|---|
| 108 | DLGTEMPLATE *ConvertWin32DlgTemplate(DLGTEMPLATE *windlg) | 
|---|
| 109 | #endif | 
|---|
| 110 | { | 
|---|
| 111 | WINDLGTEMPLATEEX *windlgex = (WINDLGTEMPLATEEX *)dhdr; | 
|---|
| 112 | DLGTEMPLATE *dlgt; | 
|---|
| 113 | DLGTITEM    *dlgitem; | 
|---|
| 114 | PRESPARAMS  *dlgpparam; | 
|---|
| 115 | char        *dlgdata, *dlgcurdata; | 
|---|
| 116 | WCHAR       *szCaption; | 
|---|
| 117 | WORD        *ptrArray; | 
|---|
| 118 | char        *ctrltext, *szClass, *font; | 
|---|
| 119 | FontHeader  *fhdr; | 
|---|
| 120 | ControlData *ctrldata; | 
|---|
| 121 | int          i; | 
|---|
| 122 | ULONG        ctrlflag, winclass; | 
|---|
| 123 | BOOL         fIconBmp; | 
|---|
| 124 | ULONG        ulCpSize, ulCP; | 
|---|
| 125 |  | 
|---|
| 126 | #ifdef DIALOG_USER32 | 
|---|
| 127 | DialogBoxHeader *dhdr = (DialogBoxHeader *)windlg; | 
|---|
| 128 | int size = dhdr->NumberOfItems*sizeof(DLGTITEM) * 128; | 
|---|
| 129 | int id = 0; | 
|---|
| 130 | #endif | 
|---|
| 131 |  | 
|---|
| 132 | ltassert((ULONG)dhdr > MINPTR && (ULONG)dhdr+size < MAXPTR); | 
|---|
| 133 |  | 
|---|
| 134 | if(windlgex->wDlgVer == 1 && windlgex->wSignature == 0xFFFF) | 
|---|
| 135 | { | 
|---|
| 136 | #ifndef DIALOG_USER32 | 
|---|
| 137 | return ConvertDialogEx(OS2Exe, id, windlgex, size, pulSize, cp); | 
|---|
| 138 | #else | 
|---|
| 139 | dprintf(("ConvertWin32DlgTemplate: DLGTEMPLATEEX!\n")); | 
|---|
| 140 | return(ConvertWin32DlgTemplateEx(windlgex, cp)); | 
|---|
| 141 | #endif | 
|---|
| 142 |  | 
|---|
| 143 | } | 
|---|
| 144 |  | 
|---|
| 145 | //should be enough | 
|---|
| 146 | dlgt    = (DLGTEMPLATE *)malloc(sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size); | 
|---|
| 147 | ltassert(dlgt != NULL); | 
|---|
| 148 | dlgitem = &dlgt->adlgti[0]; | 
|---|
| 149 | dlgdata = (char *)&dlgt->adlgti[dhdr->NumberOfItems+1];  //for control data, presparams & strings | 
|---|
| 150 | memset((char *)dlgt, 0, sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size); | 
|---|
| 151 | dlgcurdata = dlgdata; | 
|---|
| 152 |  | 
|---|
| 153 | #ifdef RING0 | 
|---|
| 154 | dlgt->codepage = 437; | 
|---|
| 155 | #else | 
|---|
| 156 | if (cp == 0) | 
|---|
| 157 | dlgt->codepage     = 437; | 
|---|
| 158 | else | 
|---|
| 159 | { | 
|---|
| 160 | DosQueryCp(sizeof(ulCP), &ulCP, &ulCpSize); | 
|---|
| 161 | dlgt->codepage = ulCP; | 
|---|
| 162 | } | 
|---|
| 163 | #endif | 
|---|
| 164 | dlgt->offadlgti    = 14; | 
|---|
| 165 | dlgt->fsTemplateStatus = 1; | 
|---|
| 166 | dlgt->iItemFocus       = 65535; | 
|---|
| 167 | dlgt->coffPresParams   = 0; | 
|---|
| 168 |  | 
|---|
| 169 | dlgitem->flStyle = ConvertDlgStyle(dhdr->lStyle) | WS_SYNCPAINT | WS_CLIPSIBLINGS; | 
|---|
| 170 |  | 
|---|
| 171 | ctrlflag = 0; | 
|---|
| 172 | if((dhdr->lStyle & WINWS_CAPTION) == WINWS_CAPTION) { | 
|---|
| 173 | ctrlflag |= FCF_TITLEBAR; | 
|---|
| 174 | dlgitem->flStyle |= FS_BORDER; | 
|---|
| 175 | } | 
|---|
| 176 | else | 
|---|
| 177 | if(dhdr->lStyle & WINWS_DLGFRAME) //can't have title bar | 
|---|
| 178 | dlgitem->flStyle |= FS_DLGBORDER; | 
|---|
| 179 |  | 
|---|
| 180 | if((dhdr->lStyle & (WINWS_SYSMENU | WINWS_CAPTION)) == (WINWS_SYSMENU | WINWS_CAPTION)) | 
|---|
| 181 | ctrlflag |= FCF_SYSMENU; | 
|---|
| 182 | if(dhdr->lStyle & WINWS_VSCROLL) | 
|---|
| 183 | ctrlflag |= FCF_VERTSCROLL; | 
|---|
| 184 | if(dhdr->lStyle & WINWS_HSCROLL) | 
|---|
| 185 | ctrlflag |= FCF_HORZSCROLL; | 
|---|
| 186 | if(dhdr->lStyle & WINWS_MINIMIZEBOX) | 
|---|
| 187 | ctrlflag |= FCF_MINBUTTON; | 
|---|
| 188 | if(dhdr->lStyle & WINWS_MAXIMIZEBOX) | 
|---|
| 189 | ctrlflag |= FCF_MAXBUTTON; | 
|---|
| 190 | if(dhdr->lStyle & WINWS_THICKFRAME) | 
|---|
| 191 | dlgitem->flStyle |= FS_SIZEBORDER; | 
|---|
| 192 |  | 
|---|
| 193 | if(ctrlflag) { | 
|---|
| 194 | *(ULONG *)dlgcurdata = ctrlflag; | 
|---|
| 195 | dlgitem->offCtlData  = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 196 | dlgcurdata          += sizeof(ULONG); | 
|---|
| 197 | } | 
|---|
| 198 | else  dlgitem->offCtlData  = 0xFFFF; | 
|---|
| 199 | dlgitem->x            = dhdr->x; | 
|---|
| 200 | //TODO: SvL: Calc has x = 32768 Special value??? | 
|---|
| 201 | if(dlgitem->x > 1024 || dlgitem->x < 0) | 
|---|
| 202 | dlgitem->x = 64; | 
|---|
| 203 |  | 
|---|
| 204 | dlgitem->y            = dhdr->y; | 
|---|
| 205 | dlgitem->cx           = dhdr->cx; | 
|---|
| 206 | dlgitem->cy           = dhdr->cy; | 
|---|
| 207 | dlgitem->cChildren    = dhdr->NumberOfItems; | 
|---|
| 208 | dlgitem->id           = (USHORT)id;       //ord id or converted name id | 
|---|
| 209 | dlgitem->fsItemStatus = 1; | 
|---|
| 210 | dlgitem->offClassName = 1;    //WC_FRAME | 
|---|
| 211 |  | 
|---|
| 212 | #ifndef DIALOG_USER32 | 
|---|
| 213 | cout.setf(ios::hex, ios::basefield); | 
|---|
| 214 | cout << "Dialog Style         : " << dhdr->lStyle << endl; | 
|---|
| 215 | cout << "Extended Dialog Style: " << dhdr->lExtendedStyle << endl; | 
|---|
| 216 | cout.setf(ios::dec, ios::basefield); | 
|---|
| 217 | cout << "Position             : (" << dhdr->x << ',' << dhdr->y << ')' << endl; | 
|---|
| 218 | cout << "Size                 : (" << dhdr->cx << ',' << dhdr->cy << ')' << endl; | 
|---|
| 219 | cout << "Number of Items      : "  << dhdr->NumberOfItems << endl; | 
|---|
| 220 | #else | 
|---|
| 221 | dprintf(("Dialog Style         : %X\n", dhdr->lStyle)); | 
|---|
| 222 | dprintf(("Extended Dialog Style: %X\n", dhdr->lExtendedStyle)); | 
|---|
| 223 | dprintf(("Position             : (%d,%d)\n", dhdr->x ,dhdr->y)); | 
|---|
| 224 | dprintf(("Size                 : (%d,%d)\n", dhdr->cx, dhdr->cy)); | 
|---|
| 225 | dprintf(("Number of Items      : %d\n", dhdr->NumberOfItems)); | 
|---|
| 226 | dprintf(("Sizeof(dhdr)         : %d\n", sizeof(*dhdr))); | 
|---|
| 227 | #endif | 
|---|
| 228 | //Menu id | 
|---|
| 229 | if(dhdr->fNameOrd == 0xFFFF) { | 
|---|
| 230 | #ifndef DIALOG_USER32 | 
|---|
| 231 | cout << "Menu ID            : " << *(WORD *)(dhdr+1) << endl; | 
|---|
| 232 | #else | 
|---|
| 233 | dprintf(("Menu ID            : %d\n", (int)*(WORD *)(dhdr+1))); | 
|---|
| 234 | #endif | 
|---|
| 235 | ptrArray = (WORD *)((int)dhdr + sizeof(DialogBoxHeader) + sizeof(WORD)); | 
|---|
| 236 | } | 
|---|
| 237 | else { | 
|---|
| 238 | if(dhdr->fNameOrd == 0) {//SvL: 0 == no menu! | 
|---|
| 239 | ptrArray = (WORD *)((int)dhdr + sizeof(DialogBoxHeader)); | 
|---|
| 240 | } | 
|---|
| 241 | else { | 
|---|
| 242 | #ifndef DIALOG_USER32 | 
|---|
| 243 | cout << "Menu namestring    : " << UnicodeToAscii((WCHAR *)(&dhdr->fNameOrd), cp) << endl; | 
|---|
| 244 | #else | 
|---|
| 245 | ctrltext = UnicodeToAsciiString((WCHAR *)&dhdr->fNameOrd); | 
|---|
| 246 | dprintf(("Menu namestring    : %s\n", ctrltext)); | 
|---|
| 247 | FreeAsciiString(ctrltext); | 
|---|
| 248 | #endif | 
|---|
| 249 | ptrArray = (WORD *)((int)&dhdr->fNameOrd + UniStrlen((WCHAR *)(&dhdr->fNameOrd))*2 + sizeof(WCHAR)); | 
|---|
| 250 | } | 
|---|
| 251 | } | 
|---|
| 252 | //Class id | 
|---|
| 253 | if(*ptrArray == 0xFFFF) { | 
|---|
| 254 | #ifndef DIALOG_USER32 | 
|---|
| 255 | cout << "Class ID            : " << *(WORD *)(ptrArray+1) << endl; | 
|---|
| 256 | #else | 
|---|
| 257 | dprintf(("Class ID            : %d\n", *(WORD *)(ptrArray+1))); | 
|---|
| 258 | #endif | 
|---|
| 259 | ptrArray = (WORD *)((int)ptrArray + 2*sizeof(WORD)); | 
|---|
| 260 | } | 
|---|
| 261 | else { | 
|---|
| 262 | if(*ptrArray == 0) {//SvL: 0 == no menu! | 
|---|
| 263 | ptrArray = (WORD *)((int)ptrArray + sizeof(WORD)); | 
|---|
| 264 | } | 
|---|
| 265 | else { | 
|---|
| 266 | #ifndef DIALOG_USER32 | 
|---|
| 267 | szClass = UnicodeToAscii((WCHAR *)ptrArray, cp); | 
|---|
| 268 | cout << "Class Name            : " << szClass << endl; | 
|---|
| 269 | #else | 
|---|
| 270 | szClass = UnicodeToAsciiString((WCHAR *)ptrArray); | 
|---|
| 271 | printf(("Class Name            : %s", szClass)); | 
|---|
| 272 | #endif | 
|---|
| 273 | dlgitem->cchClassName = (USHORT)strlen(szClass); | 
|---|
| 274 | dlgitem->offClassName = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 275 | strcpy((char *)dlgcurdata, szClass); | 
|---|
| 276 | //Open32 wants class name in upper case! | 
|---|
| 277 | UpCase((char *)dlgcurdata); | 
|---|
| 278 | dlgcurdata           += dlgitem->cchClassName + 1;  //include terminating 0 (just to be sure) | 
|---|
| 279 | //TODO: SvL: Can they also be system classes? | 
|---|
| 280 | //      dlgitem->flStyle      = dhdr->lStyle; | 
|---|
| 281 | //      dlgitem->flStyle      = ConvertDlgItemStyle(dhdr->lStyle); | 
|---|
| 282 | ptrArray = (WORD *)((int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD)); | 
|---|
| 283 | #ifdef DIALOG_USER32 | 
|---|
| 284 | FreeAsciiString(szClass); | 
|---|
| 285 | #endif | 
|---|
| 286 | } | 
|---|
| 287 | } | 
|---|
| 288 |  | 
|---|
| 289 | //Title | 
|---|
| 290 | if(*ptrArray == 0) { | 
|---|
| 291 | #ifndef DIALOG_USER32 | 
|---|
| 292 | cout << "No title " << endl; | 
|---|
| 293 | #else | 
|---|
| 294 | dprintf(("No title \n")); | 
|---|
| 295 | #endif | 
|---|
| 296 | ctrldata = (ControlData *)((int)(int)ptrArray + sizeof(WORD)); | 
|---|
| 297 | } | 
|---|
| 298 | else { | 
|---|
| 299 | #ifndef DIALOG_USER32 | 
|---|
| 300 | ctrltext = UnicodeToAscii((WCHAR *)(ptrArray), cp); | 
|---|
| 301 | cout << "Title                : " << ctrltext << endl; | 
|---|
| 302 | #else | 
|---|
| 303 | ctrltext = UnicodeToAsciiString((WCHAR *)(ptrArray)); | 
|---|
| 304 | dprintf(("Title                : %s\n", ctrltext)); | 
|---|
| 305 | #endif | 
|---|
| 306 | ctrldata = (ControlData *)((int)(int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD)); | 
|---|
| 307 |  | 
|---|
| 308 | if(ctrltext[0] != 0) { | 
|---|
| 309 | dlgitem->cchText = (USHORT)strlen(ctrltext); | 
|---|
| 310 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 311 | strcpy((char *)dlgcurdata, ctrltext); | 
|---|
| 312 | dlgcurdata      += dlgitem->cchText + 1;    //include terminating 0 (just to be sure) | 
|---|
| 313 | } else | 
|---|
| 314 | { //CB: cchText == 0, OS/2 uses offText anyway! (entryfields) | 
|---|
| 315 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt); | 
|---|
| 316 | dlgcurdata++; //0 at offText | 
|---|
| 317 | } | 
|---|
| 318 | #ifdef DIALOG_USER32 | 
|---|
| 319 | FreeAsciiString(ctrltext); | 
|---|
| 320 | #endif | 
|---|
| 321 | } | 
|---|
| 322 |  | 
|---|
| 323 | if(dhdr->lStyle & DS_SETFONT) { | 
|---|
| 324 | fhdr = (FontHeader *)ctrldata; | 
|---|
| 325 | #ifndef DIALOG_USER32 | 
|---|
| 326 | font = UnicodeToAscii(fhdr->szFontName, cp); | 
|---|
| 327 | cout << "Font Point Size      : " << fhdr->wPointSize << endl; | 
|---|
| 328 | cout << "Font Name            : " << font << endl; | 
|---|
| 329 | #else | 
|---|
| 330 | font = UnicodeToAsciiString(fhdr->szFontName); | 
|---|
| 331 | dprintf(("Font Point Size      : %d\n", fhdr->wPointSize)); | 
|---|
| 332 | dprintf(("Font Name            : %s\n", font)); | 
|---|
| 333 | #endif | 
|---|
| 334 | ctrldata = (ControlData *)((int)fhdr + sizeof(FontHeader) - 2 + UniStrlen(fhdr->szFontName)*2 + sizeof(WORD));  /*PLF Sat  97-06-21 20:22:44*/ | 
|---|
| 335 | //TODO: no pres params yet (font in win32 dialog ignored) | 
|---|
| 336 | dlgpparam = (PRESPARAMS *)dlgcurdata; | 
|---|
| 337 | dlgpparam->cb = 0; | 
|---|
| 338 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE; | 
|---|
| 339 | dlgpparam->aparam[0].cb = 0; | 
|---|
| 340 | UpCase(font); | 
|---|
| 341 | if(ConvertFont(font, dlgpparam, fhdr->wPointSize) == TRUE) { | 
|---|
| 342 | dlgpparam->aparam[0].cb = strlen(dlgpparam->aparam[0].ab) + 2*sizeof(ULONG) + 1; | 
|---|
| 343 | //      dlgpparam->cb           = sizeof(ULONG) + dlgpparam->aparam[0].cb; | 
|---|
| 344 | dlgpparam->cb           = dlgpparam->aparam[0].cb; | 
|---|
| 345 | dlgitem->offPresParams  = (USHORT)((int)dlgpparam - (int)dlgt); | 
|---|
| 346 | dlgcurdata             += dlgpparam->cb + sizeof(ULONG); | 
|---|
| 347 | } else | 
|---|
| 348 | { //CB: set default font | 
|---|
| 349 | dlgpparam = (PRESPARAMS*)dlgcurdata; | 
|---|
| 350 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE; | 
|---|
| 351 | dlgpparam->aparam[0].cb = strlen(DEFAULT_DLGFONT)+1; | 
|---|
| 352 | strcpy((char*)&dlgpparam->aparam[0].ab,DEFAULT_DLGFONT); | 
|---|
| 353 | dlgpparam->cb           = dlgpparam->aparam[0].cb+2*sizeof(ULONG); | 
|---|
| 354 | dlgitem->offPresParams  = (USHORT)((int)dlgpparam-(int)dlgt); | 
|---|
| 355 | dlgt->coffPresParams++; | 
|---|
| 356 | dlgcurdata             += dlgpparam->cb+sizeof(dlgpparam->cb); | 
|---|
| 357 | } | 
|---|
| 358 | #ifdef DIALOG_USER32 | 
|---|
| 359 | FreeAsciiString(font); | 
|---|
| 360 | #endif | 
|---|
| 361 | } | 
|---|
| 362 | dlgitem++; | 
|---|
| 363 |  | 
|---|
| 364 | ctrldata = (ControlData *)(((int)ctrldata+3) & ~3); | 
|---|
| 365 | for(i=0;i<dhdr->NumberOfItems;i++) { | 
|---|
| 366 | //save as OS/2 DLGTITEM | 
|---|
| 367 | dlgitem->x             = ctrldata->x; | 
|---|
| 368 | //SvL: 3-8-'97 | 
|---|
| 369 | // OS/2  -> left bottom == origin and y coordinate == left bottom origin control | 
|---|
| 370 | // Win32 -> left top    == origin and y coordinate == left top origin | 
|---|
| 371 | dlgitem->y             = dlgt->adlgti[0].cy - ctrldata->y - ctrldata->cy; | 
|---|
| 372 | dlgitem->cx            = ctrldata->cx; | 
|---|
| 373 | dlgitem->cy            = ctrldata->cy; | 
|---|
| 374 | dlgitem->id            = ctrldata->wId; | 
|---|
| 375 | dlgitem->offCtlData    = 0xFFFF; | 
|---|
| 376 | dlgitem->offPresParams = 0xFFFF; | 
|---|
| 377 |  | 
|---|
| 378 | //TODO: Extended style | 
|---|
| 379 | #ifndef DIALOG_USER32 | 
|---|
| 380 | cout.setf(ios::hex, ios::basefield); | 
|---|
| 381 | cout << "***** Control Style   : " << ctrldata->lStyle << endl; | 
|---|
| 382 | cout << "Extended Control Style: " << ctrldata->lExtendedStyle << endl; | 
|---|
| 383 | cout.setf(ios::dec, ios::basefield); | 
|---|
| 384 | cout << "Position              : (" << ctrldata->x << ',' << ctrldata->y << ')' << endl; | 
|---|
| 385 | cout << "Size                  : (" << ctrldata->cx << ',' << ctrldata->cy << ')' << endl; | 
|---|
| 386 | cout << "wID                   : " << ctrldata->wId << endl; | 
|---|
| 387 | #else | 
|---|
| 388 | dprintf(("***** Control Style   : %X\n", ctrldata->lStyle)); | 
|---|
| 389 | dprintf(("Extended Control Style: %X\n", ctrldata->lExtendedStyle)); | 
|---|
| 390 | dprintf(("Position              : (%d,%d)\n", ctrldata->x, ctrldata->y)); | 
|---|
| 391 | dprintf(("Size                  : (%d,%d)\n", ctrldata->cx, ctrldata->cy)); | 
|---|
| 392 | dprintf(("wID                   : %d\n", ctrldata->wId)); | 
|---|
| 393 | #endif | 
|---|
| 394 | winclass = 0; | 
|---|
| 395 | if(ctrldata->fClassId == 0xFFFF) { | 
|---|
| 396 | winclass = *(WORD *)(ctrldata+1); | 
|---|
| 397 | #ifndef DIALOG_USER32 | 
|---|
| 398 | cout << "Class ID              : " << winclass << endl; | 
|---|
| 399 | #else | 
|---|
| 400 | dprintf(("Class ID              : %d\n", winclass)); | 
|---|
| 401 | #endif | 
|---|
| 402 | szCaption = (WCHAR *)((int)ctrldata + sizeof(ControlData) + sizeof(WORD)); | 
|---|
| 403 | dlgitem->flStyle      = ConvertClassAndStyle(*(WORD *)(ctrldata+1), ctrldata->lStyle, &dlgitem->offClassName, (BOOL*)SSToDS(&fIconBmp)); | 
|---|
| 404 | dlgitem->cchClassName = 0; | 
|---|
| 405 | } | 
|---|
| 406 | else { | 
|---|
| 407 | #ifndef DIALOG32_USER32 | 
|---|
| 408 | szClass = UnicodeToAscii((WCHAR *)&ctrldata->fClassId, cp); | 
|---|
| 409 | cout <<  "Class Name            : " << szClass << endl; | 
|---|
| 410 | #else | 
|---|
| 411 | szClass = UnicodeToAsciiString((WCHAR *)&ctrldata->fClassId); | 
|---|
| 412 | dprintf(("Class Name            : %s\n", szClass)); | 
|---|
| 413 | #endif | 
|---|
| 414 | szCaption = (WCHAR *)((int)ctrldata + sizeof(ControlData) + strlen(szClass)*2); | 
|---|
| 415 | dlgitem->cchClassName = (USHORT)strlen(szClass); | 
|---|
| 416 | dlgitem->offClassName = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 417 | strcpy((char *)dlgcurdata, szClass); | 
|---|
| 418 | //Open32 wants class name in upper case! | 
|---|
| 419 | UpCase((char *)dlgcurdata); | 
|---|
| 420 | dlgcurdata           += dlgitem->cchClassName + 1;  //include terminating 0 (just to be sure) | 
|---|
| 421 | dlgitem->flStyle      = ConvertDlgItemStyle(ctrldata->lStyle) ; | 
|---|
| 422 | #ifdef DIALOG_USER32 | 
|---|
| 423 | FreeAsciiString(szClass); | 
|---|
| 424 | #endif | 
|---|
| 425 | } | 
|---|
| 426 | if(*(USHORT *)szCaption == 0xFFFF) { | 
|---|
| 427 | szCaption += 2; | 
|---|
| 428 | dlgitem->cchText = 0; | 
|---|
| 429 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt); | 
|---|
| 430 | dlgcurdata += 1; //CB: offText == empty string | 
|---|
| 431 | } | 
|---|
| 432 | else {  //Handle Caption | 
|---|
| 433 | #ifndef DIALOG_USER32 | 
|---|
| 434 | ctrltext = UnicodeToAscii(szCaption, cp); | 
|---|
| 435 | #else | 
|---|
| 436 | ctrltext = UnicodeToAsciiString(szCaption); | 
|---|
| 437 | #endif | 
|---|
| 438 | //SvL: (16-9-'97) Convert '&' chars to '~' (for some classes) | 
|---|
| 439 | ConvertCaption(winclass, ctrltext); | 
|---|
| 440 | if(fIconBmp == TRUE) {//control contains bitmap or icon | 
|---|
| 441 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 442 | #ifndef DIALOG_USER32 | 
|---|
| 443 | int resid = OS2Exe.ConvertNametoId(ctrltext); | 
|---|
| 444 | #else | 
|---|
| 445 | int resid = ConvertNameId(ctrltext); | 
|---|
| 446 | #endif | 
|---|
| 447 | sprintf(dlgcurdata,"#%d",resid);//KSO: sprintf(...) not itoa | 
|---|
| 448 | dlgitem->cchText = (USHORT)strlen((char *)dlgcurdata);  //one USHORT for res id | 
|---|
| 449 | dlgcurdata      += dlgitem->cchText + 1;    //include terminating 0 (just to be sure) | 
|---|
| 450 | } | 
|---|
| 451 | else { | 
|---|
| 452 | if(ctrltext[0] != 0) { | 
|---|
| 453 | dlgitem->cchText = (USHORT)strlen(ctrltext); | 
|---|
| 454 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 455 | strcpy((char *)dlgcurdata, ctrltext); | 
|---|
| 456 | dlgcurdata      += dlgitem->cchText + 1;    //include terminating 0 (just to be sure) | 
|---|
| 457 | } else | 
|---|
| 458 | { //CB: cchText == 0, OS/2 uses offText anyway! (entryfields) | 
|---|
| 459 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt); | 
|---|
| 460 | dlgcurdata++; //0 at offText | 
|---|
| 461 | } | 
|---|
| 462 | } | 
|---|
| 463 | #ifndef DIALOG_USER32 | 
|---|
| 464 | cout << "Text                  : " << UnicodeToAscii(szCaption) << endl; | 
|---|
| 465 | #else | 
|---|
| 466 | FreeAsciiString(ctrltext); | 
|---|
| 467 | szClass = UnicodeToAsciiString(szCaption); | 
|---|
| 468 | dprintf(("Text                  : %s\n", szClass)); | 
|---|
| 469 | FreeAsciiString(szClass); | 
|---|
| 470 | #endif | 
|---|
| 471 |  | 
|---|
| 472 | szCaption = (WCHAR *)((int)szCaption + UniStrlen(szCaption)*2 + sizeof(WORD)); | 
|---|
| 473 | } | 
|---|
| 474 |  | 
|---|
| 475 | #ifndef DIALOG_USER32 | 
|---|
| 476 | cout <<  "Extra Stuff WORD      : " << *(WORD *)(szCaption) << endl; | 
|---|
| 477 | #else | 
|---|
| 478 | dprintf(("Extra Stuff WORD      : %d\n", *(WORD *)(szCaption))); | 
|---|
| 479 | #endif | 
|---|
| 480 | ctrldata = (ControlData *)((int)szCaption + sizeof(WORD)); | 
|---|
| 481 | ctrldata = (ControlData *)(((int)ctrldata+3) & ~3); | 
|---|
| 482 | dlgitem++; | 
|---|
| 483 | } | 
|---|
| 484 | //calculate dialog box length | 
|---|
| 485 | dlgt->cbTemplate = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 486 |  | 
|---|
| 487 | #ifndef DIALOG_USER32 | 
|---|
| 488 | *pulSize = dlgt->cbTemplate; | 
|---|
| 489 | return (void*)dlgt; | 
|---|
| 490 | #else | 
|---|
| 491 | return dlgt; | 
|---|
| 492 | #endif | 
|---|
| 493 | } | 
|---|
| 494 |  | 
|---|
| 495 |  | 
|---|
| 496 | //****************************************************************************** | 
|---|
| 497 | //****************************************************************************** | 
|---|
| 498 | #ifndef DIALOG_USER32 | 
|---|
| 499 | static void *ConvertDialogEx(LXHeaderSuper &OS2Exe, int id, WINDLGTEMPLATEEX *dhdr, int size, PULONG pulSize, int cp) | 
|---|
| 500 | #else | 
|---|
| 501 | DLGTEMPLATE *ConvertWin32DlgTemplateEx(WINDLGTEMPLATEEX *dhdr, cp) | 
|---|
| 502 | #endif | 
|---|
| 503 | { | 
|---|
| 504 | DLGTEMPLATE *dlgt; | 
|---|
| 505 | DLGTITEM    *dlgitem; | 
|---|
| 506 | PRESPARAMS  *dlgpparam; | 
|---|
| 507 | char        *dlgdata, *dlgcurdata; | 
|---|
| 508 | WCHAR       *szCaption; | 
|---|
| 509 | WORD        *ptrArray; | 
|---|
| 510 | char        *ctrltext, *szClass, *font; | 
|---|
| 511 | FontHeaderEx *fhdr; | 
|---|
| 512 | WINDLGITEMTEMPLATEEX *ctrldata; | 
|---|
| 513 | int          i; | 
|---|
| 514 | ULONG        ctrlflag, winclass; | 
|---|
| 515 | BOOL         fIconBmp; | 
|---|
| 516 | ULONG        ulCpSize, ulCP; | 
|---|
| 517 | #ifdef DIALOG_USER32 | 
|---|
| 518 | int size = dhdr->NumberOfItems*sizeof(DLGTITEM) * 128; | 
|---|
| 519 | int id = 0; | 
|---|
| 520 | #endif | 
|---|
| 521 |  | 
|---|
| 522 | //should be enough | 
|---|
| 523 | dlgt    = (DLGTEMPLATE *)malloc(sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size); | 
|---|
| 524 | ltassert(dlgt != NULL); | 
|---|
| 525 | dlgitem = &dlgt->adlgti[0]; | 
|---|
| 526 | dlgdata = (char *)&dlgt->adlgti[dhdr->NumberOfItems+1];  //for control data, presparams & strings | 
|---|
| 527 | memset((char *)dlgt, 0, sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size); | 
|---|
| 528 | dlgcurdata = dlgdata; | 
|---|
| 529 |  | 
|---|
| 530 | #ifdef RING0 | 
|---|
| 531 | dlgt->codepage     = 437; | 
|---|
| 532 | #else | 
|---|
| 533 | if (cp == 0) | 
|---|
| 534 | dlgt->codepage = 437; | 
|---|
| 535 | else | 
|---|
| 536 | { | 
|---|
| 537 | DosQueryCp(sizeof(ulCP), &ulCP, &ulCpSize); | 
|---|
| 538 | dlgt->codepage = ulCP; | 
|---|
| 539 | } | 
|---|
| 540 | #endif | 
|---|
| 541 | dlgt->offadlgti    = 14; | 
|---|
| 542 | dlgt->fsTemplateStatus = 1; | 
|---|
| 543 | dlgt->iItemFocus       = 65535; | 
|---|
| 544 | dlgt->coffPresParams   = 0; | 
|---|
| 545 |  | 
|---|
| 546 | dlgitem->flStyle = ConvertDlgStyle(dhdr->lStyle) | WS_SYNCPAINT | WS_CLIPSIBLINGS; | 
|---|
| 547 |  | 
|---|
| 548 | ctrlflag = 0; | 
|---|
| 549 | if((dhdr->lStyle & WINWS_CAPTION) == WINWS_CAPTION) { | 
|---|
| 550 | ctrlflag |= FCF_TITLEBAR; | 
|---|
| 551 | dlgitem->flStyle |= FS_BORDER; | 
|---|
| 552 | } | 
|---|
| 553 | else | 
|---|
| 554 | if(dhdr->lStyle & WINWS_DLGFRAME) //can't have title bar | 
|---|
| 555 | dlgitem->flStyle |= FS_DLGBORDER; | 
|---|
| 556 |  | 
|---|
| 557 | if((dhdr->lStyle & (WINWS_SYSMENU | WINWS_CAPTION)) == (WINWS_SYSMENU | WINWS_CAPTION)) | 
|---|
| 558 | ctrlflag |= FCF_SYSMENU; | 
|---|
| 559 | if(dhdr->lStyle & WINWS_VSCROLL) | 
|---|
| 560 | ctrlflag |= FCF_VERTSCROLL; | 
|---|
| 561 | if(dhdr->lStyle & WINWS_HSCROLL) | 
|---|
| 562 | ctrlflag |= FCF_HORZSCROLL; | 
|---|
| 563 | if(dhdr->lStyle & WINWS_MINIMIZEBOX) | 
|---|
| 564 | ctrlflag |= FCF_MINBUTTON; | 
|---|
| 565 | if(dhdr->lStyle & WINWS_MAXIMIZEBOX) | 
|---|
| 566 | ctrlflag |= FCF_MAXBUTTON; | 
|---|
| 567 | if(dhdr->lStyle & WINWS_THICKFRAME) | 
|---|
| 568 | dlgitem->flStyle |= FS_SIZEBORDER; | 
|---|
| 569 |  | 
|---|
| 570 | if(ctrlflag) { | 
|---|
| 571 | *(ULONG *)dlgcurdata = ctrlflag; | 
|---|
| 572 | dlgitem->offCtlData  = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 573 | dlgcurdata          += sizeof(ULONG); | 
|---|
| 574 | } | 
|---|
| 575 | else  dlgitem->offCtlData  = 0xFFFF; | 
|---|
| 576 | dlgitem->x            = dhdr->x; | 
|---|
| 577 | dlgitem->y            = dhdr->y; | 
|---|
| 578 | dlgitem->cx           = dhdr->cx; | 
|---|
| 579 | dlgitem->cy           = dhdr->cy; | 
|---|
| 580 | dlgitem->cChildren    = dhdr->NumberOfItems; | 
|---|
| 581 | dlgitem->id           = (USHORT)id;       //ord id or converted name id | 
|---|
| 582 | dlgitem->fsItemStatus = 1; | 
|---|
| 583 | dlgitem->offClassName = 1;    //WC_FRAME | 
|---|
| 584 | #ifndef DIALOG_USER32 | 
|---|
| 585 | cout.setf(ios::hex, ios::basefield); | 
|---|
| 586 | cout << "Dialog Style         : " << dhdr->lStyle << endl; | 
|---|
| 587 | cout << "Extended Dialog Style: " << dhdr->lExtendedStyle << endl; | 
|---|
| 588 | cout.setf(ios::dec, ios::basefield); | 
|---|
| 589 | cout << "Position             : (" << dhdr->x << ',' << dhdr->y << ')' << endl; | 
|---|
| 590 | cout << "Size                 : (" << dhdr->cx << ',' << dhdr->cy << ')' << endl; | 
|---|
| 591 | cout << "Number of Items      : "  << dhdr->NumberOfItems << endl; | 
|---|
| 592 | #else | 
|---|
| 593 | dprintf(("Dialog Style         : %X\n", dhdr->lStyle)); | 
|---|
| 594 | dprintf(("Extended Dialog Style: %X\n", dhdr->lExtendedStyle)); | 
|---|
| 595 | dprintf(("Position             : (%d,%d)\n", dhdr->x ,dhdr->y)); | 
|---|
| 596 | dprintf(("Size                 : (%d,%d)\n", dhdr->cx, dhdr->cy)); | 
|---|
| 597 | dprintf(("Number of Items      : %d\n", dhdr->NumberOfItems)); | 
|---|
| 598 | dprintf(("Sizeof(dhdr)         : %d\n", sizeof(*dhdr))); | 
|---|
| 599 | #endif | 
|---|
| 600 | //Menu id | 
|---|
| 601 | if(dhdr->fNameOrd == 0xFFFF) { | 
|---|
| 602 | #ifndef DIALOG_USER32 | 
|---|
| 603 | cout <<  "Menu ID            : " << *(WORD *)(dhdr+1) << endl; | 
|---|
| 604 | #else | 
|---|
| 605 | dprintf(("Menu ID            : %d\n", (int)*(WORD *)(dhdr+1))); | 
|---|
| 606 | #endif | 
|---|
| 607 | ptrArray = (WORD *)((int)dhdr + sizeof(WINDLGTEMPLATEEX) + sizeof(WORD)); | 
|---|
| 608 | } | 
|---|
| 609 | else { | 
|---|
| 610 | if(dhdr->fNameOrd == 0) {//SvL: 0 == no menu! | 
|---|
| 611 | ptrArray = (WORD *)((int)dhdr + sizeof(WINDLGTEMPLATEEX)); | 
|---|
| 612 | } | 
|---|
| 613 | else { | 
|---|
| 614 | #ifndef DIALOG_USER32 | 
|---|
| 615 | cout << "Menu namestring    : " << UnicodeToAscii((WCHAR *)(&dhdr->fNameOrd), cp) << endl; | 
|---|
| 616 | #else | 
|---|
| 617 | #ifdef DEBUG | 
|---|
| 618 | ctrltext = UnicodeToAsciiString((WCHAR *)&dhdr->fNameOrd); | 
|---|
| 619 | WriteLog("Menu namestring    : %s\n", ctrltext); | 
|---|
| 620 | FreeAsciiString(ctrltext); | 
|---|
| 621 | #endif | 
|---|
| 622 | #endif | 
|---|
| 623 | ptrArray = (WORD *)((int)&dhdr->fNameOrd + UniStrlen((WCHAR *)(&dhdr->fNameOrd))*2 + sizeof(WCHAR)); | 
|---|
| 624 | } | 
|---|
| 625 | } | 
|---|
| 626 | //Class id | 
|---|
| 627 | if(*ptrArray == 0xFFFF) { | 
|---|
| 628 | #ifndef DIALOG_USER32 | 
|---|
| 629 | cout << "Class ID            : " << *(WORD *)(ptrArray+1) << endl; | 
|---|
| 630 | #else | 
|---|
| 631 | dprintf(("Class ID           : %d\n", (int)*(WORD *)(ptrArray+1))); | 
|---|
| 632 | #endif | 
|---|
| 633 | ptrArray = (WORD *)((int)ptrArray + 2*sizeof(WORD)); | 
|---|
| 634 | } | 
|---|
| 635 | else { | 
|---|
| 636 | if(*ptrArray == 0) {//SvL: 0 == no menu! | 
|---|
| 637 | ptrArray = (WORD *)((int)ptrArray + sizeof(WORD)); | 
|---|
| 638 | } | 
|---|
| 639 | else { | 
|---|
| 640 | #ifndef DIALOG_USER32 | 
|---|
| 641 | szClass = UnicodeToAscii((WCHAR *)ptrArray, cp); | 
|---|
| 642 | cout << "Class Name            : " << szClass << endl; | 
|---|
| 643 | #else | 
|---|
| 644 | szClass = UnicodeToAsciiString((WCHAR *)ptrArray); | 
|---|
| 645 | dprintf(("Class namestring    : %s\n", szClass)); | 
|---|
| 646 | #endif | 
|---|
| 647 |  | 
|---|
| 648 | dlgitem->cchClassName = (USHORT)strlen(szClass); | 
|---|
| 649 | dlgitem->offClassName = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 650 | strcpy((char *)dlgcurdata, szClass); | 
|---|
| 651 | //Open32 wants class name in upper case! | 
|---|
| 652 | UpCase((char *)dlgcurdata); | 
|---|
| 653 | dlgcurdata           += dlgitem->cchClassName + 1;  //include terminating 0 (just to be sure) | 
|---|
| 654 | //TODO: SvL: Can they also be system classes? | 
|---|
| 655 | //      dlgitem->flStyle      = dhdr->lStyle; | 
|---|
| 656 | //      dlgitem->flStyle      = ConvertDlgItemStyle(dhdr->lStyle); | 
|---|
| 657 | ptrArray = (WORD *)((int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD)); | 
|---|
| 658 | #ifdef DIALOG_USER32 | 
|---|
| 659 | FreeAsciiString(szClass); | 
|---|
| 660 | #endif | 
|---|
| 661 | } | 
|---|
| 662 | } | 
|---|
| 663 |  | 
|---|
| 664 | //Title | 
|---|
| 665 | if(*ptrArray == 0) { | 
|---|
| 666 | #ifndef DIALOG_USER32 | 
|---|
| 667 | cout << "No title " << endl; | 
|---|
| 668 | #else | 
|---|
| 669 | dprintf(("No Title\n")); | 
|---|
| 670 | #endif | 
|---|
| 671 | ctrldata = (WINDLGITEMTEMPLATEEX *)((int)(int)ptrArray + sizeof(WORD)); | 
|---|
| 672 | } | 
|---|
| 673 | else { | 
|---|
| 674 | #ifndef DIALOG_USER32 | 
|---|
| 675 | ctrltext = UnicodeToAscii((WCHAR *)(ptrArray), cp); | 
|---|
| 676 | cout << "Title                : " << ctrltext << endl; | 
|---|
| 677 | #else | 
|---|
| 678 | ctrltext = UnicodeToAsciiString((WCHAR *)(ptrArray)); | 
|---|
| 679 | dprintf(("Title                : %s\n", ctrltext)); | 
|---|
| 680 | #endif | 
|---|
| 681 | ctrldata = (WINDLGITEMTEMPLATEEX *)((int)(int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD)); | 
|---|
| 682 |  | 
|---|
| 683 | if(ctrltext[0] != 0) { | 
|---|
| 684 | dlgitem->cchText = (USHORT)strlen(ctrltext); | 
|---|
| 685 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 686 | strcpy((char *)dlgcurdata, ctrltext); | 
|---|
| 687 | dlgcurdata      += dlgitem->cchText + 1;    //include terminating 0 (just to be sure) | 
|---|
| 688 | } else | 
|---|
| 689 | { //CB: cchText == 0, OS/2 uses offText anyway! (entryfields) | 
|---|
| 690 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt); | 
|---|
| 691 | dlgcurdata++; //0 at offText | 
|---|
| 692 | } | 
|---|
| 693 | #ifdef DIALOG_USER32 | 
|---|
| 694 | FreeAsciiString(ctrltext); | 
|---|
| 695 | #endif | 
|---|
| 696 | } | 
|---|
| 697 | dlgitem++; | 
|---|
| 698 |  | 
|---|
| 699 | if(dhdr->lStyle & DS_SETFONT) { | 
|---|
| 700 | fhdr = (FontHeaderEx *)ctrldata; | 
|---|
| 701 | #ifndef DIALOG_USER32 | 
|---|
| 702 | font = UnicodeToAscii(fhdr->szFontName, cp); | 
|---|
| 703 | cout << "Font Point Size      : " << fhdr->wPointSize << endl; | 
|---|
| 704 | cout << "Font Name            : " << font << endl; | 
|---|
| 705 | #else | 
|---|
| 706 | font = UnicodeToAsciiString(fhdr->szFontName); | 
|---|
| 707 | dprintf(("Font Point Size      : %d\n", fhdr->wPointSize)); | 
|---|
| 708 | dprintf(("Font Name            : %s\n", font)); | 
|---|
| 709 | #endif | 
|---|
| 710 | ctrldata = (WINDLGITEMTEMPLATEEX *)((int)fhdr + sizeof(FontHeaderEx) - 2 + UniStrlen(fhdr->szFontName)*2 + sizeof(WORD));  /*PLF Sat  97-06-21 20:22:44*/ | 
|---|
| 711 | //TODO: no pres params yet (font in win32 dialog ignored) | 
|---|
| 712 | dlgpparam = (PRESPARAMS *)dlgcurdata; | 
|---|
| 713 | dlgpparam->cb = 0; | 
|---|
| 714 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE; | 
|---|
| 715 | dlgpparam->aparam[0].cb = 0; | 
|---|
| 716 | UpCase(font); | 
|---|
| 717 | if(ConvertFont(font, dlgpparam, fhdr->wPointSize) == TRUE) { | 
|---|
| 718 | dlgpparam->aparam[0].cb = strlen(dlgpparam->aparam[0].ab) + 2*sizeof(ULONG) + 1; | 
|---|
| 719 | dlgpparam->cb           = sizeof(ULONG) + dlgpparam->aparam[0].cb; | 
|---|
| 720 | dlgt->coffPresParams    = (USHORT)((int)dlgpparam - (int)dlgt); | 
|---|
| 721 | dlgcurdata             += dlgpparam->cb; | 
|---|
| 722 | } else | 
|---|
| 723 | { //CB: set default font | 
|---|
| 724 | dlgpparam = (PRESPARAMS*)dlgcurdata; | 
|---|
| 725 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE; | 
|---|
| 726 | dlgpparam->aparam[0].cb = strlen(DEFAULT_DLGFONT)+1; | 
|---|
| 727 | strcpy((char*)&dlgpparam->aparam[0].ab,DEFAULT_DLGFONT); | 
|---|
| 728 | dlgpparam->cb           = dlgpparam->aparam[0].cb+2*sizeof(ULONG); | 
|---|
| 729 | dlgitem->offPresParams  = (USHORT)((int)dlgpparam-(int)dlgt); | 
|---|
| 730 | dlgt->coffPresParams++; | 
|---|
| 731 | dlgcurdata             += dlgpparam->cb+sizeof(dlgpparam->cb); | 
|---|
| 732 | } | 
|---|
| 733 | #ifdef DIALOG_USER32 | 
|---|
| 734 | FreeAsciiString(font); | 
|---|
| 735 | #endif | 
|---|
| 736 | } | 
|---|
| 737 | else | 
|---|
| 738 | { //CB: set default font | 
|---|
| 739 | dlgpparam = (PRESPARAMS*)dlgcurdata; | 
|---|
| 740 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE; | 
|---|
| 741 | dlgpparam->aparam[0].cb = strlen(DEFAULT_DLGFONT)+1; | 
|---|
| 742 | strcpy((char*)&dlgpparam->aparam[0].ab,DEFAULT_DLGFONT); | 
|---|
| 743 | dlgpparam->cb           = dlgpparam->aparam[0].cb+2*sizeof(ULONG); | 
|---|
| 744 | dlgitem->offPresParams  = (USHORT)((int)dlgpparam-(int)dlgt); | 
|---|
| 745 | dlgt->coffPresParams++; | 
|---|
| 746 | dlgcurdata             += dlgpparam->cb+sizeof(dlgpparam->cb); | 
|---|
| 747 | } | 
|---|
| 748 | ctrldata = (WINDLGITEMTEMPLATEEX *)(((int)ctrldata+3) & ~3); | 
|---|
| 749 |  | 
|---|
| 750 | for(i=0;i<dhdr->NumberOfItems;i++) { | 
|---|
| 751 | //save as OS/2 DLGTITEM | 
|---|
| 752 | dlgitem->x             = ctrldata->x; | 
|---|
| 753 | //SvL: 3-8-'97 | 
|---|
| 754 | // OS/2  -> left bottom == origin and y coordinate == left bottom origin control | 
|---|
| 755 | // Win32 -> left top    == origin and y coordinate == left top origin | 
|---|
| 756 | dlgitem->y             = dlgt->adlgti[0].cy - ctrldata->y - ctrldata->cy; | 
|---|
| 757 | dlgitem->cx            = ctrldata->cx; | 
|---|
| 758 | dlgitem->cy            = ctrldata->cy; | 
|---|
| 759 | dlgitem->id            = (USHORT)ctrldata->wId; | 
|---|
| 760 | dlgitem->offCtlData    = 0xFFFF; | 
|---|
| 761 | dlgitem->offPresParams = 0xFFFF; | 
|---|
| 762 |  | 
|---|
| 763 | //TODO: Extended style | 
|---|
| 764 |  | 
|---|
| 765 | #ifndef DIALOG_USER32 | 
|---|
| 766 | cout.setf(ios::hex, ios::basefield); | 
|---|
| 767 | cout << "***** Control Style   : " << ctrldata->lStyle << endl; | 
|---|
| 768 | cout << "Extended Control Style: " << ctrldata->lExtendedStyle << endl; | 
|---|
| 769 | cout.setf(ios::dec, ios::basefield); | 
|---|
| 770 | cout << "Position              : (" << ctrldata->x << ',' << ctrldata->y << ')' << endl; | 
|---|
| 771 | cout << "Size                  : (" << ctrldata->cx << ',' << ctrldata->cy << ')' << endl; | 
|---|
| 772 | cout << "wID                   : " << ctrldata->wId << endl; | 
|---|
| 773 | #else | 
|---|
| 774 | dprintf(("***** Control Style   : %X\n", ctrldata->lStyle)); | 
|---|
| 775 | dprintf(("Extended Control Style: %X\n", ctrldata->lExtendedStyle)); | 
|---|
| 776 | dprintf(("Position              : (%d,%d)\n", ctrldata->x, ctrldata->y)); | 
|---|
| 777 | dprintf(("Size                  : (%d,%d)\n", ctrldata->cx, ctrldata->cy)); | 
|---|
| 778 | dprintf(("wID                   : %d\n", ctrldata->wId)); | 
|---|
| 779 | #endif | 
|---|
| 780 | winclass = 0; | 
|---|
| 781 | if(ctrldata->fClassId == 0xFFFF) { | 
|---|
| 782 | winclass = *(WORD *)(ctrldata+1); | 
|---|
| 783 | #ifndef DIALOG_USER32 | 
|---|
| 784 | cout << "Class ID              : " << winclass << endl; | 
|---|
| 785 | #else | 
|---|
| 786 | dprintf(("Class ID              : %d\n", winclass)); | 
|---|
| 787 | #endif | 
|---|
| 788 | szCaption = (WCHAR *)((int)ctrldata + sizeof(WINDLGITEMTEMPLATEEX) + sizeof(WORD)); | 
|---|
| 789 | dlgitem->flStyle      = ConvertClassAndStyle(*(WORD *)(ctrldata+1), ctrldata->lStyle, &dlgitem->offClassName, (BOOL*)SSToDS(&fIconBmp)); | 
|---|
| 790 | dlgitem->cchClassName = 0; | 
|---|
| 791 | } | 
|---|
| 792 | else { | 
|---|
| 793 | #ifndef DIALOG_USER32 | 
|---|
| 794 | szClass = UnicodeToAscii((WCHAR *)&ctrldata->fClassId, cp); | 
|---|
| 795 | cout << "Class Name            : " << szClass << endl; | 
|---|
| 796 | #else | 
|---|
| 797 | szClass = UnicodeToAsciiString((WCHAR *)&ctrldata->fClassId); | 
|---|
| 798 | dprintf(("Class Name            : %s\n", szClass)); | 
|---|
| 799 | #endif | 
|---|
| 800 | szCaption = (WCHAR *)((int)ctrldata + sizeof(WINDLGITEMTEMPLATEEX) + strlen(szClass)*2); | 
|---|
| 801 | dlgitem->cchClassName = (USHORT)strlen(szClass); | 
|---|
| 802 | dlgitem->offClassName = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 803 | strcpy((char *)dlgcurdata, szClass); | 
|---|
| 804 | //Open32 wants class name in upper case! | 
|---|
| 805 | UpCase((char *)dlgcurdata); | 
|---|
| 806 | dlgcurdata           += dlgitem->cchClassName + 1;  //include terminating 0 (just to be sure) | 
|---|
| 807 | dlgitem->flStyle      = ConvertDlgItemStyle(ctrldata->lStyle) ; | 
|---|
| 808 | #ifdef DIALOG_USER32 | 
|---|
| 809 | FreeAsciiString(szClass); | 
|---|
| 810 | #endif | 
|---|
| 811 | } | 
|---|
| 812 | if(*(USHORT *)szCaption == 0xFFFF) { | 
|---|
| 813 | szCaption += 2; | 
|---|
| 814 | } | 
|---|
| 815 | else {  //Handle Caption | 
|---|
| 816 | #ifndef DIALOG_USER32 | 
|---|
| 817 | ctrltext = UnicodeToAscii(szCaption, cp); | 
|---|
| 818 | #else | 
|---|
| 819 | ctrltext = UnicodeToAsciiString(szCaption); | 
|---|
| 820 | #endif | 
|---|
| 821 | //SvL: (16-9-'97) Convert '&' chars to '~' (for some classes) | 
|---|
| 822 | ConvertCaption(winclass, ctrltext); | 
|---|
| 823 | if(fIconBmp == TRUE) {//control contains bitmap or icon | 
|---|
| 824 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 825 | #ifndef DIALOG_USER32 | 
|---|
| 826 | int resid = OS2Exe.ConvertNametoId(ctrltext); | 
|---|
| 827 | #else | 
|---|
| 828 | int resid = ConvertNameId(ctrltext); | 
|---|
| 829 | #endif | 
|---|
| 830 | sprintf(dlgcurdata,"#%d",resid); //KSO: sprintf(...) not itoa | 
|---|
| 831 | dlgitem->cchText = (USHORT)strlen((char *)dlgcurdata);  //one USHORT for res id | 
|---|
| 832 | dlgcurdata      += dlgitem->cchText + 1;    //include terminating 0 (just to be sure) | 
|---|
| 833 | } | 
|---|
| 834 | else { | 
|---|
| 835 | if(ctrltext[0] != 0) { | 
|---|
| 836 | dlgitem->cchText = (USHORT)strlen(ctrltext); | 
|---|
| 837 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 838 | strcpy((char *)dlgcurdata, ctrltext); | 
|---|
| 839 | dlgcurdata      += dlgitem->cchText + 1;    //include terminating 0 (just to be sure) | 
|---|
| 840 | } else | 
|---|
| 841 | { //CB: cchText == 0, OS/2 uses offText anyway! (entryfields) | 
|---|
| 842 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt); | 
|---|
| 843 | dlgcurdata++; //0 at offText | 
|---|
| 844 | } | 
|---|
| 845 | } | 
|---|
| 846 | #ifndef DIALOG_USER32 | 
|---|
| 847 | cout << "Text                  : " << UnicodeToAscii(szCaption, cp) << endl; | 
|---|
| 848 | #else | 
|---|
| 849 | FreeAsciiString(ctrltext); | 
|---|
| 850 | #ifdef DEBUG | 
|---|
| 851 | szClass = UnicodeToAsciiString(szCaption); | 
|---|
| 852 | WriteLog("Text                  : %s\n", szClass); | 
|---|
| 853 | FreeAsciiString(szClass); | 
|---|
| 854 | #endif | 
|---|
| 855 | #endif | 
|---|
| 856 |  | 
|---|
| 857 | szCaption = (WCHAR *)((int)szCaption + UniStrlen(szCaption)*2 + sizeof(WORD)); | 
|---|
| 858 | } | 
|---|
| 859 |  | 
|---|
| 860 | #ifndef DIALOG_USER32 | 
|---|
| 861 | cout <<  "Extra Stuff WORD      : " << *(WORD *)(szCaption) << endl; | 
|---|
| 862 | #else | 
|---|
| 863 | dprintf(("Extra Stuff WORD      : %d\n", *(WORD*)(szCaption))); | 
|---|
| 864 | #endif | 
|---|
| 865 | ctrldata = (WINDLGITEMTEMPLATEEX *)((int)szCaption + sizeof(WORD)); | 
|---|
| 866 | ctrldata = (WINDLGITEMTEMPLATEEX *)(((int)ctrldata+3) & ~3); | 
|---|
| 867 | dlgitem++; | 
|---|
| 868 | } | 
|---|
| 869 |  | 
|---|
| 870 | //calculate dialog box length | 
|---|
| 871 | dlgt->cbTemplate = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 872 |  | 
|---|
| 873 | #ifndef DIALOG_USER32 | 
|---|
| 874 | *pulSize = dlgt->cbTemplate; | 
|---|
| 875 | return (void*)dlgt; | 
|---|
| 876 | #else | 
|---|
| 877 | return (dlgt); | 
|---|
| 878 | #endif | 
|---|
| 879 | } | 
|---|
| 880 | //****************************************************************************** | 
|---|
| 881 | //****************************************************************************** | 
|---|
| 882 | static int ConvertClassAndStyle(int    winclass, | 
|---|
| 883 | int    style, | 
|---|
| 884 | USHORT *os2class, | 
|---|
| 885 | BOOL   *fIconBmp) | 
|---|
| 886 | { | 
|---|
| 887 | int os2style = ConvertDlgItemStyle(style); | 
|---|
| 888 |  | 
|---|
| 889 | *fIconBmp = FALSE; | 
|---|
| 890 |  | 
|---|
| 891 | switch(winclass) { | 
|---|
| 892 | case WIN_BUTTON: | 
|---|
| 893 | #if 0 | 
|---|
| 894 | if(style & WINBS_LEFTTEXT) | 
|---|
| 895 | os2style |= ; //not supported | 
|---|
| 896 | #endif | 
|---|
| 897 | style &= 0xF; | 
|---|
| 898 | //BS_TEXT, BS_BITMAP, BS_ICON, BS_MINIICON can only be used with BS_PUSHBUTTON | 
|---|
| 899 | *os2class = (int)WC_BUTTON & 0xFFFF; | 
|---|
| 900 | if(style == WINBS_PUSHBUTTON) | 
|---|
| 901 | os2style |= BS_PUSHBUTTON; | 
|---|
| 902 | else | 
|---|
| 903 | if(style == WINBS_DEFPUSHBUTTON) | 
|---|
| 904 | os2style |= (BS_PUSHBUTTON | BS_DEFAULT);   //TODO: Correct? | 
|---|
| 905 | else | 
|---|
| 906 | if(style == WINBS_CHECKBOX) | 
|---|
| 907 | os2style |= BS_CHECKBOX; | 
|---|
| 908 | else | 
|---|
| 909 | if(style == WINBS_AUTOCHECKBOX) | 
|---|
| 910 | os2style |= BS_AUTOCHECKBOX; | 
|---|
| 911 | else | 
|---|
| 912 | if(style == WINBS_RADIOBUTTON) | 
|---|
| 913 | os2style |= BS_RADIOBUTTON; | 
|---|
| 914 | else | 
|---|
| 915 | if(style == WINBS_3STATE) | 
|---|
| 916 | os2style |= BS_3STATE; | 
|---|
| 917 | else | 
|---|
| 918 | if(style == WINBS_AUTO3STATE) | 
|---|
| 919 | os2style |= BS_AUTO3STATE; | 
|---|
| 920 | else | 
|---|
| 921 | if(style == WINBS_USERBUTTON) //obsolete | 
|---|
| 922 | os2style |= BS_USERBUTTON; | 
|---|
| 923 | else | 
|---|
| 924 | if(style == WINBS_AUTORADIOBUTTON) | 
|---|
| 925 | os2style |= BS_AUTORADIOBUTTON; | 
|---|
| 926 | else | 
|---|
| 927 | if(style == WINBS_GROUPBOX) { | 
|---|
| 928 | *os2class = (int)WC_STATIC & 0xFFFF;    /*PLF Sat  97-09-20 23:58:28*/ | 
|---|
| 929 | os2style  |= SS_GROUPBOX;   /*PLF Sun  97-09-21 00:11:07*/ | 
|---|
| 930 | } | 
|---|
| 931 | else | 
|---|
| 932 | if(style & WINBS_OWNERDRAW) | 
|---|
| 933 | os2style |= BS_USERBUTTON;  //TODO:Correct?? | 
|---|
| 934 | else    os2style |= (BS_TEXT | BS_PUSHBUTTON); | 
|---|
| 935 | os2style |= BS_AUTOSIZE; | 
|---|
| 936 | break; | 
|---|
| 937 |  | 
|---|
| 938 | case WIN_EDIT: | 
|---|
| 939 | /* @@@PH 98/06/13: other styles might require a MLE-class control !      */ | 
|---|
| 940 | /* please note this is experimental since MLE might behave different from */ | 
|---|
| 941 | /* the standard EF-control, maybe we'll have to build an own MLE therefore*/ | 
|---|
| 942 |  | 
|---|
| 943 | if (style & WINES_MULTILINE) | 
|---|
| 944 | { | 
|---|
| 945 | *os2class = (int)WC_MLE & 0xFFFF; | 
|---|
| 946 |  | 
|---|
| 947 | os2style |= MLS_BORDER | MLS_WORDWRAP; | 
|---|
| 948 |  | 
|---|
| 949 | //if(style & WINES_MULTILINE)   os2style |= ; | 
|---|
| 950 | //if(style & WINES_UPPERCASE)   os2style |= ; | 
|---|
| 951 | //if(style & WINES_LOWERCASE)   os2style |= ; | 
|---|
| 952 | if(style & WINES_AUTOVSCROLL) os2style |= MLS_VSCROLL; | 
|---|
| 953 | //if(style & WINES_NOHIDESEL)   os2style |= ; | 
|---|
| 954 | //if(style & WINES_OEMCONVERT)  os2style |= ; | 
|---|
| 955 | //if(style & WINES_WANTRETURN)  os2style |= ; | 
|---|
| 956 | //if(style & WINES_LEFT)        os2style |= ES_LEFT; | 
|---|
| 957 | //if(style & WINES_CENTER)      os2style |= ES_CENTER; | 
|---|
| 958 | //if(style & WINES_RIGHT)       os2style |= ES_RIGHT; | 
|---|
| 959 | if(style & WINES_AUTOHSCROLL) os2style |= MLS_HSCROLL; | 
|---|
| 960 | if(style & WINES_READONLY)    os2style |= MLS_READONLY; | 
|---|
| 961 | //if(style & WINES_PASSWORD)    os2style |= ES_UNREADABLE; | 
|---|
| 962 | } | 
|---|
| 963 | else | 
|---|
| 964 | { | 
|---|
| 965 | *os2class = (int)WC_ENTRYFIELD & 0xFFFF; | 
|---|
| 966 | if(style & WINES_LEFT)        os2style |= ES_LEFT; | 
|---|
| 967 | if(style & WINES_CENTER)      os2style |= ES_CENTER; | 
|---|
| 968 | if(style & WINES_RIGHT)       os2style |= ES_RIGHT; | 
|---|
| 969 | if(style & WINES_AUTOHSCROLL) os2style |= ES_AUTOSCROLL; | 
|---|
| 970 | if(style & WINES_READONLY)    os2style |= ES_READONLY; | 
|---|
| 971 | if(style & WINES_PASSWORD)    os2style |= ES_UNREADABLE; | 
|---|
| 972 | if(style & WINWS_BORDER)      os2style |= ES_MARGIN; | 
|---|
| 973 |  | 
|---|
| 974 | } | 
|---|
| 975 | break; | 
|---|
| 976 |  | 
|---|
| 977 | case WIN_STATIC: | 
|---|
| 978 | style &= 0xFFFF; | 
|---|
| 979 | *os2class = (int)WC_STATIC & 0xFFFF; | 
|---|
| 980 | if(style == WINSS_LEFT) | 
|---|
| 981 | os2style |= SS_TEXT | DT_LEFT; | 
|---|
| 982 | else | 
|---|
| 983 | if(style == WINSS_CENTER) | 
|---|
| 984 | os2style |= SS_TEXT | DT_CENTER; | 
|---|
| 985 | else | 
|---|
| 986 | if(style == WINSS_RIGHT) | 
|---|
| 987 | os2style |= SS_TEXT | DT_RIGHT; | 
|---|
| 988 | else | 
|---|
| 989 | if(style == WINSS_SIMPLE) | 
|---|
| 990 | os2style |= SS_TEXT | DT_LEFT; | 
|---|
| 991 | else | 
|---|
| 992 | if(style == WINSS_ICON) { | 
|---|
| 993 | os2style |= SS_ICON; | 
|---|
| 994 | *fIconBmp = TRUE; | 
|---|
| 995 | } | 
|---|
| 996 | else | 
|---|
| 997 | if(style == WINSS_BLACKRECT) | 
|---|
| 998 | os2style |= SS_FGNDRECT; | 
|---|
| 999 | else | 
|---|
| 1000 | if(style == WINSS_GRAYRECT) | 
|---|
| 1001 | os2style |= SS_HALFTONERECT; | 
|---|
| 1002 | else | 
|---|
| 1003 | if(style == WINSS_WHITERECT) | 
|---|
| 1004 | os2style |= SS_BKGNDRECT; | 
|---|
| 1005 | else | 
|---|
| 1006 | if(style == WINSS_BLACKFRAME) | 
|---|
| 1007 | os2style |= SS_FGNDFRAME; | 
|---|
| 1008 | else | 
|---|
| 1009 | if(style == WINSS_GRAYFRAME) | 
|---|
| 1010 | os2style |= SS_HALFTONEFRAME; | 
|---|
| 1011 | else | 
|---|
| 1012 | if(style == WINSS_WHITEFRAME) | 
|---|
| 1013 | os2style |= SS_BKGNDFRAME; | 
|---|
| 1014 | else    os2style |= SS_TEXT; | 
|---|
| 1015 |  | 
|---|
| 1016 | //TODO | 
|---|
| 1017 | #if 0 | 
|---|
| 1018 | if(style == WINSS_LEFTNOWORDWRAP) | 
|---|
| 1019 | os2style |= ; | 
|---|
| 1020 | if(style == WINSS_USERITEM) | 
|---|
| 1021 | os2style |= ; | 
|---|
| 1022 | if(style == WINSS_NOPREFIX) | 
|---|
| 1023 | os2style |= ; | 
|---|
| 1024 | #endif | 
|---|
| 1025 | break; | 
|---|
| 1026 | case WIN_LISTBOX: | 
|---|
| 1027 | *os2class = (int)WC_LISTBOX & 0xFFFF; | 
|---|
| 1028 | #if 0 | 
|---|
| 1029 | if(style & WINLBS_NOTIFY) | 
|---|
| 1030 | os2style |= ; | 
|---|
| 1031 | if(style & WINLBS_SORT) | 
|---|
| 1032 | os2style |= ; | 
|---|
| 1033 | if(style & WINLBS_NOREDRAW) | 
|---|
| 1034 | os2style |= ; | 
|---|
| 1035 | #endif | 
|---|
| 1036 | if(style & WINLBS_MULTIPLESEL) | 
|---|
| 1037 | os2style |= LS_MULTIPLESEL; | 
|---|
| 1038 | if(style & WINLBS_OWNERDRAWFIXED) | 
|---|
| 1039 | os2style |= LS_OWNERDRAW;   //TODO: Correct? | 
|---|
| 1040 | if(style & WINLBS_OWNERDRAWVARIABLE) | 
|---|
| 1041 | os2style |= LS_OWNERDRAW;   //TODO: Correct? | 
|---|
| 1042 | #if 0 | 
|---|
| 1043 | if(style & WINLBS_HASSTRINGS) | 
|---|
| 1044 | os2style |= ; | 
|---|
| 1045 | if(style & WINLBS_USETABSTOPS) | 
|---|
| 1046 | os2style |= ; | 
|---|
| 1047 | if(style & WINLBS_NOINTEGRALHEIGHT) | 
|---|
| 1048 | os2style |= ; | 
|---|
| 1049 | if(style & WINLBS_MULTICOLUMN) | 
|---|
| 1050 | os2style |= ; | 
|---|
| 1051 | if(style & WINLBS_WANTKEYBOARDINPUT) | 
|---|
| 1052 | os2style |= ; | 
|---|
| 1053 | if(style & WINLBS_EXTENDEDSEL) | 
|---|
| 1054 | os2style |= LS_EXTENDEDSEL; | 
|---|
| 1055 | if(style & WINLBS_DISABLENOSCROLL) | 
|---|
| 1056 | os2style |= ; | 
|---|
| 1057 | #endif | 
|---|
| 1058 | //      if(style & WINLBS_NODATA) | 
|---|
| 1059 | //          os2style |= ; | 
|---|
| 1060 | break; | 
|---|
| 1061 |  | 
|---|
| 1062 | case WIN_SCROLLBAR: | 
|---|
| 1063 | *os2class = (int)WC_SCROLLBAR & 0xFFFF; | 
|---|
| 1064 |  | 
|---|
| 1065 | if(style & WINSBS_HORZ) os2style |= SBS_HORZ; | 
|---|
| 1066 | else | 
|---|
| 1067 | if(style & WINSBS_VERT) os2style |= SBS_VERT; | 
|---|
| 1068 |  | 
|---|
| 1069 | //if(style & WINSBS_TOPALIGN)                os2style |= ; | 
|---|
| 1070 | //if(style & WINSBS_LEFTALIGN)               os2style |= ; | 
|---|
| 1071 | //if(style & WINSBS_BOTTOMALIGN)             os2style |= ; | 
|---|
| 1072 | //if(style & WINSBS_RIGHTALIGN)              os2style |= ; | 
|---|
| 1073 | //if(style & WINSBS_SIZEBOXTOPLEFTALIGN)     os2style |= ; | 
|---|
| 1074 | //if(style & WINSBS_SIZEBOXBOTTOMRIGHTALIGN) os2style |= ; | 
|---|
| 1075 |  | 
|---|
| 1076 | if(style & WINSBS_SIZEBOX) os2style |= SBS_AUTOSIZE;  //TODO: Correct? | 
|---|
| 1077 | break; | 
|---|
| 1078 |  | 
|---|
| 1079 | case WIN_COMBOBOX: | 
|---|
| 1080 | *os2class = (int)WC_COMBOBOX & 0xFFFF; | 
|---|
| 1081 |  | 
|---|
| 1082 | /* @@@PH 98/06/13 corrected style translation */ | 
|---|
| 1083 | switch (style & 0x00000003) | 
|---|
| 1084 | { | 
|---|
| 1085 | case WINCBS_SIMPLE:       os2style |= CBS_SIMPLE;       break; | 
|---|
| 1086 | case WINCBS_DROPDOWN:     os2style |= CBS_DROPDOWN;     break; | 
|---|
| 1087 | case WINCBS_DROPDOWNLIST: os2style |= CBS_DROPDOWNLIST; break; | 
|---|
| 1088 | default:                  os2style |= CBS_SIMPLE;       break; | 
|---|
| 1089 | } | 
|---|
| 1090 |  | 
|---|
| 1091 | //if(style & WINCBS_OWNERDRAWFIXED)    os2style |= ; | 
|---|
| 1092 | //if(style & WINCBS_OWNERDRAWVARIABLE) os2style |= ; | 
|---|
| 1093 | //if(style & WINCBS_AUTOHSCROLL)       os2style |= ; | 
|---|
| 1094 | //if(style & WINCBS_OEMCONVERT)        os2style |= ; | 
|---|
| 1095 | //if(style & WINCBS_SORT)              os2style |= ; | 
|---|
| 1096 | //if(style & WINCBS_HASSTRINGS )       os2style |= ; | 
|---|
| 1097 | //if(style & WINCBS_NOINTEGRALHEIGHT)  os2style |= ; | 
|---|
| 1098 | //if(style & WINCBS_DISABLENOSCROLL)   os2style |= ; | 
|---|
| 1099 | break; | 
|---|
| 1100 |  | 
|---|
| 1101 | default: | 
|---|
| 1102 | //SvL: 9nov97 Special class control. Just copy style | 
|---|
| 1103 | os2style = style; | 
|---|
| 1104 | break; | 
|---|
| 1105 | } | 
|---|
| 1106 | return(os2style); | 
|---|
| 1107 | } | 
|---|
| 1108 | //****************************************************************************** | 
|---|
| 1109 | //****************************************************************************** | 
|---|
| 1110 | static int ConvertDlgStyle(int style) | 
|---|
| 1111 | { | 
|---|
| 1112 | int os2style = 0; | 
|---|
| 1113 |  | 
|---|
| 1114 | ///  if(style & WINWS_POPUP) | 
|---|
| 1115 | /// os2style |= | 
|---|
| 1116 | ///  if(style & WINWS_CHILD) | 
|---|
| 1117 | /// os2style |= | 
|---|
| 1118 | if(style & WINWS_MINIMIZE) | 
|---|
| 1119 | os2style |= WS_MINIMIZED; | 
|---|
| 1120 | if(style & WINWS_MAXIMIZE) | 
|---|
| 1121 | os2style |= WS_MAXIMIZED; | 
|---|
| 1122 | if(style & WINWS_VISIBLE) | 
|---|
| 1123 | os2style |= WS_VISIBLE; | 
|---|
| 1124 | if(style & WINWS_DISABLED) | 
|---|
| 1125 | os2style |= WS_DISABLED; | 
|---|
| 1126 | if(style & WINWS_CLIPSIBLINGS) | 
|---|
| 1127 | os2style |= WS_CLIPSIBLINGS; | 
|---|
| 1128 | if(style & WINWS_CLIPCHILDREN) | 
|---|
| 1129 | os2style |= WS_CLIPCHILDREN; | 
|---|
| 1130 | if(style & WINWS_TABSTOP) | 
|---|
| 1131 | os2style |= WS_TABSTOP; | 
|---|
| 1132 |  | 
|---|
| 1133 | return(os2style); | 
|---|
| 1134 | } | 
|---|
| 1135 | //****************************************************************************** | 
|---|
| 1136 | //****************************************************************************** | 
|---|
| 1137 | static int ConvertDlgItemStyle(int style) | 
|---|
| 1138 | { | 
|---|
| 1139 | int os2style = 0; | 
|---|
| 1140 |  | 
|---|
| 1141 | if(style & WINWS_VISIBLE) | 
|---|
| 1142 | os2style |= WS_VISIBLE; | 
|---|
| 1143 | if(style & WINWS_DISABLED) | 
|---|
| 1144 | os2style |= WS_DISABLED; | 
|---|
| 1145 | if(style & WINWS_CLIPSIBLINGS) | 
|---|
| 1146 | os2style |= WS_CLIPSIBLINGS; | 
|---|
| 1147 | if(style & WINWS_CLIPCHILDREN) | 
|---|
| 1148 | os2style |= WS_CLIPCHILDREN; | 
|---|
| 1149 | if(style & WINWS_TABSTOP) | 
|---|
| 1150 | os2style |= WS_TABSTOP; | 
|---|
| 1151 | if(style & WINWS_GROUP) | 
|---|
| 1152 | os2style |= WS_GROUP; | 
|---|
| 1153 |  | 
|---|
| 1154 | return(os2style); | 
|---|
| 1155 | } | 
|---|
| 1156 | //****************************************************************************** | 
|---|
| 1157 | //****************************************************************************** | 
|---|
| 1158 | static BOOL ConvertCaption(ULONG style, char *caption) | 
|---|
| 1159 | { | 
|---|
| 1160 | char os2caption[512]; | 
|---|
| 1161 | int i, len = strlen(caption), j; | 
|---|
| 1162 |  | 
|---|
| 1163 | switch(style) { | 
|---|
| 1164 | case WIN_BUTTON: | 
|---|
| 1165 | case WIN_EDIT: | 
|---|
| 1166 | case WIN_LISTBOX: | 
|---|
| 1167 | case WIN_SCROLLBAR: | 
|---|
| 1168 | case WIN_COMBOBOX: | 
|---|
| 1169 | for(i=0;i<len;i++) { | 
|---|
| 1170 | if(caption[i] == '&')   caption[i] = '~'; | 
|---|
| 1171 | } | 
|---|
| 1172 | break; | 
|---|
| 1173 | case WIN_STATIC: | 
|---|
| 1174 | j = 0; | 
|---|
| 1175 | for(i=0;i<=len;i++) { | 
|---|
| 1176 | if(caption[i] != '&')   os2caption[j++] = caption[i]; | 
|---|
| 1177 | } | 
|---|
| 1178 | strcpy(caption, (char*)SSToDS(os2caption)); | 
|---|
| 1179 | break; | 
|---|
| 1180 | } | 
|---|
| 1181 | return TRUE; | 
|---|
| 1182 | } | 
|---|
| 1183 | //****************************************************************************** | 
|---|
| 1184 | //****************************************************************************** | 
|---|
| 1185 | static BOOL ConvertFont(char *font, PRESPARAMS *dlgpparam, int fsize) | 
|---|
| 1186 | { | 
|---|
| 1187 | #if 0 | 
|---|
| 1188 | //  if(strcmp(font, "MS SHELL DLG") == 0) { | 
|---|
| 1189 | sprintf(dlgpparam->aparam[0].ab, "%d.", fsize); | 
|---|
| 1190 | //  strcat(dlgpparam->aparam[0].ab, font); | 
|---|
| 1191 | strcat(dlgpparam->aparam[0].ab, "Helv"); | 
|---|
| 1192 | return(TRUE); | 
|---|
| 1193 | //  } | 
|---|
| 1194 | //  else TODO: More fonts!!! | 
|---|
| 1195 | // "MS Sans Serif" | 
|---|
| 1196 | //  return(FALSE);  //not found | 
|---|
| 1197 | #else | 
|---|
| 1198 | return(FALSE); | 
|---|
| 1199 | #endif | 
|---|
| 1200 | } | 
|---|
| 1201 | //****************************************************************************** | 
|---|
| 1202 | //****************************************************************************** | 
|---|
| 1203 |  | 
|---|
| 1204 |  | 
|---|
| 1205 |  | 
|---|
| 1206 |  | 
|---|
| 1207 | ULONG QuerySizeDialog(WINDLGTEMPLATEEX *dhdr, int size ) | 
|---|
| 1208 | { | 
|---|
| 1209 | /* very approximat! */ | 
|---|
| 1210 | return sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size; | 
|---|
| 1211 | } | 
|---|