Annotation of mstools/samples/deb/debmain.c, revision 1.1.1.3

1.1.1.3 ! root        1: 
        !             2: /******************************************************************************\
        !             3: *       This is a part of the Microsoft Source Code Samples. 
        !             4: *       Copyright (C) 1993 Microsoft Corporation.
        !             5: *       All rights reserved. 
        !             6: *       This source code is only intended as a supplement to 
        !             7: *       Microsoft Development Tools and/or WinHelp documentation.
        !             8: *       See these sources for detailed information regarding the 
        !             9: *       Microsoft samples programs.
        !            10: \******************************************************************************/
        !            11: 
1.1.1.2   root       12: // ************************************************************************
                     13: // MODULE    : DEBMain.C
1.1       root       14: // PURPOSE   : A Win32 Application demonstrating the Debug APIs
                     15: // FUNCTIONS :
1.1.1.3 ! root       16: //   WinMain()                 - application entry point
        !            17: //   MainWndProc()             - processes messages
        !            18: //   ProcessCommandsWndProc()  - processes WM_COMMAND messages
        !            19: //   PreferencesDlgProc()      - processes messages for "Preferences" dialog box
        !            20: //   AttachDlgProc()           - processes messages for "Attach" dialog box
        !            21: //   AboutDlgProc()            - processes messages for "About" dialog box
        !            22: //   NewListBoxWndProc()       - subclass procedure to prevent listbox moving
        !            23: //   TimerProc()               - timer procedure for animated icon
1.1       root       24: // COMMENTS  :
1.1.1.2   root       25: //
1.1       root       26: // ************************************************************************
1.1.1.3 ! root       27: #define   STRICT               // enable strict typing
1.1       root       28: #include <Windows.H>           // required for all Windows applications
1.1.1.3 ! root       29: #include "StdLib.H"            // __argc, __argv
1.1       root       30: 
                     31: #include "LinkList.H"          // double linked list package (OBJ)
                     32: #include "DEBDebug.H"          // debugging support functions
                     33: #include "DEBMisc.H"           // misc support functions
                     34: #include "DEBMain.H"           // specific to this module
                     35: 
                     36: // global data
1.1.1.3 ! root       37: // ------------------------------------------------------------------------
        !            38: GLOBAL  Global;                // various global data
        !            39: PROFILE Profile;               // various profile data
1.1       root       40: 
                     41: // internal data
1.1.1.3 ! root       42: // ------------------------------------------------------------------------
        !            43: #define TIMEOUT_ANIMATED_ICON 150L // animated icon timeout
        !            44: static LPCTSTR lpszSourceFileName = TEXT(__FILE__);
        !            45: 
        !            46: // location of various files
        !            47: // ------------------------------------------------------------------------
        !            48: TCHAR   szPath[MAX_PATH];         // path where the running application
        !            49:                                   //  resides
1.1       root       50: TCHAR   szExePathName[MAX_PATH];  // full pathname of the application
1.1.1.3 ! root       51: TCHAR   szHelpPathName[MAX_PATH]; // full pathname of the application's
        !            52:                                   //  help file
        !            53: TCHAR   szIniPathName[MAX_PATH];  // full pathname of the application's
        !            54:                                   //  ini file
        !            55: // internal function prototypes
        !            56: // ------------------------------------------------------------------------
1.1.1.2   root       57: LRESULT CALLBACK MainWndProc            ( HWND, UINT, WPARAM, LPARAM );
                     58: LRESULT CALLBACK ProcessCommandsWndProc ( HWND, UINT, WPARAM, LPARAM );
                     59: LRESULT CALLBACK NewListBoxWndProc      ( HWND, UINT, WPARAM, LPARAM );
                     60: BOOL    CALLBACK PreferencesDlgProc     ( HWND, UINT, WPARAM, LPARAM );
                     61: BOOL    CALLBACK AttachDlgProc          ( HWND, UINT, WPARAM, LPARAM );
                     62: BOOL    CALLBACK AboutDlgProc           ( HWND, UINT, WPARAM, LPARAM );
1.1.1.3 ! root       63: VOID    CALLBACK TimerProc              ( HWND, UINT, UINT, DWORD );
1.1.1.2   root       64: 
1.1       root       65: 
                     66: // ************************************************************************
1.1.1.3 ! root       67: // FUNCTION : WinMain( HINSTANCE, HINSTANCE, LPSTR, INT )
1.1       root       68: // PURPOSE  : initialize the window, process the message dispatch loop
                     69: // COMMENTS :
1.1.1.3 ! root       70: //
1.1       root       71: // ************************************************************************
1.1.1.3 ! root       72: INT WINAPI
        !            73: WinMain( HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine,
        !            74:   INT nCmdShow )
