| 1 | /* $Id: dialog.cpp,v 1.1 1999-05-24 20:19:59 ktk Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Win32 dialog API functions for OS/2
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1998 Sander van Leeuwen
|
|---|
| 7 | *
|
|---|
| 8 | *
|
|---|
| 9 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 10 | *
|
|---|
| 11 | */
|
|---|
| 12 | #include <os2win.h>
|
|---|
| 13 | #include <nameid.h>
|
|---|
| 14 | #include "user32.h"
|
|---|
| 15 | #include "wndproc.h"
|
|---|
| 16 | #include "wndsubproc.h"
|
|---|
| 17 | #include "wndclass.h"
|
|---|
| 18 | #include "dlgconvert.h"
|
|---|
| 19 |
|
|---|
| 20 | //TODO: dlgproc == NULL
|
|---|
| 21 | //******************************************************************************
|
|---|
| 22 | //******************************************************************************
|
|---|
| 23 | HWND WIN32API CreateDialogParamA(HINSTANCE hinst, LPCSTR lpszTemplate,
|
|---|
| 24 | HWND hwndOwner, DLGPROC dlgproc,
|
|---|
| 25 | LPARAM lParamInit)
|
|---|
| 26 | {
|
|---|
| 27 | HWND rc;
|
|---|
| 28 | Win32WindowProc *dialog = NULL;
|
|---|
| 29 |
|
|---|
| 30 | if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
|
|---|
| 31 | #ifdef DEBUG
|
|---|
| 32 | WriteLog("OS2CreateDialogParamA %s\n", lpszTemplate);
|
|---|
| 33 | #endif
|
|---|
| 34 | lpszTemplate = (LPCSTR)ConvertNameId(hinst, (char *)lpszTemplate);
|
|---|
| 35 | }
|
|---|
| 36 | #ifdef DEBUG
|
|---|
| 37 | else WriteLog("OS2CreateDialogParamA %d\n", (int)lpszTemplate);
|
|---|
| 38 | #endif
|
|---|
| 39 |
|
|---|
| 40 | if(dlgproc) {
|
|---|
| 41 | dialog = new Win32WindowProc((WNDPROC)dlgproc);
|
|---|
| 42 | rc = O32_CreateDialogParam(hinst, lpszTemplate, hwndOwner, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
|---|
| 43 | }
|
|---|
| 44 | else rc = O32_CreateDialogParam(hinst, lpszTemplate, hwndOwner, (DLGPROC_O32)O32_DefDlgProc, lParamInit);
|
|---|
| 45 |
|
|---|
| 46 | if(rc == 0 && dialog) {
|
|---|
| 47 | delete(dialog);
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | #ifdef DEBUG
|
|---|
| 51 | WriteLog("CreateDialogParamA %X %X %d returned %X (%d)\n", hinst, hwndOwner, lParamInit, rc, GetLastError());
|
|---|
| 52 | #endif
|
|---|
| 53 | return(rc);
|
|---|
| 54 | }
|
|---|
| 55 | //******************************************************************************
|
|---|
| 56 | //******************************************************************************
|
|---|
| 57 | HWND WIN32API CreateDialogParamW(HINSTANCE hinst, LPCWSTR lpszTemplate,
|
|---|
| 58 | HWND hwndOwner, DLGPROC dlgproc,
|
|---|
| 59 | LPARAM lParamInit)
|
|---|
| 60 | {
|
|---|
| 61 | HWND rc;
|
|---|
| 62 |
|
|---|
| 63 | if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
|
|---|
| 64 | char *astring = UnicodeToAsciiString((LPWSTR)lpszTemplate);
|
|---|
| 65 | #ifdef DEBUG
|
|---|
| 66 | WriteLog("OS2CreateDialogParamW %s\n", astring);
|
|---|
| 67 | #endif
|
|---|
| 68 | lpszTemplate = (LPWSTR)ConvertNameId(hinst, astring);
|
|---|
| 69 | FreeAsciiString(astring);
|
|---|
| 70 | }
|
|---|
| 71 | #ifdef DEBUG
|
|---|
| 72 | else WriteLog("OS2CreateDialogParamW %d\n", (int)lpszTemplate);
|
|---|
| 73 | #endif
|
|---|
| 74 |
|
|---|
| 75 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc);
|
|---|
| 76 |
|
|---|
| 77 | rc = O32_CreateDialogParam(hinst, (LPCSTR)lpszTemplate, hwndOwner, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
|---|
| 78 | if(rc == 0) {
|
|---|
| 79 | delete(dialog);
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | #ifdef DEBUG
|
|---|
| 83 | WriteLog("CreateDialogParamW returned %X\n", rc);
|
|---|
| 84 | #endif
|
|---|
| 85 | return(rc);
|
|---|
| 86 | }
|
|---|
| 87 | //******************************************************************************
|
|---|
| 88 | //******************************************************************************
|
|---|
| 89 | HWND WIN32API CreateDialogIndirectParamA(HINSTANCE hinst,
|
|---|
| 90 | DLGTEMPLATE *dlgtemplate,
|
|---|
| 91 | HWND hwndParent, DLGPROC dlgproc,
|
|---|
| 92 | LPARAM lParamInit)
|
|---|
| 93 | {
|
|---|
| 94 | HWND hwnd;
|
|---|
| 95 | DLGTEMPLATE *os2dlg;
|
|---|
| 96 |
|
|---|
| 97 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
|---|
| 98 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
|---|
| 99 |
|
|---|
| 100 | hwnd = O32_CreateDialogIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
|---|
| 101 | if(hwnd == 0) {
|
|---|
| 102 | delete(dialog);
|
|---|
| 103 | }
|
|---|
| 104 | #ifdef DEBUG
|
|---|
| 105 | WriteLog("CreateDialogIndirectParamA returned %X\n", hwnd);
|
|---|
| 106 | #endif
|
|---|
| 107 | return(hwnd);
|
|---|
| 108 | }
|
|---|
| 109 | //******************************************************************************
|
|---|
| 110 | //******************************************************************************
|
|---|
| 111 | HWND WIN32API CreateDialogIndirectParamW(HINSTANCE hinst,
|
|---|
| 112 | DLGTEMPLATE *dlgtemplate,
|
|---|
| 113 | HWND hwndParent, DLGPROC dlgproc,
|
|---|
| 114 | LPARAM lParamInit)
|
|---|
| 115 | {
|
|---|
| 116 | HWND hwnd;
|
|---|
| 117 | DLGTEMPLATE *os2dlg;
|
|---|
| 118 |
|
|---|
| 119 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
|---|
| 120 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
|---|
| 121 |
|
|---|
| 122 | hwnd = O32_CreateDialogIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
|---|
| 123 | if(hwnd == 0) {
|
|---|
| 124 | delete(dialog);
|
|---|
| 125 | }
|
|---|
| 126 | dprintf(("CreateDialogIndirectParamW returned %X\n", hwnd));
|
|---|
| 127 | return(hwnd);
|
|---|
| 128 | }
|
|---|
| 129 | //******************************************************************************
|
|---|
| 130 | //******************************************************************************
|
|---|
| 131 | BOOL WIN32API DialogBoxIndirectParamA(HINSTANCE hinst,
|
|---|
| 132 | DLGTEMPLATE *dlgtemplate,
|
|---|
| 133 | HWND hwndParent, DLGPROC dlgproc,
|
|---|
| 134 | LPARAM lParamInit)
|
|---|
| 135 | {
|
|---|
| 136 | BOOL rc;
|
|---|
| 137 | DLGTEMPLATE *os2dlg;
|
|---|
| 138 |
|
|---|
| 139 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
|---|
| 140 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
|---|
| 141 |
|
|---|
| 142 | rc = O32_DialogBoxIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
|---|
| 143 | //dialog already destroyed when this returns
|
|---|
| 144 | dprintf(("OS2DialogBoxIndirectParamA returned %X\n", rc));
|
|---|
| 145 | return(rc);
|
|---|
| 146 | }
|
|---|
| 147 | //******************************************************************************
|
|---|
| 148 | //******************************************************************************
|
|---|
| 149 | BOOL WIN32API DialogBoxIndirectParamW(HINSTANCE hinst,
|
|---|
| 150 | DLGTEMPLATE *dlgtemplate,
|
|---|
| 151 | HWND hwndParent, DLGPROC dlgproc,
|
|---|
| 152 | LPARAM lParamInit)
|
|---|
| 153 | {
|
|---|
| 154 | BOOL rc;
|
|---|
| 155 | DLGTEMPLATE *os2dlg;
|
|---|
| 156 |
|
|---|
| 157 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
|---|
| 158 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
|---|
| 159 |
|
|---|
| 160 | rc = O32_DialogBoxIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
|---|
| 161 | //dialog already destroyed when this returns
|
|---|
| 162 | dprintf(("OS2DialogBoxIndirectParamW returned %d\n", rc));
|
|---|
| 163 | return(rc);
|
|---|
| 164 | }
|
|---|
| 165 | //******************************************************************************
|
|---|
| 166 | //******************************************************************************
|
|---|
| 167 | int WIN32API DialogBoxParamA(HINSTANCE hinst, LPCSTR lpszTemplate, HWND hwndOwner,
|
|---|
| 168 | DLGPROC dlgprc, LPARAM lParamInit)
|
|---|
| 169 | {
|
|---|
| 170 | int rc;
|
|---|
| 171 |
|
|---|
| 172 | if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
|
|---|
| 173 | dprintf(("DialogBoxParam %s\n", lpszTemplate));
|
|---|
| 174 | lpszTemplate = (LPCSTR)ConvertNameId(hinst, (char *)lpszTemplate);
|
|---|
| 175 | }
|
|---|
| 176 | else {
|
|---|
| 177 | dprintf(("DialogBoxParam %d\n", (int)lpszTemplate));
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgprc);
|
|---|
| 181 | rc = O32_DialogBoxParam(hinst, lpszTemplate, hwndOwner, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
|---|
| 182 |
|
|---|
| 183 | dprintf(("DialogBoxParam returned %d\n", rc));
|
|---|
| 184 | return(rc);
|
|---|
| 185 | }
|
|---|
| 186 | //******************************************************************************
|
|---|
| 187 | //******************************************************************************
|
|---|
| 188 | int WIN32API DialogBoxParamW(HINSTANCE arg1, LPCWSTR arg2, HWND arg3,
|
|---|
| 189 | DLGPROC arg4, LPARAM arg5)
|
|---|
| 190 | {
|
|---|
| 191 | int rc;
|
|---|
| 192 | char *astring = NULL;
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 | if((int)arg2 >> 16 != 0) {
|
|---|
| 196 | astring = UnicodeToAsciiString((LPWSTR)arg2);
|
|---|
| 197 | }
|
|---|
| 198 | else astring = (char *)arg2;
|
|---|
| 199 | dprintf(("OS2DialogBoxParamW\n"));
|
|---|
| 200 |
|
|---|
| 201 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)arg4);
|
|---|
| 202 | rc = DialogBoxParamA(arg1, astring, arg3, arg4, arg5);
|
|---|
| 203 |
|
|---|
| 204 | if((int)astring >> 16 != 0) FreeAsciiString(astring);
|
|---|
| 205 |
|
|---|
| 206 | dprintf(("OS2DialogBoxIndirectParamA returned %d\n", rc));
|
|---|
| 207 |
|
|---|
| 208 | return(rc);
|
|---|
| 209 | }
|
|---|
| 210 | //******************************************************************************
|
|---|
| 211 | //******************************************************************************
|
|---|
| 212 |
|
|---|