Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
autorun.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (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, see <http://www.gnu.org/licenses/>.
17*/
18
19/****************************************************************************
20 ** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ****************************************************************************
22 * *
23 * Project Name : Autorun *
24 * *
25 * File Name : AUTORUN.CPP *
26 * *
27 * Programmers: Maria del Mar McCready Legg *
28 * *
29 * Start Date : September 5, 1997 *
30 * *
31 * Last Update : October 15, 2001 [MML] *
32 * *
33 *--------------------------------------------------------------------------*
34 * Functions: *
35 * WinMain *
36 * Main::MessageLoop *
37 * MainWindow::Register *
38 * MainWindow::MainWindow *
39 * MainWindow::Window_Proc *
40 * MainWindow::Is_Product_Registered *
41 * MainWindow::Run_Explorer *
42 * MainWindow::Run_Game *
43 * MainWindow::Run_Setup *
44 * MainWindow::Run_New_Account *
45 * MainWindow::Run_Register *
46 * MainWindow::Run_Auto_Update *
47 * MainWindow::Run_Uninstall *
48 * MainWindow::Create_Buttons *
49 * Wnd_Proc *
50 * Dialog_Box_Proc *
51 * Stop_Sound_Playing *
52 * Options *
53 * Valid_Environment *
54 * LoadResourceBitmap *
55 * CreateDIBPalette *
56 * LoadResourceButton *
57 * Cant_Find_MessageBox *
58 * Error_Message *
59 * Path_Add_Back_Slash *
60 * Path_Remove_Back_Slash *
61 * PlugInProductName *
62 * Fix_Single_Ampersands *
63 * Fix_Double_Ampersands *
64 * LaunchObjectClass::LaunchObjectClass *
65 * LaunchObjectClass::SetPath *
66 * LaunchObjectClass::SetArgs *
67 * LaunchObjectClass::Launch *
68 *--------------------------------------------------------------------------*/
69
70
71#define STRICT
72#include <windows.h>
73#include <windowsx.h>
74#include <assert.h>
75#include <ctype.h>
76#include <direct.h>
77#include <dos.h>
78#include <errno.h>
79#include <fcntl.h>
80#include <fstream.h>
81#include <io.h>
82#include <locale.h>
83#include <math.h>
84#include <mbctype.h>
85#include <mmsystem.h>
86#include <process.h>
87#include <stdlib.h>
88#include <string.h>
89#include <stdio.h>
90#include <strstrea.h>
91#include <sys\stat.h>
92#include <time.h>
93#include <winuser.h>
94#include "args.h"
95#include "autorun.h"
96#include "drawbutton.h"
97#include "resource.h"
98#include "wnd_file.h"
99//#include "visualc.h"
100#include "winfix.h"
101#include "cdcntrl.h"
102#include "igr.h"
103#include "viewhtml.h"
104
105#include "utils.h"
106#include "locale_api.h"
107//#include "resources.h"
108#include "getcd.h"
109
110#include "WSYS_FileSystem.h"
111#include "WSYS_STDFileSystem.h"
112
113#include <string>
114#include "GameText.h"
115
116#include "leanAndMeanAutorun.h"
117
118#ifndef LEAN_AND_MEAN
120#include "GameClient/GameText.h"
121#include "Common/UnicodeString.h"
124#endif
125
126
127
128//-----------------------------------------------------------------------------
129// DEFINES
130//-----------------------------------------------------------------------------
131#define PRETEND_ON_CD_TEST FALSE // should be FALSE
132//#define PRETEND_ON_CD_TEST TRUE // should be FALSE
133
134#define WINDOW_BRUSH FALSE
135#define BACKGROUND_BITMAP TRUE
136#define USE_MOUSE_MOVES TRUE
137#define DISABLE_KEYBOARD FALSE
138
139#define BUTTON_WIDTH 150
140#define BUTTON_HEIGHT 45
141#define NUM_BUTTONS 10
142#define NUM_ARGUMENTS 10
143#define NUM_SONGS 2 //32 //16
144#define NUM_FLICKER_FRAMES 1
145#define NUM_FLICKER_POSITIONS 15
146
147#define MOUSE_WAV "MouseMove"
148#define SOUND_FILE1 "SPEECH_FILE1"
149#define SOUND_FILE2 "SPEECH_FILE2"
150
151#define MOH_DEMO_PROGRAM "MOHAADEMO\\SETUP.EXE"
152#define SHOW_MOH_DEMO FALSE
153
154#define BFAVI_FILENAME "Autorun\\BF1942RTR.avi"
155#define SC4AVI_FILENAME "Autorun\\Preview.avi"
156#define HELP_FILENAME "HELP:FILENAME"//"Support\\eahelp.hlp"
157
158#define SHOW_GAMESPY_BUTTON FALSE
159#define GAMESPY_WEBSITE "http://www.gamespyarcade.com/features/launch.asp?svcname=ccrenegade&distID=391"
160
161#define RESOURCE_FILE "Autorun.loc"
162#define SETUP_INI_FILE1 "Setup\\Setup.ini"
163#define SETUP_INI_FILE2 "Setup.ini"
164
165#define UNINSTALL_EXECUTABLE "IDriver.exe" // JFS
166
167//-----------------------------------------------------------------------------
168// These defines need the Product name from Setup.ini to complete.
169//-----------------------------------------------------------------------------
170#define SETUP_MAIN_WINDOW_NAME "%s Setup"
171#define CLASS_NAME "%s Autorun"
172#define GAME_MAIN_WINDOW_NAME "%s Game Window"
173
174//#define GAME_WEBSITE "http://www.westwood.com/"
175#define GAME_WEBSITE "http://generals.ea.com"
176
177#define AUTORUN_MUTEX_OBJECT "01AF9993-3492-11d3-8F6F-0060089C05B1"
178//#define GAME_MUTEX_OBJECT "C6D925A3-7A9B-4ca3-866D-8B4D506C3665"
179#define GAME_MUTEX_OBJECT "685EAFF2-3216-4265-B047-251C5F4B82F3"
180#define PRODUCT_VOLUME_CD1 "Generals1"
181#define PRODUCT_VOLUME_CD2 "Generals2"
182
183
184//-----------------------------------------------------------------------------
185// Global Variables
186//-----------------------------------------------------------------------------
189int Language = 0;
191
194char ButtonImages [ NUM_BUTTONS ][ MAX_PATH ];
195CHAR szSongPath [ MAX_PATH ];
196char FocusedButtonImages [ NUM_BUTTONS ][ MAX_PATH ];
198char szWavs [ NUM_SONGS][ _MAX_PATH ];
199char szBuffer [ MAX_PATH ];
200char szBuffer1 [ MAX_PATH ];
201char szBuffer2 [ MAX_PATH ];
202char szBuffer3 [ MAX_PATH * 2];
203char szInternetPath [_MAX_PATH];
204char szGamePath [_MAX_PATH];
205char szWorldbuilderPath [_MAX_PATH];
206char szPatchgetPath [_MAX_PATH];
207char szSetupPath [_MAX_PATH];
208char szUninstallPath [_MAX_PATH];
209char szUninstallCommandLine[_MAX_PATH]; // JFS: Returned value contains parameters needed.
210char szRegisterPath [_MAX_PATH];
211char szButtonWav [_MAX_PATH ];
212char szSpeechWav [_MAX_PATH ];
213char szArgvPath [_MAX_PATH ];
214char drive [_MAX_DRIVE];
215char dir [_MAX_DIR ];
216char szSetupWindow [_MAX_PATH];
217char szGameWindow [_MAX_PATH];
218char szRegistryKey [_MAX_PATH];
219char szClassName [_MAX_PATH];
220char szVolumeName [_MAX_PATH];
221
222char szProduct_Name [ _MAX_PATH ];
223
224
225#ifdef LEAN_AND_MEAN
226
227wchar_t szWideBuffer [ _MAX_PATH ];
228wchar_t szWideBuffer0 [ _MAX_PATH ];
229wchar_t szWideBuffer2 [ _MAX_PATH ];
230wchar_t szWideBuffer3 [ _MAX_PATH ];
231wchar_t szProductName [ _MAX_PATH ];
232wchar_t szFullProductName [ _MAX_PATH ];
233
234/*
235enum
236{
237 IDS_INSTALL,
238 IDS_EXPLORE_CD,
239 IDS_PREVIEWS,
240 IDS_CANCEL,
241 IDS_AUTORUN_TITLE,
242 IDS_CANT_FIND_IEXPLORER,
243 IDS_WINDOWS_VERSION_TEXT,
244 IDS_WINDOWS_VERSION_TITLE,
245 IDS_CANT_FIND,
246 IDS_UNINSTALL,
247 IDS_WEBSITE,
248 IDS_CHECKFORUPDATES,
249 IDS_WORLDBUILDER,
250 IDS_PLAY,
251
252 IDS_GAME_TITLE,
253 IDS_FULL_GAME_TITLE,
254 IDS_REGISTRY_KEY,
255 IDS_MAIN_WINDOW,
256
257
258 IDS_COUNT // keep this last
259};
260*/
261
262#else
263
264UnicodeString wideBuffer;
265UnicodeString wideBuffer0;
266UnicodeString wideBuffer2;
267UnicodeString wideBuffer3;
268UnicodeString productName;
269UnicodeString fullProductName;
270
271#endif
272
273
274
290HANDLE AppMutex = NULL;
293
294
295
296
297#ifdef LEAN_AND_MEAN
298
300
301#else
302
306
307#endif
308
309// stuff needed to compile.
312
313const char *g_strFile = "Autorun.str";
314const char *g_csfFile = "Autorun.csf";
315
316char *gAppPrefix = "ar_"; // prefix to the debug log.
317
319
320#if( _DEBUG )
321char szCDDrive[ MAX_PATH ];
322#endif
323
324
325//-----------------------------------------------------------------------------
326// Global Function Definitions
327//-----------------------------------------------------------------------------
328void Cant_Find_MessageBox ( HINSTANCE hInstance, char *szPath );
329HPALETTE CreateDIBPalette ( LPBITMAPINFO lpbmi, LPINT lpiNumColors );
330void Debug_Date_And_Time_Stamp ( void );
331
332void Error_Message ( HINSTANCE hInstance, int title, int string, char *path );
333void Error_Message ( HINSTANCE hInstance, const char * title, const char * string, char *path );
334
335bool Is_On_CD ( char * );
336HBITMAP LoadResourceBitmap ( HMODULE hInstance, char *lpString, HPALETTE FAR *lphPalette, bool loading_a_button=FALSE );
337HBITMAP LoadResourceButton ( HMODULE hInstance, char *lpString, HPALETTE FAR lphPalette );
339void Prog_End ( void );
340bool Prompt_For_CD ( HWND window_handle, char *volume_name, const char * message1, const char * message2, int *cd_drive );
341void Reformat_Volume_Name ( char *volume_name, char *new_volume_name );
342int Show_Message ( HWND window_handle, const char * message_num1, const char * message_num2 );
343int Show_Message ( HWND window_handle, int message_num1 );
344void Stop_Sound_Playing ( void );
345BOOL Valid_Environment ( void );
346
347BOOL CALLBACK Dialog_Box_Proc ( HWND window_handle, UINT message, WPARAM w_param, LPARAM l_param );
348LRESULT CALLBACK Wnd_Proc ( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam );
349
350
351//-----------------------------------------------------------------------------
352// Main & MainWindow Public Variables
353//-----------------------------------------------------------------------------
354HINSTANCE Main::hInstance = 0;
355HINSTANCE Main::hPrevInstance = 0;
356HMODULE Main::hModule = 0;
357int Main::nCmdShow = 0;
359
360
361//*****************************************************************************
362// WinMain -- Main Program Loop.
363//
364// INPUT: HINSTANCE hInstance
365// HINSTANCE hPrevInstance
366// LPTSTR lpszCmdLine
367// int nCmdShow
368//
369// OUTPUT: int.
370//
371// WARNINGS: none.
372//
373// HISTORY:
374// 06/04/1996 MML : Created.
375//=============================================================================
376
377int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmdLine, int nCmdShow )
378{
379
380 int i = 0;
381 char szPath[ _MAX_PATH ];
382 char szIniPath[ _MAX_PATH ];
383
384 HANDLE handle;
385 WIN32_FIND_DATA FindFileData;
386
387 Main::hInstance = hInstance;
388 ApplicationHInstance = hInstance;
389 Main::hPrevInstance = hPrevInstance;
390 Main::nCmdShow = nCmdShow;
391 Main::hModule = GetModuleHandle( NULL );
392
393 memset( szSetupWindow, '\0', MAX_PATH );
394 memset( szGameWindow, '\0', MAX_PATH );
395 memset( szProductName, '\0', MAX_PATH );
396 memset( szFullProductName, '\0', MAX_PATH );
397 memset( szRegistryKey, '\0', MAX_PATH );
398 memset( szClassName, '\0', MAX_PATH );
399 memset( szVolumeName, '\0', MAX_PATH );
400
401 Msg( __LINE__, __FILE__, "Entering WinMain." );
402
403 //-------------------------------------------------------------------------
404 // Set Cleanup function.
405 //-------------------------------------------------------------------------
406 atexit( Prog_End );
407
408 //-------------------------------------------------------------------------
409 // Clear Argument Array.
410 //-------------------------------------------------------------------------
411 for ( i = 0; i < NUM_ARGUMENTS; i++ ) {
412 memset( Arguments[i], '\0', sizeof( Arguments[i] ));
413 }
414 for ( i = 0; i < NUM_SONGS; i++ ) {
415 memset( szWavs[i], '\0', sizeof( szWavs[i] ));
416 }
417
418 //-------------------------------------------------------------------------
419 // Init Args class.
420 //-------------------------------------------------------------------------
421 Args = new Command_Line_Arguments( hInstance, GetCommandLine());
422 if ( Args == NULL ) {
423// Error_Message( hInstance, IDS_ERROR, IDS_COMMAND_LINE_ERR, NULL );
424 Error_Message( hInstance, "Autorun:Error", "Autorun:CommandLineError", NULL );
425 return( 0 );
426 }
427 Msg( __LINE__, __FILE__, "Args Created." );
428
429#if( PRETEND_ON_CD_TEST )
430 strcpy( szCDDrive, "E:\\" );
431 Options( Args );
432 strcat( szCDDrive, "autorun.exe" );
433 Msg( __LINE__, __FILE__, "szCDDrive = %s.", szCDDrive );
434 Args->Set_argv( 0, szCDDrive );
435#endif
436
437 //-------------------------------------------------------------------------
438 // Get the CD volume to check on which CD in the product we are on.
439 //-------------------------------------------------------------------------
440 strcpy( szBuffer, Args->Get_argv(0));
441 CDList.Get_Volume_For_This_CD_Drive( szBuffer, szVolumeName );
442
443 Msg( __LINE__, __FILE__, "szVolumeName = %s.", szVolumeName );
444
445
446#ifdef LEAN_AND_MEAN
447
449
450#else
451
452 // create singletons
453 TheFileSystem->init();
457 TheGameText->init();
458
459#endif
460
461 //=========================================================================
462 // Make paths to .INI and .LOC files.
463 //=========================================================================
466
467 handle = FindFirstFile( szIniPath, &FindFileData );
468 if ( handle == INVALID_HANDLE_VALUE ) {
469
470 //---------------------------------------------------------------------
471 // This might be a secondary CD.
472 //---------------------------------------------------------------------
474 }
475 FindClose( handle );
476
477 Msg( __LINE__, __FILE__, "Resource file = %s.", szPath );
478 Msg( __LINE__, __FILE__, "Setup.ini file = %s.", szIniPath );
479
480 //--------------------------------------------------------------------------
481 // Get the language we are using from the Setup.ini file.
482 //--------------------------------------------------------------------------
483 Language = GetPrivateProfileInt( "Setup", "Language", 0, szIniPath );
484
485 if( Language == 0 ) {
486 IsEnglish = true;
487 }
488
489 Msg( __LINE__, __FILE__, "Language = %d.", Language );
490 Msg( __LINE__, __FILE__, "IsEnglish = %d.", IsEnglish );
491
492 //--------------------------------------------------------------------------
493 // Set language to use.
494 //--------------------------------------------------------------------------
496
499 }
500
501 /*switch( Language ) {
502
503 case LANG_GER:
504 LanguageToUse = IDL_GERMAN;
505 break;
506
507 case LANG_FRE:
508 LanguageToUse = IDL_FRENCH;
509 break;
510
511 case LANG_JAP:
512 LanguageToUse = IDL_JAPANESE;
513 break;
514
515 case LANG_KOR:
516 LanguageToUse = IDL_KOREAN;
517 break;
518
519 case LANG_CHI:
520 LanguageToUse = IDL_CHINESE;
521 break;
522
523 case LANG_USA:
524 default:
525 LanguageToUse = IDL_ENGLISH;
526 break;
527 }
528 */
530
531 }
532 Msg( __LINE__, __FILE__, "LanguageToUse = %d.", LanguageToUse );
533
534 //-------------------------------------------------------------------------
535 // Process the Command Line Options. This may change the language id.
536 //-------------------------------------------------------------------------
537 if ( !Options( Args )) {
538 return( 0 );
539 }
540
541 //-------------------------------------------------------------------------
542 // Save off the Current path for use by other stuff.
543 //-------------------------------------------------------------------------
544 _tcscpy( szArgvPath, Args->Get_argv(0));
545 _tsplitpath( szArgvPath, drive, dir, NULL, NULL );
546 _tmakepath ( szArgvPath, drive, dir, NULL, NULL );
548 Msg( __LINE__, TEXT(__FILE__), TEXT("szArgvPath = %s."), szArgvPath );
549
550 Msg( __LINE__, __FILE__, "About to Init text strings." );
551
552 //=========================================================================
553 // Init the strings chosen.
554 //=========================================================================
555
556
557 Locale_Init( LanguageToUse, szPath );
558
559 /*
560 if( !Locale_Init( LanguageToUse, szPath )) {
561 LoadString( Main::hInstance, IDS_CANT_FIND_FILE, szBuffer1, _MAX_PATH );
562 MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szPath, _MAX_PATH, szWideBuffer0, _MAX_PATH );
563 sprintf( szBuffer2, szBuffer1, szWideBuffer0 );
564 MessageBox( NULL, szBuffer2, "Autorun", MB_APPLMODAL | MB_OK );
565 return 0;
566 }
567 */
568
569
570 //-------------------------------------------------------------------------
571 // Get some pertinent strings.
572 //-------------------------------------------------------------------------
573 Locale_GetString( "Autorun:Title", szProductName );
574 Locale_GetString( "Autorun:Command&ConquerGenerals", szFullProductName );
575 //Locale_GetString( IDS_GAME_TITLE, szProductName );
576 //Locale_GetString( IDS_FULL_GAME_TITLE, szFullProductName );
577// Locale_GetString( IDS_REGISTRY_KEY, szRegistryKey ); // jfs
578// Locale_GetString( IDS_MAIN_WINDOW, szGameWindow );
579
580
581 //-------------------------------------------------------------------------
582 // Set other variables used through out.
583 //-------------------------------------------------------------------------
584#ifdef LEAN_AND_MEAN
585
586 //Fix_Single_Ampersands( &szProductName[0], false );
587 //Fix_Single_Ampersands( &szFullProductName[0], false );
588 Msg( __LINE__, __FILE__, "szProductName = %s.", szProductName );
589 WideCharToMultiByte( CodePage, 0, szProductName, _MAX_PATH, szProduct_Name, _MAX_PATH, NULL, NULL );
590
591#else
592
593 productName = TheGameText->fetch("Autorun:Generals");
594 fullProductName = TheGameText->fetch("Autorun:Command&ConquerGenerals");
595 Msg( __LINE__, __FILE__, "Product Name = %ls.", productName.str() );
596 Msg( __LINE__, __FILE__, "Full Product Name = %ls.", fullProductName.str() );
597 Msg( __LINE__, __FILE__, "szRegistryKey = %s.", szRegistryKey );
598 Msg( __LINE__, __FILE__, "szGameWindow = %s.", szGameWindow );
599 WideCharToMultiByte( CodePage, 0, productName.str(), productName.getLength()+1, szProduct_Name, _MAX_PATH, NULL, NULL );
600
601#endif
602
606
607 Msg( __LINE__, __FILE__, "szClassName = %s.", szClassName );
608 Msg( __LINE__, __FILE__, "szSetupWindow = %s.", szSetupWindow );
609
610 //=========================================================================
611 // Create a mutex with a unique name to Autorun in order to determine if
612 // our app is already running.
613 //
614 // Return Values:
615 // If the function succeeds, the return value is a handle to the mutex object.
616 // If the named mutex object existed before the function call, the function returns
617 // a handle to the existing object and GetLastError returns ERROR_ALREADY_EXISTS.
618 // Otherwise, the caller created the mutex.
619 // If the function fails, the return value is NULL. To get extended error
620 // information, call GetLastError.
621 //
622 // WARNING: DO NOT use this number for any other application except Autorun
623 //=========================================================================
624 if( WinVersion.Is_Win_XP() || WinVersion.Version() > 500 ) {
625 strcat( strcpy( szBuffer, "Global\\" ), AUTORUN_MUTEX_OBJECT );
626 } else {
628 }
629 AppMutex = CreateMutex( NULL, FALSE, szBuffer );
630
631 if ( AppMutex != NULL && ( GetLastError() == ERROR_ALREADY_EXISTS )) {
632
633 Msg( __LINE__, __FILE__, "AppMutex of %s already exists. Exit here.", szBuffer );
634
635 //---------------------------------------------------------------------
636 // Handle is closed in the ProgEnd().
637 //---------------------------------------------------------------------
638
639 //---------------------------------------------------------------------
640 // Check if Game/Setup is already running, and is looking for the CDRom.
641 //---------------------------------------------------------------------
642 HWND prev = FindWindow( szClassName, NULL );
643 if( prev ){
644 //if( IsIconic( prev )){
645 //ShowWindow( prev, SW_RESTORE );
646 //}
647 SetForegroundWindow( prev );
648 }
649 return 0;
650 }
651 Msg( __LINE__, __FILE__, "AppMutex of %s created.", szBuffer );
652
653 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
654 // if AppMutex was NULL, let through. Perhaps in future we want to trap it?
655 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
656 if ( AppMutex == NULL ) {
657 }
658
659 //=========================================================================
660 // Create a mutex with a unique name to Game/Setup in order to
661 // determine if our app is already running.
662 //
663 // Return Values
664 // If the function succeeds, the return value is a handle to the mutex object.
665 // If the function fails, the return value is NULL. To get extended error
666 // information, call GetLastError.
667 //
668 // WARNING: DO NOT use this number for any other application except Game/Setup.
669 //=========================================================================
670 if( WinVersion.Is_Win_XP() || WinVersion.Version() > 500 ) {
671 strcat( strcpy( szBuffer, "Global\\" ), GAME_MUTEX_OBJECT );
672 } else {
673 strcpy( szBuffer, GAME_MUTEX_OBJECT );
674 }
675 GameAppMutex = OpenMutex( MUTEX_ALL_ACCESS, FALSE, szBuffer );
676
677 if ( GameAppMutex != NULL ) {
678
679 Msg( __LINE__, TEXT(__FILE__), TEXT("Mutex Object of game found."));
680 Msg( __LINE__, TEXT(__FILE__), TEXT("Looking for Game Window."));
681
682 HWND ccwindow = FindWindow( szGameWindow, NULL );
683 if ( ccwindow ) {
684
685 Msg( __LINE__, TEXT(__FILE__), TEXT("Found Game Window."));
686
687 if( IsIconic( ccwindow )){
688 ShowWindow( ccwindow, SW_RESTORE );
689 }
690 SetForegroundWindow( ccwindow );
691
692 } else {
693
694 Msg( __LINE__, TEXT(__FILE__), TEXT("Looking for Setup Window."));
695
696 ccwindow = FindWindow( szSetupWindow, NULL );
697 if ( ccwindow ) {
698
699 Msg( __LINE__, TEXT(__FILE__), TEXT("Found Setup Window."));
700
701 if( IsIconic( ccwindow )){
702 ShowWindow( ccwindow, SW_RESTORE );
703 }
704 BOOL result = SetForegroundWindow( ccwindow );
705 Msg( __LINE__, TEXT(__FILE__), TEXT("SetForegroundWindow = %d."), result );
706 }
707 }
708
709 //---------------------------------------------------------------------
710 // Handle(s) are closed in the ProgEnd().
711 //---------------------------------------------------------------------
712
713 return 0;
714 }
715
716 //---------------------------------------------------------------------
717 // Check if Game/Setup is already running, and is looking for the CDRom.
718 //---------------------------------------------------------------------
719 HWND prev = FindWindow( szClassName, NULL );
720 if ( prev == NULL ) {
721 prev = FindWindow( szGameWindow, NULL );
722 if ( prev == NULL ) {
723 prev = FindWindow( szSetupWindow, NULL );
724 }
725 }
726 if( prev ){
727 if( IsIconic( prev )){
728 ShowWindow( prev, SW_RESTORE );
729 }
730 SetForegroundWindow( prev );
731
732 Msg( __LINE__, __FILE__, "Either same app, game or setup was found. Exit and set window to foreground." );
733 return 0;
734 }
735
736 //---------------------------------------------------------------------
737 // Check if another installshield session is already running. This happens
738 // because we ask the user to insert CD-1 again at the end of the install
739 // to prevent a crash on Windows ME where it tries to access CD-1 again.
740 //---------------------------------------------------------------------
741 prev = FindWindow( NULL,"InstallShield Wizard");
742 if( prev ){
743 return 0;
744 }
745
746 //=========================================================================
747 // Select Sounds.
748 //=========================================================================
749 memset( szButtonWav, '\0', _MAX_PATH );
750 _tcscpy( szButtonWav, _TEXT( MOUSE_WAV ));
751
752// memset( szSpeechWav, '\0', _MAX_PATH );
753// _tcscpy( szSpeechWav, _TEXT( AUTORUN_WAV ));
754
755 if( LanguageID == LANG_USA ) {
756
757 strcpy( szWavs[0], SOUND_FILE1 );
758 strcpy( szWavs[1], SOUND_FILE2 );
759
760 // Pick a number between 0 and 1. ( NUM_SONGS - 1 )
761 // Seed the random-number generator with current time so that
762 // the numbers will be different every time we run.
763
764 Msg( __LINE__, __FILE__, "szWav[0] = %s.", szWavs[0] );
765 Msg( __LINE__, __FILE__, "szWav[1] = %s.", szWavs[1] );
766
767 srand(( unsigned )time( NULL ));
768 SongNumber = rand() & 1;
769// UseSounds = TRUE;
770
771 Msg( __LINE__, __FILE__, "SongNumber = %d.", SongNumber );
772 Msg( __LINE__, __FILE__, "UseSounds = %d.", UseSounds );
773 }
774
775 //-------------------------------------------------------------------------
776 // Get the CD volume to check on which CD in the product we are on.
777 //-------------------------------------------------------------------------
778// strcpy( szBuffer, Args->Get_argv(0));
779// CDList.Get_Volume_For_This_CD_Drive( szBuffer, szVolumeName );
780
781// Msg( __LINE__, __FILE__, "szVolumeName = %s.", szVolumeName );
782
783 //-------------------------------------------------------------------------
784 // Check if we are on the CD-ROM and in Windows 95.
785 //-------------------------------------------------------------------------
786 if ( !Valid_Environment( )) {
787 return( -1 );
788 }
789
790 //=========================================================================
791 // Lock the CD!
792 //=========================================================================
793// memset( szPath, '\0', _MAX_PATH );
794// szPath[0] = (char)( toupper( szArgvPath[0] ));
795// strcat( szPath, ":\\" );
796
797 //-------------------------------------------------------------------------
798 // NOTE: Based on A=0, B=1, etc.
799 //-------------------------------------------------------------------------
800//#if(!PRETEND_ON_CD_TEST)
801 char driveLetter = Args->Get_argv(0)[0];
802 Msg( __LINE__, TEXT(__FILE__), TEXT("About to lock on CD: %c:\\ "), toupper( driveLetter ));
803// CDLocked = CDControl.Lock_CD_Tray((unsigned)( toupper( szPath[0] ) - 'A' ));
804 CDLocked = CDControl.Lock_CD_Tray((unsigned)( toupper( driveLetter ) - 'A' ));
805 Msg( __LINE__, TEXT(__FILE__), TEXT("CDLocked = %d. "), CDLocked );
806//#endif
807
808 //=========================================================================
809 // Set the buttons images. Use when images are unique for each button.
810 //=========================================================================
811 strcpy( ButtonImages[0], BUTTON_REG );
812 strcpy( ButtonImages[1], BUTTON_REG );
813 strcpy( ButtonImages[2], BUTTON_REG );
814 strcpy( ButtonImages[3], BUTTON_REG );
815 strcpy( ButtonImages[4], BUTTON_REG );
816 strcpy( ButtonImages[5], BUTTON_REG );
817 strcpy( ButtonImages[6], BUTTON_REG );
818 strcpy( ButtonImages[7], BUTTON_REG );
819 strcpy( ButtonImages[8], BUTTON_REG );
820 strcpy( ButtonImages[9], BUTTON_REG );
821
822 strcpy( FocusedButtonImages[0], BUTTON_SEL );
823 strcpy( FocusedButtonImages[1], BUTTON_SEL );
824 strcpy( FocusedButtonImages[2], BUTTON_SEL );
825 strcpy( FocusedButtonImages[3], BUTTON_SEL );
826 strcpy( FocusedButtonImages[4], BUTTON_SEL );
827 strcpy( FocusedButtonImages[5], BUTTON_SEL );
828 strcpy( FocusedButtonImages[6], BUTTON_SEL );
829 strcpy( FocusedButtonImages[7], BUTTON_SEL );
830 strcpy( FocusedButtonImages[8], BUTTON_SEL );
831 strcpy( FocusedButtonImages[9], BUTTON_SEL );
832
833 //=========================================================================
834 // A Windows class should be registered with Windows before any windows
835 // of that type are created. Register here all Windows classes that
836 // will be used in the program.
837 //-------------------------------------------------------------------------
838 // Register the class only AFTER WinMain assigns appropriate values to
839 // static members of Main and only if no previous instances of the program
840 // exist (a previous instance would have already performed the registration).
841 //=========================================================================
842 if ( !Main::hPrevInstance ) {
844 }
845
846 //-------------------------------------------------------------------------
847 // Create MainWnd, calls MainWindow Constructor.
848 //-------------------------------------------------------------------------
849 MainWindow MainWnd;
850
851 //-------------------------------------------------------------------------
852 // Begin processing Window Messages.
853 //-------------------------------------------------------------------------
854 return( Main::MessageLoop( ));
855}
856
857//*****************************************************************************
858// Prog_End -- Close all objects that were created.
859//
860// INPUT: none.
861//
862// OUTPUT: int.
863//
864// WARNINGS: none.
865//
866// HISTORY:
867// 01/22/2001 MML : Created.
868//=============================================================================
869
870void Prog_End ( void )
871{
872 //==========================================================================
873 // UnLock the CD!
874 //==========================================================================
875 if( CDLocked ) {
876 CDControl.Unlock_CD_Tray((unsigned)( toupper( szArgvPath[0] ) - 'A' ));
877 CDLocked = false;
878 }
879
880 if( Args != NULL ) {
881 delete( Args );
882 Args = NULL;
883 Msg( __LINE__, __FILE__, "Args deleted." );
884 }
885
886 if ( AppMutex != NULL ) {
887 CloseHandle( AppMutex );
888 AppMutex = NULL;
889 Msg( __LINE__, __FILE__, "AppMutex deleted." );
890 }
891
892 if ( GameAppMutex != NULL) {
893 CloseHandle( GameAppMutex );
895 }
896
897 if ( FontManager != NULL ) {
898 delete( FontManager );
900 Msg( __LINE__, __FILE__, "FontManager deleted." );
901 }
902
903 if ( OnlineOptions != NULL ) {
904 delete( OnlineOptions );
906 Msg( __LINE__, __FILE__, "OnlineOptions deleted." );
907 }
908
909 //-------------------------------------------------------------------------
910 // Delete language resource file.
911 //-------------------------------------------------------------------------
913
915}
916
917
918//*****************************************************************************
919// Main::MessageLoop -- Dispatch Message Loop.
920//
921// INPUT: none.
922//
923// OUTPUT: int.
924//
925// WARNINGS: none.
926//
927// HISTORY:
928// 06/04/1996 MML : Created.
929//=============================================================================
930
932{
933 MSG msg;
934
935 while( GetMessage( &msg, NULL, 0, 0 )) {
936 TranslateMessage( &msg );
937 DispatchMessage( &msg );
938 }
939
940 //--------------------------------------------------------------------------
941 // Stop the sound if still going.
942 //--------------------------------------------------------------------------
944
945 //==========================================================================
946 // UnLock the CD!
947 //==========================================================================
948//#if(!PRETEND_ON_CD_TEST)
949 if( CDLocked ) {
950 CDControl.Unlock_CD_Tray((unsigned)( toupper( szArgvPath[0] ) - 'A' ));
951 CDLocked = false;
952 }
953//#endif
954
955 //==========================================================================
956 // Something to launch?
957 //==========================================================================
958 if( LaunchObject.Launch_A_Program()) {
959 LaunchObject.Launch();
960 }
961
962 return( msg.wParam );
963}
964
965
966//*****************************************************************************
967// MainWindow::Register -- Register the Main Window.
968//
969// INPUT: none.
970//
971// OUTPUT: none.
972//
973// WARNINGS: none.
974//
975// HISTORY:
976// 06/04/1996 MML : Created.
977//=============================================================================
978
980{
981 //--------------------------------------------------------------------------
982 // Structure used to register Windows class.
983 //--------------------------------------------------------------------------
984 WNDCLASSEX wndclass;
985
986 //--------------------------------------------------------------------------
987 // set up and register window class
988 //--------------------------------------------------------------------------
989 wndclass.cbSize = sizeof(WNDCLASSEX);
990 wndclass.style = CS_HREDRAW | CS_VREDRAW;
991 wndclass.lpfnWndProc = Wnd_Proc;
992 wndclass.cbClsExtra = 0;
993
994 //--------------------------------------------------------------------------
995 // Reserve extra bytes for each instance of the window. We will use these
996 // bytes to store a pointer to the C++ (MainWindow) object corresponding
997 // to the window. The size of a 'this' pointer depends on the memory model.
998 //--------------------------------------------------------------------------
999 wndclass.cbWndExtra = sizeof( MainWindow * );
1000 wndclass.hInstance = Main::hInstance;
1001 wndclass.hIcon = LoadIcon( Main::hInstance, MAKEINTRESOURCE(1));
1002
1003// strcpy( szBuffer, "C&C2.ICO" );
1004// wndclass.hIcon = (HICON)LoadImage( NULL, szBuffer, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE );
1005
1006 wndclass.hCursor = LoadCursor( Main::hInstance, MAKEINTRESOURCE(2) );
1007 wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
1008 wndclass.lpszMenuName = szClassName;
1009 wndclass.lpszClassName = szClassName;
1010 wndclass.hIconSm = LoadIcon( Main::hInstance, MAKEINTRESOURCE(1));
1011
1012 if ( !RegisterClassEx((const WNDCLASSEX *) &wndclass ) ) {
1013
1014 #if(_DEBUG)
1015 LPVOID szMessage;
1016
1017 FormatMessage(
1018 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
1019 NULL,
1020 GetLastError(),
1021 MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
1022 (LPTSTR)&szMessage,
1023 0,
1024 NULL );
1025
1026 _stprintf( szBuffer, TEXT( "%s(%lx)" ), szMessage, GetLastError());
1027 Msg( __LINE__, TEXT(__FILE__), TEXT("GetLastError: %s"), szBuffer );
1028 #endif
1029
1030 exit( FALSE );
1031 }
1032}
1033
1034//*****************************************************************************
1035// MainWindow::MainWindow -- Main Window Constructor function.
1036//
1037// INPUT: none.
1038//
1039// OUTPUT: none.
1040//
1041// WARNINGS: none.
1042//
1043// HISTORY:
1044// 06/04/1996 MML : Created.
1045//=============================================================================
1046
1048{
1049 char szTitle[ _MAX_PATH ];
1050 hWnd = 0;
1051
1052#ifdef LEAN_AND_MEAN
1053
1054 WideCharToMultiByte( CodePage, 0, szFullProductName, _MAX_PATH, szBuffer, _MAX_PATH, NULL, NULL );
1055
1056#else
1057
1058 WideCharToMultiByte( CodePage, 0, fullProductName.str(), fullProductName.getLength()+1, szBuffer, _MAX_PATH, NULL, NULL );
1059
1060#endif
1061
1062 memset( szTitle, '\0', _MAX_PATH );
1063 sprintf( szTitle, CLASS_NAME, szBuffer );
1064
1065 //--------------------------------------------------------------------------
1066 // Create the MainWindow.
1067 // Pass 'this' pointer in lpParam of CreateWindow().
1068 //--------------------------------------------------------------------------
1069 hWnd = CreateWindowEx(
1070 0,
1071 szClassName,
1073 WS_POPUPWINDOW | WS_MINIMIZE | !WS_VISIBLE,
1074 0,
1075 0,
1076 640,
1077 480,
1078 NULL,
1079 NULL,
1081 (LPTSTR) this );
1082
1083 if ( !hWnd ) {
1085 exit( FALSE );
1086 }
1087
1089
1090 //-------------------------------------------------------------------------
1091 // Save the pointer so we can access it globally.
1092 //-------------------------------------------------------------------------
1093 GlobalMainWindow = this;
1094
1095 //--------------------------------------------------------------------------
1096 // If you want to see the Background Window, enable these.
1097 //--------------------------------------------------------------------------
1098// Show( Main::nCmdShow );
1099// Update();
1100}
1101
1102//*****************************************************************************
1103// MainWindow::Window_Proc -- Main Window Procedure fnc to process msgs.
1104//
1105// INPUT: none.
1106//
1107// OUTPUT: none.
1108//
1109// WARNINGS: none.
1110//
1111// HISTORY:
1112// 06/04/1996 MML : Created.
1113//=============================================================================
1114
1115LRESULT MainWindow::Window_Proc( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam )
1116{
1117 static RECT rect;
1118 static int cxChar, cyChar;
1119 static HBRUSH hBrush = 0;
1120 static POINT point;
1121 int decision;
1122 static int bits_pixel = 0;
1123
1124 switch( iMessage ) {
1125
1126 //-----------------------------------------------------------------------
1127 // Create Message.
1128 //-----------------------------------------------------------------------
1129 case WM_CREATE:
1130 #if(0)
1131 hBrush = CreateSolidBrush( GetSysColor( COLOR_WINDOW ));
1132 #endif
1133 GetClientRect( GetDesktopWindow(), &rect );
1134 SendMessage( hWnd, WM_GO, wParam, lParam );
1135 break;
1136
1137 //-----------------------------------------------------------------------
1138 // Go!
1139 //-----------------------------------------------------------------------
1140 case WM_GO:
1141
1142 decision = DialogBox( Main::hInstance, _TEXT( "BitmapDialog" ), hWnd, Dialog_Box_Proc );
1143
1144 if ( Args ) {
1145 delete( Args );
1146 Args = NULL;
1147 }
1149
1150 MoveWindow( hWnd, 0, 0, 0, 0, TRUE );
1151 SendMessage( hWnd, WM_DESTROY, wParam, lParam );
1152 Msg( __LINE__, TEXT(__FILE__), TEXT("---------------------- end of WM_GO ---------------------" ));
1153 break;
1154
1155 //-----------------------------------------------------------------------
1156 // WM_CTLCOLOR Message.
1157 // wParam Handle to Child Window's device context
1158 // LOWORD( lParam ) Child Window handle
1159 // HIWORD( lParam ) Type of Window: CTLCOLOR_MSGBOX, _EDIT, _LISTBOX, _BTN, _DLG, _SCROLLBAR, _STATIC
1160 //-----------------------------------------------------------------------
1161 #if( WINDOW_BRUSH )
1162 case WM_CTLCOLOR:
1163 if ( HIWORD( lParam ) == CTLCOLOR_BTN ) {
1164 SetBkColor( (HDC)wParam, GetSysColor( COLOR_WINDOW ));
1165 SetTextColor( (HDC)wParam, GetSysColor( COLOR_WINDOWTEXT ));
1166 UnrealizeObject( hBrush ); // reset the origin of the brush next time used.
1167 point.x = point.y = 0; // create a point.
1168 ClientToScreen( hWnd, &point ); // translate into screen coordinates.
1169 SetBrushOrg( (HDC)wParam, point.x, point.y ); // New Origin to use when next selected.
1170 return ((DWORD) hBrush);
1171 }
1172 break;
1173
1174 //-----------------------------------------------------------------------
1175 // WM_SYSCOLORCHANGE Message.
1176 //-----------------------------------------------------------------------
1177 case WM_SYSCOLORCHANGE:
1178 DeleteObject( hBrush );
1179 hBrush = CreateSolidBrush( GetSysColor( COLOR_WINDOW ));
1180 break;
1181
1182 //-----------------------------------------------------------------------
1183 // WM_SIZE Message.
1184 //-----------------------------------------------------------------------
1185 case WM_SIZE:
1186 rect.left = 24 * cxChar;
1187 rect.top = 2 * cyChar;
1188 rect.right = LOWORD( lParam );
1189 rect.bottom = HIWORD( lParam );
1190 break;
1191 #endif
1192
1193 //-----------------------------------------------------------------------
1194 // WM_COMMAND Message.
1195 // wParam Child Window ID
1196 // LOWORD( lParam ) Child Window handle
1197 // HIWORD( lParam ) Notification Code: BN_CLICKED, BN_PAINT, etc...
1198 //-----------------------------------------------------------------------
1199 case WM_COMMAND:
1200 break;
1201
1202 //-----------------------------------------------------------------------
1203 // WM_DESTROY Message.
1204 //-----------------------------------------------------------------------
1205 case WM_DESTROY:
1206 #if(WINDOW_BRUSH)
1207 DeleteObject( hBrush );
1208 #endif
1209 PostQuitMessage( 0 );
1210 break;
1211
1212 default:
1213 return DefWindowProc( hWnd, iMessage, wParam, lParam );
1214 }
1215 return 0;
1216}
1217
1218
1219//*****************************************************************************
1220// MainWindow::Is_Product_Registered -- Check the Registration Table information.
1221//
1222// INPUT: none.
1223//
1224// OUTPUT: BOOL - TRUE if product is already installed, FALSE if not.
1225//
1226// WARNINGS: none.
1227//
1228// HISTORY:
1229// 06/04/1996 MML : Created.
1230//=============================================================================
1231
1233{
1234 HKEY phKey;
1235 BOOL result = FALSE;
1236
1237 char key [_MAX_PATH];
1238 wchar_t szPath [_MAX_PATH];
1239 char aName [_MAX_PATH]; //jfs
1240
1241 unsigned long Type;
1242 unsigned long Size = _MAX_PATH;
1243
1244 HANDLE handle;
1245 WIN32_FIND_DATA FindFileData;
1246
1247 memset( szPath, '\0', sizeof( szPath ));
1248 memset( szGamePath, '\0', sizeof( szGamePath ));
1249 memset( szSetupPath, '\0', sizeof( szSetupPath ));
1250 memset( szRegisterPath, '\0', sizeof( szRegisterPath ));
1251 memset( szInternetPath, '\0', sizeof( szInternetPath ));
1252 memset( szUninstallPath, '\0', sizeof( szUninstallPath ));
1253 memset( szUninstallCommandLine, '\0', sizeof( szUninstallCommandLine ));
1254 memset( FindFileData.cFileName, '\0', sizeof( FindFileData.cFileName ));
1255 memset( FindFileData.cAlternateFileName, '\0', sizeof( FindFileData.cAlternateFileName ));
1256
1262
1263 //==========================================================================
1264 // Look for keys under the Game's Registry key.
1265 //==========================================================================
1266// _tcscat( _tcscpy( key, SOFTWARE_EAGAMES_KEY ), szRegistryKey );
1267 _tcscat( _tcscpy( key, EAGAMES_GENERALS_KEY ), szRegistryKey );
1268
1269 //--------------------------------------------------------------------------
1270 // Try to open the key.
1271 //--------------------------------------------------------------------------
1272 if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE, &phKey ) == ERROR_SUCCESS ) {
1273
1274 //-----------------------------------------------------------------------
1275 // Get Full path\filename of product to execute ("Play").
1276 //-----------------------------------------------------------------------
1277 Size = _MAX_PATH;
1278 if ( RegQueryValueEx( phKey, INSTALL_PATH_KEY, NULL, &Type, (unsigned char *)szGamePath, &Size ) == ERROR_SUCCESS ) {
1280 _tcscpy(szPatchgetPath, szGamePath);
1281 _tcscat(szGamePath, LAUNCHER_FILENAME);
1284 handle = FindFirstFile( szGamePath, &FindFileData );
1285 if ( handle != INVALID_HANDLE_VALUE ) {
1287 FindClose( handle );
1288 }
1289 }
1290 Msg( __LINE__, TEXT(__FILE__), TEXT("GamePath = %s."), szGamePath );
1291
1292 RegCloseKey( phKey );
1293 }
1294
1295 //==========================================================================
1296 // Find Keys under "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
1297 //==========================================================================
1298
1299 _tcscpy( key, SHELL_UNINSTALL_KEY );
1300 Path_Add_Back_Slash( key );
1301 _tcscat( key, szRegistryKey );
1302
1303 //--------------------------------------------------------------------------
1304 // Query the Uninstall key "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
1305 //--------------------------------------------------------------------------
1306 if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, key, 0, KEY_ALL_ACCESS, &phKey ) == ERROR_SUCCESS ) {
1307
1308 Size = _MAX_PATH;
1309 if ( RegQueryValueEx( phKey, UNINSTALL_STRING_SUBKEY, NULL, &Type, (unsigned char *)aName, &Size ) == ERROR_SUCCESS )
1310 {
1311 //------------------------------------------------------------------------------------------------------
1312 // Look for the uninstall program. If found, set flag.
1313 // JFS... need to extract path and command line... 8/26/03
1314 // JFS... further verify that we use a very limited uninstall based on the presence of "IDriver.exe"
1315 //------------------------------------------------------------------------------------------------------
1316 if(strstr(aName,UNINSTALL_EXECUTABLE) != NULL)
1317 {
1318 char *sp;
1319
1320 strcpy( szUninstallPath, aName );
1321 sp = strchr(szUninstallPath,'/');
1322 if(*sp != NULL)
1323 {
1324 strcpy( szUninstallCommandLine, sp );
1325 strcpy( szUninstallPath, aName );
1326 *sp = '\0';
1327 }
1328 }
1329
1330 handle = FindFirstFile( szUninstallPath, &FindFileData );
1331 if ( handle != INVALID_HANDLE_VALUE ) {
1333 FindClose( handle );
1334 }
1335 }
1336 RegCloseKey( phKey );
1337 }
1338
1339 //==========================================================================
1340 // Look for keys under Register. If available, we should show the "Register"
1341 // button. WESTWOOD_REGISTER_KEY "Software\\Westwood\\Register"
1342 //==========================================================================
1343// _tcscpy( key, WESTWOOD_REGISTER_KEY );
1344
1345 //-------------------------------------------------------------------------
1346 // Create IGR Options Object.
1347 //-------------------------------------------------------------------------
1349 if ( OnlineOptions ) {
1350 OnlineOptions->Init();
1351 }
1352
1353 //--------------------------------------------------------------------------
1354 // If "Options" is set under WOLAPI, then this is a Game Room Edition and
1355 // registration should NOT be allowed.
1356 //--------------------------------------------------------------------------
1357 if ( OnlineOptions ) {
1358 DisplayRegisterButton = OnlineOptions->Is_Running_Reg_App_Allowed();
1359 }
1360
1361 //--------------------------------------------------------------------------
1362 // If Registration is allowed...
1363 //--------------------------------------------------------------------------
1364/*
1365 if ( DisplayRegisterButton ) {
1366
1367 DisplayRegisterButton = false;
1368
1369 if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE, &phKey ) == ERROR_SUCCESS ) {
1370
1371 //-----------------------------------------------------------------------
1372 // Get Full path\filename of product to execute ("Register.exe").
1373 //-----------------------------------------------------------------------
1374 Size = _MAX_PATH;
1375 if ( RegQueryValueEx( phKey, INSTALLPATH_SUBKEY, NULL, &Type, (unsigned char *)szRegisterPath, &Size ) == ERROR_SUCCESS ) {
1376
1377 //--------------------------------------------------------------------
1378 // Check if this executable exists.
1379 //--------------------------------------------------------------------
1380 handle = FindFirstFile( szRegisterPath, &FindFileData );
1381 if ( handle != INVALID_HANDLE_VALUE ) {
1382 DisplayRegisterButton = TRUE;
1383 FindClose( handle );
1384 }
1385 }
1386 RegCloseKey( phKey );
1387 }
1388 }
1389*/
1390 //==========================================================================
1391 // Is WOLAPI DLL installed?
1392 //==========================================================================
1393/*
1394 _tcscpy( key, WESTWOOD_WOLAPI_KEY );
1395
1396 if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE, &phKey ) == ERROR_SUCCESS ) {
1397
1398 //-----------------------------------------------------------------------
1399 // Get Full path\filename of product to execute ("Register.exe").
1400 //-----------------------------------------------------------------------
1401 Size = _MAX_PATH;
1402 if ( RegQueryValueEx( phKey, INSTALLPATH_SUBKEY, NULL, &Type, (unsigned char *)szBuffer, &Size ) == ERROR_SUCCESS ) {
1403
1404 //--------------------------------------------------------------------
1405 // Check if this executable exists.
1406 //--------------------------------------------------------------------
1407 handle = FindFirstFile( szBuffer, &FindFileData );
1408 if ( handle != INVALID_HANDLE_VALUE ) {
1409 IsWolapiAvailable = TRUE;
1410 FindClose( handle );
1411 }
1412 }
1413 RegCloseKey( phKey );
1414 }
1415*/
1416
1417 Msg( __LINE__, TEXT(__FILE__), TEXT("---------------- Is_Product_Registered---------------" ));
1418 Msg( __LINE__, TEXT(__FILE__), TEXT(" InstallProduct = %d."), InstallProduct );
1419 Msg( __LINE__, TEXT(__FILE__), TEXT(" UninstallAvailable = %d."), UninstallAvailable );
1420 Msg( __LINE__, TEXT(__FILE__), TEXT(" IsUserRegistered = %d."), IsUserRegistered );
1421 Msg( __LINE__, TEXT(__FILE__), TEXT(" DisplayRegisterButton = %d."), DisplayRegisterButton );
1422 Msg( __LINE__, TEXT(__FILE__), TEXT(" szGamePath = %s."), szGamePath );
1423 Msg( __LINE__, TEXT(__FILE__), TEXT(" szSetupPath = %s."), szSetupPath );
1424 Msg( __LINE__, TEXT(__FILE__), TEXT(" szRegisterPath = %s."), szRegisterPath );
1425 Msg( __LINE__, TEXT(__FILE__), TEXT(" szInternetPath = %s."), szInternetPath );
1426 Msg( __LINE__, TEXT(__FILE__), TEXT(" szUninstallPath = %s."), szUninstallPath );
1427
1428 return( result );
1429}
1430
1431
1432//*****************************************************************************
1433// MainWindow::Run_Explorer
1434//
1435// Get the Current Dir from argv[0]. Open the Explorer Window with
1436// this dir. The Explorer will open and display everything in this dir.
1437//
1438// INPUT: none.
1439//
1440// OUTPUT: none.
1441//
1442// WARNINGS: none.
1443//
1444// HISTORY:
1445// 06/04/1996 MML : Created.
1446//=============================================================================
1447
1448BOOL MainWindow::Run_Explorer( char *szString, HWND hWnd, RECT *rect )
1449{
1450 char szWindowsPath [ _MAX_PATH ];
1451 char szPath [ _MAX_PATH ];
1452 char szCurDir [ _MAX_PATH ];
1453 char drive [ _MAX_DRIVE ];
1454 char dir [ _MAX_DIR ];
1455 char lpszComLine [ 127 ];
1456
1457 BOOL result = FALSE;
1458 PROCESS_INFORMATION processinfo;
1459 STARTUPINFO startupinfo;
1460
1461 //--------------------------------------------------------------------------
1462 // Get current drive/directory from _argv[0].
1463 //--------------------------------------------------------------------------
1464 _tcscpy( szPath, szArgvPath );
1465 _tsplitpath( szPath, drive, dir, NULL, NULL );
1466 _tmakepath ( szPath, drive, dir, NULL, NULL );
1467
1468 //--------------------------------------------------------------------------
1469 // Get Windows directory and build path to Explorer. Pas in szPath as
1470 // the directory for Explorer to open.
1471 //--------------------------------------------------------------------------
1472 GetWindowsDirectory( szWindowsPath, _MAX_PATH );
1473 Path_Add_Back_Slash( szWindowsPath );
1474
1475 _tcscat( szWindowsPath, EXPLORER_NAME );
1476 _tcscat( _tcscat( _tcscpy( lpszComLine, szWindowsPath ), _TEXT( " " )), szPath );
1477 _tcscpy( szCurDir, szPath );
1478
1479 //==========================================================================
1480 // Setup the call
1481 //==========================================================================
1482 memset( &startupinfo, 0, sizeof( STARTUPINFO ));
1483 startupinfo.cb = sizeof( STARTUPINFO );
1484
1485 //--------------------------------------------------------------------------
1486 // Next, start the process
1487 //--------------------------------------------------------------------------
1488 result = CreateProcess(
1489 szWindowsPath, // address of module name
1490 lpszComLine, // address of command line
1491 NULL, // address of process security attributes
1492 NULL, // address of thread security attributes
1493 FALSE, // new process inherits handles
1494 0, // creation flags
1495 NULL, // address of new environment block
1496 szCurDir, // address of current directory name
1497 &startupinfo, // address of STARTUPINFO
1498 &processinfo ); // address of PROCESS_INFORMATION
1499
1500 //--------------------------------------------------------------------------
1501 // If WinExec returned 0, error occurred.
1502 //--------------------------------------------------------------------------
1503 if ( !result ) {
1504
1506
1507 #if(BACKGROUND_BITMAP)
1508 //-----------------------------------------------------------------------
1509 // Recreate Buttons based on Registry, then repaint window.
1510 //-----------------------------------------------------------------------
1511 Create_Buttons( hWnd, rect );
1512 InvalidateRect( hWnd, rect, FALSE );
1513 #endif
1514 }
1515 return ( result );
1516}
1517
1518//*****************************************************************************
1519// MainWindow::Run_Game -- Launch the game based on registry information.
1520//
1521// INPUT: none.
1522//
1523// OUTPUT: none.
1524//
1525// WARNINGS: none.
1526//
1527// HISTORY:
1528// 06/04/1996 MML : Created.
1529//=============================================================================
1530
1531unsigned int MainWindow::Run_Game ( HWND hWnd, RECT *rect )
1532{
1533 char dir [_MAX_DIR];
1534 char ext [_MAX_EXT];
1535 char drive [_MAX_DRIVE];
1536 char file [_MAX_FNAME];
1537
1538// unsigned abc = 0;
1539 HANDLE handle;
1540 WIN32_FIND_DATA FindFileData;
1541
1542 //--------------------------------------------------------------------------
1543 // Check if C&C is already running, and is looking for the CDRom.
1544 // The Autorun keeps asking to "Play" when this happens.
1545 //--------------------------------------------------------------------------
1546 HWND game_window = FindWindow ( szGameWindow, NULL );
1547 if ( game_window ){
1548 ShowWindow( game_window, SW_RESTORE );
1549 SetForegroundWindow ( game_window );
1550 return FALSE;
1551 }
1552
1553 //--------------------------------------------------------------------------
1554 // Split into parts.
1555 //--------------------------------------------------------------------------
1556 _tsplitpath( szGamePath, drive, dir, file, ext );
1557
1558 //--------------------------------------------------------------------------
1559 // Launch the game.
1560 //--------------------------------------------------------------------------
1561 handle = FindFirstFile( szGamePath, &FindFileData );
1562 if ( handle == INVALID_HANDLE_VALUE ) {
1563 return FALSE;
1564 }
1565
1566 FindClose( handle );
1567
1568 //-----------------------------------------------------------------------
1569 // Stop Sound if sound was playing.
1570 //-----------------------------------------------------------------------
1572
1573 LaunchObject.SetPath( szGamePath );
1574 LaunchObject.Set_Launch( true );
1575 return( true );
1576}
1577
1578//*****************************************************************************
1579// MainWindow::Run_WorldBuilder -- Launch the map editor based on registry information.
1580//
1581// INPUT: none.
1582//
1583// OUTPUT: none.
1584//
1585// WARNINGS: none.
1586//
1587// HISTORY:
1588// 12/02/2002 BGC : Created.
1589//=============================================================================
1590
1591unsigned int MainWindow::Run_WorldBuilder( HWND hWnd, RECT *rect)
1592{
1593 HANDLE handle;
1594 WIN32_FIND_DATA FindFileData;
1595
1596 //--------------------------------------------------------------------------
1597 // Launch the game.
1598 //--------------------------------------------------------------------------
1599 handle = FindFirstFile( szWorldbuilderPath, &FindFileData );
1600 if ( handle == INVALID_HANDLE_VALUE ) {
1601 return FALSE;
1602 }
1603
1604 FindClose( handle );
1605
1606 //-----------------------------------------------------------------------
1607 // Stop Sound if sound was playing.
1608 //-----------------------------------------------------------------------
1610
1612 LaunchObject.Set_Launch( true );
1613 return( true );
1614}
1615
1616//*****************************************************************************
1617// MainWindow::Run_PatchGet -- Launch the patch checker based on registry information.
1618//
1619// INPUT: none.
1620//
1621// OUTPUT: none.
1622//
1623// WARNINGS: none.
1624//
1625// HISTORY:
1626// 12/02/2002 BGC : Created.
1627//=============================================================================
1628
1629unsigned int MainWindow::Run_PatchGet( HWND hWnd, RECT *rect)
1630{
1631 HANDLE handle;
1632 WIN32_FIND_DATA FindFileData;
1633
1634 //--------------------------------------------------------------------------
1635 // Launch the game.
1636 //--------------------------------------------------------------------------
1637 handle = FindFirstFile( szPatchgetPath, &FindFileData );
1638 if ( handle == INVALID_HANDLE_VALUE ) {
1639 return FALSE;
1640 }
1641
1642 FindClose( handle );
1643
1644 //-----------------------------------------------------------------------
1645 // Stop Sound if sound was playing.
1646 //-----------------------------------------------------------------------
1648
1649 LaunchObject.SetPath( szPatchgetPath );
1650 LaunchObject.Set_Launch( true );
1651 return( true );
1652}
1653
1654//*****************************************************************************
1655// MainWindow::Run_Demo -- Launch a demo program if desired.
1656//
1657// INPUT: none.
1658//
1659// OUTPUT: none.
1660//
1661// WARNINGS: none.
1662//
1663// HISTORY:
1664// 01/08/2002 MML : Created.
1665//=============================================================================
1666
1667unsigned int MainWindow::Run_Demo ( HWND hWnd, RECT *rect, int cd_drive )
1668{
1669// unsigned abc = 0;
1670 HANDLE handle;
1671 WIN32_FIND_DATA FindFileData;
1672
1673 //--------------------------------------------------------------------------
1674 // Make path to demo program.
1675 //--------------------------------------------------------------------------
1676// Make_Current_Path_To( MOH_DEMO_PROGRAM, szBuffer );
1677 wsprintf( szBuffer, "%c:\\", 'A' + cd_drive );
1679 strcat( szBuffer, MOH_DEMO_PROGRAM );
1680
1681 //--------------------------------------------------------------------------
1682 // Launch the game.
1683 //--------------------------------------------------------------------------
1684 handle = FindFirstFile( szBuffer, &FindFileData );
1685 if ( handle == INVALID_HANDLE_VALUE ) {
1687 return FALSE;
1688 }
1689
1690 FindClose( handle );
1691
1692 //-----------------------------------------------------------------------
1693 // Stop Sound if sound was playing.
1694 //-----------------------------------------------------------------------
1696
1697 LaunchObject.SetPath( szBuffer );
1698 LaunchObject.Set_Launch( true );
1699 return( true );
1700}
1701
1702//*****************************************************************************
1703// MainWindow::Run_OpenFile -- Main Window function to perform Setup tasks.
1704//
1705// INPUT: none.
1706//
1707// OUTPUT: none.
1708//
1709// WARNINGS: none.
1710//
1711// HISTORY:
1712// 06/04/1996 MML : Created.
1713//=============================================================================
1714
1715unsigned int MainWindow::Run_OpenFile(int cd_drive, const char *filename, bool wait /* = false */)
1716{
1717 char filepath[MAX_PATH];
1718 MSG msg;
1719 BOOL returnValue;
1720
1721 SHELLEXECUTEINFO executeInfo;
1722 memset(&executeInfo, 0, sizeof(executeInfo));
1723
1724 executeInfo.cbSize = sizeof(executeInfo);
1725 executeInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
1726 executeInfo.hwnd = ApplicationHWnd;
1727 executeInfo.lpVerb = "open";
1728 executeInfo.lpFile = filename;
1729 executeInfo.nShow = SW_SHOWNORMAL;
1730
1731 HANDLE hProcess;
1732
1733
1734 BOOL ret = ShellExecuteEx(&executeInfo);
1735
1736 if ((ret == 0) || ((int)(executeInfo.hInstApp) <= 32)) {
1737 Msg(__LINE__, TEXT(__FILE__), TEXT("Couldn't find executable for %s\n"), filepath);
1738 return 0;
1739 }
1740
1741 hProcess = executeInfo.hProcess;
1742
1743 if (wait == true) {
1744 WaitForInputIdle(hProcess, 5000);
1745
1746 bool waiting = true;
1747 bool quit = false;
1748
1749 while ((waiting == true) && (quit != true)) {
1750 Sleep(0);
1751
1752 while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
1753 {
1754
1755 // get the message
1756 returnValue = GetMessage( &msg, NULL, 0, 0 );
1757
1758 // check for quitting
1759 if( returnValue == 0 )
1760 quit = TRUE;
1761
1762 // translate and dispatch the message
1763 TranslateMessage( &msg );
1764 DispatchMessage( &msg );
1765
1766 } // end while
1767
1768 DWORD exitCode;
1769 GetExitCodeProcess(hProcess, &exitCode);
1770
1771 if (exitCode != STILL_ACTIVE) {
1772 waiting = false;
1773 }
1774 }
1775 }
1776
1777 return 1;
1778}
1779
1780//*****************************************************************************
1781// MainWindow::Run_Setup -- Main Window function to perform Setup tasks.
1782//
1783// INPUT: none.
1784//
1785// OUTPUT: none.
1786//
1787// WARNINGS: none.
1788//
1789// HISTORY:
1790// 06/04/1996 MML : Created.
1791//=============================================================================
1792
1793unsigned int MainWindow::Run_Setup( HWND hWnd, RECT *rect, int cd_drive )
1794{
1795// UINT result = 0;
1796 int i = 0;
1797 char params [ 127 ];
1798 char filepath[ _MAX_PATH ];
1799 HANDLE handle;
1800 WIN32_FIND_DATA FindFileData;
1801
1802 Msg( __LINE__, TEXT(__FILE__), TEXT("---------------------- Run_Setup --------------------." ));
1803
1804 //--------------------------------------------------------------------------
1805 // Clear these buffers for later use.
1806 //--------------------------------------------------------------------------
1807 memset( params, '\0', 127 );
1808
1809 //--------------------------------------------------------------------------
1810 // Get Drive & Dir from ARGV[0] and create path to SETUP.EXE.
1811 //--------------------------------------------------------------------------
1812// strcpy( filepath, szArgvPath );
1813// Path_Add_Back_Slash( filepath );
1814
1815 wsprintf( filepath, "%c:\\", 'A' + cd_drive );
1816 Path_Add_Back_Slash( filepath );
1817 strcat( filepath, SETUP_NAME );
1818
1819 //--------------------------------------------------------------------------
1820 // If we could not find SETUP.EXE, then display error msg and exit.
1821 //--------------------------------------------------------------------------
1822 handle = FindFirstFile( filepath, &FindFileData );
1823 if ( handle == INVALID_HANDLE_VALUE ) {
1825 return FALSE;
1826 }
1827 FindClose( handle );
1828
1829 //--------------------------------------------------------------------------
1830 // Create parameters to pass in with the program we are calling.
1831 //--------------------------------------------------------------------------
1832 memset( params, '\0', sizeof( params ));
1833 if ( NumberArguments ) {
1834
1835 _tcscpy( params, Arguments[0] );
1836 i = 1;
1837 while (( i < NUM_ARGUMENTS ) && ( i < NumberArguments )) {
1838 _tcscat( _tcscat( params, _TEXT( " " )), Arguments[i] );
1839 i++;
1840 }
1841 }
1842
1843 //--------------------------------------------------------------------------
1844 // Stop Sound if sound was playing.
1845 //--------------------------------------------------------------------------
1847
1848 LaunchObject.SetPath( filepath );
1849 LaunchObject.SetArgs( params );
1850 LaunchObject.Set_Launch( true );
1851 return( true );
1852}
1853
1854
1855//*****************************************************************************
1856// MainWindow::Run_New_Account -- Create a new online account.
1857//
1858// INPUT: none.
1859//
1860// OUTPUT: none.
1861//
1862// WARNINGS: none.
1863//
1864// HISTORY:
1865// 06/04/1996 MML : Created.
1866//=============================================================================
1867
1868unsigned int MainWindow::Run_New_Account ( HWND hWnd, RECT *rect )
1869{
1870// UINT result = 0;
1871 int i = 0;
1872 char params [ 127 ];
1873 char filepath[ _MAX_PATH ];
1874 HANDLE handle;
1875 WIN32_FIND_DATA FindFileData;
1876
1877 //--------------------------------------------------------------------------
1878 // Clear these buffers for later use.
1879 //--------------------------------------------------------------------------
1880 memset( params, '\0', 127 );
1881
1882 //--------------------------------------------------------------------------
1883 // Get Drive & Dir from ARGV[0] and create path to SETUP.EXE.
1884 //--------------------------------------------------------------------------
1885 _tcscpy( filepath, szArgvPath );
1886 Path_Add_Back_Slash( filepath );
1887 _tcscat( filepath, SETUP_NAME );
1888
1889 //--------------------------------------------------------------------------
1890 // If we could not find SETUP.EXE, then display error msg and exit.
1891 //--------------------------------------------------------------------------
1892 handle = FindFirstFile( filepath, &FindFileData );
1893 if ( handle == INVALID_HANDLE_VALUE ) {
1895 return FALSE;
1896 }
1897 FindClose( handle );
1898
1899 //--------------------------------------------------------------------------
1900 // Create parameters to pass in with the program we are calling.
1901 //--------------------------------------------------------------------------
1902 memset( params, '\0', sizeof( params ));
1903 if ( NumberArguments ) {
1904
1905 _tcscpy( params, Arguments[0] );
1906 i = 1;
1907 while (( i < NUM_ARGUMENTS ) && ( i < NumberArguments )) {
1908 _tcscat( _tcscat( params, _TEXT( " " )), Arguments[i] );
1909 i++;
1910 }
1911 _tcscat( params, _TEXT( " " ));
1912 }
1913 _tcscat( params, "-o" );
1914
1915 //--------------------------------------------------------------------------
1916 // Stop Sound if sound was playing.
1917 //--------------------------------------------------------------------------
1919
1920 LaunchObject.SetPath( filepath );
1921 LaunchObject.SetArgs( params );
1922 LaunchObject.Set_Launch( true );
1923 return( true );
1924}
1925
1926
1927//*****************************************************************************
1928// MainWindow::Run_Register_Or_Auto_Update
1929//
1930// Either run Register.exe or Game Update Program from the user's harddrive.
1931//
1932// INPUT: none.
1933//
1934// OUTPUT: none.
1935//
1936// WARNINGS: none.
1937//
1938// HISTORY:
1939// 02/24/1999 MML : Created.
1940//=============================================================================
1941
1942unsigned int MainWindow::Run_Register ( HWND hWnd, RECT *rect )
1943{
1944 char szArgs[ MAX_PATH ];
1945 HANDLE handle;
1946 WIN32_FIND_DATA FindFileData;
1947 BOOL result = FALSE;
1948
1949 //--------------------------------------------------------------------------
1950 // Register Program is available. Continue...
1951 //--------------------------------------------------------------------------
1952 if ( DisplayRegisterButton ) {
1953
1954 //-----------------------------------------------------------------------
1955 // Check again. May have been changed ...
1956 //-----------------------------------------------------------------------
1957 handle = FindFirstFile( szRegisterPath, &FindFileData );
1958 if ( handle == INVALID_HANDLE_VALUE ) {
1959 return( 0 );
1960 }
1961 FindClose( handle );
1962
1963 //-----------------------------------------------------------------------
1964 // User is already registered, so maybe we should Auto Update!
1965 //-----------------------------------------------------------------------
1966 strcpy( szArgs, _TEXT( " " ));
1967
1968 LaunchObject.SetPath( szRegisterPath );
1969 LaunchObject.SetArgs( szArgs );
1970 LaunchObject.Set_Launch( true );
1971 result = true;
1972 }
1973
1974 return( result );
1975}
1976
1977//*****************************************************************************
1978// MainWindow::Run_Auto_Update
1979//
1980// Either run Register.exe or Game Update Program from the user's harddrive.
1981//
1982// INPUT: none.
1983//
1984// OUTPUT: none.
1985//
1986// WARNINGS: none.
1987//
1988// HISTORY:
1989// 02/24/1999 MML : Created.
1990//=============================================================================
1991
1992unsigned int MainWindow::Run_Auto_Update ( HWND hWnd, RECT *rect )
1993{
1994 char szArgs [ MAX_PATH ];
1995 HANDLE handle;
1996 WIN32_FIND_DATA FindFileData;
1997 BOOL result = FALSE;
1998
1999 //--------------------------------------------------------------------------
2000 // Register Program is available. Continue...
2001 //--------------------------------------------------------------------------
2002 if ( !InstallProduct ) {
2003
2004 //-----------------------------------------------------------------------
2005 // Check again. May have been changed ...
2006 //-----------------------------------------------------------------------
2007 handle = FindFirstFile( szGamePath, &FindFileData );
2008 if ( handle == INVALID_HANDLE_VALUE ) {
2009 return( 0 );
2010 }
2011 FindClose( handle );
2012
2013 _tcscpy( szArgs, _TEXT( " GrabPatches" ));
2014
2015 LaunchObject.SetPath( szGamePath );
2016 LaunchObject.SetArgs( szArgs );
2017 LaunchObject.Set_Launch( true );
2018 result = true;
2019 }
2020 return( result );
2021}
2022
2023
2024//*****************************************************************************
2025// MainWindow::Run_Uninstall -- Main Window function to perform Setup tasks.
2026//
2027// INPUT: none.
2028//
2029// OUTPUT: none.
2030//
2031// WARNINGS: none.
2032//
2033// HISTORY:
2034// 06/04/1996 MML : Created.
2035//=============================================================================
2036
2037unsigned int MainWindow::Run_Uninstall( HWND hWnd, RECT *rect )
2038{
2039// MSG msg;
2040 UINT result = 0;
2041// int done = 0;
2042// DWORD dwTimeout = 1500;
2043// DWORD dwRC = WAIT_TIMEOUT;
2044 DWORD lpExitCode;
2045
2046 STARTUPINFO startupinfo;
2047 PROCESS_INFORMATION processinfo;
2048 HANDLE handle;
2049 WIN32_FIND_DATA FindFileData;
2050
2051 char szCurDir [_MAX_PATH];
2052 char file [_MAX_FNAME];
2053 char ext [_MAX_EXT];
2054 char szPath [_MAX_PATH];
2055
2056 //--------------------------------------------------------------------------
2057 // Launch the UNINSTALL.
2058 //--------------------------------------------------------------------------
2059 handle = FindFirstFile( szUninstallPath, &FindFileData );
2060 if ( handle == INVALID_HANDLE_VALUE ) {
2061 return( 0 );
2062 }
2063
2064 FindClose( handle );
2065
2066 _splitpath( szUninstallPath, drive, dir, NULL, NULL );
2067 _makepath ( szCurDir, drive, dir, NULL, NULL );
2068
2069 //=======================================================================
2070 // Setup the call
2071 //=======================================================================
2072 memset( &startupinfo, 0, sizeof( STARTUPINFO ));
2073 startupinfo.cb = sizeof( STARTUPINFO );
2074
2075 result = CreateProcess(
2076 szUninstallPath, // address of module name
2077 szUninstallCommandLine, // address of command line
2078 NULL, // address of process security attributes
2079 NULL, // address of thread security attributes
2080 0, // new process inherits handles
2081 0,
2082 NULL, // address of new environment block
2083 szCurDir,
2084 &startupinfo, // address of STARTUPINFO
2085 &processinfo ); // address of PROCESS_INFORMATION
2086
2087 //--------------------------------------------------------------------------
2088 // If WinExec returned 0, error occurred.
2089 //--------------------------------------------------------------------------
2090 if ( !result ) {
2091
2092 _tsplitpath( szUninstallPath, NULL, NULL, file, ext );
2093 _tmakepath ( szPath, NULL, NULL, file, ext );
2095
2096// #if(BACKGROUND_BITMAP)
2097 //-----------------------------------------------------------------------
2098 // Recreate Buttons based on Registry, then repaint window.
2099 //-----------------------------------------------------------------------
2100// Create_Buttons( hWnd, rect );
2101// InvalidateRect( hWnd, rect, FALSE );
2102// #endif
2103
2104 return( result );
2105 }
2106
2107 // JFS: 8-26-03... Can't have auto run going during an uninstall!
2108#if 0
2109 //--------------------------------------------------------------------------
2110 // Wait for App to shutdown
2111 //--------------------------------------------------------------------------
2112 while (dwRC == WAIT_TIMEOUT)
2113 {
2114
2115 //-----------------------------------------------------------------------
2116 // Wait for object
2117 //-----------------------------------------------------------------------
2118 dwRC = WaitForSingleObject( processinfo.hProcess, dwTimeout );
2119
2120
2121 //-----------------------------------------------------------------------
2122 // Flush the Queue
2123 //-----------------------------------------------------------------------
2124 while (PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) {
2125 TranslateMessage( &msg );
2126// DispatchMessage( &msg );
2127 }
2128 }
2129#endif
2130 //--------------------------------------------------------------------------
2131 // If the specified process has not terminated, the termination status
2132 // returned is STILL_ACTIVE.
2133 //--------------------------------------------------------------------------
2134 GetExitCodeProcess( processinfo.hProcess, &lpExitCode );
2135 CloseHandle( processinfo.hProcess );
2136 CloseHandle( processinfo.hThread );
2137
2138#if(BACKGROUND_BITMAP)
2139
2140 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2141 // MML 5/27/99: This function is dropping through because we launch Uninstll.exe
2142 // which in turn launches Uninst.exe thus ::Run_Install ends before Uninst.exe is done.
2143 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2144
2145 //--------------------------------------------------------------------------
2146 // Recreate Buttons based on Registry.
2147 // Repaint calling Window.
2148 //--------------------------------------------------------------------------
2149 Create_Buttons( hWnd, rect );
2150 InvalidateRect( hWnd, rect, FALSE );
2151#endif
2152
2153 return( result );
2154}
2155
2156//*****************************************************************************
2157// MainWindow::Create_Buttons -- Reset the Buttons.
2158//
2159// INPUT: none.
2160//
2161// OUTPUT: none.
2162//
2163// WARNINGS: none.
2164//
2165// HISTORY:
2166// 06/04/1996 MML : Created.
2167//=============================================================================
2168
2169void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect )
2170{
2171 int j = 0;
2172 int i = 0;
2173 int x_pos = 0;
2174 int y_pos = 0;
2175 int width = 0;
2176 int height = 0;
2177 int button_index = 0;
2178
2179 HBITMAP hButtonBitmap = 0;
2180 HPALETTE hpal = 0;
2181 BITMAP button_bm;
2182 char next_button_name[_MAX_PATH];
2183 char focused_button_name[_MAX_PATH];
2184 RECT * button_size = ButtonSizes;
2185
2186 //--------------------------------------------------------------------------
2187 // Reset all the flags.
2188 //--------------------------------------------------------------------------
2190
2191 Msg( __LINE__, TEXT(__FILE__), TEXT("------------------------ Create_Buttons ------------------------" ));
2192
2193 //--------------------------------------------------------------------------
2194 // Get width and height of the button.
2195 //--------------------------------------------------------------------------
2196 hButtonBitmap = LoadResourceBitmap( Main::hModule, BUTTON_REG, &hpal, TRUE );
2197 if ( hButtonBitmap ) {
2198 GetObject( hButtonBitmap, sizeof( BITMAP ), (LPTSTR)&button_bm );
2199 width = button_bm.bmWidth;
2200 height = button_bm.bmHeight;
2201 DeleteObject( hButtonBitmap );
2202 hButtonBitmap = 0;
2203 } else {
2204 button_bm.bmWidth = width = BUTTON_WIDTH;
2205 button_bm.bmHeight = height = BUTTON_HEIGHT;
2206 }
2207
2208 //--------------------------------------------------------------------------
2209 // Initialize the ButtonList.
2210 //--------------------------------------------------------------------------
2211 if( b640X480 || b800X600 ) {
2212
2213 x_pos = 410;
2214 y_pos = 90;
2215 } else {
2216 x_pos = 540;
2217 y_pos = 117;
2218 }
2219
2220 for ( i = 0; i < NUM_BUTTONS; i++ ) {
2221
2222 if ( ButtonList[i] )
2223 {
2224 delete( ButtonList[i] );
2225 }
2226
2227 ButtonList[i] = NULL;
2228 ButtonSizes[i].left = x_pos; // X position.
2229 ButtonSizes[i].top = y_pos; // Y position.
2230 ButtonSizes[i].right = width; // Button's width.
2231 ButtonSizes[i].bottom = height; // Button's height.
2232 y_pos += height + 4;
2233
2234 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonSizes[%d] = ( %d, %d, %d, %d )"),
2235 i, ButtonSizes[i].left, ButtonSizes[i].top, ButtonSizes[i].right, ButtonSizes[i].bottom );
2236 }
2237
2238 //==========================================================================
2239 // Create the "Buttons"
2240 //==========================================================================
2241 i = 0;
2242 j = 0;
2243
2244 //--------------------------------------------------------------------------
2245 // Make any other necessary adjustments here.
2246 //--------------------------------------------------------------------------
2247 int count = 7;
2248
2249 if ( !UninstallAvailable ) {
2250 count--; // No uninstall button.
2251 }
2252 if ( InstallProduct ) {
2253 count--; // No Website button.
2254 }
2255 button_index = 0;
2256
2257 strcpy( next_button_name, ButtonImages[button_index] );
2258 strcpy( focused_button_name, FocusedButtonImages[button_index] );
2259
2260 button_size = ButtonSizes;
2261 i = j = button_index;
2262
2263 Msg( __LINE__, TEXT(__FILE__), TEXT("count = %d."), count );
2264 Msg( __LINE__, TEXT(__FILE__), TEXT("button_index = %d."), button_index );
2265 Msg( __LINE__, TEXT(__FILE__), TEXT("next_button_name = %s."), next_button_name );
2266 Msg( __LINE__, TEXT(__FILE__), TEXT("focused_button_name = %s."), focused_button_name );
2267
2268
2269 //-------------------------------------------------------------------------
2270 // INSTALL or PLAY?
2271 //-------------------------------------------------------------------------
2272 if ( InstallProduct ) {
2273
2274 //---------------------------------------------------------------------
2275 // (8) INSTALL button.
2276 //---------------------------------------------------------------------
2277 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonList[%d]: Id=%d, ButtonSizes=%d, String=%s."), i, IDD_OK, j, "Install" );
2278 ButtonList[i++] = new DrawButton(
2279 IDD_OK,
2280 button_size[j++],
2281 BUTTON_REG,
2282 BUTTON_SEL,
2283 BUTTON_SEL,
2284#ifdef LEAN_AND_MEAN
2285 Locale_GetString( "Autorun:Install" ),
2286#else
2287 AsciiString("Autorun:Install"),
2288#endif
2290
2291 } else {
2292
2293 //---------------------------------------------------------------------
2294 // (8) PLAY button.
2295 //---------------------------------------------------------------------
2296 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonList[%d]: Id=%d, ButtonSizes=%d, String=%s."), i, IDD_OK2, j, "Play" );
2297 ButtonList[i++] = new DrawButton(
2298 IDD_OK2,
2299 button_size[j++],
2300 BUTTON_REG,
2301 BUTTON_SEL,
2302 BUTTON_SEL,
2303#ifdef LEAN_AND_MEAN
2304 Locale_GetString( "Autorun:Play" ),
2305#else
2306 AsciiString("Autorun:Play"),
2307#endif
2309/*
2310 //---------------------------------------------------------------------
2311 // (8) WorldBuilder button.
2312 //---------------------------------------------------------------------
2313 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonList[%d]: Id=%d, ButtonSizes=%d, String=%s."), i, IDD_OK2, j, "WorldBuilder" );
2314// ButtonList[i--] = new DrawButton(
2315 ButtonList[i++] = new DrawButton(
2316 IDD_OK3,
2317// button_size[j--],
2318 button_size[j++],
2319 BUTTON_REG,
2320 BUTTON_SEL,
2321 BUTTON_SEL,
2322#ifdef LEAN_AND_MEAN
2323 Locale_GetString( "Autorun:Worldbuilder" ),
2324#else
2325 AsciiString("Autorun:Worldbuilder"),
2326#endif
2327 TTButtonFontPtr );
2328*/
2329 //---------------------------------------------------------------------
2330 // (8) Check for updates button.
2331 //---------------------------------------------------------------------
2332 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonList[%d]: Id=%d, ButtonSizes=%d, String=%s."), i, IDD_OK2, j, "Check For Updates" );
2333// ButtonList[i--] = new DrawButton(
2334 ButtonList[i++] = new DrawButton(
2335 IDD_OK4,
2336// button_size[j--],
2337 button_size[j++],
2338 BUTTON_REG,
2339 BUTTON_SEL,
2340 BUTTON_SEL,
2341#ifdef LEAN_AND_MEAN
2342 Locale_GetString( "Autorun:CheckForUpdates" ),
2343#else
2344 AsciiString("Autorun:CheckForUpdates"),
2345#endif
2347 }
2348
2349 //-------------------------------------------------------------------------
2350 // (7) EXPLORE CD
2351 //-------------------------------------------------------------------------
2352 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonList[%d]: Id=%d, ButtonSizes=%d, String=%s."), i, IDD_EXPLORE, j, "Explore" );
2353 ButtonList[i++] = new DrawButton (
2355 button_size[j++],
2356 BUTTON_REG,
2357 BUTTON_SEL,
2358 BUTTON_SEL,
2359#ifdef LEAN_AND_MEAN
2360 Locale_GetString( "Autorun:ExploreCD" ),
2361#else
2362 AsciiString("Autorun:ExploreCD"),
2363#endif
2365// strcpy( next_button_name, ButtonImages[button_index] );
2366// strcpy( focused_button_name, FocusedButtonImages[button_index--] );
2367// strcpy( focused_button_name, FocusedButtonImages[button_index++] );
2368
2369 if ( !InstallProduct ) {
2370 //-----------------------------------------------------------------------
2371 // (3) WebSite button.
2372 //-----------------------------------------------------------------------
2373 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonList[%d]: Id=%d, ButtonSizes=%d, String=%s."), i, IDD_OK, j, "Install" );
2374 ButtonList[i++] = new DrawButton(
2375 IDD_INTERNET,
2376 button_size[j++],
2377 BUTTON_REG,
2378 BUTTON_SEL,
2379 BUTTON_SEL,
2380#ifdef LEAN_AND_MEAN
2381 Locale_GetString( "Autorun:Website" ),
2382#else
2383 AsciiString("Autorun:Website"),
2384#endif
2386
2387// strcpy( next_button_name, ButtonImages[button_index] );
2388// strcpy( focused_button_name, FocusedButtonImages[button_index--] );
2389// strcpy( focused_button_name, FocusedButtonImages[button_index++] );
2390 }
2391
2392 //--------------------------------------------------------------------------
2393 // (2) UNINSTALL?
2394 //--------------------------------------------------------------------------
2396 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonList[%d]: Id=%d, ButtonSizes=%d, String=%s."), i, IDD_UNINSTALL, j, "Uninstall" );
2397 ButtonList[i++] = new DrawButton(
2399 button_size[j++],
2400 BUTTON_REG,
2401 BUTTON_SEL,
2402 BUTTON_SEL,
2403#ifdef LEAN_AND_MEAN
2404 Locale_GetString( "Autorun:Uninstall" ),
2405#else
2406 AsciiString("Autorun:Uninstall"),
2407#endif
2409
2410// strcpy( next_button_name, ButtonImages[button_index] );
2411// strcpy( focused_button_name, FocusedButtonImages[button_index--] );
2412// strcpy( focused_button_name, FocusedButtonImages[button_index++] );
2413 }
2414
2415 //--------------------------------------------------------------------------
2416 // (1) MOH movie
2417 //--------------------------------------------------------------------------
2418 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonList[%d]: Id=%d, ButtonSizes=%d, String=%s."), i, IDD_PREVIEWS, j, "Preview Movies");
2419 ButtonList[i++] = new DrawButton(
2421 button_size[j++],
2422 BUTTON_REG,
2423 BUTTON_SEL,
2424 BUTTON_SEL,
2425#ifdef LEAN_AND_MEAN
2426 Locale_GetString( "Autorun:Previews" ),
2427#else
2428 AsciiString("Autorun:Previews"),
2429#endif
2431
2432 //--------------------------------------------------------------------------
2433 // (1) Help file
2434 //--------------------------------------------------------------------------
2435 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonList[%d]: Id=%d, ButtonSizes=%d, String=%s."), i, IDD_HELP, j, "Help file");
2436 ButtonList[i++] = new DrawButton(
2437 IDD_HELP,
2438 button_size[j++],
2439 BUTTON_REG,
2440 BUTTON_SEL,
2441 BUTTON_SEL,
2442#ifdef LEAN_AND_MEAN
2443 Locale_GetString( "Autorun:Help" ),
2444#else
2445 AsciiString("Autorun:Help"),
2446#endif
2448
2449 //--------------------------------------------------------------------------
2450 // (1) CANCEL?
2451 //--------------------------------------------------------------------------
2452 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonList[%d]: Id=%d, ButtonSizes=%d, String=%s."), i, IDD_CANCEL, j, "Cancel" );
2453 ButtonList[i++] = new DrawButton(
2454 IDD_CANCEL,
2455 button_size[j++],
2456 BUTTON_REG,
2457 BUTTON_SEL,
2458 BUTTON_SEL,
2459#ifdef LEAN_AND_MEAN
2460 Locale_GetString( "Autorun:Cancel" ),
2461#else
2462 AsciiString("Autorun:Cancel"),
2463#endif
2465
2466// strcpy( next_button_name, ButtonImages[button_index] );
2467// strcpy( focused_button_name, FocusedButtonImages[button_index--] );
2468// strcpy( focused_button_name, FocusedButtonImages[button_index++] );
2469
2470 //-------------------------------------------------------------------------
2471 // Set the top button to have the focus.
2472 //-------------------------------------------------------------------------
2473 if ( ButtonList[0]) {
2474 Msg( __LINE__, TEXT(__FILE__), TEXT("Button with starting Focus = %d"), i );
2475 ButtonList[0]->Set_State( DrawButton::FOCUS_STATE );
2476 }
2477
2478#if( _DEBUG )
2479 Msg( __LINE__, TEXT(__FILE__), TEXT("----------------------------------------------------------------------------------"));
2480 for( i=0; i<NUM_BUTTONS; i++ ) {
2481 if ( ButtonList[i]) {
2482 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonList[%d]: Id=%d, ButtonSizes=[%d,%d,%d,%d]."),
2483 i,
2484 ButtonList[i]->Return_Id(),
2485 ButtonList[i]->Return_X_Pos(),
2486 ButtonList[i]->Return_Y_Pos(),
2487 ButtonList[i]->Return_Width(),
2488 ButtonList[i]->Return_Height());
2489 }
2490 }
2491#endif
2492}
2493
2494
2495//*****************************************************************************
2496// WndProc -- Get Main Window's Stored Word.
2497//
2498// INPUT: HWND hWnd.
2499// Window *pWindow
2500//
2501// OUTPUT: none.
2502//
2503// WARNINGS: none.
2504//
2505// HISTORY:
2506// 06/04/1996 MML : Created.
2507//=============================================================================
2508
2509LRESULT CALLBACK Wnd_Proc ( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam )
2510{
2511 //--------------------------------------------------------------------------
2512 // If the GlobalMainWindow Ptr is not initialized, do it when the MW-CREATE
2513 // msg is called. Then we use the GlobalMainWindow's WindowProc to
2514 // process all the individual msgs sent.
2515 //--------------------------------------------------------------------------
2516 if ( GlobalMainWindow == NULL ) {
2517 if ( iMessage == WM_CREATE ) {
2518
2519 LPCREATESTRUCT lpcs;
2520
2521 lpcs = (LPCREATESTRUCT) lParam;
2522 GlobalMainWindow = (MainWindow *) lpcs->lpCreateParams;
2523
2524 //-----------------------------------------------------------------
2525 // Now let the object perform whatever initialization it needs
2526 // for WM_CREATE in its own WndProc.
2527 //-----------------------------------------------------------------
2528 return GlobalMainWindow->Window_Proc( hWnd, iMessage, wParam, lParam );
2529
2530 } else {
2531 return DefWindowProc( hWnd, iMessage, wParam, lParam );
2532 }
2533
2534 } else {
2535 return GlobalMainWindow->Window_Proc( hWnd, iMessage, wParam, lParam );
2536 }
2537}
2538
2539//*****************************************************************************
2540// DIALOG_BOX_PROC -- Handles dlg messages
2541//
2542// INPUT: standard windows dialog command parameters
2543//
2544// OUTPUT: unused
2545//
2546// WARNINGS: none
2547//
2548// HISTORY:
2549// 06/04/1996 MML : Created.
2550//=============================================================================
2551
2552BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param, LPARAM l_param )
2553{
2554 int i = 0, j = 0;
2555 int nResult = 0;
2556// int space_between = 5;
2557 int prevDCStretchMode;
2558 int prevMemDCStretchMode;
2559 int prevButtonDCStretchMode;
2560 int prevLicenseDCStretchMode;
2561 int result = 0;
2562 char buffer1[ 50 ];
2563// char buffer2[ 50 ];
2564
2565 HDC hDC, memDC, buttonDC, licenseDC;
2566 BITMAP bm, fm, lm;
2567// LOGPALETTE * plgpl = NULL;
2568 PAINTSTRUCT ps;
2569 static int bits_pixel = 0;
2570 static int idCtl = 0;
2571 static int mouse_x, mouse_y;
2572
2573 static char szBitmap[_MAX_PATH];
2574 static char szLicense[ _MAX_PATH ];
2575 static char szButtonBitmap[_MAX_PATH];
2576
2577 static wchar_t szString1[ 500 ];
2578 static wchar_t szString2[ 500 ];
2579 static wchar_t szWholeString[ 1000 ];
2580// static wchar_t szWSMsg1[ _MAX_PATH ];
2581
2582#ifdef LEAN_AND_MEAN
2583
2584#else
2585 static UnicodeString wsMsg1;
2586#endif
2587
2588 static wchar_t szWSMsg2[ _MAX_PATH ];
2589 static wchar_t szWholeWSMsg[ 1000 ];
2590// static wchar_t szInstallWarningMsg[ _MAX_PATH ];
2591
2592 static HBITMAP hBitmap = 0;
2593 static HBITMAP oldBitmap = 0;
2594// static HBITMAP oldButtonBitmap = 0;
2595 static HBITMAP oldLicenseBitmap = 0;
2596 static HBITMAP hButtonBitmap = 0;
2597 static HBITMAP hFlicker[NUM_FLICKER_FRAMES];
2598 static HBITMAP hLicenseBitmap;
2599
2600 static POINT point;
2601 static HBRUSH hStaticBrush = 0;
2602 static HPALETTE hpal = 0;
2603 static HPALETTE hpalold = 0;
2604 static BOOL FirstTime = TRUE;
2605// static BOOL Flicker = TRUE;
2606 static BOOL Flicker = FALSE;
2607 static int FlickerIndex = 0;
2608 static BOOL PaintOnlyFlicker = TRUE;
2609 static BOOL PaintBackground = TRUE;
2610 static UINT timer_id = 0;
2611 static RECT rect; // Desktop Window ( used once ).
2612 static RECT tray_rect; // Desktop Window w/o Tray size.
2613 static RECT paint_rect; // Size that needs to be repainted.
2614 static RECT dlg_rect; // Dialog client window size.
2615 static RECT bitmap_rect; // Background bitmap size.
2616 static RECT flicker_rect; // Flicker bitmap size.
2617 static RECT buttons_rect; // Area where buttons are.
2618 static RECT license_rect; // Area where buttons are.
2619 static RECT BackgroundRect[ ( NUM_BUTTONS * 3 ) + 3 ]; // Background areas outside button area.
2620
2621#if(USE_MOUSE_MOVES)
2622 static int CurrentButton = 0;
2623 static int LastButton = 0;
2624 static int PrevButton = 0;
2625#endif
2626
2627 #if(0)
2628 {
2629 //-------------------------------------------------------------------------------
2630 // Used for debugging -- lining up objects using the mouse coordinates.
2631 //-------------------------------------------------------------------------------
2632 int i = 0;
2633 HDC hdc = GetDC( window_handle );
2634 char string[10];
2635 POINT pPoint;
2636
2637 GetCursorPos( &pPoint );
2638 ScreenToClient( window_handle, &pPoint );
2639 sprintf( string, "%d, %d", pPoint.x, pPoint.y );
2640 TextOut( hdc, 10, 50, string, 8 );
2641 ReleaseDC( window_handle, hdc );
2642 }
2643 #endif
2644
2645
2646 //-----------------------------------------------------------------------------------
2647 // Process Dialogs messages.
2648 //-----------------------------------------------------------------------------------
2649 switch( message ) {
2650
2651 case WM_INITDIALOG:
2652 {
2653 //-----------------------------------------------------------------------
2654 // Set dialog's caption.
2655 //-----------------------------------------------------------------------
2656
2657#ifdef LEAN_AND_MEAN
2658
2659 Locale_GetString( "Autorun:Title", szWideBuffer );
2660 memset( szWideBuffer2, '\0', _MAX_PATH );
2663
2664#else
2665
2666 wideBuffer = TheGameText->fetch("Autorun:Title");
2667 wideBuffer2.format(wideBuffer, fullProductName.str());
2668 WideCharToMultiByte( CodePage, 0, wideBuffer2.str(), wideBuffer2.getLength()+1, szBuffer, _MAX_PATH, NULL, NULL );
2669
2670#endif
2671
2672
2673 SetWindowText( window_handle, szBuffer );
2674
2675 //-----------------------------------------------------------------------
2676 // Set Icon.
2677 //-----------------------------------------------------------------------
2678 SendMessage( window_handle, WM_SETICON, ICON_SMALL, (long)LoadIcon( Main::hInstance, MAKEINTRESOURCE(1)));
2679
2680 #if(BACKGROUND_BITMAP)
2681
2682 //-----------------------------------------------------------------------
2683 // Get the DeskTop's size and this dialogs size (in pixels).
2684 //-----------------------------------------------------------------------
2685 GetClientRect( GetDesktopWindow(), &rect );
2686 SystemParametersInfo( SPI_GETWORKAREA, 0, &tray_rect, 0 );
2687
2689// b640X480 = TRUE;
2690// } else if( rect.right <= 800 ) {
2691 b800X600 = TRUE;
2692// }
2693
2694 //=======================================================================
2695 // Create Fonts.
2696 //=======================================================================
2697 HDC hdc = GetDC( window_handle );
2698
2699 FontManager = new FontManagerClass( hdc );
2700 assert( FontManager != NULL );
2701 ReleaseDC( window_handle, hdc );
2702
2703 //=======================================================================
2704 // Load messages for bottom of screen.
2705 //=======================================================================
2706// memset( szString1, '\0', MAX_PATH );
2707// memset( szString2, '\0', MAX_PATH );
2708// memset( szWholeString, '\0', 1000 );
2709
2710// Locale_GetString( EA_LICENSE_MSG1, szString1 );
2711// Locale_GetString( EA_LICENSE_MSG2, szString2 );
2712// swprintf( szWholeString, L"%s %s", szString1, szString2 );
2713
2714// memset( szWSMsg1, '\0', _MAX_PATH );
2715 memset( szWSMsg2, '\0', _MAX_PATH );
2716 memset( szWholeWSMsg, '\0', 1000 );
2717
2718// Locale_GetString( WESTWOOD_COM_MSG, szWSMsg1 );
2719// wsMsg1 = TheGameText->fetch("Autorun:WestwoodComMsg");
2720
2721// PlugInProductName( szWSMsg1, (wchar_t *)(fullProductName.str()) );
2722// PlugInProductName( (wchar_t *)(wsMsg1.str()), (wchar_t *)(fullProductName.str()) );
2723// wsMsg1 = Fix_Single_Ampersands ( wsMsg1, false );
2724// swprintf( szWholeWSMsg, L"%s", wsMsg1.str() );
2725
2726// memset( szInstallWarningMsg, '\0', _MAX_PATH );
2727
2728// Locale_GetString( IDS_INSTALL_WARNING_MSG, szWideBuffer );
2729// wideBuffer = TheGameText->fetch("Autorun:InstallWarningMsg");
2730
2731// swprintf( szInstallWarningMsg, wideBuffer.str(), fullProductName.str() );
2732
2733 //=======================================================================
2734 // Load the correct background & animation bitmap.
2735 //=======================================================================
2736 memset( buffer1, '\0', sizeof( buffer1 ));
2737
2738 if( b640X480 ) {
2739
2740 strcpy( szBitmap, _TEXT( "Background2" ));
2741
2742 if ( LANG_FRE == LanguageID ) {
2743 strcpy( szLicense, _TEXT( "License_FRENCH2" ));
2744 } else if ( LANG_GER == LanguageID ) {
2745 strcpy( szLicense, _TEXT( "License_GERMAN2" ));
2746 } else {
2747 strcpy( szLicense, _TEXT( "License_USA2" ));
2748 }
2749 license_rect.left = 186;
2750 license_rect.top = 414;
2751
2752 } else if( b800X600 ) {
2753
2754 strcpy( szBitmap, _TEXT( "BacKground" ));
2755
2756 if ( LANG_FRE == LanguageID ) {
2757 strcpy( szLicense, _TEXT( "License_FRENCH2" ));
2758 } else if ( LANG_GER == LanguageID ) {
2759 strcpy( szLicense, _TEXT( "License_GERMAN2" ));
2760 } else {
2761 strcpy( szLicense, _TEXT( "License_USA2" ));
2762 }
2763 license_rect.left = 186;
2764 license_rect.top = 414;
2765
2766 } else {
2767
2768 strcpy( szBitmap, _TEXT( "Background" ));
2769 strcpy( buffer1, "FLICKER" );
2770
2771 if ( LANG_FRE == LanguageID ) {
2772 strcpy( szLicense, _TEXT( "License_FRENCH" ));
2773 } else if ( LANG_GER == LanguageID ) {
2774 strcpy( szLicense, _TEXT( "License_GERMAN" ));
2775 } else {
2776 strcpy( szLicense, _TEXT( "License_USA" ));
2777 }
2778 license_rect.left = 238;
2779 license_rect.top = 580;
2780 }
2781
2782 //=======================================================================
2783 // Load flicker bitmap.
2784 //=======================================================================
2785 for( i = 0; i < NUM_FLICKER_FRAMES; i++ ) {
2786 hFlicker[i] = 0;
2787// sprintf( buffer2, "%s%02d", buffer1, i );
2788// hFlicker[i] = LoadResourceBitmap( Main::hModule, buffer2, &hpal );
2789 hFlicker[i] = LoadResourceBitmap( Main::hModule, buffer1, &hpal );
2790 }
2791
2792 //-----------------------------------------------------------------------
2793 // Get the flicker bitmap's dimensions.
2794 //-----------------------------------------------------------------------
2795 result = 712;
2796
2797 for( i = 0; i < NUM_FLICKER_POSITIONS; i++ ) {
2798 if( i == 8 ) {
2799 FlickerPositions[i][0] = result - 33;
2800 } else if( i == 9 ) {
2801 FlickerPositions[i][0] = result - 35;
2802 } else if ( i > 8 ) {
2803 FlickerPositions[i][0] = result - 28;
2804 } else {
2805 FlickerPositions[i][0] = result - 31;
2806 }
2807 FlickerPositions[i][1] = 560;
2808 result = FlickerPositions[i][0];
2809 }
2810
2811 if ( hFlicker[0] ) {
2812 GetObject( hFlicker[0], sizeof( BITMAP ), (LPTSTR)&fm );
2813 flicker_rect.left = FlickerPositions[0][0];
2814 flicker_rect.top = FlickerPositions[0][1];
2815 flicker_rect.right = flicker_rect.left + fm.bmWidth;
2816 flicker_rect.bottom = flicker_rect.top + fm.bmHeight;
2817 }
2818
2819 //-----------------------------------------------------------------------
2820 // Get the bitmap's dimensions.
2821 //-----------------------------------------------------------------------
2822 hLicenseBitmap = LoadResourceBitmap( Main::hModule, szLicense, &hpal );
2823 if ( hLicenseBitmap ) {
2824 GetObject( hLicenseBitmap, sizeof( BITMAP ), (LPTSTR)&lm );
2825 license_rect.right = license_rect.left + lm.bmWidth;
2826 license_rect.bottom = license_rect.top + lm.bmHeight;
2827 }
2828
2829 //=======================================================================
2830 // Load background bitmap.
2831 //=======================================================================
2832 hBitmap = LoadResourceBitmap( Main::hModule, szBitmap, &hpal );
2833 if ( hBitmap ) {
2834 GetObject( hBitmap, sizeof( BITMAP ), (LPTSTR)&bm );
2835 }
2836
2837 //-----------------------------------------------------------------------
2838 // Set the x, y, width, height of the Dialog and bitmaps dimensions.
2839 //-----------------------------------------------------------------------
2840 bitmap_rect.left = dlg_rect.left = 0;
2841 bitmap_rect.top = dlg_rect.top = 0;
2842 bitmap_rect.right = dlg_rect.right = bm.bmWidth;
2843 bitmap_rect.bottom = dlg_rect.bottom = bm.bmHeight;
2844
2845 //-----------------------------------------------------------------------
2846 // Set the x, y, width, height of the Dialog and bitmaps dimensions.
2847 //-----------------------------------------------------------------------
2848 dlg_rect.left = 0;
2849 dlg_rect.top = 0;
2850
2851 if( b640X480 ) {
2852 dlg_rect.right = rect.right;
2853 dlg_rect.bottom = tray_rect.bottom; // desktop smaller than image
2854 } else if( b800X600 ) {
2855 if(true){
2856 dlg_rect.right = bm.bmWidth + 6;
2857 dlg_rect.bottom = bm.bmHeight + GetSystemMetrics( SM_CYCAPTION ) + 6; // desktop larger than image
2858 } else {
2859 dlg_rect.right = 640;//bm.bmWidth + 6;
2860 dlg_rect.bottom = 480; //bm.bmHeight + GetSystemMetrics( SM_CYCAPTION ) + 6; // desktop larger than image
2861 }
2862 } else {
2863 dlg_rect.right = bm.bmWidth + 6;
2864 dlg_rect.bottom = bm.bmHeight + GetSystemMetrics( SM_CYCAPTION ) + 6; // desktop larger than image
2865 }
2866
2867 //=======================================================================
2868 // Recreate Buttons based on Registry.
2869 //=======================================================================
2870 GlobalMainWindow->Create_Buttons( window_handle, &dlg_rect );
2871
2872 //=======================================================================
2873 // Set Main Rectangle Areas around all the Buttons.
2874 //=======================================================================
2875
2876 //-----------------------------------------------------------------------
2877 // Who is the first button?
2878 //-----------------------------------------------------------------------
2879 i = 0;
2880 while ( i < NUM_BUTTONS ) {
2881 if ( ButtonList[i] == NULL ) {
2882 i++;
2883 } else {
2884 break;
2885 }
2886 }
2887
2888 if( i >= NUM_BUTTONS || i < 0 ) {
2889 i = 0;
2890 }
2891
2892 Msg( __LINE__, TEXT(__FILE__), TEXT("----------------------------- determining button area ---------------------------" ));
2893
2894 buttons_rect.left = ButtonSizes[i].left;
2895 buttons_rect.top = ButtonSizes[i].top;
2896 buttons_rect.right = ButtonSizes[i].left + ButtonSizes[i].right;
2897 buttons_rect.bottom = ButtonSizes[i].top + ButtonSizes[i].bottom;
2898
2899// Msg( __LINE__, TEXT(__FILE__), TEXT("buttons_rect = [%d,%d,%d,%d]"), buttons_rect.left, buttons_rect.top, buttons_rect.right, buttons_rect.bottom );
2900
2901 for( j = 0; j < NUM_BUTTONS; j++ ) {
2902 if ( ButtonList[j] != NULL ) {
2903 buttons_rect.left = __min( ButtonSizes[j].left , buttons_rect.left );
2904 buttons_rect.top = __min( ButtonSizes[j].top , buttons_rect.top );
2905 buttons_rect.right = __max( ButtonSizes[j].left + ButtonSizes[j].right , buttons_rect.right );
2906 buttons_rect.bottom = __max( ButtonSizes[j].top + ButtonSizes[j].bottom , buttons_rect.bottom );
2907 }
2908 }
2909
2910 Msg( __LINE__, TEXT(__FILE__), TEXT("buttons_rect = [%d,%d,%d,%d]"), buttons_rect.left, buttons_rect.top, buttons_rect.right, buttons_rect.bottom );
2911 Msg( __LINE__, TEXT(__FILE__), TEXT("----------------------------- determining button area ---------------------------" ));
2912
2913 //=======================================================================
2914 // Center the dialog on the desktop.
2915 //=======================================================================
2916 if ( !b640X480 ) {
2917 MoveWindow( window_handle,
2918 ( rect.right - dlg_rect.right )/2,
2919 ( rect.bottom - dlg_rect.bottom )/2,
2920 dlg_rect.right,
2921 dlg_rect.bottom, TRUE );
2922 } else {
2923 MoveWindow( window_handle,
2924 0, 0,
2925 dlg_rect.right,
2926 dlg_rect.bottom, TRUE );
2927 }
2928
2929 //-----------------------------------------------------------------------
2930 // Get the new Client area.
2931 //-----------------------------------------------------------------------
2932 GetClientRect( window_handle, &dlg_rect );
2933
2934
2935 //=======================================================================================
2936 // JFS: 8/26/03 -- This was not getting cleared so if the button cnt were reduced...
2937 //=======================================================================================
2938 memset( BackgroundRect, 0, sizeof ( BackgroundRect ) );
2939
2940 //=======================================================================
2941 // These are the areas of the Background to paint minus the Button Area.
2942 // This will prevent "flickering".
2943 //=======================================================================
2944 BackgroundRect[0].left = dlg_rect.left;
2945 BackgroundRect[0].top = dlg_rect.top;
2946 BackgroundRect[0].right = dlg_rect.right;
2947 BackgroundRect[0].bottom = buttons_rect.top;
2948
2949 BackgroundRect[1].left = dlg_rect.left;
2950 BackgroundRect[1].top = buttons_rect.top;
2951 BackgroundRect[1].right = buttons_rect.left;
2952 BackgroundRect[1].bottom = dlg_rect.bottom;
2953
2954 BackgroundRect[2].left = buttons_rect.left;
2955 BackgroundRect[2].top = buttons_rect.bottom;
2956 BackgroundRect[2].right = buttons_rect.right;
2957 BackgroundRect[2].bottom = dlg_rect.bottom;
2958
2959 BackgroundRect[3].left = buttons_rect.right;
2960 BackgroundRect[3].top = buttons_rect.top;
2961 BackgroundRect[3].right = dlg_rect.right;
2962 BackgroundRect[3].bottom = dlg_rect.bottom;
2963
2964 //=======================================================================
2965 // Find Areas that are in between, infront of, and behind each Buttons.
2966 //=======================================================================
2967 i = 0;
2968 j = 4;
2969
2970 //-----------------------------------------------------------------------
2971 // Who is the first button?
2972 //-----------------------------------------------------------------------
2973 while ( i < NUM_BUTTONS ) {
2974 if ( ButtonList[i] == NULL ) {
2975 i++;
2976 } else {
2977 break;
2978 }
2979 }
2980
2981 if( i >= NUM_BUTTONS || i < 0 ) {
2982 i = 0;
2983 }
2984
2985 //-----------------------------------------------------------------------
2986 // For each button...
2987 //-----------------------------------------------------------------------
2988 for( int index = i; index < NUM_BUTTONS; index++ ) {
2989
2990 //-------------------------------------------------------------------
2991 // Make areas between the buttons.
2992 //-------------------------------------------------------------------
2993 if ( ButtonList[index] != NULL && ButtonList[index+1] != NULL ) {
2994
2995 // Area between buttons.
2996 BackgroundRect[j].top = ButtonList[index]->Return_Y_Pos() + ButtonList[index]->Return_Height();
2997 BackgroundRect[j].bottom = ButtonList[index+1]->Return_Y_Pos() - BackgroundRect[j].top;
2998 BackgroundRect[j].left = BackgroundRect[1].right;
2999 BackgroundRect[j].right = BackgroundRect[3].left - BackgroundRect[1].left - 1;
3000 j++;
3001 }
3002
3003 //-------------------------------------------------------------------
3004 // Now look for areas in front of and behind each button.
3005 //-------------------------------------------------------------------
3006 if ( ButtonList[index] != NULL ) {
3007
3008 // Area in front of buttons.
3009 BackgroundRect[j].top = ButtonList[index]->Return_Y_Pos();
3010 BackgroundRect[j].bottom = ButtonList[index]->Return_Height();
3011 BackgroundRect[j].left = BackgroundRect[1].right;
3012 BackgroundRect[j].right = ButtonList[index]->Return_X_Pos() - BackgroundRect[1].right;
3013 j++;
3014
3015 // Area behind buttons.
3016 BackgroundRect[j].top = ButtonList[index]->Return_Y_Pos();
3017 BackgroundRect[j].bottom = ButtonList[index]->Return_Height();
3018 BackgroundRect[j].left = ButtonList[index]->Return_X_Pos() + ButtonList[index]->Return_Width();
3019 BackgroundRect[j].right = BackgroundRect[3].left - ( ButtonList[index]->Return_X_Pos() + ButtonList[index]->Return_Width());
3020 j++;
3021 }
3022 }
3023
3024 #if(_DEBUG)
3025 Msg( __LINE__, TEXT(__FILE__), TEXT("----------------------------- WM_INITDIALOG ---------------------------" ));
3026 Msg( __LINE__, TEXT(__FILE__), TEXT("DeskTopWindowRect(w/o tray) = [%d,%d,%d,%d]"), tray_rect.left, tray_rect.top, tray_rect.right, tray_rect.bottom );
3027 Msg( __LINE__, TEXT(__FILE__), TEXT("DeskTopWindowRect = [%d,%d,%d,%d]"), rect.left, rect.top, rect.right, rect.bottom );
3028 Msg( __LINE__, TEXT(__FILE__), TEXT("b640X480 = [%d]"), b640X480 );
3029 Msg( __LINE__, TEXT(__FILE__), TEXT("b800X600 = [%d]"), b800X600 );
3030 Msg( __LINE__, TEXT(__FILE__), TEXT("ClientRect = [%d,%d,%d,%d]"), dlg_rect.left, dlg_rect.top, dlg_rect.right, dlg_rect.bottom );
3031
3032 for( index = 0; index < ( NUM_BUTTONS * 3 ) + 3; index++ ) {
3033 Msg( __LINE__, TEXT(__FILE__), TEXT("BackgroundRect[%d] = [%d,%d,%d,%d]"), index, BackgroundRect[index].top, BackgroundRect[index].bottom, BackgroundRect[index].left, BackgroundRect[index].right );
3034 }
3035
3036 Msg( __LINE__, TEXT(__FILE__), TEXT("BitmapRect = [%d,%d,%d,%d]"), bitmap_rect.left, bitmap_rect.top, bitmap_rect.right, bitmap_rect.bottom );
3037 Msg( __LINE__, TEXT(__FILE__), TEXT("FlickerRect = [%d,%d,%d,%d]"), flicker_rect.left, flicker_rect.top, flicker_rect.right, flicker_rect.bottom );
3038 Msg( __LINE__, TEXT(__FILE__), TEXT("ButtonsRect = [%d,%d,%d,%d]"), buttons_rect.left, buttons_rect.top, buttons_rect.right, buttons_rect.bottom );
3039 Msg( __LINE__, TEXT(__FILE__), TEXT("-----------------------------------------------------------------------" ));
3040 #endif
3041
3042 #else
3043
3044 //-----------------------------------------------------------------------
3045 // Create Brush.
3046 //-----------------------------------------------------------------------
3047 hStaticBrush = CreateSolidBrush( RGB( 192, 192, 192 ));
3048
3049 #endif
3050
3051 //=======================================================================
3052 // Set dialog's timer! 1000 = 1 second.
3053 //=======================================================================
3054// timer_id = SetTimer( window_handle, 1000, 250L, NULL );
3055 timer_id = SetTimer( window_handle, 1000, 500L, NULL );
3056 }
3057 return( TRUE );
3058
3059 //-------------------------------------------------------------------------------
3060 // Try and set a custom cursor.
3061 //-------------------------------------------------------------------------------
3062// case WM_SETCURSOR:
3063// SetCursor(LoadCursor( Main::hInstance, MAKEINTRESOURCE(2)));
3064// break;
3065
3066 //-------------------------------------------------------------------------------
3067 // Tell Window to Select Palette if we are not the Focused Window.
3068 // This is to avoid getting stuck in a loop of receiving this msg
3069 // when we are focused.
3070 //-------------------------------------------------------------------------------
3071 case WM_PALETTECHANGED:
3072 if (( HWND )w_param != window_handle ) {
3073 SendMessage( window_handle, WM_QUERYNEWPALETTE, w_param, l_param );
3074 }
3075 break;
3076
3077 //-------------------------------------------------------------------------------
3078 // Set and Realize our palette, then repaint if necessary.
3079 // Note that SelectPalette here is passed a FALSE.
3080 // This means reset palette as if we are in the foreground.
3081 //-------------------------------------------------------------------------------
3082 case WM_QUERYNEWPALETTE:
3083 hDC = GetDC( window_handle );
3084 hpalold = SelectPalette( hDC, hpal, FALSE );
3085 i = RealizePalette( hDC );
3086 if ( i != 0 ) {
3087 InvalidateRect( window_handle, &dlg_rect, TRUE );
3088 }
3089 SelectPalette( hDC, hpalold, TRUE );
3090 RealizePalette( hDC );
3091 ReleaseDC( window_handle, hDC );
3092 return i;
3093
3094 //-------------------------------------------------------------------------------
3095 // Process Timer Messages.
3096 //-------------------------------------------------------------------------------
3097 case WM_TIMER:
3098 {
3099 if ( w_param == 1000 ) {
3100
3101// if ( Flicker && hFlicker[FlickerIndex] ) {
3102 if ( Flicker && hFlicker[0] ) {
3103
3104 FlickerIndex++;
3105// if ( FlickerIndex >= NUM_FLICKER_FRAMES ) {
3106 if ( FlickerIndex >= NUM_FLICKER_POSITIONS ) {
3107 FlickerIndex = 0;
3108 }
3109
3110 InvalidateRect( window_handle, &flicker_rect, FALSE );
3111 flicker_rect.left = FlickerPositions[ FlickerIndex ][0];
3112 InvalidateRect( window_handle, &flicker_rect, FALSE );
3113 UpdateWindow( window_handle );
3114
3115 Msg( __LINE__, TEXT(__FILE__), TEXT("WM_TIMER: FlickerRect = [%d,%d,%d,%d]"), flicker_rect.left, flicker_rect.right, flicker_rect.top, flicker_rect.bottom );
3116 }
3117 }
3118
3119 //-----------------------------------------------------------------------
3120 // If game is running, the mutex will return! Time to exit...
3121 // Note: This number is unique for Tiberian Sun ONLY!!!
3122 //-----------------------------------------------------------------------
3123 if( WinVersion.Is_Win_XP() || WinVersion.Version() > 500 ) {
3124 strcat( strcpy( szBuffer, "Global\\" ), GAME_MUTEX_OBJECT );
3125 } else {
3126 strcpy( szBuffer, GAME_MUTEX_OBJECT );
3127 }
3128 GameAppMutex = OpenMutex( MUTEX_ALL_ACCESS, FALSE, szBuffer );
3129
3130 if ( GameAppMutex != NULL ) {
3131
3132 //---------------------------------------------------------
3133 // Handle(s) are closed in the ProgEnd().
3134 //---------------------------------------------------------
3135
3136 HWND ccwindow = FindWindow( szGameWindow, NULL );
3137 if ( ccwindow ) {
3138 if( IsIconic( ccwindow )){
3139 ShowWindow( ccwindow, SW_RESTORE );
3140 }
3141 SetForegroundWindow( ccwindow );
3142
3143 } else {
3144
3145 ccwindow = FindWindow( szSetupWindow, NULL );
3146 if ( ccwindow ) {
3147 if( IsIconic( ccwindow )){
3148 ShowWindow( ccwindow, SW_RESTORE );
3149 }
3150 SetForegroundWindow( ccwindow );
3151 }
3152 }
3153
3154 PostMessage( window_handle, WM_COMMAND, (WPARAM)MAKELONG( IDD_CANCEL, BN_CLICKED ), (LPARAM)GetDlgItem( window_handle, IDD_CANCEL ));
3155 }
3156 }
3157 return ( 0 );
3158
3159 //===============================================================================
3160 // Dialog's main paint routine.
3161 //===============================================================================
3162 case WM_PAINT:
3163
3164 //---------------------------------------------------------------------------
3165 // If there is an area to update, repaint it.
3166 //---------------------------------------------------------------------------
3167 if ( GetUpdateRect( window_handle, &paint_rect, FALSE )) {
3168
3169// Msg( __LINE__, TEXT(__FILE__), TEXT("---------------------- WM_PAINT ---------------------"), i );
3170// Msg( __LINE__, TEXT(__FILE__), TEXT("Rectangle to update = [%d,%d,%d,%d]"), paint_rect.left, paint_rect.top, paint_rect.right, paint_rect.bottom );
3171
3172 //-----------------------------------------------------------------------
3173 // Get dialog's hDC.
3174 //-----------------------------------------------------------------------
3175 hDC = BeginPaint( window_handle, &ps );
3176
3177 #if( BACKGROUND_BITMAP )
3178
3179 if ( hBitmap ) {
3180
3181 //---------------------------------------------------------------
3182 // Create a compatible DC for the bitmap.
3183 //---------------------------------------------------------------
3184 memDC = CreateCompatibleDC( hDC );
3185 buttonDC = CreateCompatibleDC( hDC );
3186 licenseDC = CreateCompatibleDC( hDC );
3187
3188 //---------------------------------------------------------------
3189 // Set stretching mode for bitmaps.
3190 //---------------------------------------------------------------
3191 prevDCStretchMode = SetStretchBltMode( hDC, STRETCH_DELETESCANS );
3192 prevMemDCStretchMode = SetStretchBltMode( memDC, STRETCH_DELETESCANS );
3193 prevButtonDCStretchMode = SetStretchBltMode( buttonDC,STRETCH_DELETESCANS );
3194 prevLicenseDCStretchMode = SetStretchBltMode( licenseDC,STRETCH_DELETESCANS );
3195
3196 //---------------------------------------------------------------
3197 // Set the palette in each DC.
3198 //---------------------------------------------------------------
3199 hpalold = SelectPalette( hDC, hpal, FALSE );
3200 RealizePalette( hDC );
3201 SelectPalette( memDC, hpal, FALSE );
3202 RealizePalette( memDC );
3203 SelectPalette( buttonDC, hpal, FALSE );
3204 RealizePalette( buttonDC );
3205 SelectPalette( licenseDC, hpal, FALSE );
3206 RealizePalette( licenseDC );
3207
3208 //---------------------------------------------------------------
3209 // If area to update is a button area, this will be drawn farther
3210 // on. This is to prevent "flickering" by drawing the background
3211 // then the button image.
3212 //---------------------------------------------------------------
3213 for ( i = 0; i < NUM_BUTTONS; i++ ) {
3214
3215 if ( ButtonList[i] ) {
3216
3217 ButtonList[i]->Return_Area( &rect );
3218
3219 if ( paint_rect.left == rect.left &&
3220 paint_rect.top == rect.top &&
3221 paint_rect.right == rect.right &&
3222 paint_rect.bottom == rect.bottom ) {
3223
3224 PaintBackground = FALSE;
3225// Msg( __LINE__, TEXT(__FILE__), TEXT("Rectangle matches a button to update = [%d,%d,%d,%d]"), rect.left, rect.top, rect.right, rect.bottom );
3226 break;
3227 }
3228 }
3229 }
3230
3231 //===============================================================
3232 // Paint the background.
3233 //===============================================================
3234 if ( PaintBackground ) {
3235
3236 //-----------------------------------------------------------
3237 // Select & Draw the background bitmap.
3238 //-----------------------------------------------------------
3239 oldBitmap = ( HBITMAP )SelectObject( memDC, hBitmap );
3240
3241 //-----------------------------------------------------------
3242 // Updates area around the button area.
3243 //-----------------------------------------------------------
3244 #if(1)
3245 for( int i=0; i < ( NUM_BUTTONS * 3 ) + 3; i++ ) {
3246
3247 if( BackgroundRect[i].left != 0 || BackgroundRect[i].top != 0 ||
3248 BackgroundRect[i].right != 0 || BackgroundRect[i].bottom != 0 ) {
3249
3250 result = StretchBlt( hDC,
3251 BackgroundRect[i].left,
3252 BackgroundRect[i].top,
3253 BackgroundRect[i].right,
3254 BackgroundRect[i].bottom,
3255 memDC,
3256 BackgroundRect[i].left,
3257 BackgroundRect[i].top,
3258 BackgroundRect[i].right,
3259 BackgroundRect[i].bottom,
3260 SRCCOPY );
3261
3262 if( result != 0 ) {
3263// Msg( __LINE__, TEXT(__FILE__), TEXT("Paint this rect = [%d,%d,%d,%d]"), BackgroundRect[i].left, BackgroundRect[i].top, BackgroundRect[i].right, BackgroundRect[i].bottom );
3264 }
3265
3266 #if(0)
3267 HPEN pen = CreatePen( /*PS_DOT*/ PS_SOLID, 1, TEXT_COLOR );
3268 HGDIOBJ oldpen = SelectObject( hDC, pen );
3269 SetBkMode( hDC, TRANSPARENT );
3270
3271 MoveToEx( hDC, BackgroundRect[i].left+1, BackgroundRect[i].top+1, NULL );
3272 LineTo( hDC, BackgroundRect[i].right-1, BackgroundRect[i].top+1 );
3273 LineTo( hDC, BackgroundRect[i].right-1, BackgroundRect[i].bottom-1 );
3274 LineTo( hDC, BackgroundRect[i].left+1, BackgroundRect[i].bottom-1 );
3275 LineTo( hDC, BackgroundRect[i].left+1, BackgroundRect[i].top+1 );
3276
3277 SelectObject( hDC, oldpen );
3278 DeleteObject( pen );
3279 #endif
3280 }
3281 }
3282/*
3283 //-----------------------------------------------------------
3284 // Select & Draw the background bitmap.
3285 //-----------------------------------------------------------
3286 oldLicenseBitmap = ( HBITMAP )SelectObject( licenseDC, hLicenseBitmap );
3287
3288 //-----------------------------------------------------------
3289 // Updates area around the button area.
3290 //-----------------------------------------------------------
3291 result = StretchBlt( hDC,
3292 license_rect.left,
3293 license_rect.top,
3294 license_rect.right,
3295 license_rect.bottom,
3296 licenseDC,
3297 0,
3298 0,
3299 license_rect.right,
3300 license_rect.bottom,
3301 SRCCOPY );
3302*/
3303 #else
3304
3305 //-----------------------------------------------------------
3306 // Blit whole background, in one shot.
3307 //-----------------------------------------------------------
3308 StretchBlt( hDC, dlg_rect.left, dlg_rect.top, dlg_rect.right, dlg_rect.bottom,
3309 memDC, bitmap_rect.left, bitmap_rect.top, bitmap_rect.right, bitmap_rect.bottom,
3310 SRCCOPY );
3311 #endif
3312
3313 SelectObject( memDC, oldBitmap );
3314 SelectObject( licenseDC, oldLicenseBitmap );
3315
3316 } else {
3317 PaintBackground = TRUE;
3318 }
3319
3320 //---------------------------------------------------------------
3321 // Animation.
3322 //---------------------------------------------------------------
3323// if ( Flicker && hFlicker[FlickerIndex] ) {
3324 if ( Flicker && hFlicker[0] ) {
3325
3326// oldBitmap = ( HBITMAP )SelectObject( memDC, hFlicker[FlickerIndex] );
3327 oldBitmap = ( HBITMAP )SelectObject( memDC, hFlicker[0] );
3328
3329 StretchBlt(
3330 hDC,
3331 flicker_rect.left,
3332 flicker_rect.top,
3333 flicker_rect.right,
3334 flicker_rect.bottom,
3335 memDC,
3336 0,
3337 0,
3338 flicker_rect.right,
3339 flicker_rect.bottom,
3340 SRCCOPY );
3341
3342 #if(0)
3343 HPEN pen = CreatePen( /*PS_DOT*/ PS_SOLID, 1, TEXT_COLOR );
3344 HGDIOBJ oldpen = SelectObject( hDC, pen );
3345 SetBkMode( hDC, TRANSPARENT );
3346
3347 MoveToEx( hDC, flicker_rect.left+1, flicker_rect.top+1, NULL );
3348 LineTo( hDC, flicker_rect.right-1, flicker_rect.top+1 );
3349 LineTo( hDC, flicker_rect.right-1, flicker_rect.bottom-1 );
3350 LineTo( hDC, flicker_rect.left+1, flicker_rect.bottom-1 );
3351 LineTo( hDC, flicker_rect.left+1, flicker_rect.top+1 );
3352
3353 SelectObject( hDC, oldpen );
3354 DeleteObject( pen );
3355 #endif
3356
3357 SelectObject( memDC, oldBitmap );
3358
3359// Msg( __LINE__, TEXT(__FILE__), TEXT(" Drawing Flicker [%d,%d,%d,%d]."), flicker_rect.left, flicker_rect.top, flicker_rect.right, flicker_rect.bottom );
3360 }
3361
3362 //---------------------------------------------------------------
3363 // Draw each button.
3364 //---------------------------------------------------------------
3365 for ( i = 0; i < NUM_BUTTONS; i++ ) {
3366
3367 if ( ButtonList[i] ) {
3368
3369 Rect rect;
3370
3371 //-------------------------------------------------------
3372 // Uses Bitmaps or DrawText???
3373 //-------------------------------------------------------
3374 if ( ButtonList[i]->Draw_Bitmaps()) {
3375
3376 RECT src_rect, dst_rect;
3377
3378 strcpy( szButtonBitmap, ButtonList[i]->Return_Bitmap( ));
3379 hButtonBitmap = LoadResourceBitmap( Main::hInstance, szButtonBitmap, &hpal, TRUE );
3380 if ( hButtonBitmap ) {
3381
3382 GetObject( hButtonBitmap, sizeof( BITMAP ), (LPTSTR)&bm );
3383
3384 dst_rect.left = ButtonList[i]->Return_X_Pos();
3385 dst_rect.top = ButtonList[i]->Return_Y_Pos();
3386 dst_rect.right = ButtonList[i]->Return_Stretched_Width();
3387 dst_rect.bottom = ButtonList[i]->Return_Stretched_Height();
3388 src_rect.left = 0;
3389 src_rect.top = 0;
3390 src_rect.right = bm.bmWidth;
3391 src_rect.bottom = bm.bmHeight;
3392
3393 //-----------------------------------------------
3394 // Draw the button's bitmap background.
3395 //-----------------------------------------------
3396 oldBitmap = ( HBITMAP ) SelectObject( buttonDC, hButtonBitmap );
3397 StretchBlt(
3398 hDC,
3399 dst_rect.left,
3400 dst_rect.top,
3401 dst_rect.right,
3402 dst_rect.bottom,
3403 buttonDC,
3404 src_rect.left,
3405 src_rect.top,
3406 src_rect.right,
3407 src_rect.bottom,
3408 SRCCOPY );
3409
3410 SelectObject( buttonDC, oldBitmap );
3411 DeleteObject( hButtonBitmap );
3412 hButtonBitmap = 0;
3413 }
3414
3415 } // END OF DRAW BITMAPS
3416
3417#if(0)
3418 TTFontClass *fontptr = ButtonList[i]->Return_Font_Ptr();
3419 if ( fontptr ) {
3420
3421 RECT outline_rect;
3422
3423 ButtonList[i]->Return_Area( &outline_rect );
3424 ButtonList[i]->Return_Text_Area( &rect );
3425
3426 /*
3427 ** This function was combining the pixel color with the background,
3428 ** so it never looked correct.
3429 */
3430// SetTextColor( hDC, RGB( 0, 240, 0 ));
3431// DrawFocusRect( hDC, &dst_rect );
3432
3433 if ( ButtonList[i]->Get_State() == DrawButton::PRESSED_STATE ) {
3434 fontptr->Print(
3435 hDC,
3436 ButtonList[i]->Return_Text(),
3437 rect,
3440 TPF_BUTTON,
3441 TPF_SHADOW );
3442
3443 } else if ( ButtonList[i]->Get_State() == DrawButton::FOCUS_STATE ) {
3444 fontptr->Print(
3445 hDC,
3446 ButtonList[i]->Return_Text(),
3447 rect,
3450 TPF_BUTTON,
3451 TPF_SHADOW );
3452
3453 } else {
3454 fontptr->Print(
3455 hDC,
3456 ButtonList[i]->Return_Text(),
3457 rect,
3460 TPF_BUTTON,
3461 TPF_SHADOW );
3462 }
3463
3464 #if(0)
3465 HPEN pen = CreatePen( /*PS_DOT*/ PS_SOLID, 2, TEXT_COLOR );
3466 HGDIOBJ oldpen = SelectObject( hDC, pen );
3467 SetBkMode( hDC, TRANSPARENT );
3468
3469 MoveToEx( hDC, // handle to device context
3470 outline_rect.left, // x-coordinate of new current position
3471 outline_rect.top, // y-coordinate of new current position
3472 NULL ); // pointer to old current position
3473
3474 LineTo( hDC, // device context handle
3475 outline_rect.right, // x-coordinate of line's ending point
3476 outline_rect.top ); // y-coordinate of line's ending point
3477
3478 LineTo( hDC, // device context handle
3479 outline_rect.right, // x-coordinate of line's ending point
3480 outline_rect.bottom ); // y-coordinate of line's ending point
3481
3482 LineTo( hDC, // device context handle
3483 outline_rect.left, // x-coordinate of line's ending point
3484 outline_rect.bottom ); // y-coordinate of line's ending point
3485
3486 LineTo( hDC, // device context handle
3487 outline_rect.left, // x-coordinate of line's ending point
3488 outline_rect.top ); // y-coordinate of line's ending point
3489
3490 SelectObject( hDC, oldpen );
3491 DeleteObject( pen );
3492 #endif
3493 }
3494#else
3495 ButtonList[i]->Draw_Text( hDC );
3496#endif
3497
3498
3499
3500 } // end of if button
3501
3502 } // For each button...
3503
3504 //---------------------------------------------------------------
3505 // Used in debugging -- draw rect around where buttons are.
3506 //---------------------------------------------------------------
3507 #if(0)
3508 {
3509 HPEN hPen1 = CreatePen( PS_SOLID, 1, RGB( 255, 255, 255 ));
3510 if (hPen1) {
3511
3512 for ( int i = 0; i < NUM_BUTTONS; i++ ) {
3513 if ( ButtonList[i] ) {
3514
3515 HGDIOBJ oldpen = SelectObject( hDC, hPen1 );
3516
3517 MoveToEx( hDC,
3518 ButtonList[i]->Return_X_Pos()-1,
3519 ButtonList[i]->Return_Y_Pos()-1, NULL );
3520 LineTo( hDC,
3521 ButtonList[i]->Return_X_Pos() + ButtonList[i]->Return_Width() + 1,
3522 ButtonList[i]->Return_Y_Pos()-1 );
3523 LineTo( hDC,
3524 ButtonList[i]->Return_X_Pos() + ButtonList[i]->Return_Width() + 1,
3525 ButtonList[i]->Return_Y_Pos() + ButtonList[i]->Return_Height() + 1);
3526 LineTo( hDC,
3527 ButtonList[i]->Return_X_Pos()-1,
3528 ButtonList[i]->Return_Y_Pos() + ButtonList[i]->Return_Height() + 1);
3529 LineTo( hDC,
3530 ButtonList[i]->Return_X_Pos() - 1,
3531 ButtonList[i]->Return_Y_Pos() - 1);
3532
3533 SelectObject( hDC, oldpen );
3534 }
3535 }
3536 }
3537 DeleteObject( hPen1 );
3538 }
3539 #endif
3540
3541 //---------------------------------------------------------------
3542 // Restore all default objects to DCs and delete.
3543 //---------------------------------------------------------------
3544 SetStretchBltMode( hDC, prevDCStretchMode );
3545 SetStretchBltMode( memDC, prevMemDCStretchMode );
3546 SetStretchBltMode( buttonDC, prevButtonDCStretchMode );
3547 SetStretchBltMode( licenseDC, prevLicenseDCStretchMode );
3548
3549 SelectPalette( hDC, hpalold, FALSE );
3550 SelectPalette( memDC, hpalold, FALSE );
3551 SelectPalette( buttonDC, hpalold, FALSE );
3552 SelectPalette( licenseDC, hpalold, FALSE );
3553
3554 DeleteDC( memDC );
3555 DeleteDC( buttonDC );
3556 DeleteDC( licenseDC );
3557
3558 } // end of bitmaps
3559
3560 //===================================================================
3561 // Draw a solid colored background.
3562 //===================================================================
3563// GetClientRect( window_handle, (LPRECT) &dlg_rect );
3564// FillRect( hDC, &dlg_rect, (HBRUSH)( COLOR_WINDOW + 1 ));
3565
3566 //===================================================================
3567 // Print text at bottom of screen.
3568 //===================================================================
3569 Rect text_rect;
3570 TTFontClass *fontptr = NULL;
3571
3572 if ( b640X480 ) {
3573 fontptr = TTTextFontPtr640;
3574 } else if ( b800X600 ) {
3575 fontptr = TTTextFontPtr800;
3576 } else {
3577 fontptr = TTTextFontPtr;
3578 }
3579
3580 if ( fontptr ) {
3581
3582 if ( b640X480 || b800X600 ) {
3583 text_rect.X = 10;
3584 text_rect.Y = 240;
3585 text_rect.Width = 140; //498;
3586 text_rect.Height = 100; //26;
3587 } else {
3588 text_rect.X = 20;
3589 text_rect.Y = 340;
3590 text_rect.Width = 180; //498;
3591 text_rect.Height = 120; //26;
3592 }
3593
3594 #if(0)
3595 RECT one;
3596
3597 one.left = text_rect.X;
3598 one.top = text_rect.Y;
3599 one.right = text_rect.X + text_rect.Width;
3600 one.bottom = text_rect.Y + text_rect.Height;
3601
3602 FrameRect( hDC, &one, (HBRUSH)( COLOR_WINDOW + 1 ));
3603// DrawFocusRect( hDC, &one );
3604 #endif
3605
3606 //---------------------------------------------------------------
3607 // WESTWOOD_COM Message at the top.
3608 //---------------------------------------------------------------
3609/*
3610 fontptr->Print(
3611 hDC,
3612 szWholeWSMsg,
3613 text_rect,
3614 TEXT_COLOR,
3615 SHADOW_COLOR,
3616 TPF_CENTER_TEXT,
3617 TPF_SHADOW );
3618*/
3619 }
3620
3621 //---------------------------------------------------------------
3622 // EA_COM Message at the bottom.
3623 //---------------------------------------------------------------
3624 #if(0) // Moved this text to a bitmap.
3625 fontptr = TTLicenseFontPtr;
3626 if( fontptr ) {
3627
3628 if ( b640X480 || b800X600 ) {
3629 text_rect.X = 220;
3630 text_rect.Y = 400;
3631 text_rect.Width = 300; //460;
3632 text_rect.Height = 48; //26;
3633 } else {
3634 text_rect.X = 250;
3635 text_rect.Y = 574;
3636 text_rect.Width = 420; //460;
3637 text_rect.Height = 60; //26;
3638 }
3639
3640 #if(0)
3641 RECT one;
3642
3643 one.left = text_rect.X;
3644 one.top = text_rect.Y;
3645 one.right = text_rect.X + text_rect.Width;
3646 one.bottom = text_rect.Y + text_rect.Height;
3647
3648 FrameRect( hDC, &one, (HBRUSH)( COLOR_WINDOW + 1 ));
3649// DrawFocusRect( hDC, &one );
3650 #endif
3651
3652 fontptr->Print(
3653 hDC,
3654 szWholeString,
3655 text_rect,
3656 TEXT_COLOR,
3657 SHADOW_COLOR,
3659 TPF_SHADOW );
3660 }
3661 #endif
3662
3663 #else
3664 //-------------------------------------------------------------------
3665 // Select the Brush if it was successfully created.
3666 //-------------------------------------------------------------------
3667 if ( hStaticBrush ) {
3668 HBRUSH oldBrush = (HBRUSH) SelectObject( hDC, hStaticBrush );
3669 GetClientRect( window_handle, (LPRECT) &dlg_rect );
3670 FillRect( hDC, &dlg_rect, hStaticBrush );
3671 SelectObject( hDC, oldBrush );
3672 }
3673 #endif
3674
3675// Msg( __LINE__, TEXT(__FILE__), TEXT("--------------------------------------------------------" ));
3676
3677 EndPaint( window_handle, &ps );
3678
3679 //-----------------------------------------------------------------------
3680 // Play DISK.WAV sound on CD.
3681 //-----------------------------------------------------------------------
3682 if ( FirstTime ) {
3683 if( UseSounds ) {
3684 PlaySound( szWavs[ SongNumber ], NULL, SND_ASYNC | SND_RESOURCE );
3685 }
3686 FirstTime = FALSE;
3687 }
3688 } /* end of if */
3689 break;
3690
3691 //-------------------------------------------------------------------------------
3692 // Background needs to be erased. Note we are returning 1 here to "fake"
3693 // Windows into thinking we have already repainted the background with
3694 // our window brush. This prevents "flickering" because of background
3695 // being repainted ( ususally white ) before WM_PAINT is processed.
3696 //-------------------------------------------------------------------------------
3697 #if(BACKGROUND_BITMAP)
3698 case WM_ERASEBKGND:
3699 InvalidateRect( window_handle, &dlg_rect, FALSE );
3700 return ( 1 );
3701 #endif
3702
3703 //-------------------------------------------------------------------------------
3704 // Check which button was pressed. If Explorer button was pressed,
3705 // call it now so we don't have to exit dialog.
3706 //-------------------------------------------------------------------------------
3707 case WM_COMMAND:
3708 {
3709 idCtl = LOWORD( w_param );
3710
3711 unsigned int result = TRUE;
3712 bool end_dialog = false;
3713 int cd_drive;
3714
3715 szBuffer[1] = '\0';
3716 szBuffer[0] = tolower( szArgvPath[0] );
3717// cd_drive = (int)( szBuffer[0] - 'a' + 1 );
3718 cd_drive = (int)( szBuffer[0] - 'a' );
3719
3720 #if(BACKGROUND_BITMAP)
3721
3722 switch ( idCtl ) {
3723
3724 //-------------------------------------------------------------------
3725 // IDD_MOHAVI
3726 //-------------------------------------------------------------------
3727 case IDD_PREVIEWS:
3728 {
3729 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_PREVIEWS Selected." ));
3730 // show the previews in succession. each will wait for the previous to finish
3731 // before playing.
3732 unsigned int success;
3733
3734 char filepath[MAX_PATH];
3735 _snprintf(filepath, MAX_PATH, "%s%s", szArgvPath, SC4AVI_FILENAME);
3736
3737 success = GlobalMainWindow->Run_OpenFile(cd_drive, filepath, true);
3738// if (success != 0) {
3739// success = GlobalMainWindow->Run_OpenFile(cd_drive, BFAVI_FILENAME, true);
3740// }
3741/*
3742 if (success == 0) {
3743 std::wstring wideBuffer = TheGameText->fetch("Autorun:CantRunAVIs");
3744 std::wstring wideBuffer2 = TheGameText->fetch("Autorun:Error");
3745 int length = wideBuffer.length();
3746 WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, NULL, NULL );
3747 length = wideBuffer2.length();
3748 WideCharToMultiByte( CodePage, 0, wideBuffer2.c_str(), length+1, szBuffer2, _MAX_PATH, NULL, NULL );
3749 MessageBox( NULL, szBuffer, szBuffer2, MB_APPLMODAL | MB_OK );
3750 }
3751*/
3752 }
3753 break;
3754
3755 case IDD_HELP:
3756 {
3757 std::wstring wFileName;
3758 wFileName = Locale_GetString(HELP_FILENAME);
3759
3760 std::string fname;
3761 const wchar_t *tmp = wFileName.c_str();
3762 char hack[2] = "a";
3763 while (*tmp)
3764 {
3765 hack[0] = (char)( *tmp & 0xFF );
3766 fname.append( hack );
3767 tmp++;
3768 }
3769
3770 char newdir[MAX_PATH];
3771 char olddir[MAX_PATH];
3772 char filepath[MAX_PATH];
3773
3774 GetCurrentDirectory(MAX_PATH, olddir);
3775
3776 _snprintf(newdir, MAX_PATH, "%ssupport", szArgvPath);
3777 SetCurrentDirectory(newdir);
3778
3779 _snprintf(filepath, MAX_PATH, "%s%s", szArgvPath, fname.c_str());
3780
3781 unsigned int success;
3782 success = GlobalMainWindow->Run_OpenFile(cd_drive, filepath, false);
3783
3784 SetCurrentDirectory(olddir);
3785
3786/*
3787 if (success == 0) {
3788 std::wstring wideBuffer = TheGameText->fetch("Autorun:CantRunHelp");
3789 std::wstring wideBuffer2 = TheGameText->fetch("Autorun:Error");
3790 int length = wideBuffer.length();
3791 WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, NULL, NULL );
3792 length = wideBuffer2.length();
3793 WideCharToMultiByte( CodePage, 0, wideBuffer2.c_str(), length+1, szBuffer2, _MAX_PATH, NULL, NULL );
3794 MessageBox( NULL, szBuffer, szBuffer2, MB_APPLMODAL | MB_OK );
3795 }
3796*/
3797 }
3798 break;
3799
3800 //-------------------------------------------------------------------
3801 // IDD_CANCEL
3802 //-------------------------------------------------------------------
3803 case IDD_CANCEL:
3804 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_CANCEL Selected." ));
3805 end_dialog = true;
3806 break;
3807
3808 //-------------------------------------------------------------------
3809 // IDD_OK -- Install
3810 // IDD_OK2 -- Play
3811 //-------------------------------------------------------------------
3812 case IDD_OK:
3813 case IDD_OK2:
3814 case IDD_OK3:
3815 case IDD_OK4:
3816
3817// if( !Is_On_CD( PRODUCT_VOLUME_CD1 ) && IsEnglish ) {
3818 if( !Is_On_CD( PRODUCT_VOLUME_CD1 )) {
3819
3820 //-----------------------------------------------------------
3821 // If false is returned, then CANCEL was pressed.
3822 //-----------------------------------------------------------
3823 char volume_to_match[ MAX_PATH ];
3824
3825 Reformat_Volume_Name( PRODUCT_VOLUME_CD1, volume_to_match );
3826// result = Prompt_For_CD( window_handle, volume_to_match, IDS_INSERT_CDROM_WITH_VOLUME1, IDS_EXIT_MESSAGE2, &cd_drive );
3827 result = Prompt_For_CD( window_handle, volume_to_match, "Autorun:InsertCDROMWithVolume1", "Autorun:ExitMessage2", &cd_drive );
3828 }
3829
3830 if ( result ) {
3831 if ( idCtl == IDD_OK ) {
3832 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_OK Selected." ));
3833 result = GlobalMainWindow->Run_Setup( window_handle, &dlg_rect, cd_drive );
3834 } else if ( idCtl == IDD_OK2 ) {
3835 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_OK2 Selected." ));
3836 result = GlobalMainWindow->Run_Game( window_handle, &dlg_rect );
3837 } else if (idCtl == IDD_OK3 ) {
3838 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_OK3 Selected, running WorldBuilder." ));
3839 result = GlobalMainWindow->Run_WorldBuilder( window_handle, &dlg_rect );
3840 } else if (idCtl == IDD_OK4 ) {
3841 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_OK4 Selected, running PatchGet." ));
3842 result = GlobalMainWindow->Run_PatchGet( window_handle, &dlg_rect );
3843 }
3844 }
3845
3846 if ( result ) {
3847 end_dialog = true;
3848 }
3849 break;
3850
3851 #if(SHOW_MOH_DEMO)
3852 //-------------------------------------------------------------------
3853 // Launch demo from CD.
3854 //-------------------------------------------------------------------
3855 case IDD_VIEW_DEMO:
3856
3857 if( !Is_On_CD( PRODUCT_VOLUME_CD2 )) {
3858
3859 //-----------------------------------------------------------
3860 // If false is returned, then CANCEL was pressed.
3861 //-----------------------------------------------------------
3862 char volume_to_match[ MAX_PATH ];
3863
3864 Reformat_Volume_Name( PRODUCT_VOLUME_CD2, volume_to_match );
3865// result = Prompt_For_CD( window_handle, volume_to_match, IDS_INSERT_CDROM_WITH_VOLUME2, IDS_EXIT_MESSAGE2, &cd_drive );
3866 result = Prompt_For_CD( window_handle, volume_to_match, AsciiString("Autorun:InsertCDROMWithVolume2"), AsciiString("Autorun:ExitMessage2"), &cd_drive );
3867 }
3868
3869 if ( result ) {
3870 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_VIEW_DEMO Selected." ));
3871 result = GlobalMainWindow->Run_Demo( window_handle, &dlg_rect, cd_drive );
3872 }
3873
3874 if ( result ) {
3875 end_dialog = true;
3876 }
3877
3878 break;
3879 #endif
3880
3881 #if( SHOW_GAMESPY_BUTTON )
3882 //-------------------------------------------------------------------
3883 // Launch GameSpy Website.
3884 //-------------------------------------------------------------------
3885 case IDD_GAMESPY:
3886 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_GAMESPY Selected." ));
3887 if( ViewHTML( GAMESPY_WEBSITE ))
3888 {
3889 end_dialog = true;
3890 }
3891 else
3892 {
3893 Error_Message( Main::hInstance, AsciiString("Autorun:Generals"), AsciiString("Autorun:CantFindExplorer"), GAME_WEBSITE );
3894 }
3895 break;
3896 #endif
3897
3898 //-------------------------------------------------------------------
3899 // Create a new online account.
3900 //-------------------------------------------------------------------
3901 case IDD_NEW_ACCOUNT:
3902 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_NEW_ACCOUNT Selected." ));
3903 result = GlobalMainWindow->Run_New_Account( window_handle, &dlg_rect );
3904 if ( result ) {
3905 end_dialog = true;
3906 }
3907 break;
3908
3909 //-------------------------------------------------------------------
3910 // IDD_REGISTER
3911 //-------------------------------------------------------------------
3912 case IDD_REGISTER:
3913 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_REGISTER Selected." ));
3914 result = GlobalMainWindow->Run_Register( window_handle, &dlg_rect );
3915 if ( result ) {
3916 end_dialog = true;
3917 }
3918 break;
3919
3920 //-------------------------------------------------------------------
3921 // IDD_INTERNET
3922 //-------------------------------------------------------------------
3923 case IDD_INTERNET:
3924 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_INTERNET Selected." ));
3925 if( ViewHTML( GAME_WEBSITE )) {
3926 end_dialog = true;
3927 }
3928 else
3929 {
3930 Error_Message( Main::hInstance, "Autorun:Generals", "Autorun:CantFindExplorer", GAME_WEBSITE );
3931 }
3932 break;
3933
3934 //-------------------------------------------------------------------
3935 // IDD_UPDATE
3936 //-------------------------------------------------------------------
3937 case IDD_UPDATE:
3938 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_UPDATE Selected." ));
3939 result = GlobalMainWindow->Run_Auto_Update( window_handle, &dlg_rect );
3940 if ( result ) {
3941 end_dialog = true;
3942 }
3943 break;
3944
3945 //-------------------------------------------------------------------
3946 // IDD_EXPLORE
3947 //-------------------------------------------------------------------
3948 case IDD_EXPLORE:
3949 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_EXPLORE Selected." ));
3950 GlobalMainWindow->Run_Explorer( "", window_handle, &dlg_rect );
3951 end_dialog = true;
3952 break;
3953
3954 //-------------------------------------------------------------------
3955 // IDD_UNINSTALL
3956 //-------------------------------------------------------------------
3957 case IDD_UNINSTALL:
3958 Msg( __LINE__, TEXT(__FILE__), TEXT("IDD_UNINSTALL Selected." ));
3959 result = GlobalMainWindow->Run_Uninstall( window_handle, &dlg_rect );
3960
3961 //---------------------------------------------------------------
3962 // MML 5/27/99: I am exiting here because the we launch
3963 // Uninstll.exe which in turn launches Uninst.exe thus
3964 // ::Run_Install ends before Uninst.exe is done.
3965 //---------------------------------------------------------------
3966#if 1
3967 if ( result ) {
3968 end_dialog = true;
3969 }
3970#endif
3971 break;
3972
3973 default:
3974 break;
3975 }
3976
3977 //-----------------------------------------------------------------------
3978 // Exit Autorun.
3979 //-----------------------------------------------------------------------
3980 if( end_dialog ) {
3981
3982 for ( i = 0; i < NUM_BUTTONS; i++ ) {
3983 if ( ButtonList[i] ) {
3984 delete( ButtonList[i] );
3985 ButtonList[i] = NULL;
3986 }
3987 }
3988 if ( hpal ) {
3989 DeleteObject( hpal );
3990 }
3991 if ( hBitmap ) {
3992 DeleteObject( hBitmap );
3993 }
3994 for( i = 0; i < NUM_FLICKER_FRAMES; i++ ) {
3995 DeleteObject( hFlicker[i] );
3996 hFlicker[i] = 0;
3997 }
3999 KillTimer( window_handle, timer_id );
4000 EndDialog( window_handle, idCtl );
4001 }
4002
4003 #else
4004 if ( hStaticBrush ) {
4005 DeleteObject( hStaticBrush );
4006 hStaticBrush = 0;
4007 }
4008 EndDialog( window_handle, idCtl );
4009 KillTimer( window_handle, timer_id );
4010 KillTimer( window_handle, gem_timer_id );
4011 #endif
4012
4013 }
4014 break;
4015
4016 //-------------------------------------------------------------------------------
4017 // This message is the response to the Close Button in upper right corner.
4018 //-------------------------------------------------------------------------------
4019 case WM_SYSCOMMAND:
4020
4021 if ( w_param == SC_CLOSE ) {
4022 #if(BACKGROUND_BITMAP)
4023
4024 for ( i = 0; i < NUM_BUTTONS; i++ ) {
4025 if ( ButtonList[i] ) {
4026 delete( ButtonList[i] );
4027 ButtonList[i] = NULL;
4028 }
4029 }
4030 if ( hpal ) {
4031 DeleteObject( hpal );
4032 }
4033 if ( hBitmap ) {
4034 DeleteObject( hBitmap );
4035 }
4036 for( i = 0; i < NUM_FLICKER_FRAMES; i++ ) {
4037 DeleteObject( hFlicker[i] );
4038 hFlicker[i] = 0;
4039 }
4040
4041 #else
4042 if ( hStaticBrush ) {
4043 DeleteObject( hStaticBrush );
4044 hStaticBrush = 0;
4045 }
4046 #endif
4047
4048 //-----------------------------------------------------------------------
4049 // Stop the sound if still going.
4050 //-----------------------------------------------------------------------
4052
4053 //-----------------------------------------------------------------------
4054 // Delete the arguments.
4055 //-----------------------------------------------------------------------
4056 if ( Args ) {
4057 delete( Args );
4058 Args = NULL;
4059 }
4060 KillTimer( window_handle, timer_id );
4061 EndDialog( window_handle, w_param );
4062 }
4063 break;
4064
4065 //-------------------------------------------------------------------------------
4066 // WM_SYSCOLORCHANGE Message.
4067 // If your applications uses controls in Windows 95/NT, forward the
4068 // WM_SYSCOLORCHANGE message to the controls.
4069 //-------------------------------------------------------------------------------
4070 #if( !BACKGROUND_BITMAP )
4071 case WM_SYSCOLORCHANGE:
4072 if ( hStaticBrush ) {
4073 DeleteObject( hStaticBrush );
4074 hStaticBrush = CreateSolidBrush( GetSysColor( COLOR_WINDOW ));
4075 }
4076 break;
4077 #endif
4078
4079 //-------------------------------------------------------------------------------
4080 // WM_CTLCOLOR Message.
4081 // wParam Handle to Child Window's device context
4082 // LOWORD( lParam ) Child Window handle
4083 // HIWORD( lParam ) Type of Window: CTLCOLOR_MSGBOX, _EDIT, _LISTBOX, _BTN, _DLG, _SCROLLBAR, _STATIC
4084 //
4085 // WM_CTLCOLORMSGBOX
4086 // WM_CTLCOLOREDIT
4087 // WM_CTLCOLORLISTBOX
4088 // WM_CTLCOLORBTN
4089 // WM_CTLCOLORDLG
4090 // WM_CTLCOLORSCROLLBAR
4091 // WM_CTLCOLORSTATIC
4092 // #define WM_CTLCOLOR 0x0019
4093 // #define GET_WM_CTLCOLOR_HDC (wp, lp, msg) (HDC)(wp)
4094 // #define GET_WM_CTLCOLOR_HWND(wp, lp, msg) (HWND)(lp)
4095 // #define GET_WM_CTLCOLOR_TYPE(wp, lp, msg) (WORD)(msg - WM_CTLCOLORMSGBOX)
4096 // #define GET_WM_CTLCOLOR_MSG (type) (WORD)(WM_CTLCOLORMSGBOX+(type))
4097 //-------------------------------------------------------------------------------
4098 #if( !BACKGROUND_BITMAP )
4099 case WM_CTLCOLOR:
4100 if ( HIWORD( l_param ) == CTLCOLOR_STATIC ) {
4101
4102 SetTextColor(( HDC )w_param, GetSysColor( COLOR_WINDOWTEXT ));
4103 SetBkColor( (HDC)wParam, GetSysColor( COLOR_WINDOW ));
4104// SetBkColor(( HDC )w_param, RGB( 192, 192, 192 ));
4105
4106 UnrealizeObject( hStaticBrush ); // reset the origin of the brush next time used.
4107 point.x = point.y = 0; // create a point.
4108 ClientToScreen( window_handle, &point ); // translate into screen coordinates.
4109 SetBrushOrgEx( (HDC)w_param, point.x, point.y, NULL ); // New Origin to use when next selected.
4110 return((LRESULT) hStaticBrush );
4111 }
4112 #endif
4113
4114 //===============================================================================
4115 // Check where Left Mouse button was pressed.
4116 //===============================================================================
4117 #if(BACKGROUND_BITMAP)
4118 case WM_LBUTTONDOWN:
4119 {
4120 RECT rect;
4121
4122 //----------------------------------------------------------------------
4123 // Get mouse coordinates.
4124 //----------------------------------------------------------------------
4125 mouse_x = LOWORD( l_param );
4126 mouse_y = HIWORD( l_param );
4127
4128 //----------------------------------------------------------------------
4129 // For each button in the list...
4130 //----------------------------------------------------------------------
4131 for ( i = 0; i < NUM_BUTTONS; i++ ) {
4132
4133 //-------------------------------------------------------------------
4134 // If mouse was clicked in one of the "buttons", then change
4135 // that button's state to "pressed".
4136 //-------------------------------------------------------------------
4137 if ( ButtonList[i] && ButtonList[i]->Is_Mouse_In_Region( mouse_x, mouse_y )) {
4138
4139 if ( ButtonList[i]->Get_State() != DrawButton::PRESSED_STATE ) {
4140
4141 ButtonList[i]->Return_Area ( &rect );
4142 ButtonList[i]->Set_State( DrawButton::PRESSED_STATE );
4143 InvalidateRect( window_handle, &rect, FALSE );
4144
4145 Msg( __LINE__, TEXT(__FILE__), TEXT("WM_LBUTTONDOWN -- %s. rect = [%d,%d,%d,%d]."),
4146 ButtonList[i]->Return_Normal_Bitmap(), rect.left, rect.top, rect.right, rect.bottom );
4147
4148 UpdateWindow( window_handle );
4149 }
4150 break;
4151 }
4152 }
4153 }
4154 break;
4155 #endif
4156
4157 //===============================================================================
4158 // Check where Left Mouse button was released.
4159 //===============================================================================
4160 #if(BACKGROUND_BITMAP)
4161 case WM_LBUTTONUP:
4162 {
4163 RECT rect;
4164 int focus_index = 0;
4165 int found_focus = -1;
4166
4167 //-----------------------------------------------------------------------
4168 // Get mouse coordinates.
4169 //-----------------------------------------------------------------------
4170 mouse_x = LOWORD( l_param );
4171 mouse_y = HIWORD( l_param );
4172
4173 //=======================================================================
4174 // focus_index = previous PRESSED/FOCUSED button.
4175 // found_focus = new PRESSED/FOCUSED button ( if different ).
4176 //=======================================================================
4177
4178 //-----------------------------------------------------------------------
4179 // First find the button that is either focused or pressed.
4180 //-----------------------------------------------------------------------
4181 for ( i = 0; i < NUM_BUTTONS; i++ ) {
4182 if ( ButtonList[i] ) {
4183
4184 //---------------------------------------------------------------
4185 // Save index of button with focus.
4186 //---------------------------------------------------------------
4187 if( ButtonList[i]->Get_State() == DrawButton::FOCUS_STATE ||
4188 ButtonList[i]->Get_State() == DrawButton::PRESSED_STATE ) {
4189 focus_index = i;
4190 }
4191 }
4192 }
4193
4194 //-----------------------------------------------------------------------
4195 // Then find the button that is to be focused or pressed.
4196 //-----------------------------------------------------------------------
4197 for ( i = 0; i < NUM_BUTTONS; i++ ) {
4198 if ( ButtonList[i] && ButtonList[i]->Is_Mouse_In_Region( mouse_x, mouse_y )) {
4199 found_focus = i;
4200 }
4201 }
4202
4203 //-----------------------------------------------------------------------
4204 // If new button is not found...
4205 //-----------------------------------------------------------------------
4206 if ( found_focus == -1 ) {
4207
4208 //-------------------------------------------------------------------
4209 // Make sure previously focused/pressed button is now is a
4210 // focused state and no action is taken. This occurs when
4211 // mouse is clicked outside of any button areas.
4212 //-------------------------------------------------------------------
4213 if ( ButtonList[focus_index] && ( ButtonList[focus_index]->Get_State() != DrawButton::FOCUS_STATE )) {
4214
4215 ButtonList[focus_index]->Set_State( DrawButton::FOCUS_STATE );
4216 ButtonList[focus_index]->Return_Area ( &rect );
4217 InvalidateRect( window_handle, &rect, FALSE );
4218
4219 Msg( __LINE__, TEXT(__FILE__), TEXT("WM_LBUTTONUP -- %s[FOCUS_STATE] = [x=%d, y=%d, w=%d, h=%d]."),
4220 ButtonList[ focus_index ]->Return_Normal_Bitmap(), rect.left, rect.top, rect.right, rect.bottom );
4221
4222 UpdateWindow( window_handle );
4223 }
4224
4225 } else {
4226
4227 //-------------------------------------------------------------------
4228 // Buttons are one and the same.
4229 //-------------------------------------------------------------------
4230 if( focus_index == found_focus ) {
4231
4232 ButtonList[ found_focus ]->Set_State( DrawButton::FOCUS_STATE );
4233 ButtonList[ found_focus ]->Return_Area ( &rect );
4234 InvalidateRect( window_handle, &rect, FALSE );
4235
4236 Msg( __LINE__, TEXT(__FILE__), TEXT("WM_LBUTTONUP -- %s[FOCUS_STATE] = [x=%d, y=%d, w=%d, h=%d]."),
4237 ButtonList[ found_focus ]->Return_Normal_Bitmap(), rect.left, rect.top, rect.right, rect.bottom );
4238
4239 UpdateWindow( window_handle );
4240
4241 } else {
4242
4243 //---------------------------------------------------------------
4244 // Make previously focused button, Normal...
4245 //---------------------------------------------------------------
4246 if ( ButtonList[ focus_index ] ) {
4247
4248 ButtonList[ focus_index ]->Set_State( DrawButton::NORMAL_STATE );
4249 ButtonList[ focus_index ]->Return_Area ( &rect );
4250 InvalidateRect( window_handle, &rect, FALSE );
4251
4252 Msg( __LINE__, TEXT(__FILE__), TEXT("WM_LBUTTONUP -- %s[NORMAL_STATE] = [x=%d, y=%d, w=%d, h=%d]."),
4253 ButtonList[ focus_index ]->Return_Normal_Bitmap(),
4254 rect.left, rect.top, rect.right, rect.bottom );
4255
4256 UpdateWindow( window_handle );
4257 }
4258
4259 //---------------------------------------------------------------
4260 // ...and the new button now has focus.
4261 //---------------------------------------------------------------
4262 if ( ButtonList[ found_focus ] ) {
4263
4264 ButtonList[ found_focus ]->Set_State( DrawButton::FOCUS_STATE );
4265 ButtonList[ found_focus ]->Return_Area ( &rect );
4266 InvalidateRect( window_handle, &rect, FALSE );
4267
4268 Msg( __LINE__, TEXT(__FILE__), TEXT("WM_LBUTTONUP -- %s[FOCUS_STATE] = [x=%d, y=%d, w=%d, h=%d]."),
4269 ButtonList[ found_focus ]->Return_Normal_Bitmap(), rect.left, rect.top, rect.right, rect.bottom );
4270
4271 UpdateWindow( window_handle );
4272 }
4273 }
4274 }
4275
4276 //-----------------------------------------------------------------------
4277 // Repaint the Window now.
4278 //-----------------------------------------------------------------------
4279 nResult = UpdateWindow( window_handle );
4280
4281 //-----------------------------------------------------------------------
4282 // Do the focus button's action.
4283 //-----------------------------------------------------------------------
4284 if ( found_focus >= 0 ) {
4285 if (( ButtonList[found_focus] ) &&
4286 ( ButtonList[found_focus]->Get_State() == DrawButton::FOCUS_STATE ) &&
4287 ( ButtonList[found_focus]->Is_Mouse_In_Region( mouse_x, mouse_y ))) {
4288 SendMessage( window_handle, WM_COMMAND, ButtonList[found_focus]->Return_Id(), 0L );
4289 break;
4290 }
4291 }
4292 }
4293 break;
4294 #endif
4295
4296 //-------------------------------------------------------------------------------
4297 // Check Mouse moves over buttons.
4298 //-------------------------------------------------------------------------------
4299//#if(DISABLE_KEYBOARD)
4300 #if(BACKGROUND_BITMAP)
4301 case WM_MOUSEMOVE:
4302 {
4303 RECT rect;
4304 int j;
4305 int done = 0;
4306
4307 //-----------------------------------------------------------------------
4308 // Get mouse coordinates.
4309 //-----------------------------------------------------------------------
4310 mouse_x = LOWORD( l_param );
4311 mouse_y = HIWORD( l_param );
4312
4313 #if(USE_MOUSE_MOVES)
4314 //-----------------------------------------------------------------------
4315 // Reset most current button.
4316 //-----------------------------------------------------------------------
4317 CurrentButton = 0;
4318 #endif
4319
4320 //-----------------------------------------------------------------------
4321 // For each button in the list...
4322 //-----------------------------------------------------------------------
4323 i = 0;
4324 while( i < NUM_BUTTONS && !done ) {
4325
4326 //-------------------------------------------------------------------
4327 // For each button, check if mouse is in it's area.
4328 //-------------------------------------------------------------------
4329 if ( ButtonList[i] && ButtonList[i]->Is_Mouse_In_Region( mouse_x, mouse_y )) {
4330
4331 //---------------------------------------------------------------
4332 // This is now the current button.
4333 //---------------------------------------------------------------
4334 CurrentButton = ButtonList[i]->Return_Id();
4335
4336 if( CurrentButton != LastButton ) {
4337
4338 //-----------------------------------------------------------
4339 // Make all other buttons, NORMAL.
4340 //-----------------------------------------------------------
4341 for ( j = 0; j < NUM_BUTTONS; j++ ) {
4342 if ( ButtonList[j] ) {
4343 ButtonList[j]->Set_State( DrawButton::NORMAL_STATE );
4344// Msg( __LINE__, TEXT(__FILE__), TEXT("WM_MOUSEMOVE -- %s[NORMAL_STATE]]."), ButtonList[j]->Return_Normal_Bitmap());
4345 }
4346 }
4347
4348 if ( w_param & MK_LBUTTON ) {
4349
4350 //--------------------------------------------------------
4351 // Left Mouse button is pressed! Make it a pressed button!
4352 //--------------------------------------------------------
4353 if ( ButtonList[i] && ButtonList[i]->Get_State() != DrawButton::PRESSED_STATE ) {
4354 ButtonList[i]->Set_State( DrawButton::PRESSED_STATE );
4355// Msg( __LINE__, TEXT(__FILE__), TEXT("WM_MOUSEMOVE -- %s[PRESSED_STATE]."), ButtonList[i]->Return_Normal_Bitmap());
4356 }
4357
4358 } else {
4359
4360 //--------------------------------------------------------
4361 // If this button is not already focused, give it the focus.
4362 //--------------------------------------------------------
4363 if ( ButtonList[i] && ButtonList[i]->Get_State() != DrawButton::FOCUS_STATE ) {
4364 ButtonList[i]->Set_State( DrawButton::FOCUS_STATE );
4365// Msg( __LINE__, TEXT(__FILE__), TEXT("WM_MOUSEMOVE -- %s[FOCUS_STATE]."), ButtonList[i]->Return_Normal_Bitmap());
4366 }
4367 } // end of if
4368
4369 //-----------------------------------------------------------
4370 // Get the area of the button, and post it for updating.
4371 //-----------------------------------------------------------
4372 for ( j = 0; j < NUM_BUTTONS; j++ ) {
4373 if ( ButtonList[j] ) {
4374 ButtonList[j]->Return_Area ( &rect );
4375 InvalidateRect( window_handle, &rect, FALSE );
4376 }
4377 }
4378
4379 //-----------------------------------------------------------
4380 // Repaint now!
4381 //-----------------------------------------------------------
4382 UpdateWindow( window_handle );
4383
4384 done = 1;
4385 }
4386
4387 } // end of if
4388 i++;
4389
4390 } // end of for
4391
4392
4393 #if( USE_MOUSE_MOVES )
4394 //-----------------------------------------------------------------------
4395 // If a MouseMove was found to be in one of the buttons, then
4396 // CurrentButton will have a value.
4397 //-----------------------------------------------------------------------
4398 if ( CurrentButton != 0 ) {
4399
4400 LastButton = CurrentButton;
4401
4402 //-------------------------------------------------------------------
4403 // If we are still in the same button, don't make a sound!
4404 //-------------------------------------------------------------------
4405 if ( LastButton != PrevButton ) {
4406 PrevButton = LastButton;
4407 PlaySound( szButtonWav, Main::hModule, SND_ASYNC | SND_RESOURCE );
4408 }
4409 }
4410 #endif
4411 }
4412 break;
4413
4414 #endif // Background_Bitmap flag
4415//#endif
4416
4417 //-------------------------------------------------------------------------------
4418 // Repaint when focus is restored (does partial repaint), and when
4419 // mouse is double clicked on dialog ( full repaint ).
4420 //-------------------------------------------------------------------------------
4421 case WM_LBUTTONDBLCLK:
4422 case WM_SETFOCUS:
4423 InvalidateRect( window_handle, &dlg_rect, TRUE );
4424// nResult = UpdateWindow( window_handle );
4425// Msg( __LINE__, TEXT(__FILE__), TEXT("WM_LBUTTONDBLCLK -- dlg_rect = [x=%d, y=%d, w=%d, h=%d]."),
4426// dlg_rect.left, dlg_rect.top, dlg_rect.right, dlg_rect.bottom );
4427 break;
4428
4429 #if(BACKGROUND_BITMAP)
4430 //-------------------------------------------------------------------------------
4431 // bit 30 of lParam - Specifies the previous key state.
4432 // The value is 1 if the key is down before the message is sent,
4433 // or it is 0 if the key is up.
4434 //-------------------------------------------------------------------------------
4435 case WM_KEYUP:
4436 {
4437// int j = 0;
4438
4439 switch( w_param ) {
4440
4441 case VK_ESCAPE:
4442 SendMessage( window_handle, WM_SYSCOMMAND, SC_CLOSE, 0L );
4443 break;
4444
4445//#if(DISABLE_KEYBOARD)
4446 case VK_RETURN:
4447 //---------------------------------------------------------------
4448 // If the Return/Enter key is pressed... find the focused
4449 // button and call its action.
4450 //---------------------------------------------------------------
4451// result = ( l_param & 0x40000000 );
4452 for ( i = 0; i < NUM_BUTTONS; i++ ) {
4453 if ( ButtonList[i] && ButtonList[i]->Get_State() == DrawButton::FOCUS_STATE ) {
4454 SendMessage( window_handle, WM_COMMAND, ButtonList[i]->Return_Id(), 0L );
4455 break;
4456 }
4457 }
4458 break;
4459//#endif
4460
4461//#if(DISABLE_KEYBOARD)
4462 case VK_TAB:
4463 case VK_DOWN:
4464 {
4465 //-----------------------------------------------------------
4466 // Find the button with focus and "tab" to the next button by finding
4467 // the next valid index. If past last button, circle back to the top.
4468 //-----------------------------------------------------------
4469 int focused_button = 0;
4470 int next_button = 0;
4471
4472 for ( i = 0; i < NUM_BUTTONS; i++ ) {
4473 if ( ButtonList[i] && ButtonList[i]->Get_State() == DrawButton::FOCUS_STATE ) {
4474
4475 focused_button = i;
4476 next_button = i+1;
4477
4478 if ( next_button >= NUM_BUTTONS ) {
4479 next_button = 0;
4480 }
4481 while (( next_button < NUM_BUTTONS ) && !ButtonList[ next_button ] ) {
4482 next_button++;
4483 }
4484
4485 if ( next_button >= NUM_BUTTONS ) {
4486 next_button = 0;
4487 while (( next_button < NUM_BUTTONS ) && !ButtonList[ next_button ] ) {
4488 next_button++;
4489 }
4490 }
4491 break;
4492 }
4493 }
4494
4495 //-----------------------------------------------------------
4496 // Set the previous button to Normal status.
4497 //-----------------------------------------------------------
4498 if ( ButtonList[focused_button] && ( ButtonList[focused_button]->Get_State() != DrawButton::NORMAL_STATE )) {
4499
4500 ButtonList[focused_button]->Set_State( DrawButton::NORMAL_STATE );
4501 ButtonList[focused_button]->Return_Area ( &rect );
4502 InvalidateRect( window_handle, &rect, FALSE );
4503
4504 Msg( __LINE__, TEXT(__FILE__), TEXT("VK_DOWN/VK_TAB -- %s = [%s]."), ButtonList[focused_button]->Return_Normal_Bitmap(), "NORMAL_STATE" );
4505 }
4506
4507 //-----------------------------------------------------------
4508 // Set the new button to focus status.
4509 //-----------------------------------------------------------
4510 if ( ButtonList[next_button] && ( ButtonList[next_button]->Get_State() != DrawButton::FOCUS_STATE )) {
4511
4512 ButtonList[next_button]->Set_State( DrawButton::FOCUS_STATE );
4513 ButtonList[next_button]->Return_Area ( &rect );
4514 InvalidateRect( window_handle, &rect, FALSE );
4515 PlaySound( szButtonWav, Main::hModule, SND_ASYNC | SND_RESOURCE );
4516
4517 Msg( __LINE__, TEXT(__FILE__), TEXT("VK_DOWN/VK_TAB -- %s = [%s]."), ButtonList[next_button]->Return_Normal_Bitmap(), "FOCUS_STATE" );
4518 }
4519 }
4520 break;
4521
4522 case VK_UP:
4523 {
4524 //-----------------------------------------------------------
4525 // Find the button with focus and "tab" to the next button by finding
4526 // the next valid index. If past last button, circle back to the top.
4527 //-----------------------------------------------------------
4528 int focused_button = 0;
4529 int next_button = 0;
4530
4531 for ( i = 0; i < NUM_BUTTONS; i++ ) {
4532 if ( ButtonList[i] && ButtonList[i]->Get_State() == DrawButton::FOCUS_STATE ) {
4533
4534 focused_button = i;
4535 next_button = i-1;
4536
4537 if ( next_button < 0 ) {
4538 next_button = NUM_BUTTONS - 1;
4539 }
4540 while (( next_button > 0 ) && !ButtonList[ next_button ] ) {
4541 next_button--;
4542 }
4543
4544 if ( !ButtonList[ next_button ]) {
4545 next_button = NUM_BUTTONS - 1;
4546 }
4547 while (( next_button >= 0 ) && !ButtonList[ next_button ] ) {
4548 next_button--;
4549 }
4550 break;
4551 }
4552 }
4553
4554 //-----------------------------------------------------------
4555 // Set the previous button to Normal status.
4556 //-----------------------------------------------------------
4557 if ( ButtonList[focused_button] && ( ButtonList[focused_button]->Get_State() != DrawButton::NORMAL_STATE )) {
4558
4559 ButtonList[focused_button]->Set_State( DrawButton::NORMAL_STATE );
4560 ButtonList[focused_button]->Return_Area ( &rect );
4561 InvalidateRect( window_handle, &rect, FALSE );
4562
4563 Msg( __LINE__, TEXT(__FILE__), TEXT("VK_DOWN/VK_TAB -- %s = [%s]."), ButtonList[focused_button]->Return_Normal_Bitmap(), "NORMAL_STATE" );
4564 }
4565
4566 //-----------------------------------------------------------
4567 // Set the new button to focus status.
4568 //-----------------------------------------------------------
4569 if ( ButtonList[next_button] && ( ButtonList[next_button]->Get_State() != DrawButton::FOCUS_STATE )) {
4570
4571 ButtonList[next_button]->Set_State( DrawButton::FOCUS_STATE );
4572 ButtonList[next_button]->Return_Area ( &rect );
4573 InvalidateRect( window_handle, &rect, FALSE );
4574 PlaySound( szButtonWav, Main::hModule, SND_ASYNC | SND_RESOURCE );
4575
4576 Msg( __LINE__, TEXT(__FILE__), TEXT("VK_DOWN/VK_TAB -- %s = [%s]."), ButtonList[next_button]->Return_Normal_Bitmap(), "FOCUS_STATE" );
4577 }
4578 }
4579 break;
4580//#endif
4581
4582 } /* end of switch */
4583 } /* end of case stmt */
4584
4585 return ( 0 );
4586
4587 #endif
4588 }
4589 return( FALSE );
4590}
4591
4592//*****************************************************************************
4593// STOP_SOUND_PLAYING -- Stop the background sound.
4594//
4595// INPUT: none.
4596//
4597// OUTPUT: none.
4598//
4599// WARNINGS: Will stop any sound started by PlaySound.
4600//
4601// HISTORY:
4602// 06/04/1999 MML : Created.
4603//=============================================================================
4604
4606{
4607 PlaySound( NULL, NULL, SND_ASYNC | SND_FILENAME );
4608}
4609
4610//*****************************************************************************
4611// OPTIONS -- Find any user options and set the correct flags
4612//
4613// INPUT: int argc = no. of arguments to check
4614// BYTE *argv[] = ptr to actual command line parameters
4615//
4616// OUTPUT:
4617//
4618// WARNINGS:
4619//
4620// HISTORY:
4621// 06/04/1996 MML : Created.
4622//=============================================================================
4623
4625{
4626 int i;
4627 BOOL result = TRUE;
4628 char buffer[ MAX_ARGUMENT_LENGTH ];
4629
4630 //-------------------------------------------------------------------------
4631 // Scan arguments for any options ( / or - followed by a letter)
4632 //-------------------------------------------------------------------------
4633 for ( i = 0; i < Orgs->Get_argc(); i++ ) {
4634
4635 //---------------------------------------------------------------------
4636 // Get the next item in the list.
4637 //---------------------------------------------------------------------
4638 memset( buffer, '\0', sizeof( buffer ));
4639 strcpy( buffer, Orgs->Get_argv(i));
4640
4641 Msg( __LINE__, TEXT(__FILE__), TEXT("Options -- Argument[%d] = %s."), i, buffer );
4642
4643 //---------------------------------------------------------------------
4644 // If starts with / or -
4645 //---------------------------------------------------------------------
4646 if (( buffer[0] == '/' ) || ( buffer[0] == '-' )) {
4647
4648 switch ( tolower( buffer[1] )) {
4649
4650 //-------------------------------------------------------------
4651 // Retrieve the game's version info.
4652 //-------------------------------------------------------------
4653 case 'v':
4654 {
4655 char szPath [ MAX_PATH ];
4656 char szVersion[ MAX_PATH ];
4657
4659 GetPrivateProfileString( "Setup", "Version", "1.0", szVersion, sizeof( szVersion ), szPath );
4660
4661 LoadString( Main::hInstance, IDS_VERSION_STRING, szBuffer, MAX_PATH );
4662
4663// sprintf( szBuffer3, "V %s", szVersion );
4664 sprintf( szBuffer3, szBuffer, szVersion );
4665// strcpy( szBuffer, szRegistryKey );
4666
4667 MessageBox( NULL, szBuffer3, "Autorun", MB_TASKMODAL | MB_OK );
4668 result = FALSE;
4669 }
4670 break;
4671
4672 //-------------------------------------------------------------
4673 // Bypass the volume check.
4674 //-------------------------------------------------------------
4675 case 'n':
4676 {
4677 HANDLE handle;
4678 WIN32_FIND_DATA FindFileData;
4679
4680 memset( szVolumeName, '\0', MAX_PATH );
4681
4682 //-----------------------------------------------------
4683 // If we think we are on CD2, then use PRODUCT_VOLUME_CD2.
4684 //-----------------------------------------------------
4686 handle = FindFirstFile( szBuffer, &FindFileData );
4687 if ( handle == INVALID_HANDLE_VALUE ) {
4689 } else {
4691 FindClose( handle );
4692 }
4693
4694 strcpy( Arguments[ NumberArguments++ ], buffer );
4695 }
4696 break;
4697
4698 #if( _DEBUG )
4699
4700 case 'c':
4701 if( buffer[2] == 'd' ) {
4702 szCDDrive[0] = buffer[3];
4703 szCDDrive[1] = ':';
4704 szCDDrive[2] = '\\';
4705 }
4706 break;
4707
4708 //-------------------------------------------------------------
4709 // Change languages?
4710 //-------------------------------------------------------------
4711 case 'l':
4712 {
4713 //-----------------------------------------------------
4714 // Identifier Meaning
4715 // 932 Japan
4716 // 936 Chinese (PRC, Singapore)
4717 // 949 Korean
4718 // 1252 Windows 3.1 Latin 1 (US, Western Europe)
4719 //-----------------------------------------------------
4720 char *temp = buffer+2;
4721 int number = atoi( temp );
4722
4723 switch( number ) {
4724
4725 case LANG_GER:
4727 CodePage = 1252;
4728 break;
4729
4730 case LANG_FRE:
4732 CodePage = 1252;
4733 break;
4734
4735 case LANG_JAP:
4737 CodePage = 932;
4738 break;
4739
4740 case LANG_KOR:
4742 CodePage = 949;
4743 break;
4744
4745 case LANG_CHI:
4747 CodePage = 950;
4748 break;
4749
4750 case LANG_USA:
4751 default:
4753 CodePage = 1252;
4754 break;
4755 }
4756 }
4757 break;
4758
4759
4760 #endif
4761
4762 default:
4763 strcpy( Arguments[ NumberArguments++ ], buffer );
4764 break;
4765 }
4766 }
4767 }
4768
4769 Msg( __LINE__, TEXT(__FILE__), TEXT("Options -- Language = %d"), Language );
4770 Msg( __LINE__, TEXT(__FILE__), TEXT("Options -- CodePage = %d"), CodePage );
4771
4772#if(0)
4773 struct lconv *info = localeconv();
4774 char szDefaultLangID[ MAX_PATH ];
4775
4776 GetLocaleInfo(
4777 LOCALE_USER_DEFAULT, // locale identifier
4778 LOCALE_ILANGUAGE, // type of information
4779 szBuffer1, // address of buffer for information
4780 MAX_PATH ); // size of buffer
4781
4782 Msg( __LINE__, TEXT(__FILE__), TEXT("Options -- GetLocalInfo = %s"), szBuffer1 );
4783
4784 sprintf( szDefaultLangID, "%04X", GetUserDefaultLangID());
4785 Msg( __LINE__, __FILE__, "Options -- GetUserDefaultLangID() = %s", szDefaultLangID );
4786
4787 sprintf( szDefaultLangID, "%04X", GetSystemDefaultLangID());
4788 Msg( __LINE__, __FILE__, "Options -- GetSystemDefaultLangID() = %s", szDefaultLangID );
4789 Msg( __LINE__, __FILE__, "-------------------------------------------------------------" );
4790#endif
4791
4792 return( result );
4793}
4794
4795//*****************************************************************************
4796// Valid_Environment -- Make sure this program is run from CD-ROM disc only
4797// AND it is a Win95 system.
4798//
4799// INPUT: none.
4800//
4801// OUTPUT: none.
4802//
4803// WARNINGS: returns 0 if ok to continue.
4804//
4805// HISTORY:
4806// 06/04/1996 MML : Created.
4807//=============================================================================
4808
4810{
4811 bool result = 0;
4812
4813 //--------------------------------------------------------------------------
4814 // Check Windows Version.
4815 //--------------------------------------------------------------------------
4816
4817 int length = 0;
4818 result = WinVersion.Meets_Minimum_Version_Requirements();
4819 if ( !result )
4820 {
4821 std::wstring wideBuffer = TheGameText->fetch("GUI:WindowsVersionText");
4822 std::wstring wideBuffer2 = TheGameText->fetch("GUI:WindowsVersionTitle");
4823 length = wideBuffer.length();
4824 WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, NULL, NULL );
4825 length = wideBuffer2.length();
4826 WideCharToMultiByte( CodePage, 0, wideBuffer2.c_str(), length+1, szBuffer2, _MAX_PATH, NULL, NULL );
4827 MessageBox( NULL, szBuffer, szBuffer2, MB_APPLMODAL | MB_OK );
4828 }
4829
4830 return( result );
4831}
4832
4833//****************************************************************************
4834// LOADRESOURCEBITMAP -- Find & Load the bitmap from the resource.
4835//
4836// INPUT: HINSTANCE hInstance -- Program's hInstance.
4837// LPTSTR lpString -- name of bitmap to find.
4838// HPALETTE FAR *lphPalette -- we will return palette in this.
4839//
4840// OUTPUT: HBITMAP -- handle to the bitmap if found.
4841//
4842// WARNINGS:
4843//
4844// HISTORY: Found this routine on MS Developmemt CD, July 1996.
4845// 09/26/1996 MML : Created.
4846//=============================================================================
4847
4848HBITMAP LoadResourceBitmap( HINSTANCE hInstance, LPTSTR lpString, HPALETTE FAR *lphPalette, bool loading_a_button )
4849{
4850// HDC hdc;
4851 int iNumColors;
4852 HRSRC hRsrc;
4853 HGLOBAL hGlobal;
4854 HBITMAP hBitmapFinal = NULL;
4855 LPBITMAPINFOHEADER lpbi;
4856
4857 hBitmapFinal = LoadBitmap( hInstance, lpString );
4858
4859 //--------------------------------------------------------------------------
4860 // Find the Bitmap in this program's resources.
4861 //--------------------------------------------------------------------------
4862 hRsrc = FindResource( hInstance, lpString, RT_BITMAP );
4863 if ( hRsrc ) {
4864
4865 //-----------------------------------------------------------------------
4866 // Load the resource, lock the memory, grab a DC.
4867 //-----------------------------------------------------------------------
4868 hGlobal = LoadResource( hInstance, hRsrc );
4869 lpbi = (LPBITMAPINFOHEADER) LockResource( hGlobal );
4870
4871 if ( loading_a_button ) {
4872
4873 //--------------------------------------------------------------------------
4874 // Set number of colors ( 2 to the nth ).
4875 //--------------------------------------------------------------------------
4876 if ( lpbi->biBitCount <= 8 ) {
4877 iNumColors = ( 1 << lpbi->biBitCount );
4878 } else {
4879 iNumColors = 0;
4880 }
4881
4882 } else {
4883
4884 //--------------------------------------------------------------------
4885 // Get the palette from the resource.
4886 //--------------------------------------------------------------------
4887 *lphPalette = CreateDIBPalette((LPBITMAPINFO) lpbi, &iNumColors );
4888 }
4889
4890 //-----------------------------------------------------------------------
4891 // Free DS and memory used.
4892 //-----------------------------------------------------------------------
4893 UnlockResource( hGlobal );
4894 FreeResource( hGlobal );
4895 }
4896
4897 return( hBitmapFinal );
4898}
4899
4900//*****************************************************************************
4901// CREATEDIBPALETTE -- Creates the palette from the Bitmap found above.
4902//
4903// INPUT: LPBITMAPINFO lpbmi -- bitmap info from header.
4904// LPINT lpiNumColors -- number of colors.
4905//
4906// OUTPUT: HPALETTE -- handle to the bitmap if found.
4907//
4908// WARNINGS:
4909//
4910// HISTORY: Found this routine on MS Developmemt CD, July 1996.
4911// 09/26/1996 MML : Created.
4912//=============================================================================
4913HPALETTE CreateDIBPalette ( LPBITMAPINFO lpbmi, LPINT lpiNumColors )
4914{
4915 LPBITMAPINFOHEADER lpbi;
4916 LPLOGPALETTE lpPal;
4917 HANDLE hLogPal;
4918 HPALETTE hPal = NULL;
4919 int i;
4920
4921 lpbi = (LPBITMAPINFOHEADER) lpbmi;
4922
4923 //--------------------------------------------------------------------------
4924 // Set number of colors ( 2 to the nth ).
4925 //--------------------------------------------------------------------------
4926 if ( lpbi->biBitCount <= 8 ) {
4927 *lpiNumColors = ( 1 << lpbi->biBitCount );
4928 } else {
4929 *lpiNumColors = 0;
4930 }
4931
4932 //--------------------------------------------------------------------------
4933 // If bitmap has a palette ( bitcount ), lock some memory and create
4934 // a palette from the bitmapinfoheader passed in.
4935 //--------------------------------------------------------------------------
4936 if ( *lpiNumColors ) {
4937
4938 hLogPal = GlobalAlloc( GHND, sizeof( LOGPALETTE ) + sizeof( PALETTEENTRY ) * ( *lpiNumColors ));
4939 lpPal = (LPLOGPALETTE) GlobalLock( hLogPal );
4940 lpPal->palVersion = 0x300;
4941 lpPal->palNumEntries = (WORD)*lpiNumColors;
4942
4943 for ( i = 0; i < *lpiNumColors; i++ ) {
4944 lpPal->palPalEntry[i].peRed = lpbmi->bmiColors[i].rgbRed;
4945 lpPal->palPalEntry[i].peGreen = lpbmi->bmiColors[i].rgbGreen;
4946 lpPal->palPalEntry[i].peBlue = lpbmi->bmiColors[i].rgbBlue;
4947 lpPal->palPalEntry[i].peFlags = 0;
4948 }
4949 hPal = CreatePalette( lpPal );
4950 GlobalUnlock( hLogPal );
4951 GlobalFree( hLogPal );
4952
4953#if(0)
4954 StandardFileClass fileout;
4955 char buff[2];
4956
4957 fileout.Open( "test.pal", MODE_WRITE_TRUNCATE );
4958 for ( i = 0; i < *lpiNumColors; i++ ) {
4959 sprintf( buff, "%d", lpPal->palPalEntry[i].peRed >> 2 );
4960 fileout.Write(( void *)buff, 2 );
4961 sprintf( buff, "%d", lpPal->palPalEntry[i].peGreen >> 2 );
4962 fileout.Write(( void *)buff, 2 );
4963 sprintf( buff, "%d", lpPal->palPalEntry[i].peBlue >> 2 );
4964 fileout.Write(( void *)buff, 2 );
4965 }
4966 fileout.Close();
4967#endif
4968
4969 }
4970 return( hPal );
4971}
4972
4973//*****************************************************************************
4974// LOADRESOURCEBUTTON -- Find & Load the bitmap from the resource.
4975//
4976// INPUT: HINSTANCE hInstance -- Program's hInstance.
4977// LPTSTR lpString -- name of bitmap to find.
4978// HPALETTE FAR *lphPalette -- we will return palette in this.
4979//
4980// OUTPUT: HBITMAP -- handle to the bitmap if found.
4981//
4982// WARNINGS:
4983//
4984// HISTORY: Found this routine on MS Developmemt CD, July 1996.
4985// 09/26/1996 MML : Created.
4986//=============================================================================
4987HBITMAP LoadResourceButton( HINSTANCE hInstance, LPTSTR lpString, HPALETTE FAR lphPalette )
4988{
4989 HDC hdc;
4990 int iNumColors;
4991 HRSRC hRsrc;
4992 HGLOBAL hGlobal;
4993 HBITMAP hBitmapFinal = NULL;
4994 LPBITMAPINFOHEADER lpbi;
4995
4996 //--------------------------------------------------------------------------
4997 // Find the Bitmap in this program's resources.
4998 //--------------------------------------------------------------------------
4999 hRsrc = FindResource( hInstance, lpString, RT_BITMAP );
5000 if ( hRsrc ) {
5001
5002 //-----------------------------------------------------------------------
5003 // Load the resource, lock the memory, grab a DC.
5004 //-----------------------------------------------------------------------
5005 hGlobal = LoadResource( hInstance, hRsrc );
5006 lpbi = (LPBITMAPINFOHEADER) LockResource( hGlobal );
5007 hdc = GetDC( NULL );
5008
5009 //--------------------------------------------------------------------------
5010 // Set number of colors ( 2 to the nth ).
5011 //--------------------------------------------------------------------------
5012 if ( lpbi->biBitCount <= 8 ) {
5013 iNumColors = ( 1 << lpbi->biBitCount );
5014 } else {
5015 iNumColors = 0;
5016 }
5017
5018 //-----------------------------------------------------------------------
5019 // Get the palette from the resource.
5020 // Select to the DC and realize it in the System palette.
5021 //-----------------------------------------------------------------------
5022// *lphPalette = CreateDIBPalette((LPBITMAPINFO) lpbi, &iNumColors );
5023 if ( lphPalette != NULL ) {
5024 SelectPalette( hdc, lphPalette, FALSE );
5025 RealizePalette( hdc );
5026 }
5027
5028 //-----------------------------------------------------------------------
5029 // Now create the bitmap itself.
5030 //-----------------------------------------------------------------------
5031 hBitmapFinal = CreateDIBitmap(
5032 hdc,
5033 (LPBITMAPINFOHEADER)lpbi,
5034 (LONG)CBM_INIT,
5035 (LPTSTR)lpbi + lpbi->biSize + iNumColors * sizeof( RGBQUAD ),
5036 (LPBITMAPINFO)lpbi,
5037 DIB_RGB_COLORS );
5038
5039 //-----------------------------------------------------------------------
5040 // Free DS and memory used.
5041 //-----------------------------------------------------------------------
5042 ReleaseDC( NULL, hdc );
5043 UnlockResource( hGlobal );
5044 FreeResource( hGlobal );
5045 }
5046 return( hBitmapFinal );
5047}
5048
5049//*****************************************************************************
5050// Cant_Find_MessageBox -- Find & Load the bitmap from the resource.
5051//
5052// INPUT: HINSTANCE hInstance -- Program's hInstance.
5053// LPTSTR lpString -- name of bitmap to find.
5054// HPALETTE FAR *lphPalette -- we will return palette in this.
5055//
5056// OUTPUT: HBITMAP -- handle to the bitmap if found.
5057//
5058// WARNINGS:
5059//
5060// HISTORY: Found this routine on MS Developmemt CD, July 1996.
5061// 09/26/1996 MML : Created.
5062// 08/27/2003 JFS : Repaired!
5063//=============================================================================
5064
5065void Cant_Find_MessageBox ( HINSTANCE hInstance, char *szPath )
5066{
5067
5068 //
5069 // JFS... Added functionality to make this work in wide characters.
5070 //
5071#ifdef LEAN_AND_MEAN
5072 {
5073 Locale_GetString( "Autorun:AutorunTitle", szWideBuffer );
5075
5076 Locale_GetString( "Autorun:CantFind", szWideBuffer );
5077 MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szPath, _MAX_PATH, szWideBuffer0, _MAX_PATH );
5079
5080 MessageBoxW( NULL, szWideBuffer2, szWideBuffer3, MB_APPLMODAL | MB_OK );
5081 }
5082
5083#else
5084
5085 std::wstring wideBuffer = TheGameText->fetch("Autorun:AutorunTitle");
5086 std::wstring wideBuffer2.format( wideBuffer.str(), productName.str() );
5087 std::wstring wideBuffer3 = TheGameText->fetch("Autorun:CantFind");
5088
5089 WideCharToMultiByte( CodePage, 0, wideBuffer3.str(), wideBuffer3.getLength()+1, szBuffer3, _MAX_PATH, NULL, NULL );
5090 WideCharToMultiByte( CodePage, 0, wideBuffer2.str(), wideBuffer2.getLength()+1, szBuffer2, _MAX_PATH, NULL, NULL );
5091
5092
5093 sprintf( szBuffer1, szBuffer3, szPath );
5094
5095
5096 if ( strlen( szPath ) < 3 )
5097 {
5098 MessageBox( NULL, "The path specified in Cant_Find_MessageBox was blank", "Autorun", MB_APPLMODAL | MB_OK );
5099 return;
5100 }
5101 if ( strlen( szBuffer1 ) < 3 && strlen( szBuffer3 ) < 3 )
5102 {
5103 MessageBox( NULL, "***MISSING MESSAGES***... IDS_AUTORUN_TITLE and IDS_CANT_FIND", "Autorun", MB_APPLMODAL | MB_OK );
5104 return;
5105 }
5106 if ( strlen( szBuffer1 ) < 3 )
5107 {
5108 MessageBox( NULL, "***MISSING MESSAGE***... IDS_AUTORUN_TITLE", "Autorun", MB_APPLMODAL | MB_OK );
5109 return;
5110 }
5111 if ( strlen( szBuffer3 ) < 3 )
5112 {
5113 MessageBox( NULL, "***MISSING MESSAGE***... IDS_CANT_FIND", "Autorun", MB_APPLMODAL | MB_OK );
5114 return;
5115 }
5116
5117
5118
5119
5120 MessageBox( NULL, szBuffer1, szBuffer2, MB_APPLMODAL | MB_OK );
5121#endif
5122
5123}
5124
5125
5126/******************************************************************************
5127 * Error_Message --
5128 *
5129 * INPUT:
5130 *
5131 * OUTPUT:
5132 *
5133 * WARNINGS: none
5134 *
5135 * HISTORY:
5136 * 08/14/1998 MML : Created.
5137 *============================================================================*/
5138
5139void Error_Message ( HINSTANCE hInstance, const char * title, const char * string, char *path )
5140{
5141
5142#ifndef LEAN_AND_MEAN
5143
5144 wideBuffer2 = TheGameText->fetch(title);
5145 wideBuffer3 = TheGameText->fetch(string);
5146
5147 if ( path && ( path[0] != '\0' ))
5148 {
5149 wideBuffer3.format( wideBuffer.str(), path );
5150 }
5151 else
5152 {
5153 wideBuffer3 = wideBuffer; // insert not provided
5154 }
5155
5156 WideCharToMultiByte( CodePage, 0, wideBuffer2.str(), wideBuffer2.getLength()+1, szBuffer2, _MAX_PATH, NULL, NULL );
5157 WideCharToMultiByte( CodePage, 0, wideBuffer3.str(), wideBuffer3.getLength()+1, szBuffer3, _MAX_PATH, NULL, NULL );
5158
5159 MessageBox( NULL, szBuffer3, szBuffer2, MB_APPLMODAL | MB_OK );
5160
5161#endif
5162
5163 MessageBox( NULL, "ERROR_UNDEFINED", "ERROR_UNDEFINED", MB_APPLMODAL | MB_OK );
5164
5165
5166}
5167
5168
5169/******************************************************************************
5170/ Launch Class Object
5171/******************************************************************************/
5172
5174{
5175 memset( szPath, '\0', _MAX_PATH );
5176 memset( szArgs, '\0', _MAX_PATH );
5177
5178 if( path != NULL && path[0] != '\0' ) {
5179 strcpy( szPath, path );
5180 }
5181 if( args != NULL && args[0] != '\0' ) {
5182 strcpy( szArgs, args );
5183 }
5184}
5185
5187{
5188 if( path != NULL && path[0] != '\0' ) {
5189 memset( szPath, '\0', _MAX_PATH );
5190 strcpy( szPath, path );
5191 }
5192}
5193
5195{
5196 if( args != NULL && args[0] != '\0' ) {
5197 memset( szArgs, '\0', _MAX_PATH );
5198 strcpy( szArgs, args );
5199 }
5200}
5201
5202unsigned int LaunchObjectClass::Launch ( void )
5203{
5204 char filepath [_MAX_PATH];
5205 char dir [_MAX_DIR];
5206 char ext [_MAX_EXT];
5207 char drive [_MAX_DRIVE];
5208 char file [_MAX_FNAME];
5209 char lpszComLine [ 127 ];
5210
5211 PROCESS_INFORMATION processinfo;
5212 STARTUPINFO startupinfo;
5213 unsigned int abc = 0;
5214 unsigned int result = 0;
5215
5216 memset( lpszComLine, '\0', 127 );
5217
5218 //--------------------------------------------------------------------------
5219 // Split into parts.
5220 //--------------------------------------------------------------------------
5221 _splitpath( szPath, drive, dir, file, ext );
5222
5223 //--------------------------------------------------------------------------
5224 // Change current path to the correct dir.
5225 //
5226 // The _chdrive function changes the current working drive to the drive
5227 // specified by drive. The drive parameter uses an integer to specify the
5228 // new working drive (1=A, 2=B, and so forth). This function changes only
5229 // the working drive; _chdir changes the working directory.
5230 //--------------------------------------------------------------------------
5231 _makepath( filepath, drive, dir, NULL, NULL );
5232 Path_Remove_Back_Slash( filepath );
5233
5234 abc = (unsigned)( toupper( filepath[0] ) - 'A' + 1 );
5235 if ( !_chdrive( abc )) {
5236
5237 //----------------------------------------------------------------------
5238 // Returns a value of 0 if successful.
5239 //----------------------------------------------------------------------
5240 abc = _chdir( filepath );
5241 }
5242
5243#if (_DEBUG)
5244
5245 int cde = _getdrive();
5246 _getcwd( szBuffer, _MAX_PATH );
5247
5248 Msg( __LINE__, TEXT(__FILE__), TEXT("Current Working Dir = %d\\%s." ), cde, szBuffer );
5249#endif
5250
5251 //--------------------------------------------------------------------------
5252 // Try to launch the EXE...
5253 //--------------------------------------------------------------------------
5254 _stprintf( lpszComLine, _TEXT( "%s %s" ), szPath, szArgs );
5255
5256 //==========================================================================
5257 // Setup the call
5258 //==========================================================================
5259 memset( &startupinfo, 0, sizeof( STARTUPINFO ));
5260 startupinfo.cb = sizeof( STARTUPINFO );
5261
5262 Msg( __LINE__, TEXT(__FILE__), TEXT("About to launch %s." ), lpszComLine );
5263
5264 result = CreateProcess(
5265 szPath, // address of module name
5266 lpszComLine, // address of command line
5267 NULL, // address of process security attributes
5268 NULL, // address of thread security attributes
5269 FALSE, // new process inherits handles
5270 FALSE,
5271 NULL, // address of new environment block
5272 NULL, // address of current directory name
5273 &startupinfo, // address of STARTUPINFO
5274 &processinfo ); // address of PROCESS_INFORMATION
5275
5276 //--------------------------------------------------------------------------
5277 // If WinExec returned 0, error occurred.
5278 //--------------------------------------------------------------------------
5279 if ( !result ) {
5280
5281 Msg( __LINE__, TEXT(__FILE__), TEXT("Launch of %s failed." ), lpszComLine );
5282 _makepath ( filepath, NULL, NULL, file, ext );
5284 }
5285 Msg( __LINE__, TEXT(__FILE__), TEXT("Launch of %s succeeded." ), lpszComLine );
5286
5287 return( result );
5288}
5289
5291{
5292 //-------------------------------------------------------------------------
5293 // tm_sec - Seconds after minute (0 – 59)
5294 // tm_min - Minutes after hour (0 – 59)
5295 // tm_hour - Hours after midnight (0 – 23)
5296 // tm_mday - Day of month (1 – 31)
5297 // tm_mon - Month (0 – 11; January = 0)
5298 // tm_year - Year (current year minus 1900)
5299 // tm_wday - Day of week (0 – 6; Sunday = 0)
5300 // tm_yday - Day of year (0 – 365; January 1 = 0)
5301 //-------------------------------------------------------------------------
5302 static char *Month_Strings[ 12 ] = {
5303 "January",
5304 "February",
5305 "March",
5306 "April",
5307 "May",
5308 "June",
5309 "July",
5310 "August",
5311 "September",
5312 "October",
5313 "November",
5314 "December"
5315 };
5316
5317 static char *Week_Day_Strings[ 7 ] = {
5318 "Sunday",
5319 "Monday",
5320 "Tuesday",
5321 "Wednesday",
5322 "Thursday",
5323 "Friday",
5324 "Saturday",
5325 };
5326
5327 char ampm[] = "AM";
5328 time_t ltime;
5329 struct tm * today;
5330
5331 /*-------------------------------------------------------------------------
5332 *Convert to time structure and adjust for PM if necessary.
5333 */
5334 time( &ltime );
5335 today = localtime( &ltime );
5336 if( today->tm_hour > 12 ) {
5337 strcpy( ampm, "PM" );
5338 today->tm_hour -= 12;
5339 }
5340 if( today->tm_hour == 0 ) { /* Adjust if midnight hour. */
5341 today->tm_hour = 12;
5342 }
5343
5344 Msg( __LINE__, __FILE__, "%s, %s %d, %d %d:%d:%d %s",
5345 Week_Day_Strings[ today->tm_wday ],
5346 Month_Strings[ today->tm_mon ],
5347 today->tm_mday,
5348 today->tm_year + 1900,
5349 today->tm_hour,
5350 today->tm_min,
5351 today->tm_sec,
5352 ampm );
5353
5354 /*-------------------------------------------------------------------------
5355 * Note how pointer addition is used to skip the first 11
5356 * characters and printf is used to trim off terminating
5357 * characters.
5358 */
5359// Msg( __LINE__, __FILE__, "%s %s\n", asctime( today ), ampm );
5360}
5361
5362
5363bool Is_On_CD ( char *volume_name )
5364{
5365 char volume_to_match[ MAX_PATH ];
5366
5367 Reformat_Volume_Name( volume_name, volume_to_match );
5368
5369 if( _stricmp( szVolumeName, volume_to_match ) == 0 ) {
5370 return true;
5371 } else {
5372 return false;
5373 }
5374}
5375
5376bool Prompt_For_CD ( HWND window_handle, char *volume_name, const char * message1, const char * message2, int *cd_drive )
5377{
5378 int drive;
5379
5380 strcpy( szBuffer, Args->Get_argv( 0 ));
5381 drive = toupper( szBuffer[0] ) - 'A';
5382 memset( szBuffer, '\0', MAX_PATH );
5383
5384 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5385 // This is the correct check for a CD Check.
5386 //
5387 // MML: Modified on 10/18/2000 so it would check for all available CD drives.
5388 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5389 int result = IDRETRY;
5390
5391 while( result == IDRETRY ) {
5392
5393 if ( CD_Volume_Verification( drive, szBuffer, volume_name )) {
5394
5395 result = IDOK;
5396 *cd_drive = drive;
5397
5398 } else {
5399
5400 CDList.Reset_Index();
5401
5402 while(( result == IDRETRY ) && ( CDList.Get_Index() < CDList.Get_Number_Of_Drives())) {
5403
5404 drive = CDList.Get_Next_CD_Drive();
5405
5406 if ( CD_Volume_Verification( drive, szBuffer, volume_name )) {
5407 result = IDOK;
5408 *cd_drive = drive;
5409 }
5410 }
5411 }
5412
5413 if ( result == IDRETRY ) {
5414 result = ( Show_Message( window_handle, message1, message2 ));
5415 }
5416 }
5417
5418 if ( result == IDCANCEL ) {
5419 return( false );
5420// return true;
5421 }
5422
5423 return( true );
5424}
5425
5426
5427
5428int Show_Message ( HWND window_handle, const char * message1, const char * message2 )
5429{
5430
5431#ifndef LEAN_AND_MEAN
5432
5433 UnicodeString string1;
5434 UnicodeString string2;
5435 WCHAR szString3[ MAX_PATH ];
5436 int result = false;
5437
5438 string1 = TheGameText->fetch(message1);
5439 string2 = TheGameText->fetch(message2);
5440
5441 wcscpy( szString3, string1.str() );
5442 wcscat( szString3, L" " );
5443 wcscat( szString3, string2.str() );
5444
5445 WideCharToMultiByte( CodePage, 0, szString3, _MAX_PATH, szBuffer, _MAX_PATH, NULL, NULL );
5446 result = MessageBox( window_handle, szBuffer, "Autorun", MB_RETRYCANCEL|MB_APPLMODAL|MB_SETFOREGROUND );
5447
5448 return( result );
5449
5450#else
5451
5452 return ( 0 );
5453
5454#endif
5455
5456}
5457
5458
5459void Reformat_Volume_Name ( char *volume_name, char *new_volume_name )
5460{
5461 char temp_volume_name[ MAX_PATH ];
5462
5463 strcpy( temp_volume_name, volume_name );
5464
5465 if( WinVersion.Is_Win95()) {
5466 temp_volume_name[11] = '\0';
5467 }
5468
5469 if( new_volume_name != NULL ) {
5470 strcpy( new_volume_name, temp_volume_name );
5471 }
5472}
5473
5474
Command_Line_Arguments * Args
Definition ARGS.CPP:49
#define MAX_ARGUMENT_LENGTH
Definition ARGS.H:46
ArchiveFileSystem * TheArchiveFileSystem
#define NULL
Definition BaseType.h:92
#define TRUE
Definition BaseType.h:109
#define FALSE
Definition BaseType.h:113
CDControlClass CDControl
Definition CDCNTRL.CPP:73
FileSystem * TheFileSystem
bool CD_Volume_Verification(int cd_drive, char *volume_label, char *volume_to_find)
Definition GETCD.CPP:341
GetCDClass CDList
Definition GETCD.CPP:74
GameTextInterface * TheGameText
Definition GameText.cpp:212
GameTextInterface * CreateGameTextInterface(void)
Definition GameText.cpp:234
char * gAppPrefix
Definition WinMain.cpp:86
const Char * g_strFile
So GuiEdit can have a different debug log file name if we need it.
Definition WinMain.cpp:84
const Char * g_csfFile
Definition WinMain.cpp:85
HINSTANCE ApplicationHInstance
our application instance
Definition WinMain.cpp:78
HWND ApplicationHWnd
our application window handle
Definition WinMain.cpp:79
IGROptionsClass * OnlineOptions
Definition IGR.cpp:32
LanguageID
Definition Language.h:63
#define VK_TAB
Definition keyboard.h:130
#define VK_UP
Definition keyboard.h:159
#define VK_RETURN
Definition keyboard.h:134
#define VK_DOWN
Definition keyboard.h:161
#define VK_ESCAPE
Definition keyboard.h:148
unsigned short WORD
Definition bittype.h:58
unsigned int UINT
Definition bittype.h:63
unsigned long DWORD
Definition bittype.h:57
void Prog_End(void)
Definition autorun.cpp:870
LocalFileSystem * TheLocalFileSystem
void Locale_Restore(void)
const char * Locale_GetString(int StringID, char *String)
int CodePage
bool Locale_Use_Multi_Language_Files(void)
int Locale_Init(int language, char *file)
LPVOID(__stdcall *SnmpUtilMemAllocPtr)(IN DWORD bytes)
unsigned long TEXT_NORMAL_SHADOW_COLOR
Definition TTFont.cpp:86
unsigned long TEXT_PRESSED_COLOR
Definition TTFont.cpp:89
unsigned long TEXT_PRESSED_SHADOW_COLOR
Definition TTFont.cpp:90
unsigned long SHADOW_COLOR
Definition TTFont.cpp:83
TTFontClass * TTTextFontPtr800
Definition TTFont.cpp:75
TTFontClass * TTTextFontPtr640
Definition TTFont.cpp:74
TTFontClass * TTTextFontPtr
Definition TTFont.cpp:73
unsigned long TEXT_COLOR
Definition TTFont.cpp:82
FontManagerClass * FontManager
Definition TTFont.cpp:78
unsigned long TEXT_FOCUSED_COLOR
Definition TTFont.cpp:87
unsigned long TEXT_NORMAL_COLOR
Definition TTFont.cpp:85
unsigned long TEXT_FOCUSED_SHADOW_COLOR
Definition TTFont.cpp:88
TTFontClass * TTLicenseFontPtr
Definition TTFont.cpp:76
TTFontClass * TTButtonFontPtr
Definition TTFont.cpp:71
#define TPF_CENTER_TEXT
Definition TTFont.h:111
@ TPF_SHADOW
Definition TTFont.h:75
#define TPF_BUTTON
Definition TTFont.h:103
char * Path_Add_Back_Slash(char *path)
Definition Utils.cpp:393
char * Make_Current_Path_To(char *filename, char *path)
Definition Utils.cpp:343
char * Path_Remove_Back_Slash(char *path)
Definition Utils.cpp:427
#define IDD_INTERNET
Definition resource.h:28
#define IDD_OK3
Definition resource.h:34
#define IDD_EXPLORE
Definition resource.h:26
#define IDD_HELP
Definition resource.h:37
#define IDD_CANCEL
Definition resource.h:27
#define IDD_OK
Definition resource.h:23
#define IDD_OK4
Definition resource.h:35
#define IDD_REGISTER
Definition resource.h:25
#define IDD_UNINSTALL
Definition resource.h:29
#define IDD_OK2
Definition resource.h:24
#define IDD_UPDATE
Definition resource.h:30
#define IDD_PREVIEWS
Definition resource.h:36
#define IDS_VERSION_STRING
Definition resource.h:38
#define IDD_NEW_ACCOUNT
Definition resource.h:31
#define IDD_VIEW_DEMO
Definition resource.h:32
#define IDD_GAMESPY
Definition resource.h:33
bool ViewHTML(const char *url, bool wait, CallbackHook &callback)
Definition ViewHTML.cpp:63
WindowsVersionInfo WinVersion
Definition WinFix.CPP:54
#define BOOL
Definition Wnd_File.h:57
#define Msg
Definition Wnd_File.h:102
#define MODE_WRITE_TRUNCATE
Definition Wnd_File.h:76
#define HELP_FILENAME
Definition autorun.cpp:156
char FocusedButtonImages[NUM_BUTTONS][MAX_PATH]
Definition autorun.cpp:196
int NumberArguments
Definition autorun.cpp:288
#define RESOURCE_FILE
Definition autorun.cpp:161
wchar_t szWideBuffer0[_MAX_PATH]
Definition autorun.cpp:228
BOOL UninstallAvailable
Definition autorun.cpp:282
HBITMAP LoadResourceBitmap(HMODULE hInstance, char *lpString, HPALETTE FAR *lphPalette, bool loading_a_button=FALSE)
BOOL IsUserRegistered
Definition autorun.cpp:283
char szPatchgetPath[_MAX_PATH]
Definition autorun.cpp:206
void Reformat_Volume_Name(char *volume_name, char *new_volume_name)
Definition autorun.cpp:5459
CHAR szSongPath[MAX_PATH]
Definition autorun.cpp:195
char szBuffer3[MAX_PATH *2]
Definition autorun.cpp:202
void Cant_Find_MessageBox(HINSTANCE hInstance, char *szPath)
Definition autorun.cpp:5065
int SongNumber
Definition autorun.cpp:289
#define GAME_WEBSITE
Definition autorun.cpp:175
BOOL DisplayRegisterButton
Definition autorun.cpp:284
HPALETTE CreateDIBPalette(LPBITMAPINFO lpbmi, LPINT lpiNumColors)
Definition autorun.cpp:4913
char szBuffer1[MAX_PATH]
Definition autorun.cpp:200
char szInternetPath[_MAX_PATH]
Definition autorun.cpp:203
char szClassName[_MAX_PATH]
Definition autorun.cpp:219
char szGamePath[_MAX_PATH]
Definition autorun.cpp:204
wchar_t szWideBuffer[_MAX_PATH]
Definition autorun.cpp:227
char szBuffer[MAX_PATH]
Definition autorun.cpp:199
#define GAME_MUTEX_OBJECT
Definition autorun.cpp:179
bool IsEnglish
Definition autorun.cpp:275
#define SETUP_MAIN_WINDOW_NAME
Definition autorun.cpp:170
BOOL IsWolapiAvailable
Definition autorun.cpp:285
#define NUM_ARGUMENTS
Definition autorun.cpp:142
bool b800X600
Definition autorun.cpp:278
char szSetupPath[_MAX_PATH]
Definition autorun.cpp:207
#define NUM_BUTTONS
Definition autorun.cpp:141
int Show_Message(HWND window_handle, const char *message_num1, const char *message_num2)
Definition autorun.cpp:5428
#define SOUND_FILE1
Definition autorun.cpp:148
HBITMAP LoadResourceButton(HMODULE hInstance, char *lpString, HPALETTE FAR lphPalette)
BOOL Options(Command_Line_Arguments *Orgs)
Definition autorun.cpp:4624
#define PRODUCT_VOLUME_CD1
Definition autorun.cpp:180
MainWindow * GlobalMainWindow
Definition autorun.cpp:188
#define SC4AVI_FILENAME
Definition autorun.cpp:155
char szVolumeName[_MAX_PATH]
Definition autorun.cpp:220
#define UNINSTALL_EXECUTABLE
Definition autorun.cpp:165
#define GAMESPY_WEBSITE
Definition autorun.cpp:159
#define PRODUCT_VOLUME_CD2
Definition autorun.cpp:181
char drive[_MAX_DRIVE]
Definition autorun.cpp:214
wchar_t szWideBuffer3[_MAX_PATH]
Definition autorun.cpp:230
wchar_t szProductName[_MAX_PATH]
Definition autorun.cpp:231
#define MOUSE_WAV
Definition autorun.cpp:147
int LanguageToUse
Definition autorun.cpp:190
char szSetupWindow[_MAX_PATH]
Definition autorun.cpp:216
#define SOUND_FILE2
Definition autorun.cpp:149
#define CLASS_NAME
Definition autorun.cpp:171
char szProduct_Name[_MAX_PATH]
Definition autorun.cpp:222
LaunchObjectClass LaunchObject
Definition autorun.cpp:187
char szWorldbuilderPath[_MAX_PATH]
Definition autorun.cpp:205
int FlickerPositions[NUM_FLICKER_POSITIONS][2]
Definition autorun.cpp:318
int WindowsVersion
Definition autorun.cpp:287
bool b640X480
Definition autorun.cpp:277
BOOL CALLBACK Dialog_Box_Proc(HWND window_handle, UINT message, WPARAM w_param, LPARAM l_param)
Definition autorun.cpp:2552
BOOL CDLocked
Definition autorun.cpp:286
char ButtonImages[NUM_BUTTONS][MAX_PATH]
Definition autorun.cpp:194
char szGameWindow[_MAX_PATH]
Definition autorun.cpp:217
HANDLE AppMutex
Definition autorun.cpp:290
#define NUM_SONGS
Definition autorun.cpp:143
#define BUTTON_HEIGHT
Definition autorun.cpp:140
void Debug_Date_And_Time_Stamp(void)
Definition autorun.cpp:5290
char szUninstallPath[_MAX_PATH]
Definition autorun.cpp:208
BOOL Valid_Environment(void)
Definition autorun.cpp:4809
void Error_Message(HINSTANCE hInstance, int title, int string, char *path)
DrawButton * ButtonList[NUM_BUTTONS]
Definition autorun.cpp:192
bool UseSounds
Definition autorun.cpp:276
char szWavs[NUM_SONGS][_MAX_PATH]
Definition autorun.cpp:198
bool Prompt_For_CD(HWND window_handle, char *volume_name, const char *message1, const char *message2, int *cd_drive)
Definition autorun.cpp:5376
char szArgvPath[_MAX_PATH]
Definition autorun.cpp:213
BOOL InstallProduct
Definition autorun.cpp:281
char szUninstallCommandLine[_MAX_PATH]
Definition autorun.cpp:209
#define NUM_FLICKER_FRAMES
Definition autorun.cpp:144
#define AUTORUN_MUTEX_OBJECT
Definition autorun.cpp:177
LRESULT CALLBACK Wnd_Proc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
Definition autorun.cpp:2509
char szRegistryKey[_MAX_PATH]
Definition autorun.cpp:218
#define MOH_DEMO_PROGRAM
Definition autorun.cpp:151
char szRegisterPath[_MAX_PATH]
Definition autorun.cpp:210
char Arguments[NUM_ARGUMENTS][30]
Definition autorun.cpp:197
#define SETUP_INI_FILE1
Definition autorun.cpp:162
char szButtonWav[_MAX_PATH]
Definition autorun.cpp:211
char szBuffer2[MAX_PATH]
Definition autorun.cpp:201
char szSpeechWav[_MAX_PATH]
Definition autorun.cpp:212
void Prog_End(void)
Definition autorun.cpp:870
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmdLine, int nCmdShow)
Definition autorun.cpp:377
#define NUM_FLICKER_POSITIONS
Definition autorun.cpp:145
HANDLE GameAppMutex
Definition autorun.cpp:291
wchar_t szWideBuffer2[_MAX_PATH]
Definition autorun.cpp:229
bool Is_On_CD(char *)
Definition autorun.cpp:5363
wchar_t szFullProductName[_MAX_PATH]
Definition autorun.cpp:232
char dir[_MAX_DIR]
Definition autorun.cpp:215
#define BUTTON_WIDTH
Definition autorun.cpp:139
HANDLE SetupAppMutex
Definition autorun.cpp:292
BOOL IAmWindows95
Definition autorun.cpp:280
int Language
Definition autorun.cpp:189
#define SETUP_INI_FILE2
Definition autorun.cpp:163
BOOL OnCDRom
Definition autorun.cpp:279
RECT ButtonSizes[NUM_BUTTONS]
Definition autorun.cpp:193
void Stop_Sound_Playing(void)
Definition autorun.cpp:4605
#define PATCHGET_FILENAME
Definition autorun.h:112
#define IS_LANGUAGE_DBCS(l)
Definition autorun.h:71
#define SETUP_NAME
Definition autorun.h:89
LaunchObjectClass LaunchObject
Definition autorun.cpp:187
#define INSTALL_PATH_KEY
Definition autorun.h:87
#define EAGAMES_GENERALS_KEY
Definition autorun.h:108
#define LAUNCHER_FILENAME
Definition autorun.h:110
#define WORLDBUILDER_FILENAME
Definition autorun.h:111
#define WM_GO
Definition autorun.h:83
#define BUTTON_REG
Definition autorun.h:151
#define IS_CODEPAGE_DBCS(C)
Definition autorun.h:72
#define UNINSTALL_STRING_SUBKEY
Definition autorun.h:114
#define SHELL_UNINSTALL_KEY
Definition autorun.h:93
#define EXPLORER_NAME
Definition autorun.h:86
#define BUTTON_SEL
Definition autorun.h:152
@ LANG_USA
Definition autorun.h:57
@ LANG_FRE
Definition autorun.h:60
@ LANG_GER
Definition autorun.h:59
@ LANG_KOR
Definition autorun.h:66
@ LANG_CHI
Definition autorun.h:67
@ LANG_JAP
Definition autorun.h:63
const char * Get_argv(int argument_index)
Definition ARGS.CPP:314
char szPath[_MAX_PATH]
Definition autorun.h:169
void SetPath(char *path)
Definition autorun.cpp:5186
void SetArgs(char *args)
Definition autorun.cpp:5194
LaunchObjectClass(char *path=NULL, char *args=NULL)
Definition autorun.cpp:5173
unsigned int Launch(void)
Definition autorun.cpp:5202
char szArgs[_MAX_PATH]
Definition autorun.h:170
static HINSTANCE hInstance
Definition autorun.h:182
static int MessageLoop(void)
Definition autorun.cpp:931
static HINSTANCE hPrevInstance
Definition autorun.h:183
static HMODULE hModule
Definition autorun.h:184
static int nCmdShow
Definition autorun.h:185
unsigned int Run_OpenFile(int cd_drive, const char *filename, bool wait=false)
Definition autorun.cpp:1715
unsigned int Run_New_Account(HWND hWnd, RECT *rect)
Definition autorun.cpp:1868
unsigned int Run_Game(HWND hWnd, RECT *rect)
Definition autorun.cpp:1531
unsigned int Run_Demo(HWND hWnd, RECT *rect, int cd_drive)
Definition autorun.cpp:1667
static void Reset_Class_Name(char *string)
Definition autorun.h:221
unsigned int Run_Register(HWND hWnd, RECT *rect)
Definition autorun.cpp:1942
BOOL Is_Product_Registered(void)
Definition autorun.cpp:1232
static void Register(void)
Definition autorun.cpp:979
unsigned int Run_Uninstall(HWND hWnd, RECT *rect)
Definition autorun.cpp:2037
unsigned int Run_PatchGet(HWND hWnd, RECT *rect)
Definition autorun.cpp:1629
static char szClassName[100]
Definition autorun.h:214
unsigned int Run_Setup(HWND hWnd, RECT *rect, int cd_drive)
Definition autorun.cpp:1793
unsigned int Run_Auto_Update(HWND hWnd, RECT *rect)
Definition autorun.cpp:1992
LRESULT Window_Proc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
Definition autorun.cpp:1115
void Create_Buttons(HWND hWnd, RECT *dlg_rect)
Definition autorun.cpp:2169
BOOL Run_Explorer(char *, HWND hWnd, RECT *rect)
Definition autorun.cpp:1448
MainWindow(void)
Definition autorun.cpp:1047
unsigned int Run_WorldBuilder(HWND hWnd, RECT *rect)
Definition autorun.cpp:1591
bool Open(const char *file_name, int open_mode)
Definition Wnd_file.cpp:364
bool Close(void)
Definition Wnd_file.cpp:519
int Write(void *buffer, unsigned long int bytes_to_write)
Definition Wnd_file.cpp:685
T Width
Definition trect.h:115
T Y
Definition trect.h:109
T Height
Definition trect.h:116
T X
Definition trect.h:108
virtual Point2D Print(HDC hdc, char const *string, Rect const &cliprect, COLORREF forecolor=TEXT_COLOR, COLORREF backcolor=TEXT_NORMAL_SHADOW_COLOR, TextFormatType flag=TPF_LEFT_TEXT, TextShadowType shadow=TPF_NOSHADOW)
Definition TTFont.cpp:801
void format(UnicodeString format,...)
int getLength() const
const WideChar * str() const
HWND hWnd
Definition autorun.h:198
void DWORD HANDLE hProcess
#define LEAN_AND_MEAN
MSG msg
Definition patch.cpp:409
Definition pcx.H:46
TCHAR szTitle[MAX_LOADSTRING]
Definition test2.cpp:38
TRect< int > Rect
Definition trect.h:221
long time_t
Definition wolapi.h:436