1.1       root       75: {
1.1.1.3 ! root       76:   MSG      Msg;
        !            77:   WNDCLASS WndClass;
        !            78:   HACCEL   hAccel;
        !            79: 
        !            80:   LPCTSTR lpszIconName    = TEXT( "DebugIcon"  );
        !            81:   LPCTSTR lpszMenuName    = TEXT( "DebugMenu"  );
        !            82:   LPCTSTR lpszClassName   = TEXT( "DebugClass" );
        !            83:   LPCTSTR lpszAccelName   = TEXT( "DebugAccel" );
        !            84:   LPCTSTR lpszIniFileExt  = TEXT( "INI"        );
        !            85:   LPCTSTR lpszHelpFileExt = TEXT( "HLP"        );
        !            86: 
        !            87:   Global.hInstance = hInstance;
        !            88:   Global.dwActiveDebuggees = 0;
        !            89: 
        !            90:   //-- Load the "A Windows API Failed" resource string
        !            91:   {
        !            92:     TCHAR szApiFailedMsg[] = TEXT( "A Windows API Failed" );
        !            93: 
        !            94:     if( !LoadString( Global.hInstance, IDS_API_FAILED_MSG,
        !            95:           Global.szApiFailedMsg, sizeof(Global.szApiFailedMsg) ) ) {
        !            96:       ErrorMessageBox( TEXT( "First LoadString()" ),
        !            97:         szApiFailedMsg, lpszSourceFileName, __LINE__ );
        !            98:       lstrcpy( Global.szApiFailedMsg, szApiFailedMsg );
        !            99:     }
        !           100:   }
1.1       root      101: 
1.1.1.3 ! root      102:   //-- Load all other resource strings
        !           103:   if( !LoadString( Global.hInstance, IDS_APPNAME,  Global.szAppName,
        !           104:          sizeof(Global.szAppName) ) )
        !           105:     ErrorMessageBox( TEXT("LoadString()"),
        !           106:       Global.szApiFailedMsg, lpszSourceFileName, __LINE__ );
        !           107:   if( !LoadString( Global.hInstance, IDS_SHORT_APPNAME,
        !           108:          Global.szShortAppName, sizeof(Global.szShortAppName) ) )
        !           109:     ErrorMessageBox( TEXT("LoadString()"),
        !           110:       Global.szApiFailedMsg, lpszSourceFileName, __LINE__ );
        !           111: 
        !           112:   //-- if compiled for Win32 (Unicode) and not Win32s then display
        !           113:   //    notice and terminate
        !           114:   if( GetVersion() & 0x80000000 ) {
        !           115:     TCHAR szTitleBuffer[64];
        !           116:     TCHAR szTextBuffer[256];
        !           117: 
        !           118:     if( !LoadString( Global.hInstance, IDS_WINDOWS_NT_REQUIRED_TITLE,
        !           119:            szTitleBuffer, sizeof(szTitleBuffer) ) )
        !           120:       ErrorMessageBox( TEXT("LoadString()"),
        !           121:         Global.szApiFailedMsg, lpszSourceFileName, __LINE__ );
        !           122: 
        !           123:     if( !LoadString( Global.hInstance, IDS_WINDOWS_NT_REQUIRED,
        !           124:            szTextBuffer, sizeof(szTextBuffer) ) )
        !           125:       ErrorMessageBox( TEXT("LoadString()"),
        !           126:         Global.szApiFailedMsg, lpszSourceFileName, __LINE__ );
        !           127: 
        !           128:     MessageBox( NULL, szTextBuffer, szTitleBuffer,
        !           129:       MB_APPLMODAL | MB_ICONSTOP | MB_OK );
        !           130:     return( -1 );
        !           131:   }
1.1       root      132: 
                    133:   //-- register the debug event window class
1.1.1.3 ! root      134:   WndClass.style         = CS_DBLCLKS;
        !           135:   WndClass.lpfnWndProc   = (WNDPROC) MainWndProc;
        !           136:   WndClass.cbClsExtra    = (INT) NULL;
        !           137:   WndClass.cbWndExtra    = (INT) NULL;
        !           138:   WndClass.hInstance     = Global.hInstance;
        !           139:   WndClass.hIcon         = NULL;
        !           140:   WndClass.hCursor       = LoadCursor( Global.hInstance, (LPTSTR) IDC_ARROW );
        !           141:   WndClass.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1);
        !           142:   WndClass.lpszMenuName  = lpszMenuName;
        !           143:   WndClass.lpszClassName = lpszClassName;
        !           144: 
        !           145:   if( !RegisterClass(&WndClass) ) {
        !           146:     ErrorMessageBox( TEXT("RegisterClass()"),
        !           147:       Global.szApiFailedMsg, lpszSourceFileName, __LINE__ );
1.1       root      148:     return( FALSE );
1.1.1.3 ! root      149:   }
1.1       root      150: 
                    151:   //-- get application pathname and store the ini and help file pathname
                    152:   //   (which is located in the same directory as the application)
1.1.1.3 ! root      153:   GetModuleFileName( (HANDLE) NULL, szExePathName,
        !           154:     sizeof(szExePathName)/sizeof(TCHAR) );
        !           155:   GetPathFromFullPathName( szExePathName, szPath,
        !           156:     sizeof(szPath)/sizeof(TCHAR) );
        !           157:   wsprintf( szIniPathName,  TEXT( "%s\\%s.%s" ), szPath,
        !           158:     Global.szShortAppName, lpszIniFileExt  );
        !           159:   wsprintf( szHelpPathName, TEXT( "%s\\%s.%s" ), szPath,
        !           160:     Global.szShortAppName, lpszHelpFileExt );
1.1       root      161: 
                    162:   //-- retrieve stored default location from private profile data
1.1.1.3 ! root      163:   GetPrivateProfileSettings( Global.szAppName, szIniPathName, &Profile );
1.1       root      164: 
                    165:   //-- Create a main window for this application instance
1.1.1.3 ! root      166:   Global.hWndMain = CreateWindow( lpszClassName, Global.szAppName,
        !           167:                       WS_OVERLAPPEDWINDOW,
        !           168:                       Profile.xPos, Profile.yPos,
        !           169:                       Profile.nWidth, Profile.nHeight,
        !           170:                       NULL, NULL, Global.hInstance, NULL );
1.1       root      171: 
                    172:   //-- If window could not be created, return "failure"
1.1.1.3 ! root      173:   if( !Global.hWndMain ) {
        !           174:     ErrorMessageBox( TEXT("CreateWindow()"),
        !           175:       Global.szApiFailedMsg, lpszSourceFileName, __LINE__ );
1.1       root      176:     return( FALSE );
1.1.1.3 ! root      177:   }
1.1       root      178: 
                    179:   //-- Load main menu accelerators
1.1.1.3 ! root      180:   if( !(hAccel = LoadAccelerators( Global.hInstance, lpszAccelName) ) ) {
        !           181:     ErrorMessageBox( TEXT("LoadAccelerators()"),
        !           182:       Global.szApiFailedMsg, lpszSourceFileName, __LINE__ );
1.1       root      183:     return( FALSE );
1.1.1.3 ! root      184:   }
1.1       root      185: 
                    186:   //-- modify the menu to reflect saved settings
1.1.1.3 ! root      187:   UpdateMenuSettings( Global.hWndMain );
1.1       root      188: 
1.1.1.3 ! root      189:   //-- set the initial icon
        !           190:   Global.hIconCurrent = LoadIcon( Global.hInstance, lpszIconName );
1.1       root      191: 
1.1.1.3 ! root      192:   //-- Make the window visible; update its client area; and return "success"
        !           193:   if( Profile.fMaximized )
        !           194:     ShowWindow( Global.hWndMain, SW_SHOWMAXIMIZED );
        !           195:   else if ( Profile.fMinimized )
        !           196:     ShowWindow( Global.hWndMain, SW_SHOWMINIMIZED );
        !           197:   else
        !           198:     ShowWindow( Global.hWndMain, SW_SHOWDEFAULT );
        !           199:   UpdateWindow( Global.hWndMain );
1.1       root      200: 
                    201:   //-- Acquire and dispatch messages until a WM_QUIT message is received.
1.1.1.3 ! root      202:   while( GetMessage( &Msg, NULL, 0, 0 ) ) {
        !           203:     if( !TranslateAccelerator( Global.hWndMain, hAccel, &Msg ) ) {
        !           204:       TranslateMessage( &Msg );
        !           205:       DispatchMessage( &Msg );
1.1       root      206:     }
                    207:   }
                    208: 
1.1.1.3 ! root      209:   return( Msg.wParam );
        !           210:   UNREFERENCED_PARAMETER( lpCmdLine );  // avoid warnings
        !           211:   UNREFERENCED_PARAMETER( hPrevInst );  // always NULL under Windows NT
        !           212:   UNREFERENCED_PARAMETER( nCmdShow  );  //
1.1       root      213: }
                    214: 
                    215: 
                    216: // ************************************************************************
                    217: // FUNCTION : MainWndProc( HWND, UINT, WPARAM, LPARAM )
                    218: // PURPOSE  : Processes uMsgs
                    219: // MESSAGES :
                    220: //   WM_COMMAND   - passed to ProcessCommandsWndProc()
                    221: //   WM_DESTROY   - destroy window
                    222: //    ...
1.1.1.2   root      223: // COMMENTS :
                    224: //
