📄 debmain.c
字号:
switch( wParam ) {
case SIZE_RESTORED: {
RECT rect;
Profile.fMaximized = FALSE;
Profile.fMinimized = FALSE;
GetWindowRect( Global.hWndMain, &rect );
Profile.nWidth = (INT) (rect.right - rect.left);
Profile.nHeight = (INT) (rect.bottom - rect.top);
return( FALSE );
}
case SIZE_MAXIMIZED:
Profile.fMaximized = TRUE;
Profile.fMinimized = FALSE;
Profile.xPos = Global.xPosOld;
Profile.yPos = Global.yPosOld;
return( FALSE );
case SIZE_MINIMIZED:
Profile.fMinimized = TRUE;
Profile.fMaximized = FALSE;
Profile.xPos = Global.xPosOld;
Profile.yPos = Global.yPosOld;
return( FALSE );
}
return( DefWindowProc(hWnd, uMsg, wParam, lParam) );
//-- keep track of window position so it can be saved
case WM_MOVE: {
RECT rect;
GetWindowRect( Global.hWndMain, &rect );
Global.xPosOld = Profile.xPos;
Global.yPosOld = Profile.yPos;
Profile.xPos = (INT) rect.left;
Profile.yPos = (INT) rect.top;
return( FALSE );
}
//-- colorize the debug event listbox
case WM_CTLCOLORLISTBOX: {
LOGBRUSH LogBrush;
LogBrush.lbStyle = BS_SOLID;
LogBrush.lbColor = Profile.rgbBackColor;
LogBrush.lbHatch = (LONG) NULL;
SetTextColor( (HDC) wParam, Profile.rgbForeColor );
SetBkColor( (HDC) wParam, Profile.rgbBackColor );
return( (LPARAM) CreateBrushIndirect( &LogBrush ) );
}
//-- check if a debuggee is still active, save profile settings
case WM_CLOSE:
if( Global.dwActiveDebuggees ) {
TCHAR szExitBoxTitle[64];
TCHAR szExitBoxText[256];
LoadString( Global.hInstance, IDS_EXIT_BOX_TITLE, szExitBoxTitle,
sizeof(szExitBoxTitle)/sizeof(TCHAR) );
LoadString( Global.hInstance, IDS_EXIT_BOX_TEXT, szExitBoxText,
sizeof(szExitBoxText)/sizeof(TCHAR) );
if ( MessageBox( hWnd, szExitBoxText, szExitBoxTitle,
MB_YESNO | MB_ICONEXCLAMATION ) == IDNO )
return( FALSE );
}
//-- store location information to private profile data
WritePrivateProfileSettings( Global.szAppName, szIniPathName, &Profile );
DestroyWindow( Global.hWndToolBar );
DestroyWindow( Global.hWndListBox );
DestroyWindow( Global.hWndMain );
return( FALSE );
case WM_DESTROY:
if( Global.fHelpUsed )
WinHelp( hWnd, szHelpPathName, (UINT) HELP_QUIT, (DWORD) NULL );
PostQuitMessage( 0 );
return( FALSE );
default: // Passes it on if unproccessed
return( DefWindowProc(hWnd, uMsg, wParam, lParam) );
}
return( FALSE );
}
// ************************************************************************
// FUNCTION : ProcessCommandsWndProc( HWND, UINT, WPARAM, LPARAM )
// PURPOSE : Processes WM_COMMAND messages for MainWndProc()
// MESSAGES :
// WM_COMMAND - application menu
// IDM_FILE_EXIT - exit the application
// IDM_FILE_ABOUT - About Dialog Box
// ...
// COMMENTS :
//
// ************************************************************************
LRESULT CALLBACK
ProcessCommandsWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static LPCTSTR lpszAboutDlgBox = TEXT( "AboutDlgBox" );
static LPCTSTR lpszAttachDlgBox = TEXT( "AttachDlgBox" );
static LPCTSTR lpszPreferencesDlgBox = TEXT( "PreferencesDlgBox" );
switch( LOWORD(wParam) ) {
//-- user requests to open a new debuggee
case IDM_FILE_OPEN: {
static TCHAR szDebuggeeFileName[MAX_PATH];
if( Global.dwActiveDebuggees ) {
MaxDebuggeesMessageBox( Global.hWndMain );
return( FALSE );
}
if( !GetDebuggeeFileName( szDebuggeeFileName, hWnd ) ) {
return( FALSE );
}
else {
if( Profile.fClearOnNew ) {
SendMessage( Global.hWndListBox, LB_RESETCONTENT, 0, 0 );
Global.MaxStrLen = 0;
}
StartDebuggee( szDebuggeeFileName, Global.hWndListBox );
}
return( FALSE );
}
//-- user requests to attach to an existing process
case IDM_FILE_ATTACH:
if( Global.dwActiveDebuggees ) {
MaxDebuggeesMessageBox( Global.hWndMain );
return( FALSE );
}
if( !DialogBox( Global.hInstance, lpszAttachDlgBox, hWnd,
(DLGPROC) AttachDlgProc ) ) {
// handle cancel condition...
}
else {
if( Profile.fClearOnNew ) {
SendMessage( Global.hWndListBox, LB_RESETCONTENT, 0, 0 );
Global.MaxStrLen = 0;
}
}
return( FALSE );
//-- copy listbox contents to the clipboard and clear the listbox
case IDM_EDIT_CUT:
CopyListBoxToClipboard( Global.hWndListBox, Global.MaxStrLen );
SendMessage( hWnd, WM_COMMAND, IDM_EDIT_DELETE, 0 );
return( FALSE );
//-- copy listbox contents to the clipboard
case IDM_EDIT_COPY: {
CopyListBoxToClipboard( Global.hWndListBox, Global.MaxStrLen );
return( FALSE );
}
//-- clear the contents of the listbox
case IDM_EDIT_DELETE:
SendMessage( Global.hWndListBox, LB_RESETCONTENT, 0, 0 );
Global.MaxStrLen = 0;
return( FALSE );
//-- user requests a new font for the listbox
case IDM_OPTIONS_FONT:
if( !ChooseNewFont( Global.hWndListBox ) ) {
// handle cancel condition...
}
return( FALSE );
//-- user requests a new background color for the listbox
case IDM_OPTIONS_COLOR:
ChooseNewBackColor( Global.hWndListBox );
return( FALSE );
//-- invoke the preferences dialog box
case IDM_OPTIONS_PREFERENCES:
DialogBox( Global.hInstance, lpszPreferencesDlgBox, hWnd,
(DLGPROC) PreferencesDlgProc );
return( FALSE );
//-- toggle the toolbar on or off
case IDM_OPTIONS_TOOLBAR:
if( Profile.fToolBar ) {
Profile.fToolBar = 0;
CheckMenuItem( GetMenu(Global.hWndMain), IDM_OPTIONS_TOOLBAR,
MF_UNCHECKED );
ShowWindow( Global.hWndToolBar, SW_HIDE );
SendWmSizeMessage( Global.hWndMain );
}
else {
Profile.fToolBar = 1;
CheckMenuItem( GetMenu(Global.hWndMain), IDM_OPTIONS_TOOLBAR,
MF_CHECKED );
ShowWindow( Global.hWndToolBar, SW_SHOW );
SendWmSizeMessage( Global.hWndMain );
}
return( FALSE );
//-- toggles whether the used directory is used for the 'open' command
case IDM_OPTIONS_SAVEDDIR:
if( Profile.fSavedDirectory ) {
Profile.fSavedDirectory = 0;
CheckMenuItem( GetMenu(Global.hWndMain), IDM_OPTIONS_SAVEDDIR,
MF_UNCHECKED );
}
else {
Profile.fSavedDirectory = 1;
CheckMenuItem( GetMenu(Global.hWndMain), IDM_OPTIONS_SAVEDDIR,
MF_CHECKED );
}
return( FALSE );
//-- toggles the 'save on exit' feature
case IDM_OPTIONS_SAVEONEXIT:
if( Profile.fSaveOnExit ) {
Profile.fSaveOnExit = 0;
CheckMenuItem( GetMenu(Global.hWndMain), IDM_OPTIONS_SAVEONEXIT,
MF_UNCHECKED );
}
else {
Profile.fSaveOnExit = 1;
CheckMenuItem( GetMenu(Global.hWndMain), IDM_OPTIONS_SAVEONEXIT,
MF_CHECKED );
}
return( FALSE );
//-- store location information to private profile data now
case IDM_OPTIONS_SAVENOW: {
BOOL fOldSaveOnExit = Profile.fSaveOnExit;
BOOL fOldSavePreferences = Profile.fSavePreferences;
Profile.fSaveOnExit = TRUE;
Profile.fSavePreferences = TRUE;
WritePrivateProfileSettings( Global.szAppName, szIniPathName, &Profile );
Profile.fSaveOnExit = fOldSaveOnExit;
Profile.fSavePreferences = fOldSavePreferences;
return( FALSE );
}
//-- invoke help and display the contents panel
case IDM_HELP_CONTENTS:
Global.fHelpUsed = TRUE;
WinHelp( hWnd, (LPCTSTR) szHelpPathName, HELP_CONTENTS, (DWORD) NULL );
return( FALSE );
//-- search the help indexes
case IDM_HELP_SEARCH:
Global.fHelpUsed = TRUE;
WinHelp( hWnd, (LPCTSTR) szHelpPathName, HELP_PARTIALKEY,
(DWORD) TEXT( "" ) );
return( FALSE );
//-- invoke the main 'how to use' help panel
case IDM_HELP_HOWTOUSE:
Global.fHelpUsed = TRUE;
WinHelp( hWnd, (LPTSTR) NULL, HELP_HELPONHELP, (DWORD) NULL );
return( FALSE );
//-- display the product information dialog box
case IDM_HELP_ABOUT:
DialogBox( Global.hInstance, lpszAboutDlgBox, hWnd,
(DLGPROC) AboutDlgProc );
return( FALSE );
//-- the usr requests to terminate the app
case IDM_FILE_EXIT:
SendMessage( Global.hWndMain, WM_CLOSE, 0, 0 );
return( FALSE );
default:
return( DefWindowProc(hWnd, uMsg, wParam, lParam) );
}
return( FALSE );
}
// ************************************************************************
// FUNCTION : PreferencesDlgProc( HWND, UINT, WPARAM, LPARAM )
// PURPOSE : Processes message for "Preferences" dialog box
// MESSAGES :
// WM_INITDIALOG - initialize dialog box
// WM_COMMAND - Input received
// COMMENTS :
// Wait for user to click on "Ok" button, then close the dialog box.
// ************************************************************************
BOOL CALLBACK
PreferencesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch( uMsg ) {
case WM_COMMAND:
switch( LOWORD(wParam) ) {
case IDOK:
//-- Debugger Setting Group
if( SendMessage( GetDlgItem( hDlg, IDC_DEBUG_PROCESS),
BM_GETCHECK, 0, 0 ) )
Profile.DebugMode = DEBUG_PROCESS;
if( SendMessage( GetDlgItem( hDlg, IDC_DEBUG_ONLY_THIS_PROCESS),
BM_GETCHECK, 0, 0 ) )
Profile.DebugMode = DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS;
//-- Debuggee Priority Group
if( SendMessage( GetDlgItem( hDlg, IDC_IDLE_PRIORITY_CLASS),
BM_GETCHECK, 0, 0 ) )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -