[275] | 1 | /* $Id: dialog.cpp,v 1.7 1999-07-06 08:50:11 sandervl Exp $ */
|
---|
[97] | 2 |
|
---|
[4] | 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 | #define INCL_DOSFILEMGR /* File Manager values */
|
---|
| 15 | #define INCL_DOSERRORS /* DOS Error values */
|
---|
| 16 | #define INCL_DOSPROCESS /* DOS Process values */
|
---|
| 17 | #define INCL_DOSMISC /* DOS Miscellanous values */
|
---|
[275] | 18 | #define INCL_DOSNLS
|
---|
[4] | 19 | #define INCL_WIN
|
---|
| 20 | #define INCL_WINMLE
|
---|
| 21 | #include <os2.h>
|
---|
| 22 | #include <stdio.h>
|
---|
| 23 | #include <string.h>
|
---|
| 24 | #include <stdlib.h>
|
---|
| 25 | #include <iostream.h>
|
---|
| 26 | #include <string.h>
|
---|
| 27 | #include "pefile.h"
|
---|
| 28 | #include "lx.h"
|
---|
| 29 | #include "dialog.h"
|
---|
| 30 | #include "misc.h"
|
---|
| 31 |
|
---|
| 32 | #ifndef BS_TEXT /*PLF Sun 97-06-22 03:07:13 not in watcom's os/2 header */
|
---|
| 33 | #define BS_TEXT 0x0010
|
---|
| 34 | #endif
|
---|
| 35 |
|
---|
[265] | 36 | #define DEFAULT_DLGFONT "9.WarpSans"
|
---|
| 37 |
|
---|
[4] | 38 | static int ConvertClassAndStyle(int winclass, int style, USHORT *os2class, BOOL *fIconBmp);
|
---|
| 39 | static int ConvertDlgStyle(int style);
|
---|
| 40 | static int ConvertDlgItemStyle(int style);
|
---|
| 41 | static void ConvertCaption(ULONG style, char *caption);
|
---|
| 42 | static int ConvertFont(char *font, PRESPARAMS *dlgpparam, int fsize);
|
---|
[275] | 43 | static void ShowDialogEx(int id, WINDLGTEMPLATEEX *dhdr, int size, int cp);
|
---|
[4] | 44 |
|
---|
| 45 | //******************************************************************************
|
---|
| 46 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
| 47 | //Used (slightly modified) in user32\dlgconvert.cpp too, so synch them when changed!!
|
---|
| 48 | //ShowDialogEx is identical except for the different dialog(item) structures
|
---|
| 49 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
| 50 | //******************************************************************************
|
---|
[275] | 51 | void ShowDialog(int id, DialogBoxHeader *dhdr, int size, int cp)
|
---|
[4] | 52 | {
|
---|
| 53 | WINDLGTEMPLATEEX *windlgex = (WINDLGTEMPLATEEX *)dhdr;
|
---|
| 54 | DLGTEMPLATE *dlgt;
|
---|
| 55 | DLGTITEM *dlgitem;
|
---|
| 56 | PRESPARAMS *dlgpparam;
|
---|
| 57 | char *dlgdata, *dlgcurdata;
|
---|
| 58 | WCHAR *szCaption;
|
---|
| 59 | WORD *ptrArray;
|
---|
| 60 | char *ctrltext, *szClass, *font;
|
---|
| 61 | FontHeader *fhdr;
|
---|
| 62 | ControlData *ctrldata;
|
---|
| 63 | int i;
|
---|
| 64 | ULONG ctrlflag, winclass;
|
---|
| 65 | BOOL fIconBmp;
|
---|
[275] | 66 | ULONG ulCpSize, ulCP;
|
---|
[4] | 67 |
|
---|
| 68 | //First save original win32 resource
|
---|
| 69 | OS2Exe.StoreWin32Resource(id, RT_DIALOG, size, (char *)dhdr);
|
---|
| 70 |
|
---|
| 71 | if(windlgex->wDlgVer == 1 && windlgex->wSignature == 0xFFFF) {
|
---|
[275] | 72 | ShowDialogEx(id, windlgex, size, cp);
|
---|
[4] | 73 | return;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | //should be enough
|
---|
| 77 | dlgt = (DLGTEMPLATE *)malloc(sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size);
|
---|
| 78 | dlgitem = &dlgt->adlgti[0];
|
---|
| 79 | dlgdata = (char *)&dlgt->adlgti[dhdr->NumberOfItems+1]; //for control data, presparams & strings
|
---|
| 80 | memset((char *)dlgt, 0, sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size);
|
---|
| 81 | dlgcurdata = dlgdata;
|
---|
| 82 |
|
---|
[275] | 83 | if(cp == 0) {
|
---|
| 84 | dlgt->codepage = 437;
|
---|
| 85 | }
|
---|
| 86 | else
|
---|
| 87 | {
|
---|
| 88 | DosQueryCp(sizeof(ulCP), &ulCP, &ulCpSize);
|
---|
| 89 | dlgt->codepage = ulCP;
|
---|
| 90 | }
|
---|
[4] | 91 | dlgt->offadlgti = 14;
|
---|
| 92 | dlgt->fsTemplateStatus = 1;
|
---|
| 93 | dlgt->iItemFocus = 65535;
|
---|
| 94 | dlgt->coffPresParams = 0;
|
---|
| 95 |
|
---|
| 96 | dlgitem->flStyle = ConvertDlgStyle(dhdr->lStyle) | WS_SYNCPAINT | WS_CLIPSIBLINGS;
|
---|
| 97 |
|
---|
| 98 | ctrlflag = 0;
|
---|
| 99 | if((dhdr->lStyle & WINWS_CAPTION) == WINWS_CAPTION) {
|
---|
| 100 | ctrlflag |= FCF_TITLEBAR;
|
---|
| 101 | dlgitem->flStyle |= FS_BORDER;
|
---|
| 102 | }
|
---|
| 103 | else
|
---|
| 104 | if(dhdr->lStyle & WINWS_DLGFRAME) //can't have title bar
|
---|
| 105 | dlgitem->flStyle |= FS_DLGBORDER;
|
---|
| 106 |
|
---|
| 107 | if((dhdr->lStyle & (WINWS_SYSMENU | WINWS_CAPTION)) == (WINWS_SYSMENU | WINWS_CAPTION))
|
---|
| 108 | ctrlflag |= FCF_SYSMENU;
|
---|
| 109 | if(dhdr->lStyle & WINWS_VSCROLL)
|
---|
| 110 | ctrlflag |= FCF_VERTSCROLL;
|
---|
| 111 | if(dhdr->lStyle & WINWS_HSCROLL)
|
---|
| 112 | ctrlflag |= FCF_HORZSCROLL;
|
---|
| 113 | if(dhdr->lStyle & WINWS_MINIMIZEBOX)
|
---|
| 114 | ctrlflag |= FCF_MINBUTTON;
|
---|
| 115 | if(dhdr->lStyle & WINWS_MAXIMIZEBOX)
|
---|
| 116 | ctrlflag |= FCF_MAXBUTTON;
|
---|
| 117 | if(dhdr->lStyle & WINWS_THICKFRAME)
|
---|
| 118 | dlgitem->flStyle |= FS_SIZEBORDER;
|
---|
| 119 |
|
---|
| 120 | if(ctrlflag) {
|
---|
| 121 | *(ULONG *)dlgcurdata = ctrlflag;
|
---|
| 122 | dlgitem->offCtlData = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 123 | dlgcurdata += sizeof(ULONG);
|
---|
| 124 | }
|
---|
| 125 | else dlgitem->offCtlData = 0xFFFF;
|
---|
| 126 | dlgitem->x = dhdr->x;
|
---|
| 127 | //TODO: SvL: Calc has x = 32768 Special value???
|
---|
| 128 | if(dlgitem->x > 1024 || dlgitem->x < 0)
|
---|
| 129 | dlgitem->x = 64;
|
---|
| 130 |
|
---|
| 131 | dlgitem->y = dhdr->y;
|
---|
| 132 | dlgitem->cx = dhdr->cx;
|
---|
| 133 | dlgitem->cy = dhdr->cy;
|
---|
| 134 | dlgitem->cChildren = dhdr->NumberOfItems;
|
---|
| 135 | dlgitem->id = (USHORT)id; //ord id or converted name id
|
---|
| 136 | dlgitem->fsItemStatus = 1;
|
---|
| 137 | dlgitem->offClassName = 1; //WC_FRAME
|
---|
| 138 |
|
---|
| 139 | cout.setf(ios::hex, ios::basefield);
|
---|
| 140 | cout << "Dialog Style : " << dhdr->lStyle << endl;
|
---|
| 141 | cout << "Extended Dialog Style: " << dhdr->lExtendedStyle << endl;
|
---|
| 142 | cout.setf(ios::dec, ios::basefield);
|
---|
| 143 | cout << "Position : (" << dhdr->x << ',' << dhdr->y << ')' << endl;
|
---|
| 144 | cout << "Size : (" << dhdr->cx << ',' << dhdr->cy << ')' << endl;
|
---|
| 145 | cout << "Number of Items : " << dhdr->NumberOfItems << endl;
|
---|
| 146 | //Menu id
|
---|
| 147 | if(dhdr->fNameOrd == 0xFFFF) {
|
---|
| 148 | cout << "Menu ID : " << *(WORD *)(dhdr+1) << endl;
|
---|
| 149 | ptrArray = (WORD *)((int)dhdr + sizeof(DialogBoxHeader) + sizeof(WORD));
|
---|
| 150 | }
|
---|
| 151 | else {
|
---|
| 152 | if(dhdr->fNameOrd == 0) {//SvL: 0 == no menu!
|
---|
| 153 | ptrArray = (WORD *)((int)dhdr + sizeof(DialogBoxHeader));
|
---|
| 154 | }
|
---|
| 155 | else {
|
---|
[275] | 156 | cout << "Menu namestring : " << UnicodeToAscii((WCHAR *)(&dhdr->fNameOrd), cp) << endl;
|
---|
[4] | 157 | ptrArray = (WORD *)((int)&dhdr->fNameOrd + UniStrlen((WCHAR *)(&dhdr->fNameOrd))*2 + sizeof(WCHAR));
|
---|
| 158 | }
|
---|
| 159 | }
|
---|
| 160 | //Class id
|
---|
| 161 | if(*ptrArray == 0xFFFF) {
|
---|
| 162 | cout << "Class ID : " << *(WORD *)(ptrArray+1) << endl;
|
---|
| 163 | ptrArray = (WORD *)((int)ptrArray + 2*sizeof(WORD));
|
---|
| 164 | }
|
---|
| 165 | else {
|
---|
| 166 | if(*ptrArray == 0) {//SvL: 0 == no menu!
|
---|
| 167 | ptrArray = (WORD *)((int)ptrArray + sizeof(WORD));
|
---|
| 168 | }
|
---|
| 169 | else {
|
---|
[275] | 170 | szClass = UnicodeToAscii((WCHAR *)ptrArray, cp);
|
---|
[4] | 171 | cout << "Class Name : " << szClass << endl;
|
---|
| 172 |
|
---|
| 173 | dlgitem->cchClassName = (USHORT)strlen(szClass);
|
---|
| 174 | dlgitem->offClassName = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 175 | strcpy((char *)dlgcurdata, szClass);
|
---|
| 176 | //Open32 wants class name in upper case!
|
---|
| 177 | UpCase((char *)dlgcurdata);
|
---|
| 178 | dlgcurdata += dlgitem->cchClassName + 1; //include terminating 0 (just to be sure)
|
---|
| 179 | //TODO: SvL: Can they also be system classes?
|
---|
| 180 | // dlgitem->flStyle = dhdr->lStyle;
|
---|
| 181 | // dlgitem->flStyle = ConvertDlgItemStyle(dhdr->lStyle);
|
---|
| 182 | ptrArray = (WORD *)((int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD));
|
---|
| 183 | }
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | //Title
|
---|
| 187 | if(*ptrArray == 0) {
|
---|
| 188 | cout << "No title " << endl;
|
---|
| 189 | ctrldata = (ControlData *)((int)(int)ptrArray + sizeof(WORD));
|
---|
| 190 | }
|
---|
| 191 | else {
|
---|
[275] | 192 | ctrltext = UnicodeToAscii((WCHAR *)(ptrArray), cp);
|
---|
[4] | 193 | cout << "Title : " << ctrltext << endl;
|
---|
| 194 | ctrldata = (ControlData *)((int)(int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD));
|
---|
| 195 |
|
---|
| 196 | if(ctrltext[0] != 0) {
|
---|
| 197 | dlgitem->cchText = (USHORT)strlen(ctrltext);
|
---|
| 198 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 199 | strcpy((char *)dlgcurdata, ctrltext);
|
---|
| 200 | dlgcurdata += dlgitem->cchText + 1; //include terminating 0 (just to be sure)
|
---|
[259] | 201 | } else
|
---|
| 202 | { //CB: cchText == 0, OS/2 uses offText anyway! (entryfields)
|
---|
| 203 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt);
|
---|
| 204 | dlgcurdata++; //0 at offText
|
---|
[4] | 205 | }
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | if(dhdr->lStyle & DS_SETFONT) {
|
---|
| 209 | fhdr = (FontHeader *)ctrldata;
|
---|
[275] | 210 | font = UnicodeToAscii(fhdr->szFontName, cp);
|
---|
[4] | 211 | cout << "Font Point Size : " << fhdr->wPointSize << endl;
|
---|
| 212 | cout << "Font Name : " << font << endl;
|
---|
| 213 | ctrldata = (ControlData *)((int)fhdr + sizeof(FontHeader) - 2 + UniStrlen(fhdr->szFontName)*2 + sizeof(WORD)); /*PLF Sat 97-06-21 20:22:44*/
|
---|
| 214 | //TODO: no pres params yet (font in win32 dialog ignored)
|
---|
| 215 | dlgpparam = (PRESPARAMS *)dlgcurdata;
|
---|
| 216 | dlgpparam->cb = 0;
|
---|
| 217 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE;
|
---|
| 218 | dlgpparam->aparam[0].cb = 0;
|
---|
| 219 | UpCase(font);
|
---|
| 220 | if(ConvertFont(font, dlgpparam, fhdr->wPointSize) == TRUE) {
|
---|
| 221 | dlgpparam->aparam[0].cb = strlen(dlgpparam->aparam[0].ab) + 2*sizeof(ULONG) + 1;
|
---|
| 222 | // dlgpparam->cb = sizeof(ULONG) + dlgpparam->aparam[0].cb;
|
---|
| 223 | dlgpparam->cb = dlgpparam->aparam[0].cb;
|
---|
| 224 | dlgitem->offPresParams = (USHORT)((int)dlgpparam - (int)dlgt);
|
---|
| 225 | dlgcurdata += dlgpparam->cb + sizeof(ULONG);
|
---|
[265] | 226 | } else
|
---|
| 227 | { //CB: set default font
|
---|
| 228 | dlgpparam = (PRESPARAMS*)dlgcurdata;
|
---|
| 229 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE;
|
---|
| 230 | dlgpparam->aparam[0].cb = strlen(DEFAULT_DLGFONT)+1;
|
---|
| 231 | strcpy((char*)&dlgpparam->aparam[0].ab,DEFAULT_DLGFONT);
|
---|
| 232 | dlgpparam->cb = dlgpparam->aparam[0].cb+2*sizeof(ULONG);
|
---|
| 233 | dlgitem->offPresParams = (USHORT)((int)dlgpparam-(int)dlgt);
|
---|
| 234 | dlgt->coffPresParams++;
|
---|
| 235 | dlgcurdata += dlgpparam->cb+sizeof(dlgpparam->cb);
|
---|
[4] | 236 | }
|
---|
[265] | 237 | } else
|
---|
| 238 | { //CB: set default font
|
---|
| 239 | dlgpparam = (PRESPARAMS*)dlgcurdata;
|
---|
| 240 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE;
|
---|
| 241 | dlgpparam->aparam[0].cb = strlen(DEFAULT_DLGFONT)+1;
|
---|
| 242 | strcpy((char*)&dlgpparam->aparam[0].ab,DEFAULT_DLGFONT);
|
---|
| 243 | dlgpparam->cb = dlgpparam->aparam[0].cb+2*sizeof(ULONG);
|
---|
| 244 | dlgitem->offPresParams = (USHORT)((int)dlgpparam-(int)dlgt);
|
---|
| 245 | dlgt->coffPresParams++;
|
---|
| 246 | dlgcurdata += dlgpparam->cb+sizeof(dlgpparam->cb);
|
---|
[4] | 247 | }
|
---|
| 248 | dlgitem++;
|
---|
| 249 |
|
---|
| 250 | ctrldata = (ControlData *)(((int)ctrldata+3) & ~3);
|
---|
| 251 | for(i=0;i<dhdr->NumberOfItems;i++) {
|
---|
| 252 | //save as OS/2 DLGTITEM
|
---|
| 253 | dlgitem->x = ctrldata->x;
|
---|
| 254 | //SvL: 3-8-'97
|
---|
| 255 | // OS/2 -> left bottom == origin and y coordinate == left bottom origin control
|
---|
| 256 | // Win32 -> left top == origin and y coordinate == left top origin
|
---|
| 257 | dlgitem->y = dlgt->adlgti[0].cy - ctrldata->y - ctrldata->cy;
|
---|
| 258 | dlgitem->cx = ctrldata->cx;
|
---|
| 259 | dlgitem->cy = ctrldata->cy;
|
---|
| 260 | dlgitem->id = ctrldata->wId;
|
---|
| 261 | dlgitem->offCtlData = 0xFFFF;
|
---|
| 262 | dlgitem->offPresParams = 0xFFFF;
|
---|
| 263 |
|
---|
| 264 | //TODO: Extended style
|
---|
| 265 |
|
---|
| 266 | cout.setf(ios::hex, ios::basefield);
|
---|
| 267 | cout << "***** Control Style : " << ctrldata->lStyle << endl;
|
---|
| 268 | cout << "Extended Control Style: " << ctrldata->lExtendedStyle << endl;
|
---|
| 269 | cout.setf(ios::dec, ios::basefield);
|
---|
| 270 | cout << "Position : (" << ctrldata->x << ',' << ctrldata->y << ')' << endl;
|
---|
| 271 | cout << "Size : (" << ctrldata->cx << ',' << ctrldata->cy << ')' << endl;
|
---|
| 272 | cout << "wID : " << ctrldata->wId << endl;
|
---|
| 273 | winclass = 0;
|
---|
| 274 | if(ctrldata->fClassId == 0xFFFF) {
|
---|
| 275 | winclass = *(WORD *)(ctrldata+1);
|
---|
| 276 | cout << "Class ID : " << winclass << endl;
|
---|
| 277 | szCaption = (WCHAR *)((int)ctrldata + sizeof(ControlData) + sizeof(WORD));
|
---|
| 278 | dlgitem->flStyle = ConvertClassAndStyle(*(WORD *)(ctrldata+1), ctrldata->lStyle, &dlgitem->offClassName, &fIconBmp);
|
---|
| 279 | dlgitem->cchClassName = 0;
|
---|
| 280 | }
|
---|
| 281 | else {
|
---|
[275] | 282 | szClass = UnicodeToAscii((WCHAR *)&ctrldata->fClassId, cp);
|
---|
[4] | 283 | cout << "Class Name : " << szClass << endl;
|
---|
| 284 | szCaption = (WCHAR *)((int)ctrldata + sizeof(ControlData) + strlen(szClass)*2);
|
---|
| 285 | dlgitem->cchClassName = (USHORT)strlen(szClass);
|
---|
| 286 | dlgitem->offClassName = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 287 | strcpy((char *)dlgcurdata, szClass);
|
---|
| 288 | //Open32 wants class name in upper case!
|
---|
| 289 | UpCase((char *)dlgcurdata);
|
---|
| 290 | dlgcurdata += dlgitem->cchClassName + 1; //include terminating 0 (just to be sure)
|
---|
| 291 | dlgitem->flStyle = ConvertDlgItemStyle(ctrldata->lStyle) ;
|
---|
| 292 | }
|
---|
| 293 | if(*(USHORT *)szCaption == 0xFFFF) {
|
---|
| 294 | szCaption += 2;
|
---|
| 295 | dlgitem->cchText = 0;
|
---|
[265] | 296 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt);
|
---|
| 297 | dlgcurdata += 1; //CB: offText == empty string
|
---|
[4] | 298 | }
|
---|
| 299 | else { //Handle Caption
|
---|
[275] | 300 | ctrltext = UnicodeToAscii(szCaption, cp);
|
---|
[4] | 301 | //SvL: (16-9-'97) Convert '&' chars to '~' (for some classes)
|
---|
| 302 | ConvertCaption(winclass, ctrltext);
|
---|
| 303 | if(fIconBmp == TRUE) {//control contains bitmap or icon
|
---|
| 304 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 305 | int resid = OS2Exe.ConvertNametoId(ctrltext);
|
---|
| 306 | *(char *)dlgcurdata = '#';
|
---|
| 307 | itoa(resid, (char *)dlgcurdata+1, 10);
|
---|
| 308 | dlgitem->cchText = (USHORT)strlen((char *)dlgcurdata); //one USHORT for res id
|
---|
| 309 | dlgcurdata += dlgitem->cchText + 1; //include terminating 0 (just to be sure)
|
---|
| 310 | }
|
---|
| 311 | else {
|
---|
| 312 | if(ctrltext[0] != 0) {
|
---|
| 313 | dlgitem->cchText = (USHORT)strlen(ctrltext);
|
---|
| 314 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 315 | strcpy((char *)dlgcurdata, ctrltext);
|
---|
| 316 | dlgcurdata += dlgitem->cchText + 1; //include terminating 0 (just to be sure)
|
---|
[259] | 317 | } else
|
---|
| 318 | { //CB: cchText == 0, OS/2 uses offText anyway! (entryfields)
|
---|
| 319 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt);
|
---|
| 320 | dlgcurdata++; //0 at offText
|
---|
[4] | 321 | }
|
---|
| 322 | }
|
---|
[275] | 323 | cout << "Text : " << UnicodeToAscii(szCaption, cp) << endl;
|
---|
[4] | 324 | szCaption = (WCHAR *)((int)szCaption + UniStrlen(szCaption)*2 + sizeof(WORD));
|
---|
| 325 | }
|
---|
| 326 |
|
---|
| 327 | cout << "Extra Stuff WORD : " << *(WORD *)(szCaption) << endl;
|
---|
| 328 | ctrldata = (ControlData *)((int)szCaption + sizeof(WORD));
|
---|
| 329 | ctrldata = (ControlData *)(((int)ctrldata+3) & ~3);
|
---|
| 330 | dlgitem++;
|
---|
| 331 | }
|
---|
| 332 | //calculate dialog box length
|
---|
| 333 | dlgt->cbTemplate = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 334 | OS2Exe.StoreResource(id, RT_DIALOG, dlgt->cbTemplate, (char *)dlgt);
|
---|
| 335 | free(dlgt);
|
---|
| 336 | }
|
---|
| 337 | //******************************************************************************
|
---|
| 338 | //******************************************************************************
|
---|
[275] | 339 | void ShowDialogEx(int id, WINDLGTEMPLATEEX *dhdr, int size, int cp)
|
---|
[4] | 340 | {
|
---|
| 341 | DLGTEMPLATE *dlgt;
|
---|
| 342 | DLGTITEM *dlgitem;
|
---|
| 343 | PRESPARAMS *dlgpparam;
|
---|
| 344 | char *dlgdata, *dlgcurdata;
|
---|
| 345 | WCHAR *szCaption;
|
---|
| 346 | WORD *ptrArray;
|
---|
| 347 | char *ctrltext, *szClass, *font;
|
---|
| 348 | FontHeaderEx *fhdr;
|
---|
| 349 | WINDLGITEMTEMPLATEEX *ctrldata;
|
---|
| 350 | int i;
|
---|
| 351 | ULONG ctrlflag, winclass;
|
---|
| 352 | BOOL fIconBmp;
|
---|
[275] | 353 | ULONG ulCpSize, ulCP;
|
---|
[4] | 354 |
|
---|
| 355 | //should be enough
|
---|
| 356 | dlgt = (DLGTEMPLATE *)malloc(sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size);
|
---|
| 357 | dlgitem = &dlgt->adlgti[0];
|
---|
| 358 | dlgdata = (char *)&dlgt->adlgti[dhdr->NumberOfItems+1]; //for control data, presparams & strings
|
---|
| 359 | memset((char *)dlgt, 0, sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size);
|
---|
| 360 | dlgcurdata = dlgdata;
|
---|
| 361 |
|
---|
[275] | 362 | if(cp == 0) {
|
---|
| 363 | dlgt->codepage = 437;
|
---|
| 364 | }
|
---|
| 365 | else
|
---|
| 366 | {
|
---|
| 367 | DosQueryCp(sizeof(ulCP), &ulCP, &ulCpSize);
|
---|
| 368 | dlgt->codepage = ulCP;
|
---|
| 369 | }
|
---|
[4] | 370 | dlgt->offadlgti = 14;
|
---|
| 371 | dlgt->fsTemplateStatus = 1;
|
---|
| 372 | dlgt->iItemFocus = 65535;
|
---|
| 373 | dlgt->coffPresParams = 0;
|
---|
| 374 |
|
---|
| 375 | dlgitem->flStyle = ConvertDlgStyle(dhdr->lStyle) | WS_SYNCPAINT | WS_CLIPSIBLINGS;
|
---|
| 376 |
|
---|
| 377 | ctrlflag = 0;
|
---|
| 378 | if((dhdr->lStyle & WINWS_CAPTION) == WINWS_CAPTION) {
|
---|
| 379 | ctrlflag |= FCF_TITLEBAR;
|
---|
| 380 | dlgitem->flStyle |= FS_BORDER;
|
---|
| 381 | }
|
---|
| 382 | else
|
---|
| 383 | if(dhdr->lStyle & WINWS_DLGFRAME) //can't have title bar
|
---|
| 384 | dlgitem->flStyle |= FS_DLGBORDER;
|
---|
| 385 |
|
---|
| 386 | if((dhdr->lStyle & (WINWS_SYSMENU | WINWS_CAPTION)) == (WINWS_SYSMENU | WINWS_CAPTION))
|
---|
| 387 | ctrlflag |= FCF_SYSMENU;
|
---|
| 388 | if(dhdr->lStyle & WINWS_VSCROLL)
|
---|
| 389 | ctrlflag |= FCF_VERTSCROLL;
|
---|
| 390 | if(dhdr->lStyle & WINWS_HSCROLL)
|
---|
| 391 | ctrlflag |= FCF_HORZSCROLL;
|
---|
| 392 | if(dhdr->lStyle & WINWS_MINIMIZEBOX)
|
---|
| 393 | ctrlflag |= FCF_MINBUTTON;
|
---|
| 394 | if(dhdr->lStyle & WINWS_MAXIMIZEBOX)
|
---|
| 395 | ctrlflag |= FCF_MAXBUTTON;
|
---|
| 396 | if(dhdr->lStyle & WINWS_THICKFRAME)
|
---|
| 397 | dlgitem->flStyle |= FS_SIZEBORDER;
|
---|
| 398 |
|
---|
| 399 | if(ctrlflag) {
|
---|
| 400 | *(ULONG *)dlgcurdata = ctrlflag;
|
---|
| 401 | dlgitem->offCtlData = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 402 | dlgcurdata += sizeof(ULONG);
|
---|
| 403 | }
|
---|
| 404 | else dlgitem->offCtlData = 0xFFFF;
|
---|
| 405 | dlgitem->x = dhdr->x;
|
---|
| 406 | dlgitem->y = dhdr->y;
|
---|
| 407 | dlgitem->cx = dhdr->cx;
|
---|
| 408 | dlgitem->cy = dhdr->cy;
|
---|
| 409 | dlgitem->cChildren = dhdr->NumberOfItems;
|
---|
| 410 | dlgitem->id = (USHORT)id; //ord id or converted name id
|
---|
| 411 | dlgitem->fsItemStatus = 1;
|
---|
| 412 | dlgitem->offClassName = 1; //WC_FRAME
|
---|
| 413 |
|
---|
| 414 | cout.setf(ios::hex, ios::basefield);
|
---|
| 415 | cout << "Dialog Style : " << dhdr->lStyle << endl;
|
---|
| 416 | cout << "Extended Dialog Style: " << dhdr->lExtendedStyle << endl;
|
---|
| 417 | cout.setf(ios::dec, ios::basefield);
|
---|
| 418 | cout << "Position : (" << dhdr->x << ',' << dhdr->y << ')' << endl;
|
---|
| 419 | cout << "Size : (" << dhdr->cx << ',' << dhdr->cy << ')' << endl;
|
---|
| 420 | cout << "Number of Items : " << dhdr->NumberOfItems << endl;
|
---|
| 421 | //Menu id
|
---|
| 422 | if(dhdr->fNameOrd == 0xFFFF) {
|
---|
| 423 | cout << "Menu ID : " << *(WORD *)(dhdr+1) << endl;
|
---|
| 424 | ptrArray = (WORD *)((int)dhdr + sizeof(WINDLGTEMPLATEEX) + sizeof(WORD));
|
---|
| 425 | }
|
---|
| 426 | else {
|
---|
| 427 | if(dhdr->fNameOrd == 0) {//SvL: 0 == no menu!
|
---|
| 428 | ptrArray = (WORD *)((int)dhdr + sizeof(WINDLGTEMPLATEEX));
|
---|
| 429 | }
|
---|
| 430 | else {
|
---|
[275] | 431 | cout << "Menu namestring : " << UnicodeToAscii((WCHAR *)(&dhdr->fNameOrd, cp)) << endl;
|
---|
[4] | 432 | ptrArray = (WORD *)((int)&dhdr->fNameOrd + UniStrlen((WCHAR *)(&dhdr->fNameOrd))*2 + sizeof(WCHAR));
|
---|
| 433 | }
|
---|
| 434 | }
|
---|
| 435 | //Class id
|
---|
| 436 | if(*ptrArray == 0xFFFF) {
|
---|
| 437 | cout << "Class ID : " << *(WORD *)(ptrArray+1) << endl;
|
---|
| 438 | ptrArray = (WORD *)((int)ptrArray + 2*sizeof(WORD));
|
---|
| 439 | }
|
---|
| 440 | else {
|
---|
| 441 | if(*ptrArray == 0) {//SvL: 0 == no menu!
|
---|
| 442 | ptrArray = (WORD *)((int)ptrArray + sizeof(WORD));
|
---|
| 443 | }
|
---|
| 444 | else {
|
---|
| 445 | szClass = UnicodeToAscii((WCHAR *)ptrArray);
|
---|
| 446 | cout << "Class Name : " << szClass << endl;
|
---|
| 447 |
|
---|
| 448 | dlgitem->cchClassName = (USHORT)strlen(szClass);
|
---|
| 449 | dlgitem->offClassName = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 450 | strcpy((char *)dlgcurdata, szClass);
|
---|
| 451 | //Open32 wants class name in upper case!
|
---|
| 452 | UpCase((char *)dlgcurdata);
|
---|
| 453 | dlgcurdata += dlgitem->cchClassName + 1; //include terminating 0 (just to be sure)
|
---|
| 454 | //TODO: SvL: Can they also be system classes?
|
---|
| 455 | // dlgitem->flStyle = dhdr->lStyle;
|
---|
| 456 | // dlgitem->flStyle = ConvertDlgItemStyle(dhdr->lStyle);
|
---|
| 457 | ptrArray = (WORD *)((int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD));
|
---|
| 458 | }
|
---|
| 459 | }
|
---|
| 460 |
|
---|
| 461 | //Title
|
---|
| 462 | if(*ptrArray == 0) {
|
---|
| 463 | cout << "No title " << endl;
|
---|
| 464 | ctrldata = (WINDLGITEMTEMPLATEEX *)((int)(int)ptrArray + sizeof(WORD));
|
---|
| 465 | }
|
---|
| 466 | else {
|
---|
[275] | 467 | ctrltext = UnicodeToAscii((WCHAR *)(ptrArray), cp);
|
---|
[4] | 468 | cout << "Title : " << ctrltext << endl;
|
---|
| 469 | ctrldata = (WINDLGITEMTEMPLATEEX *)((int)(int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD));
|
---|
| 470 |
|
---|
| 471 | if(ctrltext[0] != 0) {
|
---|
| 472 | dlgitem->cchText = (USHORT)strlen(ctrltext);
|
---|
| 473 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 474 | strcpy((char *)dlgcurdata, ctrltext);
|
---|
| 475 | dlgcurdata += dlgitem->cchText + 1; //include terminating 0 (just to be sure)
|
---|
[259] | 476 | } else
|
---|
| 477 | { //CB: cchText == 0, OS/2 uses offText anyway! (entryfields)
|
---|
| 478 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt);
|
---|
| 479 | dlgcurdata++; //0 at offText
|
---|
[4] | 480 | }
|
---|
| 481 | }
|
---|
| 482 | dlgitem++;
|
---|
| 483 |
|
---|
| 484 | if(dhdr->lStyle & DS_SETFONT) {
|
---|
| 485 | fhdr = (FontHeaderEx *)ctrldata;
|
---|
[275] | 486 | font = UnicodeToAscii(fhdr->szFontName, cp);
|
---|
[4] | 487 | cout << "Font Point Size : " << fhdr->wPointSize << endl;
|
---|
| 488 | cout << "Font Name : " << font << endl;
|
---|
| 489 | ctrldata = (WINDLGITEMTEMPLATEEX *)((int)fhdr + sizeof(FontHeaderEx) - 2 + UniStrlen(fhdr->szFontName)*2 + sizeof(WORD)); /*PLF Sat 97-06-21 20:22:44*/
|
---|
| 490 | //TODO: no pres params yet (font in win32 dialog ignored)
|
---|
| 491 | dlgpparam = (PRESPARAMS *)dlgcurdata;
|
---|
| 492 | dlgpparam->cb = 0;
|
---|
| 493 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE;
|
---|
| 494 | dlgpparam->aparam[0].cb = 0;
|
---|
| 495 | UpCase(font);
|
---|
| 496 | if(ConvertFont(font, dlgpparam, fhdr->wPointSize) == TRUE) {
|
---|
| 497 | dlgpparam->aparam[0].cb = strlen(dlgpparam->aparam[0].ab) + 2*sizeof(ULONG) + 1;
|
---|
| 498 | dlgpparam->cb = sizeof(ULONG) + dlgpparam->aparam[0].cb;
|
---|
| 499 | dlgt->coffPresParams = (USHORT)((int)dlgpparam - (int)dlgt);
|
---|
| 500 | dlgcurdata += dlgpparam->cb;
|
---|
[265] | 501 | } else
|
---|
| 502 | { //CB: set default font
|
---|
| 503 | dlgpparam = (PRESPARAMS*)dlgcurdata;
|
---|
| 504 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE;
|
---|
| 505 | dlgpparam->aparam[0].cb = strlen(DEFAULT_DLGFONT)+1;
|
---|
| 506 | strcpy((char*)&dlgpparam->aparam[0].ab,DEFAULT_DLGFONT);
|
---|
| 507 | dlgpparam->cb = dlgpparam->aparam[0].cb+2*sizeof(ULONG);
|
---|
| 508 | dlgitem->offPresParams = (USHORT)((int)dlgpparam-(int)dlgt);
|
---|
| 509 | dlgt->coffPresParams++;
|
---|
| 510 | dlgcurdata += dlgpparam->cb+sizeof(dlgpparam->cb);
|
---|
[4] | 511 | }
|
---|
[265] | 512 | } else
|
---|
| 513 | { //CB: set default font
|
---|
| 514 | dlgpparam = (PRESPARAMS*)dlgcurdata;
|
---|
| 515 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE;
|
---|
| 516 | dlgpparam->aparam[0].cb = strlen(DEFAULT_DLGFONT)+1;
|
---|
| 517 | strcpy((char*)&dlgpparam->aparam[0].ab,DEFAULT_DLGFONT);
|
---|
| 518 | dlgpparam->cb = dlgpparam->aparam[0].cb+2*sizeof(ULONG);
|
---|
| 519 | dlgitem->offPresParams = (USHORT)((int)dlgpparam-(int)dlgt);
|
---|
| 520 | dlgt->coffPresParams++;
|
---|
| 521 | dlgcurdata += dlgpparam->cb+sizeof(dlgpparam->cb);
|
---|
[4] | 522 | }
|
---|
| 523 | ctrldata = (WINDLGITEMTEMPLATEEX *)(((int)ctrldata+3) & ~3);
|
---|
| 524 | for(i=0;i<dhdr->NumberOfItems;i++) {
|
---|
| 525 | //save as OS/2 DLGTITEM
|
---|
| 526 | dlgitem->x = ctrldata->x;
|
---|
| 527 | //SvL: 3-8-'97
|
---|
| 528 | // OS/2 -> left bottom == origin and y coordinate == left bottom origin control
|
---|
| 529 | // Win32 -> left top == origin and y coordinate == left top origin
|
---|
| 530 | dlgitem->y = dlgt->adlgti[0].cy - ctrldata->y - ctrldata->cy;
|
---|
| 531 | dlgitem->cx = ctrldata->cx;
|
---|
| 532 | dlgitem->cy = ctrldata->cy;
|
---|
| 533 | dlgitem->id = (USHORT)ctrldata->wId;
|
---|
| 534 | dlgitem->offCtlData = 0xFFFF;
|
---|
| 535 | dlgitem->offPresParams = 0xFFFF;
|
---|
| 536 |
|
---|
| 537 | //TODO: Extended style
|
---|
| 538 |
|
---|
| 539 | cout.setf(ios::hex, ios::basefield);
|
---|
| 540 | cout << "***** Control Style : " << ctrldata->lStyle << endl;
|
---|
| 541 | cout << "Extended Control Style: " << ctrldata->lExtendedStyle << endl;
|
---|
| 542 | cout.setf(ios::dec, ios::basefield);
|
---|
| 543 | cout << "Position : (" << ctrldata->x << ',' << ctrldata->y << ')' << endl;
|
---|
| 544 | cout << "Size : (" << ctrldata->cx << ',' << ctrldata->cy << ')' << endl;
|
---|
| 545 | cout << "wID : " << ctrldata->wId << endl;
|
---|
| 546 | winclass = 0;
|
---|
| 547 | if(ctrldata->fClassId == 0xFFFF) {
|
---|
| 548 | winclass = *(WORD *)(ctrldata+1);
|
---|
| 549 | cout << "Class ID : " << winclass << endl;
|
---|
| 550 | szCaption = (WCHAR *)((int)ctrldata + sizeof(WINDLGITEMTEMPLATEEX) + sizeof(WORD));
|
---|
| 551 | dlgitem->flStyle = ConvertClassAndStyle(*(WORD *)(ctrldata+1), ctrldata->lStyle, &dlgitem->offClassName, &fIconBmp);
|
---|
| 552 | dlgitem->cchClassName = 0;
|
---|
| 553 | }
|
---|
| 554 | else {
|
---|
[275] | 555 | szClass = UnicodeToAscii((WCHAR *)&ctrldata->fClassId, cp);
|
---|
[4] | 556 | cout << "Class Name : " << szClass << endl;
|
---|
| 557 | szCaption = (WCHAR *)((int)ctrldata + sizeof(WINDLGITEMTEMPLATEEX) + strlen(szClass)*2);
|
---|
| 558 | dlgitem->cchClassName = (USHORT)strlen(szClass);
|
---|
| 559 | dlgitem->offClassName = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 560 | strcpy((char *)dlgcurdata, szClass);
|
---|
| 561 | //Open32 wants class name in upper case!
|
---|
| 562 | UpCase((char *)dlgcurdata);
|
---|
| 563 | dlgcurdata += dlgitem->cchClassName + 1; //include terminating 0 (just to be sure)
|
---|
| 564 | dlgitem->flStyle = ConvertDlgItemStyle(ctrldata->lStyle) ;
|
---|
| 565 | }
|
---|
| 566 | if(*(USHORT *)szCaption == 0xFFFF) {
|
---|
| 567 | szCaption += 2;
|
---|
| 568 | }
|
---|
| 569 | else { //Handle Caption
|
---|
[275] | 570 | ctrltext = UnicodeToAscii(szCaption, cp);
|
---|
[4] | 571 | //SvL: (16-9-'97) Convert '&' chars to '~' (for some classes)
|
---|
| 572 | ConvertCaption(winclass, ctrltext);
|
---|
| 573 | if(fIconBmp == TRUE) {//control contains bitmap or icon
|
---|
| 574 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 575 | int resid = OS2Exe.ConvertNametoId(ctrltext);
|
---|
| 576 | *(char *)dlgcurdata = '#';
|
---|
| 577 | itoa(resid, (char *)dlgcurdata+1, 10);
|
---|
| 578 | dlgitem->cchText = (USHORT)strlen((char *)dlgcurdata); //one USHORT for res id
|
---|
| 579 | dlgcurdata += dlgitem->cchText + 1; //include terminating 0 (just to be sure)
|
---|
| 580 | }
|
---|
| 581 | else {
|
---|
| 582 | if(ctrltext[0] != 0) {
|
---|
| 583 | dlgitem->cchText = (USHORT)strlen(ctrltext);
|
---|
| 584 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 585 | strcpy((char *)dlgcurdata, ctrltext);
|
---|
| 586 | dlgcurdata += dlgitem->cchText + 1; //include terminating 0 (just to be sure)
|
---|
[259] | 587 | } else
|
---|
| 588 | { //CB: cchText == 0, OS/2 uses offText anyway! (entryfields)
|
---|
| 589 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt);
|
---|
| 590 | dlgcurdata++; //0 at offText
|
---|
[4] | 591 | }
|
---|
| 592 | }
|
---|
[275] | 593 | cout << "Text : " << UnicodeToAscii(szCaption, cp) << endl;
|
---|
[4] | 594 | szCaption = (WCHAR *)((int)szCaption + UniStrlen(szCaption)*2 + sizeof(WORD));
|
---|
| 595 | }
|
---|
| 596 |
|
---|
| 597 | cout << "Extra Stuff WORD : " << *(WORD *)(szCaption) << endl;
|
---|
| 598 | ctrldata = (WINDLGITEMTEMPLATEEX *)((int)szCaption + sizeof(WORD));
|
---|
| 599 | ctrldata = (WINDLGITEMTEMPLATEEX *)(((int)ctrldata+3) & ~3);
|
---|
| 600 | dlgitem++;
|
---|
| 601 | }
|
---|
| 602 | //calculate dialog box length
|
---|
| 603 | dlgt->cbTemplate = (USHORT)((int)dlgcurdata - (int)dlgt);
|
---|
| 604 | OS2Exe.StoreResource(id, RT_DIALOG, dlgt->cbTemplate, (char *)dlgt);
|
---|
| 605 | free(dlgt);
|
---|
| 606 | }
|
---|
| 607 | //******************************************************************************
|
---|
| 608 | //******************************************************************************
|
---|
| 609 | static int ConvertClassAndStyle(int winclass,
|
---|
| 610 | int style,
|
---|
| 611 | USHORT *os2class,
|
---|
| 612 | BOOL *fIconBmp)
|
---|
| 613 | {
|
---|
| 614 | int os2style = ConvertDlgItemStyle(style);
|
---|
| 615 |
|
---|
| 616 | *fIconBmp = FALSE;
|
---|
| 617 |
|
---|
| 618 | switch(winclass) {
|
---|
| 619 | case WIN_BUTTON:
|
---|
| 620 | #if 0
|
---|
| 621 | if(style & WINBS_LEFTTEXT)
|
---|
[265] | 622 | os2style |= ; //not supported
|
---|
[4] | 623 | #endif
|
---|
| 624 | style &= 0xF;
|
---|
| 625 | //BS_TEXT, BS_BITMAP, BS_ICON, BS_MINIICON can only be used with BS_PUSHBUTTON
|
---|
| 626 | *os2class = (int)WC_BUTTON & 0xFFFF;
|
---|
| 627 | if(style == WINBS_PUSHBUTTON)
|
---|
| 628 | os2style |= BS_PUSHBUTTON;
|
---|
| 629 | else
|
---|
| 630 | if(style == WINBS_DEFPUSHBUTTON)
|
---|
| 631 | os2style |= (BS_PUSHBUTTON | BS_DEFAULT); //TODO: Correct?
|
---|
| 632 | else
|
---|
| 633 | if(style == WINBS_CHECKBOX)
|
---|
| 634 | os2style |= BS_CHECKBOX;
|
---|
| 635 | else
|
---|
| 636 | if(style == WINBS_AUTOCHECKBOX)
|
---|
| 637 | os2style |= BS_AUTOCHECKBOX;
|
---|
| 638 | else
|
---|
| 639 | if(style == WINBS_RADIOBUTTON)
|
---|
| 640 | os2style |= BS_RADIOBUTTON;
|
---|
| 641 | else
|
---|
| 642 | if(style == WINBS_3STATE)
|
---|
| 643 | os2style |= BS_3STATE;
|
---|
| 644 | else
|
---|
| 645 | if(style == WINBS_AUTO3STATE)
|
---|
| 646 | os2style |= BS_AUTO3STATE;
|
---|
| 647 | else
|
---|
| 648 | if(style == WINBS_USERBUTTON) //obsolete
|
---|
| 649 | os2style |= BS_USERBUTTON;
|
---|
| 650 | else
|
---|
| 651 | if(style == WINBS_AUTORADIOBUTTON)
|
---|
| 652 | os2style |= BS_AUTORADIOBUTTON;
|
---|
| 653 | else
|
---|
| 654 | if(style == WINBS_GROUPBOX) {
|
---|
| 655 | *os2class = (int)WC_STATIC & 0xFFFF; /*PLF Sat 97-09-20 23:58:28*/
|
---|
| 656 | os2style |= SS_GROUPBOX; /*PLF Sun 97-09-21 00:11:07*/
|
---|
| 657 | }
|
---|
| 658 | else
|
---|
| 659 | if(style & WINBS_OWNERDRAW)
|
---|
| 660 | os2style |= BS_USERBUTTON; //TODO:Correct??
|
---|
| 661 | else os2style |= (BS_TEXT | BS_PUSHBUTTON);
|
---|
| 662 | os2style |= BS_AUTOSIZE;
|
---|
| 663 | break;
|
---|
| 664 |
|
---|
| 665 | case WIN_EDIT:
|
---|
| 666 | /* @@@PH 98/06/13: other styles might require a MLE-class control ! */
|
---|
| 667 | /* please note this is experimental since MLE might behave different from */
|
---|
| 668 | /* the standard EF-control, maybe we'll have to build an own MLE therefore*/
|
---|
| 669 |
|
---|
| 670 | if (style & WINES_MULTILINE)
|
---|
| 671 | {
|
---|
| 672 | *os2class = (int)WC_MLE & 0xFFFF;
|
---|
| 673 |
|
---|
| 674 | os2style |= MLS_BORDER | MLS_WORDWRAP;
|
---|
| 675 |
|
---|
| 676 | //if(style & WINES_MULTILINE) os2style |= ;
|
---|
| 677 | //if(style & WINES_UPPERCASE) os2style |= ;
|
---|
| 678 | //if(style & WINES_LOWERCASE) os2style |= ;
|
---|
| 679 | if(style & WINES_AUTOVSCROLL) os2style |= MLS_VSCROLL;
|
---|
| 680 | //if(style & WINES_NOHIDESEL) os2style |= ;
|
---|
| 681 | //if(style & WINES_OEMCONVERT) os2style |= ;
|
---|
| 682 | //if(style & WINES_WANTRETURN) os2style |= ;
|
---|
| 683 | //if(style & WINES_LEFT) os2style |= ES_LEFT;
|
---|
| 684 | //if(style & WINES_CENTER) os2style |= ES_CENTER;
|
---|
| 685 | //if(style & WINES_RIGHT) os2style |= ES_RIGHT;
|
---|
| 686 | if(style & WINES_AUTOHSCROLL) os2style |= MLS_HSCROLL;
|
---|
| 687 | if(style & WINES_READONLY) os2style |= MLS_READONLY;
|
---|
| 688 | //if(style & WINES_PASSWORD) os2style |= ES_UNREADABLE;
|
---|
| 689 | }
|
---|
| 690 | else
|
---|
| 691 | {
|
---|
| 692 | *os2class = (int)WC_ENTRYFIELD & 0xFFFF;
|
---|
| 693 | if(style & WINES_LEFT) os2style |= ES_LEFT;
|
---|
| 694 | if(style & WINES_CENTER) os2style |= ES_CENTER;
|
---|
| 695 | if(style & WINES_RIGHT) os2style |= ES_RIGHT;
|
---|
| 696 | if(style & WINES_AUTOHSCROLL) os2style |= ES_AUTOSCROLL;
|
---|
| 697 | if(style & WINES_READONLY) os2style |= ES_READONLY;
|
---|
| 698 | if(style & WINES_PASSWORD) os2style |= ES_UNREADABLE;
|
---|
[141] | 699 | if(style & WINWS_BORDER) os2style |= ES_MARGIN;
|
---|
| 700 |
|
---|
[4] | 701 | }
|
---|
| 702 | break;
|
---|
| 703 |
|
---|
| 704 | case WIN_STATIC:
|
---|
[141] | 705 | style &= 0xFFFF;
|
---|
[4] | 706 | *os2class = (int)WC_STATIC & 0xFFFF;
|
---|
| 707 | if(style == WINSS_LEFT)
|
---|
| 708 | os2style |= SS_TEXT | DT_LEFT;
|
---|
| 709 | else
|
---|
| 710 | if(style == WINSS_CENTER)
|
---|
| 711 | os2style |= SS_TEXT | DT_CENTER;
|
---|
| 712 | else
|
---|
| 713 | if(style == WINSS_RIGHT)
|
---|
| 714 | os2style |= SS_TEXT | DT_RIGHT;
|
---|
| 715 | else
|
---|
| 716 | if(style == WINSS_SIMPLE)
|
---|
| 717 | os2style |= SS_TEXT | DT_LEFT;
|
---|
| 718 | else
|
---|
| 719 | if(style == WINSS_ICON) {
|
---|
| 720 | os2style |= SS_ICON;
|
---|
| 721 | *fIconBmp = TRUE;
|
---|
| 722 | }
|
---|
| 723 | else
|
---|
| 724 | if(style == WINSS_BLACKRECT)
|
---|
| 725 | os2style |= SS_FGNDRECT;
|
---|
| 726 | else
|
---|
| 727 | if(style == WINSS_GRAYRECT)
|
---|
| 728 | os2style |= SS_HALFTONERECT;
|
---|
| 729 | else
|
---|
| 730 | if(style == WINSS_WHITERECT)
|
---|
| 731 | os2style |= SS_BKGNDRECT;
|
---|
| 732 | else
|
---|
| 733 | if(style == WINSS_BLACKFRAME)
|
---|
| 734 | os2style |= SS_FGNDFRAME;
|
---|
| 735 | else
|
---|
| 736 | if(style == WINSS_GRAYFRAME)
|
---|
| 737 | os2style |= SS_HALFTONEFRAME;
|
---|
| 738 | else
|
---|
| 739 | if(style == WINSS_WHITEFRAME)
|
---|
| 740 | os2style |= SS_BKGNDFRAME;
|
---|
| 741 | else os2style |= SS_TEXT;
|
---|
| 742 |
|
---|
| 743 | //TODO
|
---|
| 744 | #if 0
|
---|
| 745 | if(style == WINSS_LEFTNOWORDWRAP)
|
---|
| 746 | os2style |= ;
|
---|
| 747 | if(style == WINSS_USERITEM)
|
---|
| 748 | os2style |= ;
|
---|
| 749 | if(style == WINSS_NOPREFIX)
|
---|
| 750 | os2style |= ;
|
---|
| 751 | #endif
|
---|
| 752 | break;
|
---|
| 753 | case WIN_LISTBOX:
|
---|
| 754 | *os2class = (int)WC_LISTBOX & 0xFFFF;
|
---|
| 755 | #if 0
|
---|
| 756 | if(style & WINLBS_NOTIFY)
|
---|
| 757 | os2style |= ;
|
---|
| 758 | if(style & WINLBS_SORT)
|
---|
| 759 | os2style |= ;
|
---|
| 760 | if(style & WINLBS_NOREDRAW)
|
---|
| 761 | os2style |= ;
|
---|
| 762 | #endif
|
---|
| 763 | if(style & WINLBS_MULTIPLESEL)
|
---|
| 764 | os2style |= LS_MULTIPLESEL;
|
---|
| 765 | if(style & WINLBS_OWNERDRAWFIXED)
|
---|
| 766 | os2style |= LS_OWNERDRAW; //TODO: Correct?
|
---|
| 767 | if(style & WINLBS_OWNERDRAWVARIABLE)
|
---|
| 768 | os2style |= LS_OWNERDRAW; //TODO: Correct?
|
---|
| 769 | #if 0
|
---|
| 770 | if(style & WINLBS_HASSTRINGS)
|
---|
| 771 | os2style |= ;
|
---|
| 772 | if(style & WINLBS_USETABSTOPS)
|
---|
| 773 | os2style |= ;
|
---|
| 774 | if(style & WINLBS_NOINTEGRALHEIGHT)
|
---|
| 775 | os2style |= ;
|
---|
| 776 | if(style & WINLBS_MULTICOLUMN)
|
---|
| 777 | os2style |= ;
|
---|
| 778 | if(style & WINLBS_WANTKEYBOARDINPUT)
|
---|
| 779 | os2style |= ;
|
---|
| 780 | if(style & WINLBS_EXTENDEDSEL)
|
---|
| 781 | os2style |= LS_EXTENDEDSEL;
|
---|
| 782 | if(style & WINLBS_DISABLENOSCROLL)
|
---|
| 783 | os2style |= ;
|
---|
| 784 | #endif
|
---|
| 785 | // if(style & WINLBS_NODATA)
|
---|
| 786 | // os2style |= ;
|
---|
| 787 | break;
|
---|
| 788 |
|
---|
| 789 | case WIN_SCROLLBAR:
|
---|
| 790 | *os2class = (int)WC_SCROLLBAR & 0xFFFF;
|
---|
| 791 |
|
---|
| 792 | if(style & WINSBS_HORZ) os2style |= SBS_HORZ;
|
---|
| 793 | else
|
---|
| 794 | if(style & WINSBS_VERT) os2style |= SBS_VERT;
|
---|
| 795 |
|
---|
| 796 | //if(style & WINSBS_TOPALIGN) os2style |= ;
|
---|
| 797 | //if(style & WINSBS_LEFTALIGN) os2style |= ;
|
---|
| 798 | //if(style & WINSBS_BOTTOMALIGN) os2style |= ;
|
---|
| 799 | //if(style & WINSBS_RIGHTALIGN) os2style |= ;
|
---|
| 800 | //if(style & WINSBS_SIZEBOXTOPLEFTALIGN) os2style |= ;
|
---|
| 801 | //if(style & WINSBS_SIZEBOXBOTTOMRIGHTALIGN) os2style |= ;
|
---|
| 802 |
|
---|
| 803 | if(style & WINSBS_SIZEBOX) os2style |= SBS_AUTOSIZE; //TODO: Correct?
|
---|
| 804 | break;
|
---|
| 805 |
|
---|
| 806 | case WIN_COMBOBOX:
|
---|
| 807 | *os2class = (int)WC_COMBOBOX & 0xFFFF;
|
---|
| 808 |
|
---|
| 809 | /* @@@PH 98/06/13 corrected style translation */
|
---|
| 810 | switch (style & 0x00000003)
|
---|
| 811 | {
|
---|
| 812 | case WINCBS_SIMPLE: os2style |= CBS_SIMPLE; break;
|
---|
| 813 | case WINCBS_DROPDOWN: os2style |= CBS_DROPDOWN; break;
|
---|
| 814 | case WINCBS_DROPDOWNLIST: os2style |= CBS_DROPDOWNLIST; break;
|
---|
| 815 | default: os2style |= CBS_SIMPLE; break;
|
---|
| 816 | }
|
---|
| 817 |
|
---|
| 818 | //if(style & WINCBS_OWNERDRAWFIXED) os2style |= ;
|
---|
| 819 | //if(style & WINCBS_OWNERDRAWVARIABLE) os2style |= ;
|
---|
| 820 | //if(style & WINCBS_AUTOHSCROLL) os2style |= ;
|
---|
| 821 | //if(style & WINCBS_OEMCONVERT) os2style |= ;
|
---|
| 822 | //if(style & WINCBS_SORT) os2style |= ;
|
---|
| 823 | //if(style & WINCBS_HASSTRINGS ) os2style |= ;
|
---|
| 824 | //if(style & WINCBS_NOINTEGRALHEIGHT) os2style |= ;
|
---|
| 825 | //if(style & WINCBS_DISABLENOSCROLL) os2style |= ;
|
---|
| 826 | break;
|
---|
| 827 |
|
---|
| 828 | default:
|
---|
| 829 | //SvL: 9nov97 Special class control. Just copy style
|
---|
| 830 | os2style = style;
|
---|
| 831 | break;
|
---|
| 832 | }
|
---|
| 833 | return(os2style);
|
---|
| 834 | }
|
---|
| 835 |
|
---|
| 836 | //******************************************************************************
|
---|
| 837 | //******************************************************************************
|
---|
| 838 | static int ConvertDlgStyle(int style)
|
---|
| 839 | {
|
---|
| 840 | int os2style = 0;
|
---|
| 841 |
|
---|
| 842 | /// if(style & WINWS_POPUP)
|
---|
| 843 | /// os2style |=
|
---|
| 844 | /// if(style & WINWS_CHILD)
|
---|
| 845 | /// os2style |=
|
---|
| 846 | if(style & WINWS_MINIMIZE)
|
---|
| 847 | os2style |= WS_MINIMIZED;
|
---|
| 848 | if(style & WINWS_MAXIMIZE)
|
---|
| 849 | os2style |= WS_MAXIMIZED;
|
---|
| 850 | if(style & WINWS_VISIBLE)
|
---|
| 851 | os2style |= WS_VISIBLE;
|
---|
| 852 | if(style & WINWS_DISABLED)
|
---|
| 853 | os2style |= WS_DISABLED;
|
---|
| 854 | if(style & WINWS_CLIPSIBLINGS)
|
---|
| 855 | os2style |= WS_CLIPSIBLINGS;
|
---|
| 856 | if(style & WINWS_CLIPCHILDREN)
|
---|
| 857 | os2style |= WS_CLIPCHILDREN;
|
---|
| 858 | if(style & WINWS_TABSTOP)
|
---|
| 859 | os2style |= WS_TABSTOP;
|
---|
| 860 |
|
---|
| 861 | return(os2style);
|
---|
| 862 | }
|
---|
| 863 | //******************************************************************************
|
---|
| 864 | //******************************************************************************
|
---|
| 865 | static int ConvertDlgItemStyle(int style)
|
---|
| 866 | {
|
---|
| 867 | int os2style = 0;
|
---|
| 868 |
|
---|
| 869 | if(style & WINWS_VISIBLE)
|
---|
| 870 | os2style |= WS_VISIBLE;
|
---|
| 871 | if(style & WINWS_DISABLED)
|
---|
| 872 | os2style |= WS_DISABLED;
|
---|
| 873 | if(style & WINWS_CLIPSIBLINGS)
|
---|
| 874 | os2style |= WS_CLIPSIBLINGS;
|
---|
| 875 | if(style & WINWS_CLIPCHILDREN)
|
---|
| 876 | os2style |= WS_CLIPCHILDREN;
|
---|
| 877 | if(style & WINWS_TABSTOP)
|
---|
| 878 | os2style |= WS_TABSTOP;
|
---|
| 879 | if(style & WINWS_GROUP)
|
---|
| 880 | os2style |= WS_GROUP;
|
---|
| 881 |
|
---|
| 882 | return(os2style);
|
---|
| 883 | }
|
---|
| 884 | //******************************************************************************
|
---|
| 885 | //******************************************************************************
|
---|
| 886 | static void ConvertCaption(ULONG style, char *caption)
|
---|
| 887 | {
|
---|
| 888 | char os2caption[512];
|
---|
| 889 | int i, len = strlen(caption), j;
|
---|
| 890 |
|
---|
| 891 | switch(style) {
|
---|
| 892 | case WIN_BUTTON:
|
---|
| 893 | case WIN_EDIT:
|
---|
| 894 | case WIN_LISTBOX:
|
---|
| 895 | case WIN_SCROLLBAR:
|
---|
| 896 | case WIN_COMBOBOX:
|
---|
| 897 | for(i=0;i<len;i++) {
|
---|
| 898 | if(caption[i] == '&') caption[i] = '~';
|
---|
| 899 | }
|
---|
| 900 | break;
|
---|
| 901 | case WIN_STATIC:
|
---|
| 902 | j = 0;
|
---|
| 903 | for(i=0;i<=len;i++) {
|
---|
| 904 | if(caption[i] != '&') os2caption[j++] = caption[i];
|
---|
| 905 | }
|
---|
| 906 | strcpy(caption, os2caption);
|
---|
| 907 | break;
|
---|
| 908 | }
|
---|
| 909 | }
|
---|
| 910 | //******************************************************************************
|
---|
| 911 | //******************************************************************************
|
---|
| 912 | static int ConvertFont(char *font, PRESPARAMS *dlgpparam, int fsize)
|
---|
| 913 | {
|
---|
| 914 | #if 0
|
---|
| 915 | // if(strcmp(font, "MS SHELL DLG") == 0) {
|
---|
| 916 | sprintf(dlgpparam->aparam[0].ab, "%d.", fsize);
|
---|
| 917 | // strcat(dlgpparam->aparam[0].ab, font);
|
---|
| 918 | strcat(dlgpparam->aparam[0].ab, "Helv");
|
---|
| 919 | return(TRUE);
|
---|
| 920 | // }
|
---|
| 921 | // else TODO: More fonts!!!
|
---|
[265] | 922 | // "MS Sans Serif"
|
---|
[4] | 923 | // return(FALSE); //not found
|
---|
| 924 | #else
|
---|
| 925 | return(FALSE);
|
---|
| 926 | #endif
|
---|
| 927 | }
|
---|
| 928 | //******************************************************************************
|
---|
| 929 | //******************************************************************************
|
---|