1.1       root      225: // ************************************************************************
                    226: LRESULT CALLBACK
                    227: MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
                    228: {
1.1.1.3 ! root      229:   #define TOP_BORDER      4
        !           230:   #define BOTTOM_BORDER   4
        !           231:   #define SIDE_BORDER     4
        !           232:   #define MIN_HEIGHT    128
1.1       root      233: 
1.1.1.3 ! root      234:   static HDC hDC;
1.1.1.2   root      235: 
1.1       root      236:   switch( uMsg ) {
                    237: 
1.1.1.3 ! root      238:     //-- forward all WM_COMMANDS to separate handler function
1.1       root      239:     case WM_COMMAND:
1.1.1.3 ! root      240:       return( ProcessCommandsWndProc( hWnd, uMsg, wParam, lParam) );
1.1       root      241: 
                    242:     //-- create debug event listbox
                    243:     case UM_CREATE_LISTBOX: {
                    244:       TCHAR  szWindowName[64];
1.1.1.3 ! root      245:       HFONT  hFont;
1.1       root      246: 
1.1.1.3 ! root      247:       LoadString( Global.hInstance, IDS_DEBUG_EVENTS, szWindowName,
        !           248:         sizeof(szWindowName)/sizeof(TCHAR) );
1.1       root      249: 
1.1.1.3 ! root      250:       Global.hWndListBox = CreateWindow(
        !           251:                            TEXT( "ListBox" ),
        !           252:                            szWindowName,
        !           253:                            WS_CHILD             | WS_VISIBLE      |
        !           254:                            WS_CAPTION           | WS_VSCROLL      |
        !           255:                            WS_HSCROLL           | LBS_NOTIFY      |
        !           256:                            LBS_DISABLENOSCROLL  | LBS_USETABSTOPS |
        !           257:                            LBS_NOINTEGRALHEIGHT,
        !           258:                            (INT) SIDE_BORDER,
        !           259:                            (INT) (Profile.fToolBar
        !           260:                              ? (Global.ToolBarHeight + TOP_BORDER)
        !           261:                              : TOP_BORDER),
        !           262:                            (INT) Global.ListBoxSize.cx,
        !           263:                            (INT) Global.ListBoxSize.cy,
        !           264:                            hWnd, (HMENU) NULL, Global.hInstance, NULL );
1.1       root      265: 
                    266:       //-- Subclass the listbox so the user cannot move it
1.1.1.3 ! root      267:       Global.OldListBoxWndProc = SubclassWindow( Global.hWndListBox,
        !           268:         (WNDPROC) NewListBoxWndProc );
1.1       root      269: 
                    270:       //-- set listbox font & background color
1.1.1.3 ! root      271:       hDC = GetDC( Global.hWndListBox );
        !           272:       hFont = CreateFontIndirect( &(Profile.LogFont) );
1.1       root      273:       SelectObject( hDC, hFont );
1.1.1.3 ! root      274:       SendMessage( Global.hWndListBox, WM_CTLCOLORLISTBOX, (WPARAM) hDC,
        !           275:         (LPARAM) Global.hWndListBox );
        !           276:       SendMessage( Global.hWndListBox, WM_SETFONT, (WPARAM) hFont, TRUE );
        !           277:       ReleaseDC( Global.hWndListBox, hDC );
        !           278: 
        !           279:       //-- if command line contains a debuggee name then
        !           280:       //   start and detach the debug event processing thread
        !           281:       if( __argc == 2 )
        !           282:         StartDebuggee( (LPTSTR) __argv[1], Global.hWndListBox );
1.1       root      283: 
1.1.1.2   root      284:       return( FALSE );
1.1       root      285:     }
                    286: 
1.1.1.3 ! root      287:     //-- create ToolBar & send message to create the Debug Events listbox
1.1       root      288:     case WM_CREATE:
1.1.1.3 ! root      289:       Global.hWndToolBar = CreateTextButtonBar( hWnd, &Global.ToolBarHeight );
        !           290:       if( Profile.fToolBar )
        !           291:         ShowWindow( Global.hWndToolBar, SW_SHOW );
1.1       root      292:       PostMessage( hWnd, UM_CREATE_LISTBOX, 0, 0 );
1.1.1.2   root      293:       return( FALSE );
1.1       root      294: 
1.1.1.3 ! root      295:     //-- handle icon painting
        !           296:     case WM_PAINT:
        !           297:       if( IsIconic( hWnd ) ) {
        !           298:         static PAINTSTRUCT ps;
        !           299: 
        !           300:         BeginPaint( hWnd, (LPPAINTSTRUCT) &ps );
        !           301:         SendMessage( hWnd, WM_ICONERASEBKGND, (WPARAM) ps.hdc, 0L );
        !           302:         DrawIcon( ps.hdc, 2, 2, Global.hIconCurrent );
        !           303:         EndPaint( hWnd, (LPPAINTSTRUCT) &ps );
        !           304:         return( FALSE );
        !           305:       }
        !           306:       else
        !           307:         return( DefWindowProc(hWnd, uMsg, wParam, lParam) );
        !           308: 
        !           309:     //-- reduce icon flickering
        !           310:     case WM_ERASEBKGND:
        !           311:       if( IsIconic( hWnd ) )
        !           312:         return( TRUE );
        !           313:       else
        !           314:         return( DefWindowProc(hWnd, uMsg, wParam, lParam) );
        !           315: 
        !           316:     //-- update the icon when dragged
        !           317:     case WM_QUERYDRAGICON:
        !           318:       return( (LRESULT) (UINT) Global.hIconCurrent );
        !           319: 
1.1       root      320:     //-- resize the debug event listbox when the window size changes
                    321:     case WM_SIZE:
1.1.1.3 ! root      322:       Global.ClientSize.cx = LOWORD( lParam );
        !           323:       Global.ClientSize.cy = HIWORD( lParam );
        !           324:       Global.ListBoxSize.cx = Global.ClientSize.cx - ( 2*SIDE_BORDER );
        !           325:       Global.ListBoxSize.cy = max( Global.ClientSize.cy, MIN_HEIGHT
        !           326:                                 + TOP_BORDER )
1.1       root      327:         - (TOP_BORDER + BOTTOM_BORDER);
                    328: 
1.1.1.3 ! root      329:       if( Profile.fToolBar )
        !           330:         Global.ListBoxSize.cy -= Global.ToolBarHeight;
1.1       root      331: 
1.1.1.3 ! root      332:       if( Global.hWndListBox != NULL)
        !           333:         MoveWindow( Global.hWndListBox,
        !           334:           (INT) SIDE_BORDER,
        !           335:           (INT) (Profile.fToolBar ? Global.ToolBarHeight + TOP_BORDER : TOP_BORDER),
        !           336:           (INT) Global.ListBoxSize.cx, (INT) Global.ListBoxSize.cy, TRUE );
        !           337: 
        !           338:       switch( wParam ) {
        !           339: 
        !           340:         case SIZE_RESTORED: {
        !           341:           RECT rect;
        !           342: 
        !           343:           Profile.fMaximized = FALSE;
        !           344:           Profile.fMinimized = FALSE;
        !           345:           GetWindowRect( Global.hWndMain, &rect );
        !           346:           Profile.nWidth  = (INT) (rect.right - rect.left);
        !           347:           Profile.nHeight = (INT) (rect.bottom - rect.top);
        !           348:           if( Global.idIconTimer ) {
        !           349:             KillTimer( Global.hWndMain, Global.idIconTimer );
        !           350:             Global.idIconTimer = 0;
        !           351:           }
        !           352:           return( FALSE );
        !           353:         }
1.1       root      354: 
1.1.1.3 ! root      355:         case SIZE_MAXIMIZED:
        !           356:           Profile.fMaximized = TRUE;
        !           357:           Profile.fMinimized = FALSE;
        !           358:           Profile.xPos       = Global.xPosOld;
        !           359:           Profile.yPos       = Global.yPosOld;
        !           360:           return( FALSE );
        !           361: 
        !           362:         case SIZE_MINIMIZED:
        !           363:           Profile.fMinimized = TRUE;
        !           364:           Profile.fMaximized = FALSE;
        !           365:           Profile.xPos       = Global.xPosOld;
        !           366:           Profile.yPos       = Global.yPosOld;
        !           367:           Global.idIconTimer = SetTimer( Global.hWndMain, 1,
        !           368:                                  TIMEOUT_ANIMATED_ICON, TimerProc );
        !           369:           return( FALSE );
        !           370: 
        !           371:       }
        !           372:       return( DefWindowProc(hWnd, uMsg, wParam, lParam) );
1.1       root      373: 
1.1.1.3 ! root      374:     //-- keep track of window position so it can be saved
1.1       root      375:     case WM_MOVE: {
                    376:       RECT rect;
                    377: 
1.1.1.3 ! root      378:       GetWindowRect( Global.hWndMain, &rect );
        !           379:       Global.xPosOld      = Profile.xPos;
        !           380:       Global.yPosOld      = Profile.yPos;
        !           381:       Profile.xPos = (INT) rect.left;
        !           382:       Profile.yPos = (INT) rect.top;
1.1.1.2   root      383:       return( FALSE );
1.1       root      384:     }
                    385: 
1.1.1.3 ! root      386:     //-- colorize the debug event listbox
1.1       root      387:     case WM_CTLCOLORLISTBOX: {
                    388:       LOGBRUSH LogBrush;
                    389: 
                    390:       LogBrush.lbStyle = BS_SOLID;
1.1.1.3 ! root      391:       LogBrush.lbColor = Profile.rgbBackColor;
        !           392:       LogBrush.lbHatch = (LONG) NULL;
1.1       root      393: 
1.1.1.3 ! root      394:       SetTextColor( (HDC) wParam, Profile.rgbForeColor );
        !           395:       SetBkColor( (HDC) wParam, Profile.rgbBackColor );
1.1       root      396: 
                    397:       return( (LPARAM) CreateBrushIndirect( &LogBrush ) );
                    398:     }
                    399: 
1.1.1.3 ! root      400:     //-- check if a debuggee is still active, save profile settings
1.1       root      401:     case WM_CLOSE:
1.1.1.3 ! root      402:       if( Global.dwActiveDebuggees ) {
1.1       root      403:         TCHAR  szExitBoxTitle[64];
                    404:         TCHAR  szExitBoxText[256];
                    405: 
1.1.1.3 ! root      406:         LoadString( Global.hInstance, IDS_EXIT_BOX_TITLE, szExitBoxTitle,
        !           407:           sizeof(szExitBoxTitle)/sizeof(TCHAR) );
        !           408:         LoadString( Global.hInstance, IDS_EXIT_BOX_TEXT, szExitBoxText,
        !           409:           sizeof(szExitBoxText)/sizeof(TCHAR) );
1.1       root      410:         if ( MessageBox( hWnd, szExitBoxText, szExitBoxTitle,
                    411:                MB_YESNO | MB_ICONEXCLAMATION ) == IDNO )
1.1.1.2   root      412:           return( FALSE );
1.1       root      413:       }
                    414: 
                    415:       //-- store location information to private profile data
1.1.1.3 ! root      416:       WritePrivateProfileSettings( Global.szAppName, szIniPathName, &Profile );
1.1       root      417: 
1.1.1.3 ! root      418:       DestroyWindow( Global.hWndToolBar );
        !           419:       DestroyWindow( Global.hWndListBox );
        !           420:       DestroyWindow( Global.hWndMain );
1.1       root      421: 
1.1.1.2   root      422:       return( FALSE );
1.1       root      423: 
                    424:     case WM_DESTROY:
1.1.1.3 ! root      425:       if( Global.fHelpUsed )
1.1       root      426:         WinHelp( hWnd, szHelpPathName, (UINT) HELP_QUIT, (DWORD) NULL );
                    427:       PostQuitMessage( 0 );
1.1.1.2   root      428:       return( FALSE );
1.1       root      429: 
                    430:     default:               // Passes it on if unproccessed
                    431:       return( DefWindowProc(hWnd, uMsg, wParam, lParam) );
                    432:   }
                    433: 
1.1.1.2   root      434:   return( FALSE );
1.1       root      435: }
                    436: 
                    437: 
                    438: // ************************************************************************
                    439: // FUNCTION : ProcessCommandsWndProc( HWND, UINT, WPARAM, LPARAM )
                    440: // PURPOSE  : Processes WM_COMMAND messages for MainWndProc()
                    441: // MESSAGES :
                    442: //   WM_COMMAND         - application menu
                    443: //     IDM_FILE_EXIT    - exit the application
                    444: //     IDM_FILE_ABOUT   - About Dialog Box
                    445: //    ...
