source: trunk/Lucide/SOURCE/gui/findDlg.cpp @ 24

Last change on this file since 24 was 2, checked in by Eugene Romanenko, 16 years ago

First import

File size: 2.5 KB
Line 
1#define INCL_WIN
2#include <os2.h>
3
4#include "findDlg.h"
5#include "Lucide_res.h"
6#include "luutils.h"
7
8#define MAXSEARCHLENGTH 100
9
10FindDlg::FindDlg( HWND hWndFrame )
11{
12    hFrame        = hWndFrame;
13    searchString  = newstrdup( "" );
14    caseSensitive = false;
15}
16
17FindDlg::~FindDlg()
18{
19    delete searchString;
20}
21
22ULONG FindDlg::showDialog()
23{
24    return WinDlgBox( HWND_DESKTOP, hFrame, findDlgProc,
25                      NULLHANDLE, IDD_FIND, this );
26}
27
28
29
30MRESULT EXPENTRY FindDlg::findDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
31{
32    // This is a static method, so we don't know which instantiation we're
33    // dealing with. But we can get a pseudo-this from the parameter to
34    // WM_INITDLG, which we therafter store with the window and retrieve
35    // as follows:
36    FindDlg *_this = (FindDlg *)WinQueryWindowULong( hwnd, QWL_USER );
37
38    switch (msg)
39    {
40
41        // Dialog has just been created
42        case WM_INITDLG:
43        {
44            // Save the mp2 into our user data so that subsequent calls have
45            // access to the parent C++ object
46            WinSetWindowULong( hwnd, QWL_USER, (ULONG)mp2 );
47            _this = (FindDlg *)mp2;
48            localizeDialog( hwnd );
49            centerWindow( _this->hFrame, hwnd );
50
51            WinSendDlgItemMsg( hwnd, IDC_FINDFIELD, EM_SETTEXTLIMIT,
52                               MPFROMSHORT( MAXSEARCHLENGTH ), MPVOID );
53            WinSetDlgItemText( hwnd, IDC_FINDFIELD, _this->searchString );
54            WinCheckButton( hwnd, IDC_FINDMATCHCASE, _this->caseSensitive );
55
56            return (MRESULT)FALSE;
57        }
58
59        case WM_COMMAND:
60            switch (SHORT1FROMMP(mp1))
61            {
62                case DID_OK:
63                    {
64                        char buf[ MAXSEARCHLENGTH + 1 ];
65                        WinQueryDlgItemText( hwnd, IDC_FINDFIELD, sizeof( buf ), buf );
66                        delete _this->searchString;
67                        _this->searchString = newstrdup( buf );
68                        _this->caseSensitive = WinQueryButtonCheckstate( hwnd, IDC_FINDMATCHCASE );
69                        WinDismissDlg( hwnd, DID_OK );
70                    }
71                    return (MRESULT)FALSE;
72
73                case DID_CANCEL:
74                    WinDismissDlg( hwnd, DID_CANCEL );
75                    return (MRESULT)FALSE;
76            };
77            return (MRESULT)FALSE;
78    }
79    return WinDefDlgProc( hwnd, msg, mp1, mp2 );
80}
81
82
Note: See TracBrowser for help on using the repository browser.