1 /*
2  * AiksaurusApp - A Win32 interface to the AikSaurus library
3  * Copyright (C) 2001 by Jared Davis, Michael D. Pritchett
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18  * 02111-1307, USA.
19  */
20 
21 #include <windows.h>
22 #include <commctrl.h>   // includes the common control header
23 #include "AiksaurusApp.h"
24 #include "AiksaurusDlg.h"
25 #include "resource.h"
26 
27 
AiksaurusApp()28 AiksaurusApp::AiksaurusApp()
29 {
30 	m_hInstance = NULL;
31 }
32 
~AiksaurusApp()33 AiksaurusApp::~AiksaurusApp()
34 {
35 }
36 
37 typedef BOOL __declspec(dllimport) (CALLBACK *InitCommonControlsEx_fn)(LPINITCOMMONCONTROLSEX lpInitCtrls);
38 
initialize()39 void AiksaurusApp::initialize()
40 {
41 
42 	// Ensure that common control DLL is loaded
43 	HINSTANCE hinstCC = LoadLibrary("comctl32.dll");
44 	InitCommonControlsEx_fn  pInitCommonControlsEx = NULL;
45 	if( hinstCC != NULL )
46 		pInitCommonControlsEx = (InitCommonControlsEx_fn)GetProcAddress( hinstCC, "InitCommonControlsEx" );
47 	if( pInitCommonControlsEx != NULL )
48 	{
49 		INITCOMMONCONTROLSEX icex;
50 		icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
51 		icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES 	// load the rebar and toolbar
52 					| ICC_TAB_CLASSES | ICC_UPDOWN_CLASS	// and tab and spin controls
53 					;
54 		pInitCommonControlsEx(&icex);
55 	}
56 
57 	AiksaurusDlg dlg;
58 
59 	// If something on Command Line
60 	if( !lookup.empty() )
61 	{
62 
63 		dlg.setSearch( lookup );
64 	}
65 	// Check clipboard
66 	else
67 	{
68         if( IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL) )
69 		{
70 			HGLOBAL hMem = GetClipboardData(CF_TEXT);
71 			if( hMem )
72 			{
73 				lookup = (char *) hMem;
74 				dlg.setSearch( lookup );
75 			}
76 		}
77 	}
78 	dlg.runModal( this );
79 	replace = dlg.getReplacement();
80 }
81 
setLookup(char * word)82 void AiksaurusApp::setLookup( char * word )
83 {
84 	lookup = word;
85 }
86 
87 
WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)88 int WINAPI WinMain ( HINSTANCE hInstance,
89 					 HINSTANCE hPrevInstance,
90                      PSTR szCmdLine,
91 					 int iCmdShow)
92 {
93 	AiksaurusApp theApp;
94 	theApp.setInstance( hInstance );
95 	if( szCmdLine )
96 		theApp.setLookup( szCmdLine );
97 	theApp.initialize();
98 
99 	return 0;
100 }
101