1.1.1.2   root      446: // COMMENTS :
                    447: //
1.1       root      448: // ************************************************************************
                    449: LRESULT CALLBACK
                    450: ProcessCommandsWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
                    451: {
1.1.1.3 ! root      452:   static LPCTSTR  lpszAboutDlgBox       = TEXT( "AboutDlgBox"       );
        !           453:   static LPCTSTR  lpszAttachDlgBox      = TEXT( "AttachDlgBox"      );
        !           454:   static LPCTSTR  lpszPreferencesDlgBox = TEXT( "PreferencesDlgBox" );
1.1.1.2   root      455: 
1.1       root      456:   switch( LOWORD(wParam) ) {
                    457: 
1.1.1.3 ! root      458:     //-- user requests to open a new debuggee
        !           459:     case IDM_FILE_OPEN: {
        !           460:       static TCHAR szDebuggeeFileName[MAX_PATH];
        !           461: 
        !           462:       if( Global.dwActiveDebuggees ) {
        !           463:         MaxDebuggeesMessageBox( Global.hWndMain );
1.1       root      464:         return( FALSE );
                    465:       }
1.1.1.3 ! root      466:       if( !GetDebuggeeFileName( szDebuggeeFileName, hWnd ) ) {
        !           467:         return( FALSE );
1.1       root      468:       }
                    469:       else {
1.1.1.3 ! root      470:         if( Profile.fClearOnNew ) {
        !           471:           SendMessage( Global.hWndListBox, LB_RESETCONTENT, 0, 0 );
        !           472:           Global.MaxStrLen = 0;
1.1       root      473:         }
1.1.1.3 ! root      474:         StartDebuggee( szDebuggeeFileName, Global.hWndListBox );
1.1       root      475:       }
1.1.1.2   root      476:       return( FALSE );
1.1.1.3 ! root      477:     }
1.1       root      478: 
1.1.1.3 ! root      479:     //-- user requests to attach to an existing process
1.1       root      480:     case IDM_FILE_ATTACH:
1.1.1.3 ! root      481:       if( Global.dwActiveDebuggees ) {
        !           482:         MaxDebuggeesMessageBox( Global.hWndMain );
1.1       root      483:         return( FALSE );
                    484:       }
1.1.1.3 ! root      485:       if( !DialogBox( Global.hInstance, lpszAttachDlgBox, hWnd,
        !           486:             (DLGPROC) AttachDlgProc ) ) {
        !           487:         // handle cancel condition...
1.1       root      488:       }
                    489:       else {
1.1.1.3 ! root      490:         if( Profile.fClearOnNew ) {
        !           491:           SendMessage( Global.hWndListBox, LB_RESETCONTENT, 0, 0 );
        !           492:           Global.MaxStrLen = 0;
1.1       root      493:         }
                    494:       }
1.1.1.2   root      495:       return( FALSE );
1.1       root      496: 
1.1.1.3 ! root      497:     //-- copy listbox contents to the clipboard and clear the listbox
1.1       root      498:     case IDM_EDIT_CUT:
1.1.1.3 ! root      499:       CopyListBoxToClipboard( Global.hWndListBox, Global.MaxStrLen );
1.1       root      500:       SendMessage( hWnd, WM_COMMAND, IDM_EDIT_DELETE, 0 );
1.1.1.2   root      501:       return( FALSE );
1.1       root      502: 
1.1.1.3 ! root      503:     //-- copy listbox contents to the clipboard
1.1       root      504:     case IDM_EDIT_COPY: {
1.1.1.3 ! root      505:       CopyListBoxToClipboard( Global.hWndListBox, Global.MaxStrLen );
1.1.1.2   root      506:       return( FALSE );
1.1       root      507:     }
                    508: 
1.1.1.3 ! root      509:     //-- clear the contents of the listbox
1.1       root      510:     case IDM_EDIT_DELETE:
1.1.1.3 ! root      511:       SendMessage( Global.hWndListBox, LB_RESETCONTENT, 0, 0 );
        !           512:       Global.MaxStrLen = 0;
1.1.1.2   root      513:       return( FALSE );
1.1       root      514: 
1.1.1.3 ! root      515:     //-- user requests a new font for the listbox
1.1       root      516:     case IDM_OPTIONS_FONT:
1.1.1.3 ! root      517:       if( !ChooseNewFont( Global.hWndListBox ) ) {
        !           518:         // handle cancel condition...
1.1       root      519:       }
1.1.1.2   root      520:       return( FALSE );
1.1       root      521: 
1.1.1.3 ! root      522:     //-- user requests a new background color for the listbox
1.1       root      523:     case IDM_OPTIONS_COLOR:
1.1.1.3 ! root      524:       ChooseNewBackColor( Global.hWndListBox );
1.1.1.2   root      525:       return( FALSE );
1.1       root      526: 
1.1.1.3 ! root      527:     //-- invoke the preferences dialog box
1.1       root      528:     case IDM_OPTIONS_PREFERENCES:
1.1.1.3 ! root      529:       DialogBox( Global.hInstance, lpszPreferencesDlgBox, hWnd,
1.1       root      530:         (DLGPROC) PreferencesDlgProc );
1.1.1.2   root      531:       return( FALSE );
1.1       root      532: 
1.1.1.3 ! root      533:     //-- toggle the toolbar on or off
1.1       root      534:     case IDM_OPTIONS_TOOLBAR:
1.1.1.3 ! root      535:       if( Profile.fToolBar ) {
        !           536:         Profile.fToolBar = 0;
        !           537:         CheckMenuItem( GetMenu(Global.hWndMain), IDM_OPTIONS_TOOLBAR,
        !           538:           MF_UNCHECKED );
        !           539:         ShowWindow( Global.hWndToolBar, SW_HIDE );
        !           540:         SendWmSizeMessage( Global.hWndMain );
1.1       root      541:       }
                    542:       else {
1.1.1.3 ! root      543:         Profile.fToolBar = 1;
        !           544:         CheckMenuItem( GetMenu(Global.hWndMain), IDM_OPTIONS_TOOLBAR,
        !           545:           MF_CHECKED );
        !           546:         ShowWindow( Global.hWndToolBar, SW_SHOW );
        !           547:         SendWmSizeMessage( Global.hWndMain );
1.1       root      548:       }
1.1.1.2   root      549:       return( FALSE );
1.1       root      550: 
1.1.1.3 ! root      551:     //-- toggles whether the used directory is used for the 'open' command
1.1       root      552:     case IDM_OPTIONS_SAVEDDIR:
1.1.1.3 ! root      553:       if( Profile.fSavedDirectory ) {
        !           554:         Profile.fSavedDirectory = 0;
        !           555:         CheckMenuItem( GetMenu(Global.hWndMain), IDM_OPTIONS_SAVEDDIR,
1.1       root      556:           MF_UNCHECKED );
                    557:       }
                    558:       else {
1.1.1.3 ! root      559:         Profile.fSavedDirectory = 1;
        !           560:         CheckMenuItem( GetMenu(Global.hWndMain), IDM_OPTIONS_SAVEDDIR,
1.1       root      561:           MF_CHECKED );
                    562:       }
1.1.1.2   root      563:       return( FALSE );
1.1       root      564: 
1.1.1.3 ! root      565:     //-- toggles the 'save on exit' feature
1.1       root      566:     case IDM_OPTIONS_SAVEONEXIT:
1.1.1.3 ! root      567:       if( Profile.fSaveOnExit ) {
        !           568:         Profile.fSaveOnExit = 0;
        !           569:         CheckMenuItem( GetMenu(Global.hWndMain), IDM_OPTIONS_SAVEONEXIT,
1.1       root      570:           MF_UNCHECKED );
                    571:       }
                    572:       else {
1.1.1.3 ! root      573:         Profile.fSaveOnExit = 1;
        !           574:         CheckMenuItem( GetMenu(Global.hWndMain), IDM_OPTIONS_SAVEONEXIT,
1.1       root      575:           MF_CHECKED );
                    576:       }
1.1.1.2   root      577:       return( FALSE );
1.1       root      578: 
1.1.1.3 ! root      579:     //-- store location information to private profile data now
        !           580:     case IDM_OPTIONS_SAVENOW: {
        !           581:       BOOL fOldSaveOnExit = Profile.fSaveOnExit;
        !           582:       BOOL fOldSavePreferences = Profile.fSavePreferences;
        !           583: 
        !           584:       Profile.fSaveOnExit = TRUE;
        !           585:       Profile.fSavePreferences = TRUE;
        !           586:       WritePrivateProfileSettings( Global.szAppName, szIniPathName, &Profile );
        !           587:       Profile.fSaveOnExit = fOldSaveOnExit;
        !           588:       Profile.fSavePreferences = fOldSavePreferences;
        !           589:       return( FALSE );
        !           590:     }
        !           591: 
        !           592:     //-- invoke help and display the contents panel
1.1       root      593:     case IDM_HELP_CONTENTS:
1.1.1.3 ! root      594:       Global.fHelpUsed = TRUE;
        !           595:       WinHelp( hWnd, (LPCTSTR) szHelpPathName, HELP_CONTENTS, (DWORD) NULL );
1.1.1.2   root      596:       return( FALSE );
1.1       root      597: 
1.1.1.3 ! root      598:     //-- search the help indexes
1.1       root      599:     case IDM_HELP_SEARCH:
1.1.1.3 ! root      600:       Global.fHelpUsed = TRUE;
        !           601:       WinHelp( hWnd, (LPCTSTR) szHelpPathName, HELP_PARTIALKEY,
        !           602:         (DWORD) TEXT( "" ) );
1.1.1.2   root      603:       return( FALSE );
1.1       root      604: 
1.1.1.3 ! root      605:     //-- invoke the main 'how to use' help panel
1.1       root      606:     case IDM_HELP_HOWTOUSE:
1.1.1.3 ! root      607:       Global.fHelpUsed = TRUE;
1.1       root      608:       WinHelp( hWnd, (LPTSTR) NULL, HELP_HELPONHELP, (DWORD) NULL );
1.1.1.2   root      609:       return( FALSE );
1.1       root      610: 
1.1.1.3 ! root      611:     //-- display the product information dialog box
1.1       root      612:     case IDM_HELP_ABOUT:
1.1.1.3 ! root      613:       DialogBox( Global.hInstance, lpszAboutDlgBox, hWnd,
        !           614:         (DLGPROC) AboutDlgProc );
1.1.1.2   root      615:       return( FALSE );
1.1       root      616: 
1.1.1.3 ! root      617:     //-- the usr requests to terminate the app
1.1       root      618:     case IDM_FILE_EXIT:
1.1.1.3 ! root      619:       SendMessage( Global.hWndMain, WM_CLOSE, 0, 0 );
1.1.1.2   root      620:       return( FALSE );
1.1       root      621: 
                    622:     default:
1.1.1.2   root      623:       return( DefWindowProc(hWnd, uMsg, wParam, lParam) );
1.1       root      624:   }
                    625: 
1.1.1.2   root      626:   return( FALSE );
1.1       root      627: }
                    628: 
                    629: 
                    630: // ************************************************************************
                    631: // FUNCTION : PreferencesDlgProc( HWND, UINT, WPARAM, LPARAM )
                    632: // PURPOSE  : Processes message for "Preferences" dialog box
                    633: // MESSAGES :
                    634: //   WM_INITDIALOG - initialize dialog box
                    635: //   WM_COMMAND    - Input received
                    636: // COMMENTS :
                    637: //   Wait for user to click on "Ok" button, then close the dialog box.
                    638: // ************************************************************************
                    639: BOOL CALLBACK
                    640: PreferencesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
                    641: {
                    642:   switch( uMsg ) {
                    643: 
                    644:     case WM_COMMAND:
                    645:       switch( LOWORD(wParam) ) {
                    646: 
                    647:         case IDOK:
1.1.1.3 ! root      648: 
        !           649:           //-- Debugger Setting Group
        !           650:           if( SendMessage( GetDlgItem( hDlg, IDC_DEBUG_PROCESS),
        !           651:                 BM_GETCHECK, 0, 0 ) )
        !           652:             Profile.DebugMode = DEBUG_PROCESS;
        !           653:           if( SendMessage( GetDlgItem( hDlg, IDC_DEBUG_ONLY_THIS_PROCESS),
        !           654:                 BM_GETCHECK, 0, 0 ) )
        !           655:             Profile.DebugMode = DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS;
        !           656: 
        !           657:           //-- Debuggee Priority Group
        !           658:           if( SendMessage( GetDlgItem( hDlg, IDC_IDLE_PRIORITY_CLASS),
        !           659:                 BM_GETCHECK, 0, 0 ) )
        !           660:             Profile.DebuggeePriority = IDLE_PRIORITY_CLASS;
        !           661:           if( SendMessage( GetDlgItem( hDlg, IDC_NORMAL_PRIORITY_CLASS),
        !           662:                 BM_GETCHECK, 0, 0 ) )
        !           663:             Profile.DebuggeePriority = NORMAL_PRIORITY_CLASS;
        !           664:           if( SendMessage( GetDlgItem( hDlg, IDC_HIGH_PRIORITY_CLASS),
        !           665:                 BM_GETCHECK, 0, 0 ) )
        !           666:             Profile.DebuggeePriority = HIGH_PRIORITY_CLASS;
        !           667:           if( SendMessage( GetDlgItem( hDlg, IDC_REALTIME_PRIORITY_CLASS),
        !           668:                 BM_GETCHECK, 0, 0 ) )
        !           669:             Profile.DebuggeePriority = REALTIME_PRIORITY_CLASS;
        !           670: 
        !           671:           //-- Miscellaneous Options Group
        !           672:           Profile.fClearOnNew  = (BOOL) SendMessage(
        !           673:                                           GetDlgItem( hDlg, IDC_CLEAR_ON_NEW),
        !           674:                                           BM_GETCHECK, 0 , 0 );
        !           675:           Profile.fVerbose     = (BOOL) SendMessage(
        !           676:                                           GetDlgItem( hDlg, IDC_VERBOSE),
        !           677:                                           BM_GETCHECK, 0 , 0 );
        !           678:           Profile.fShowSymbols = (BOOL) SendMessage(
        !           679:                                           GetDlgItem( hDlg, IDC_SHOW_SYMBOLS),
        !           680:                                           BM_GETCHECK, 0 , 0 );
        !           681: 
        !           682:           //- Debug Error Level Group
        !           683:           if( SendMessage( GetDlgItem( hDlg, IDC_DEBUG_MODE_NONE),
        !           684:                 BM_GETCHECK, 0, 0 ) )
        !           685:             Profile.DebugErrorLevel = 0;
        !           686:           if( SendMessage( GetDlgItem( hDlg, IDC_DEBUG_MODE_ERROR),
        !           687:                 BM_GETCHECK, 0, 0 ) )
        !           688:             Profile.DebugErrorLevel = SLE_ERROR;
        !           689:           if( SendMessage( GetDlgItem( hDlg, IDC_DEBUG_MODE_MINORERROR),
        !           690:                 BM_GETCHECK, 0, 0 ) )
        !           691:             Profile.DebugErrorLevel = SLE_MINORERROR;
        !           692:           if( SendMessage( GetDlgItem( hDlg, IDC_DEBUG_MODE_WARNING),
        !           693:                 BM_GETCHECK, 0, 0 ) )
        !           694:             Profile.DebugErrorLevel = SLE_WARNING;
        !           695: 
        !           696:           Profile.fSavePreferences = (BOOL) SendMessage(
        !           697:                                               GetDlgItem( hDlg,
        !           698:                                                 IDC_SAVE_PREFERENCES),
        !           699:                                               BM_GETCHECK, 0 , 0 );
1.1       root      700:           EndDialog( hDlg, TRUE );
                    701:           return( TRUE );
                    702: 
                    703:         case IDCANCEL:
                    704:           EndDialog( hDlg, FALSE );
                    705:           return( TRUE );
                    706: 
                    707:         case IDHELP:
                    708:           return( TRUE );
                    709: 
                    710:       }
                    711:       break;
                    712: 
                    713:     case WM_INITDIALOG:
                    714: 
1.1.1.3 ! root      715:       //-- Debugger Setting Group
        !           716:       switch( Profile.DebugMode ) {
1.1       root      717: 
                    718:         case DEBUG_PROCESS:
                    719:           SendMessage( GetDlgItem( hDlg, IDC_DEBUG_PROCESS),
                    720:             BM_SETCHECK, 1, 0);
                    721:           break;
                    722: 
                    723:         case ( DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS ):
                    724:           SendMessage( GetDlgItem( hDlg, IDC_DEBUG_ONLY_THIS_PROCESS),
                    725:             BM_SETCHECK, 1, 0);
                    726:           break;
                    727:       }
                    728: 
1.1.1.3 ! root      729:       //-- Debuggee Priority Group
        !           730:       switch( Profile.DebuggeePriority ) {
1.1       root      731: 
                    732:         case IDLE_PRIORITY_CLASS:
                    733:           SendMessage( GetDlgItem( hDlg, IDC_IDLE_PRIORITY_CLASS),
                    734:             BM_SETCHECK, 1, 0);
                    735:           break;
                    736: 
                    737:         case NORMAL_PRIORITY_CLASS:
                    738:           SendMessage( GetDlgItem( hDlg, IDC_NORMAL_PRIORITY_CLASS),
                    739:             BM_SETCHECK, 1, 0);
                    740:           break;
                    741: 
                    742:         case HIGH_PRIORITY_CLASS:
                    743:           SendMessage( GetDlgItem( hDlg, IDC_HIGH_PRIORITY_CLASS),
                    744:             BM_SETCHECK, 1, 0);
                    745:           break;
1.1.1.3 ! root      746: 
        !           747:         case REALTIME_PRIORITY_CLASS:
        !           748:           SendMessage( GetDlgItem( hDlg, IDC_REALTIME_PRIORITY_CLASS),
        !           749:             BM_SETCHECK, 1, 0);
        !           750:           break;
        !           751: 
1.1       root      752:       }
                    753: 
1.1.1.3 ! root      754:       //-- Miscellaneous Options Group
1.1       root      755:       SendMessage( GetDlgItem( hDlg, IDC_CLEAR_ON_NEW),     BM_SETCHECK,
1.1.1.3 ! root      756:         Profile.fClearOnNew, 0 );
1.1       root      757:       SendMessage( GetDlgItem( hDlg, IDC_VERBOSE),          BM_SETCHECK,
1.1.1.3 ! root      758:         Profile.fVerbose, 0 );
1.1       root      759:       SendMessage( GetDlgItem( hDlg, IDC_SHOW_SYMBOLS),     BM_SETCHECK,
1.1.1.3 ! root      760:         Profile.fShowSymbols, 0 );
1.1       root      761:       SendMessage( GetDlgItem( hDlg, IDC_SAVE_PREFERENCES), BM_SETCHECK,
1.1.1.3 ! root      762:         Profile.fSavePreferences, 0 );
        !           763: 
        !           764:       //- Debug Error Level Group
        !           765:       switch( Profile.DebugErrorLevel ) {
        !           766: 
        !           767:         case 0:
        !           768:           SendMessage( GetDlgItem( hDlg, IDC_DEBUG_MODE_NONE),
        !           769:             BM_SETCHECK, 1, 0);
        !           770:           break;
        !           771: 
        !           772:         case SLE_ERROR:
        !           773:           SendMessage( GetDlgItem( hDlg, IDC_DEBUG_MODE_ERROR),
        !           774:             BM_SETCHECK, 1, 0);
        !           775:           break;
        !           776: 
        !           777:         case SLE_MINORERROR:
        !           778:           SendMessage( GetDlgItem( hDlg, IDC_DEBUG_MODE_MINORERROR),
        !           779:             BM_SETCHECK, 1, 0);
        !           780:           break;
        !           781: 
        !           782:         case SLE_WARNING:
        !           783:           SendMessage( GetDlgItem( hDlg, IDC_DEBUG_MODE_WARNING),
        !           784:             BM_SETCHECK, 1, 0);
        !           785:           break;
        !           786: 
        !           787:       }
1.1       root      788: 
                    789:       return( TRUE );
                    790:   }
                    791: 
                    792:   return( FALSE );
1.1.1.3 ! root      793:   UNREFERENCED_PARAMETER( lParam );
1.1       root      794: }
                    795: 
                    796: 
                    797: // ************************************************************************
                    798: // FUNCTION : AttachDlgProc( HWND, UINT, WPARAM, LPARAM )
                    799: // PURPOSE  : Processes messages for "Attach" dialog box
                    800: // MESSAGES :
                    801: //   WM_COMMAND    - Input received
