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