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