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
|
---|
9 | Copyright (c) 2005, 2007 Steven H. Levine
|
---|
10 |
|
---|
11 | 28 May 05 SHL Use saymsg
|
---|
12 | 14 Jul 06 SHL Use Runtime_Error
|
---|
13 | 22 Mar 07 GKY Use QWL_USER
|
---|
14 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
15 |
|
---|
16 | ***********************************************************************/
|
---|
17 |
|
---|
18 | #include <string.h>
|
---|
19 |
|
---|
20 | #define INCL_DOS
|
---|
21 | #define INCL_WIN
|
---|
22 | #define INCL_LONGLONG // dircnrs.h
|
---|
23 |
|
---|
24 | #include "fm3dlg.h"
|
---|
25 | #include "fm3str.h"
|
---|
26 | #include "errutil.h" // Dos_Error...
|
---|
27 | #include "strutil.h" // GetPString
|
---|
28 | #include "fm3dll.h"
|
---|
29 |
|
---|
30 | static PSZ pszSrcFile = __FILE__;
|
---|
31 |
|
---|
32 | MRESULT EXPENTRY InputDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
33 | {
|
---|
34 | // mp2 points at a structure of type STRINGINPARMS
|
---|
35 | STRINGINPARMS *psip;
|
---|
36 | PSZ psz;
|
---|
37 |
|
---|
38 | switch (msg) {
|
---|
39 | case WM_INITDLG:
|
---|
40 | if (!mp2) {
|
---|
41 | Runtime_Error(pszSrcFile, __LINE__, "no data");
|
---|
42 | WinDismissDlg(hwnd, 0);
|
---|
43 | break;
|
---|
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;
|
---|
64 |
|
---|
65 | case WM_CONTROL: // don't care
|
---|
66 | return 0;
|
---|
67 |
|
---|
68 | case WM_COMMAND:
|
---|
69 | switch (SHORT1FROMMP(mp1)) {
|
---|
70 | case DID_OK:
|
---|
71 | psip = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
72 | WinQueryDlgItemText(hwnd, STR_INPUT, psip->inputlen, psip->ret);
|
---|
73 | WinDismissDlg(hwnd, 1);
|
---|
74 | break;
|
---|
75 |
|
---|
76 | case IDM_HELP:
|
---|
77 | psip = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
78 | psz = psip->help && *psip->help ?
|
---|
79 | psip->help : GetPString(IDS_ENTERTEXTHELPTEXT);
|
---|
80 |
|
---|
81 | saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, GetPString(IDS_HELPTEXT), psz);
|
---|
82 | break;
|
---|
83 |
|
---|
84 | case DID_CANCEL:
|
---|
85 | WinDismissDlg(hwnd, 0);
|
---|
86 | break;
|
---|
87 | }
|
---|
88 | return 0;
|
---|
89 | }
|
---|
90 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
91 | }
|
---|
92 |
|
---|
93 | #pragma alloc_text(FMINPUT,InputDlgProc)
|
---|