source: trunk/dll/input.c@ 1348

Last change on this file since 1348 was 1348, checked in by Gregg Young, 17 years ago

More code cleanup

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