1.1.1.3 ! root      802: //   WM_INITDIALOG - initialize dialog box
1.1       root      803: // COMMENTS :
                    804: //   Wait for user to click on "Ok" button, then close the dialog box.
                    805: // ************************************************************************
                    806: BOOL CALLBACK
                    807: AttachDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
                    808: {
1.1.1.3 ! root      809:   static HWND hWndProcessList;
1.1       root      810: 
                    811:   switch( uMsg ) {
                    812: 
                    813:     case WM_COMMAND:
                    814:       switch( LOWORD(wParam) ) {
                    815: 
1.1.1.3 ! root      816:         case IDOK: {
        !           817:           LONG  Index;
        !           818:           DWORD dwProcessId;
        !           819: 
        !           820:           Index = (UINT) SendMessage( hWndProcessList, LB_GETCURSEL,
        !           821:                          (WPARAM) NULL, (LPARAM) NULL );
1.1       root      822:           dwProcessId = (DWORD) SendMessage( hWndProcessList,
                    823:                                   LB_GETITEMDATA,
1.1.1.3 ! root      824:                                   (WPARAM) Index, (LPARAM) NULL );
        !           825:           AttachToDebuggee( dwProcessId, Global.hWndListBox );
1.1       root      826:           EndDialog( hDlg, TRUE );
                    827:           return( TRUE );
1.1.1.3 ! root      828:         }
1.1       root      829: 
                    830:         case IDCANCEL:
                    831:           EndDialog( hDlg, FALSE );
                    832:           return( TRUE );
                    833: 
                    834:         case IDHELP:
                    835:           return( TRUE );
                    836: 
                    837:       }
                    838:       switch( HIWORD( wParam ) ) {
                    839:         case LBN_DBLCLK:
                    840:           SendMessage( hDlg, WM_COMMAND, (WPARAM) IDOK, (LPARAM) 0L );
                    841:           return( TRUE );
                    842:       }
                    843:       break;
                    844: 
                    845:     case WM_INITDIALOG:
                    846:       hWndProcessList = GetDlgItem( hDlg, IDC_PROCESSLIST );
                    847:       SendMessage( hWndProcessList, LB_RESETCONTENT, 0 , 0 );
                    848:       for(; !EnumWindows( (WNDENUMPROC) EnumProcessListFunc,
                    849:                (LPARAM) hWndProcessList ); )
                    850:         ; // continue looping until done
                    851:       return( TRUE );
                    852:   }
                    853: 
                    854:   return( FALSE );
1.1.1.3 ! root      855:   UNREFERENCED_PARAMETER( lParam );
1.1       root      856: }
                    857: 
                    858: 
