[181] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: input.c 1498 2010-01-18 00:57:01Z gyoung $
|
---|
| 5 |
|
---|
| 6 | Input dialog procecedure
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1498] | 9 | Copyright (c) 2005, 2010 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
|
---|
[1498] | 15 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
|
---|
[181] | 16 |
|
---|
| 17 | ***********************************************************************/
|
---|
| 18 |
|
---|
[907] | 19 | #include <string.h>
|
---|
| 20 |
|
---|
[2] | 21 | #define INCL_DOS
|
---|
| 22 | #define INCL_WIN
|
---|
[907] | 23 | #define INCL_LONGLONG // dircnrs.h
|
---|
[2] | 24 |
|
---|
[1224] | 25 | #include "fm3dll.h"
|
---|
| 26 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
| 27 | #include "input.h"
|
---|
[2] | 28 | #include "fm3dlg.h"
|
---|
| 29 | #include "fm3str.h"
|
---|
[907] | 30 | #include "errutil.h" // Dos_Error...
|
---|
| 31 | #include "strutil.h" // GetPString
|
---|
| 32 | #include "fm3dll.h"
|
---|
[2] | 33 |
|
---|
[343] | 34 | static PSZ pszSrcFile = __FILE__;
|
---|
| 35 |
|
---|
[551] | 36 | MRESULT EXPENTRY InputDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[181] | 37 | {
|
---|
| 38 | // mp2 points at a structure of type STRINGINPARMS
|
---|
| 39 | STRINGINPARMS *psip;
|
---|
[1394] | 40 | PCSZ psz;
|
---|
[2] | 41 |
|
---|
[551] | 42 | switch (msg) {
|
---|
| 43 | case WM_INITDLG:
|
---|
| 44 | if (!mp2) {
|
---|
[1398] | 45 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
[551] | 46 | WinDismissDlg(hwnd, 0);
|
---|
[2] | 47 | break;
|
---|
[551] | 48 | }
|
---|
| 49 | WinSetWindowPtr(hwnd, 0, (PVOID) mp2);
|
---|
| 50 | psip = (STRINGINPARMS *) mp2;
|
---|
| 51 | if (!WinSendDlgItemMsg(hwnd, STR_INPUT, EM_SETTEXTLIMIT,
|
---|
| 52 | MPFROM2SHORT(psip->inputlen, 0), MPVOID)) {
|
---|
| 53 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "setlimit failed");
|
---|
| 54 | WinDismissDlg(hwnd, 0);
|
---|
| 55 | break;
|
---|
| 56 | }
|
---|
| 57 | if (psip->prompt && *psip->prompt)
|
---|
[1498] | 58 | WinSetDlgItemText(hwnd, STR_PROMPT, (CHAR *) psip->prompt);
|
---|
[551] | 59 | if (psip->ret && *psip->ret) {
|
---|
| 60 | WinSetDlgItemText(hwnd, STR_INPUT, psip->ret);
|
---|
| 61 | WinSendDlgItemMsg(hwnd, STR_INPUT, EM_SETSEL,
|
---|
| 62 | MPFROM2SHORT(0, strlen(psip->ret)), MPVOID);
|
---|
| 63 | }
|
---|
| 64 | *psip->ret = 0;
|
---|
| 65 | if (psip->title && *psip->title)
|
---|
[1498] | 66 | WinSetWindowText(hwnd, (CHAR *) psip->title);
|
---|
[551] | 67 | break;
|
---|
[2] | 68 |
|
---|
[551] | 69 | case WM_CONTROL: // don't care
|
---|
| 70 | return 0;
|
---|
[2] | 71 |
|
---|
[551] | 72 | case WM_COMMAND:
|
---|
| 73 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 74 | case DID_OK:
|
---|
[574] | 75 | psip = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 76 | WinQueryDlgItemText(hwnd, STR_INPUT, psip->inputlen, psip->ret);
|
---|
| 77 | WinDismissDlg(hwnd, 1);
|
---|
| 78 | break;
|
---|
[2] | 79 |
|
---|
[551] | 80 | case IDM_HELP:
|
---|
[574] | 81 | psip = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 82 | psz = psip->help && *psip->help ?
|
---|
| 83 | psip->help : GetPString(IDS_ENTERTEXTHELPTEXT);
|
---|
[2] | 84 |
|
---|
[551] | 85 | saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, GetPString(IDS_HELPTEXT), psz);
|
---|
| 86 | break;
|
---|
[181] | 87 |
|
---|
[551] | 88 | case DID_CANCEL:
|
---|
| 89 | WinDismissDlg(hwnd, 0);
|
---|
| 90 | break;
|
---|
| 91 | }
|
---|
| 92 | return 0;
|
---|
[2] | 93 | }
|
---|
[551] | 94 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 95 | }
|
---|
[793] | 96 |
|
---|
| 97 | #pragma alloc_text(FMINPUT,InputDlgProc)
|
---|