| 1 |
|
|---|
| 2 | /***********************************************************************
|
|---|
| 3 |
|
|---|
| 4 | $Id: input.c 181 2005-05-28 17:47:10Z root $
|
|---|
| 5 |
|
|---|
| 6 | Input dialog procecedure
|
|---|
| 7 |
|
|---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
|---|
| 9 | Copyright (c) 2005 Steven H. Levine
|
|---|
| 10 |
|
|---|
| 11 | 28 May 05 SHL Use saymsg
|
|---|
| 12 |
|
|---|
| 13 | ***********************************************************************/
|
|---|
| 14 |
|
|---|
| 15 | #define INCL_DOS
|
|---|
| 16 | #define INCL_WIN
|
|---|
| 17 | #include <os2.h>
|
|---|
| 18 |
|
|---|
| 19 | #include <stdlib.h>
|
|---|
| 20 | #include <stdio.h>
|
|---|
| 21 | #include <string.h>
|
|---|
| 22 |
|
|---|
| 23 | #include "fm3dll.h"
|
|---|
| 24 | #include "fm3dlg.h"
|
|---|
| 25 | #include "fm3str.h"
|
|---|
| 26 |
|
|---|
| 27 | #pragma alloc_text(FMINPUT,InputDlgProc)
|
|---|
| 28 |
|
|---|
| 29 | MRESULT EXPENTRY InputDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
|
|---|
| 30 | {
|
|---|
| 31 | // mp2 points at a structure of type STRINGINPARMS
|
|---|
| 32 | STRINGINPARMS *psip;
|
|---|
| 33 | PSZ psz;
|
|---|
| 34 |
|
|---|
| 35 | switch(msg)
|
|---|
| 36 | {
|
|---|
| 37 | case WM_INITDLG:
|
|---|
| 38 | if (!mp2)
|
|---|
| 39 | {
|
|---|
| 40 | WinDismissDlg(hwnd,0);
|
|---|
| 41 | break;
|
|---|
| 42 | }
|
|---|
| 43 | WinSetWindowPtr(hwnd,0,(PVOID)mp2);
|
|---|
| 44 | psip = (STRINGINPARMS *)mp2;
|
|---|
| 45 | if (!(BOOL)WinSendDlgItemMsg(hwnd,STR_INPUT,EM_SETTEXTLIMIT,
|
|---|
| 46 | MPFROM2SHORT(psip->inputlen,0),MPVOID))
|
|---|
| 47 | {
|
|---|
| 48 | DosBeep(50,100);
|
|---|
| 49 | WinDismissDlg(hwnd,0);
|
|---|
| 50 | break;
|
|---|
| 51 | }
|
|---|
| 52 | if (psip->prompt && *psip->prompt)
|
|---|
| 53 | WinSetDlgItemText(hwnd,STR_PROMPT,psip->prompt);
|
|---|
| 54 | if (psip->ret && *psip->ret)
|
|---|
| 55 | {
|
|---|
| 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 | {
|
|---|
| 71 | case DID_OK:
|
|---|
| 72 | psip = WinQueryWindowPtr(hwnd,0);
|
|---|
| 73 | WinQueryDlgItemText(hwnd,STR_INPUT,psip->inputlen,psip->ret);
|
|---|
| 74 | WinDismissDlg(hwnd,1);
|
|---|
| 75 | break;
|
|---|
| 76 |
|
|---|
| 77 | case IDM_HELP:
|
|---|
| 78 | psip = WinQueryWindowPtr(hwnd,0);
|
|---|
| 79 | psz = psip->help && *psip->help ?
|
|---|
| 80 | psip->help : GetPString(IDS_ENTERTEXTHELPTEXT);
|
|---|
| 81 |
|
|---|
| 82 | saymsg(MB_ENTER | MB_ICONASTERISK,
|
|---|
| 83 | hwnd,
|
|---|
| 84 | GetPString(IDS_HELPTEXT),
|
|---|
| 85 | psz);
|
|---|
| 86 | break;
|
|---|
| 87 |
|
|---|
| 88 | case DID_CANCEL:
|
|---|
| 89 | WinDismissDlg(hwnd,0);
|
|---|
| 90 | break;
|
|---|
| 91 | }
|
|---|
| 92 | return 0;
|
|---|
| 93 | }
|
|---|
| 94 | return WinDefDlgProc(hwnd,msg,mp1,mp2);
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|