1.1.1.3 ! root      859: // **************************************************************************
1.1       root      860: // FUNCTION : AboutDlgProc( HWND, UINT, WPARAM, LPARAM )
                    861: // PURPOSE  : Processes messages for "About" dialog box
                    862: // MESSAGES :
                    863: //   WM_COMMAND    - Input received
1.1.1.3 ! root      864: //     IDOK        - OK button selected
        !           865: //     IDCANCEL    - Cancel button selected
        !           866: //     ...
        !           867: //   WM_INITDIALOG - initialize dialog box
        !           868: //   WM_CLOSE      - close the dialog box
        !           869: //   ...
        !           870: // COMMENTS:
        !           871: //   No initialization is needed for this particular dialog box.
        !           872: //   In this case, TRUE must be returned to Windows.
1.1       root      873: //   Wait for user to click on "Ok" button, then close the dialog box.
1.1.1.3 ! root      874: // **************************************************************************
1.1       root      875: BOOL CALLBACK
                    876: AboutDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
                    877: {
                    878:   switch( uMsg ) {
                    879: 
                    880:     case WM_COMMAND:
                    881:       switch( LOWORD(wParam) ) {
                    882: 
                    883:         case IDOK:
1.1.1.3 ! root      884:           Global.fAboutBox = FALSE;
1.1       root      885:           EndDialog( hDlg, TRUE );
                    886:           return( TRUE );
1.1.1.3 ! root      887: 
        !           888:         case IDCANCEL:
        !           889:           Global.fAboutBox = FALSE;
        !           890:           EndDialog( hDlg, FALSE );
        !           891:           return( FALSE );
        !           892: 
1.1       root      893:       }
                    894:       break;
                    895: 
                    896:     case WM_INITDIALOG:
1.1.1.3 ! root      897:       Global.hDlgAbout = hDlg;
        !           898:       Global.fAboutBox = TRUE;
        !           899:       Global.idIconTimer = SetTimer( hDlg, 1, TIMEOUT_ANIMATED_ICON,
        !           900:         TimerProc );  // for the animated icon
1.1       root      901:       return( TRUE );
                    902: 
                    903:     case WM_CLOSE:
1.1.1.3 ! root      904:       Global.fAboutBox = FALSE;
1.1       root      905:       EndDialog( hDlg, TRUE );
                    906:       return( TRUE );
                    907: 
1.1.1.3 ! root      908:     case WM_DESTROY:
        !           909:       KillTimer( hDlg, Global.idIconTimer );
        !           910:       Global.idIconTimer = 0;
        !           911:       return( TRUE );
1.1       root      912:   }
                    913: 
                    914:   return( FALSE );
1.1.1.3 ! root      915:   UNREFERENCED_PARAMETER( lParam );
1.1       root      916: }
                    917: 
                    918: 
                    919: // ************************************************************************
                    920: // FUNCTION : NewListBoxWndProc( HWND, UINT, WPARAM, LPARAM )
                    921: // PURPOSE  : Processes messages for "LISTBOX" class.
                    922: // COMMENTS : Prevents the user from moving the window
                    923: //            by dragging the titlebar.
                    924: // ************************************************************************
                    925: LRESULT CALLBACK
                    926: NewListBoxWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
                    927: {
                    928:   switch( uMsg ) {
                    929: 
                    930:     case WM_NCLBUTTONDOWN:
                    931:       if( wParam == HTCAPTION ) {
                    932:         SetFocus( hWnd );
1.1.1.2   root      933:         return( FALSE );
1.1       root      934:       }
                    935:       else
                    936:         break;
                    937:   }
                    938: 
1.1.1.3 ! root      939:   return( CallWindowProc( Global.OldListBoxWndProc, hWnd, uMsg, wParam, lParam) );
        !           940: }
        !           941: 
        !           942: 
        !           943: // ************************************************************************
        !           944: // FUNCTION : TimerProc( HWND, UINT, UINT, DWORD )
        !           945: // PURPOSE  :
        !           946: // COMMENTS :
        !           947: // ************************************************************************
        !           948: VOID CALLBACK
        !           949: TimerProc( HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime )
        !           950: {
        !           951:  #define NUM_ICONS 8
        !           952: 
        !           953:  static UINT    uIconNumber = 0;
        !           954:  static HWND    hWndIcon    = NULL;
        !           955:  static HWND    hWndIconOld = NULL;
        !           956:  static LPCTSTR lpszIconNames[NUM_ICONS] = {
        !           957:                   TEXT( "DebugIcon1" ), TEXT( "DebugIcon2" ),
        !           958:                   TEXT( "DebugIcon3" ), TEXT( "DebugIcon4" ),
        !           959:                   TEXT( "DebugIcon5" ), TEXT( "DebugIcon6" ),
        !           960:                   TEXT( "DebugIcon7" ), TEXT( "DebugIcon8" ) };
        !           961: 
        !           962:  if( (++uIconNumber) >= NUM_ICONS )
        !           963:    uIconNumber = 0;
        !           964: 
        !           965:  if( Global.fAboutBox ) {
        !           966:    hWndIconOld = hWndIcon;
        !           967:    hWndIcon = CreateIconWindow( Global.hDlgAbout, lpszIconNames[uIconNumber] );
        !           968:    if( hWndIcon != NULL ) {
        !           969:      DestroyWindow( hWndIconOld );
        !           970:    }
        !           971:  }
        !           972: 
        !           973:  if( IsIconic( Global.hWndMain ) ) {
        !           974:    InvalidateRect( Global.hWndMain, NULL, TRUE );
        !           975:    Global.hIconCurrent = LoadIcon( Global.hInstance, lpszIconNames[uIconNumber] );
        !           976:  }
        !           977: 
        !           978:  return;
        !           979:  UNREFERENCED_PARAMETER( hWnd );
        !           980:  UNREFERENCED_PARAMETER( uMsg );
        !           981:  UNREFERENCED_PARAMETER( idEvent );
        !           982:  UNREFERENCED_PARAMETER( dwTime );
1.1       root      983: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.