| [181] | 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 | 
|---|
| [342] | 9 | Copyright (c) 2005, 2006 Steven H. Levine | 
|---|
| [181] | 10 |  | 
|---|
|  | 11 | 28 May 05 SHL Use saymsg | 
|---|
| [342] | 12 | 14 Jul 06 SHL Use Runtime_Error | 
|---|
| [181] | 13 |  | 
|---|
|  | 14 | ***********************************************************************/ | 
|---|
|  | 15 |  | 
|---|
| [2] | 16 | #define INCL_DOS | 
|---|
|  | 17 | #define INCL_WIN | 
|---|
| [181] | 18 | #include <os2.h> | 
|---|
| [2] | 19 |  | 
|---|
|  | 20 | #include <stdlib.h> | 
|---|
|  | 21 | #include <stdio.h> | 
|---|
|  | 22 | #include <string.h> | 
|---|
| [181] | 23 |  | 
|---|
| [2] | 24 | #include "fm3dll.h" | 
|---|
|  | 25 | #include "fm3dlg.h" | 
|---|
|  | 26 | #include "fm3str.h" | 
|---|
|  | 27 |  | 
|---|
| [343] | 28 | static PSZ pszSrcFile = __FILE__; | 
|---|
|  | 29 |  | 
|---|
| [2] | 30 | #pragma alloc_text(FMINPUT,InputDlgProc) | 
|---|
|  | 31 |  | 
|---|
| [181] | 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; | 
|---|
| [2] | 37 |  | 
|---|
| [181] | 38 | switch(msg) | 
|---|
|  | 39 | { | 
|---|
| [2] | 40 | case WM_INITDLG: | 
|---|
| [181] | 41 | if (!mp2) | 
|---|
|  | 42 | { | 
|---|
| [342] | 43 | Runtime_Error(pszSrcFile, __LINE__, "no data"); | 
|---|
| [181] | 44 | WinDismissDlg(hwnd,0); | 
|---|
|  | 45 | break; | 
|---|
| [2] | 46 | } | 
|---|
|  | 47 | WinSetWindowPtr(hwnd,0,(PVOID)mp2); | 
|---|
| [181] | 48 | psip = (STRINGINPARMS *)mp2; | 
|---|
| [342] | 49 | if (!WinSendDlgItemMsg(hwnd,STR_INPUT,EM_SETTEXTLIMIT, | 
|---|
|  | 50 | MPFROM2SHORT(psip->inputlen,0),MPVOID)) | 
|---|
| [181] | 51 | { | 
|---|
| [343] | 52 | Win_Error(hwnd,hwnd,pszSrcFile,__LINE__, | 
|---|
| [342] | 53 | "setlimit failed"); | 
|---|
| [181] | 54 | WinDismissDlg(hwnd,0); | 
|---|
|  | 55 | break; | 
|---|
| [2] | 56 | } | 
|---|
| [181] | 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); | 
|---|
| [2] | 64 | } | 
|---|
| [181] | 65 | *psip->ret = 0; | 
|---|
|  | 66 | if (psip->title && *psip->title) | 
|---|
|  | 67 | WinSetWindowText(hwnd,psip->title); | 
|---|
| [2] | 68 | break; | 
|---|
|  | 69 |  | 
|---|
| [181] | 70 | case WM_CONTROL:                    // don't care | 
|---|
| [2] | 71 | return 0; | 
|---|
|  | 72 |  | 
|---|
|  | 73 | case WM_COMMAND: | 
|---|
| [181] | 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; | 
|---|
| [2] | 81 |  | 
|---|
| [181] | 82 | case IDM_HELP: | 
|---|
|  | 83 | psip = WinQueryWindowPtr(hwnd,0); | 
|---|
|  | 84 | psz = psip->help && *psip->help ? | 
|---|
|  | 85 | psip->help : GetPString(IDS_ENTERTEXTHELPTEXT); | 
|---|
| [2] | 86 |  | 
|---|
| [181] | 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; | 
|---|
| [2] | 96 | } | 
|---|
|  | 97 | return 0; | 
|---|
|  | 98 | } | 
|---|
|  | 99 | return WinDefDlgProc(hwnd,msg,mp1,mp2); | 
|---|
|  | 100 | } | 
|---|
|  | 101 |  | 
|---|