| [181] | 1 |  | 
|---|
|  | 2 | /*********************************************************************** | 
|---|
|  | 3 |  | 
|---|
|  | 4 | $Id: input.c 574 2007-03-23 22:37:07Z gyoung $ | 
|---|
|  | 5 |  | 
|---|
|  | 6 | Input dialog procecedure | 
|---|
|  | 7 |  | 
|---|
|  | 8 | Copyright (c) 1993-98 M. Kimes | 
|---|
| [574] | 9 | Copyright (c) 2005, 2007 Steven H. Levine | 
|---|
| [181] | 10 |  | 
|---|
|  | 11 | 28 May 05 SHL Use saymsg | 
|---|
| [342] | 12 | 14 Jul 06 SHL Use Runtime_Error | 
|---|
| [574] | 13 | 22 Mar 07 GKY Use QWL_USER | 
|---|
| [181] | 14 |  | 
|---|
|  | 15 | ***********************************************************************/ | 
|---|
|  | 16 |  | 
|---|
| [2] | 17 | #define INCL_DOS | 
|---|
|  | 18 | #define INCL_WIN | 
|---|
| [181] | 19 | #include <os2.h> | 
|---|
| [2] | 20 |  | 
|---|
|  | 21 | #include <stdlib.h> | 
|---|
|  | 22 | #include <stdio.h> | 
|---|
|  | 23 | #include <string.h> | 
|---|
| [181] | 24 |  | 
|---|
| [2] | 25 | #include "fm3dll.h" | 
|---|
|  | 26 | #include "fm3dlg.h" | 
|---|
|  | 27 | #include "fm3str.h" | 
|---|
|  | 28 |  | 
|---|
| [343] | 29 | static PSZ pszSrcFile = __FILE__; | 
|---|
|  | 30 |  | 
|---|
| [2] | 31 | #pragma alloc_text(FMINPUT,InputDlgProc) | 
|---|
|  | 32 |  | 
|---|
| [551] | 33 | MRESULT EXPENTRY InputDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| [181] | 34 | { | 
|---|
|  | 35 | // mp2 points at a structure of type STRINGINPARMS | 
|---|
|  | 36 | STRINGINPARMS *psip; | 
|---|
|  | 37 | PSZ psz; | 
|---|
| [2] | 38 |  | 
|---|
| [551] | 39 | switch (msg) { | 
|---|
|  | 40 | case WM_INITDLG: | 
|---|
|  | 41 | if (!mp2) { | 
|---|
|  | 42 | Runtime_Error(pszSrcFile, __LINE__, "no data"); | 
|---|
|  | 43 | WinDismissDlg(hwnd, 0); | 
|---|
| [2] | 44 | break; | 
|---|
| [551] | 45 | } | 
|---|
|  | 46 | WinSetWindowPtr(hwnd, 0, (PVOID) mp2); | 
|---|
|  | 47 | psip = (STRINGINPARMS *) mp2; | 
|---|
|  | 48 | if (!WinSendDlgItemMsg(hwnd, STR_INPUT, EM_SETTEXTLIMIT, | 
|---|
|  | 49 | MPFROM2SHORT(psip->inputlen, 0), MPVOID)) { | 
|---|
|  | 50 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "setlimit failed"); | 
|---|
|  | 51 | WinDismissDlg(hwnd, 0); | 
|---|
|  | 52 | break; | 
|---|
|  | 53 | } | 
|---|
|  | 54 | if (psip->prompt && *psip->prompt) | 
|---|
|  | 55 | WinSetDlgItemText(hwnd, STR_PROMPT, psip->prompt); | 
|---|
|  | 56 | if (psip->ret && *psip->ret) { | 
|---|
|  | 57 | WinSetDlgItemText(hwnd, STR_INPUT, psip->ret); | 
|---|
|  | 58 | WinSendDlgItemMsg(hwnd, STR_INPUT, EM_SETSEL, | 
|---|
|  | 59 | MPFROM2SHORT(0, strlen(psip->ret)), MPVOID); | 
|---|
|  | 60 | } | 
|---|
|  | 61 | *psip->ret = 0; | 
|---|
|  | 62 | if (psip->title && *psip->title) | 
|---|
|  | 63 | WinSetWindowText(hwnd, psip->title); | 
|---|
|  | 64 | break; | 
|---|
| [2] | 65 |  | 
|---|
| [551] | 66 | case WM_CONTROL:                      // don't care | 
|---|
|  | 67 | return 0; | 
|---|
| [2] | 68 |  | 
|---|
| [551] | 69 | case WM_COMMAND: | 
|---|
|  | 70 | switch (SHORT1FROMMP(mp1)) { | 
|---|
|  | 71 | case DID_OK: | 
|---|
| [574] | 72 | psip = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| [551] | 73 | WinQueryDlgItemText(hwnd, STR_INPUT, psip->inputlen, psip->ret); | 
|---|
|  | 74 | WinDismissDlg(hwnd, 1); | 
|---|
|  | 75 | break; | 
|---|
| [2] | 76 |  | 
|---|
| [551] | 77 | case IDM_HELP: | 
|---|
| [574] | 78 | psip = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| [551] | 79 | psz = psip->help && *psip->help ? | 
|---|
|  | 80 | psip->help : GetPString(IDS_ENTERTEXTHELPTEXT); | 
|---|
| [2] | 81 |  | 
|---|
| [551] | 82 | saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, GetPString(IDS_HELPTEXT), psz); | 
|---|
|  | 83 | break; | 
|---|
| [181] | 84 |  | 
|---|
| [551] | 85 | case DID_CANCEL: | 
|---|
|  | 86 | WinDismissDlg(hwnd, 0); | 
|---|
|  | 87 | break; | 
|---|
|  | 88 | } | 
|---|
|  | 89 | return 0; | 
|---|
| [2] | 90 | } | 
|---|
| [551] | 91 | return WinDefDlgProc(hwnd, msg, mp1, mp2); | 
|---|
| [2] | 92 | } | 
|---|