| [181] | 1 |  | 
|---|
|  | 2 | /*********************************************************************** | 
|---|
|  | 3 |  | 
|---|
|  | 4 | $Id: input.c 907 2008-01-06 07:26:17Z stevenhl $ | 
|---|
|  | 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 | 
|---|
| [793] | 14 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat | 
|---|
| [181] | 15 |  | 
|---|
|  | 16 | ***********************************************************************/ | 
|---|
|  | 17 |  | 
|---|
| [907] | 18 | #include <string.h> | 
|---|
|  | 19 |  | 
|---|
| [2] | 20 | #define INCL_DOS | 
|---|
|  | 21 | #define INCL_WIN | 
|---|
| [907] | 22 | #define INCL_LONGLONG                   // dircnrs.h | 
|---|
| [2] | 23 |  | 
|---|
|  | 24 | #include "fm3dlg.h" | 
|---|
|  | 25 | #include "fm3str.h" | 
|---|
| [907] | 26 | #include "errutil.h"                    // Dos_Error... | 
|---|
|  | 27 | #include "strutil.h"                    // GetPString | 
|---|
|  | 28 | #include "fm3dll.h" | 
|---|
| [2] | 29 |  | 
|---|
| [343] | 30 | static PSZ pszSrcFile = __FILE__; | 
|---|
|  | 31 |  | 
|---|
| [551] | 32 | MRESULT EXPENTRY InputDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| [181] | 33 | { | 
|---|
|  | 34 | // mp2 points at a structure of type STRINGINPARMS | 
|---|
|  | 35 | STRINGINPARMS *psip; | 
|---|
|  | 36 | PSZ psz; | 
|---|
| [2] | 37 |  | 
|---|
| [551] | 38 | switch (msg) { | 
|---|
|  | 39 | case WM_INITDLG: | 
|---|
|  | 40 | if (!mp2) { | 
|---|
|  | 41 | Runtime_Error(pszSrcFile, __LINE__, "no data"); | 
|---|
|  | 42 | WinDismissDlg(hwnd, 0); | 
|---|
| [2] | 43 | break; | 
|---|
| [551] | 44 | } | 
|---|
|  | 45 | WinSetWindowPtr(hwnd, 0, (PVOID) mp2); | 
|---|
|  | 46 | psip = (STRINGINPARMS *) mp2; | 
|---|
|  | 47 | if (!WinSendDlgItemMsg(hwnd, STR_INPUT, EM_SETTEXTLIMIT, | 
|---|
|  | 48 | MPFROM2SHORT(psip->inputlen, 0), MPVOID)) { | 
|---|
|  | 49 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "setlimit failed"); | 
|---|
|  | 50 | WinDismissDlg(hwnd, 0); | 
|---|
|  | 51 | break; | 
|---|
|  | 52 | } | 
|---|
|  | 53 | if (psip->prompt && *psip->prompt) | 
|---|
|  | 54 | WinSetDlgItemText(hwnd, STR_PROMPT, psip->prompt); | 
|---|
|  | 55 | if (psip->ret && *psip->ret) { | 
|---|
|  | 56 | WinSetDlgItemText(hwnd, STR_INPUT, psip->ret); | 
|---|
|  | 57 | WinSendDlgItemMsg(hwnd, STR_INPUT, EM_SETSEL, | 
|---|
|  | 58 | MPFROM2SHORT(0, strlen(psip->ret)), MPVOID); | 
|---|
|  | 59 | } | 
|---|
|  | 60 | *psip->ret = 0; | 
|---|
|  | 61 | if (psip->title && *psip->title) | 
|---|
|  | 62 | WinSetWindowText(hwnd, psip->title); | 
|---|
|  | 63 | break; | 
|---|
| [2] | 64 |  | 
|---|
| [551] | 65 | case WM_CONTROL:                      // don't care | 
|---|
|  | 66 | return 0; | 
|---|
| [2] | 67 |  | 
|---|
| [551] | 68 | case WM_COMMAND: | 
|---|
|  | 69 | switch (SHORT1FROMMP(mp1)) { | 
|---|
|  | 70 | case DID_OK: | 
|---|
| [574] | 71 | psip = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| [551] | 72 | WinQueryDlgItemText(hwnd, STR_INPUT, psip->inputlen, psip->ret); | 
|---|
|  | 73 | WinDismissDlg(hwnd, 1); | 
|---|
|  | 74 | break; | 
|---|
| [2] | 75 |  | 
|---|
| [551] | 76 | case IDM_HELP: | 
|---|
| [574] | 77 | psip = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| [551] | 78 | psz = psip->help && *psip->help ? | 
|---|
|  | 79 | psip->help : GetPString(IDS_ENTERTEXTHELPTEXT); | 
|---|
| [2] | 80 |  | 
|---|
| [551] | 81 | saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, GetPString(IDS_HELPTEXT), psz); | 
|---|
|  | 82 | break; | 
|---|
| [181] | 83 |  | 
|---|
| [551] | 84 | case DID_CANCEL: | 
|---|
|  | 85 | WinDismissDlg(hwnd, 0); | 
|---|
|  | 86 | break; | 
|---|
|  | 87 | } | 
|---|
|  | 88 | return 0; | 
|---|
| [2] | 89 | } | 
|---|
| [551] | 90 | return WinDefDlgProc(hwnd, msg, mp1, mp2); | 
|---|
| [2] | 91 | } | 
|---|
| [793] | 92 |  | 
|---|
|  | 93 | #pragma alloc_text(FMINPUT,InputDlgProc) | 
|---|