📄 wmain.c
字号:
case IDM_ACC_LOAD_SYMBOLS:
handleLoadSymbols( einfo );
pass_to_def = FALSE;
break;
case IDM_ACC_SHOWRIBBON:
menu = WGetMenuHandle ( einfo );
WShowRibbon ( einfo, menu );
pass_to_def = FALSE;
break;
case IDM_ACC_MEM_FLAGS:
WSetStatusByID( einfo->wsb, W_CHANGEACCELMEMFLAGS, -1 );
einfo->info->modified |=
WChangeMemFlags( einfo->win, &einfo->info->MemFlags,
einfo->info->res_name,
WGetEditInstance(),
WAccHelpRoutine );
pass_to_def = FALSE;
WSetStatusReadyText( einfo->wsb );
break;
case IDM_ACC_RENAME:
WHandleRename( einfo );
pass_to_def = FALSE;
break;
case IDM_HELP:
WAccHelpRoutine();
pass_to_def = FALSE;
break;
case IDM_ACC_ABOUT:
WDisplayAboutBox ( WGetEditInstance(), einfo->win, 0 );
pass_to_def = FALSE;
break;
}
break;
case WM_DESTROY:
WWinHelp( hWnd, "resacc.hlp", HELP_QUIT, 0 );
WCleanup( einfo );
break;
case WM_CLOSE:
ret = TRUE;
pass_to_def = WHandleWM_CLOSE( einfo, (Bool)wParam );
wParam = 0;
break;
}
if ( pass_to_def ) {
ret = DefWindowProc( hWnd, message, wParam, lParam );
}
return ( ret );
}
Bool WQuerySave( WAccelEditInfo *einfo, Bool force_exit )
{
return( WQuerySaveRes( einfo, force_exit ) &&
WQuerySaveSym( einfo, force_exit ) );
}
Bool WQuerySaveRes( WAccelEditInfo *einfo, Bool force_exit )
{
int ret;
UINT style;
char *title;
char *text;
if( einfo && einfo->info->modified ) {
ret = IDYES;
if( einfo->info->stand_alone ) {
if( force_exit ) {
style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION;
} else {
style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION;
}
title = WCreateEditTitle( einfo );
text = WAllocRCString( W_UPDATEMODIFIEDACCEL );
ret = MessageBox( einfo->edit_dlg, text, title, style );
if( text ) {
WFreeRCString( text );
}
if( title ) {
WMemFree( title );
}
}
if( ret == IDYES ) {
if( einfo->info->stand_alone ) {
return( WSaveObject( einfo, FALSE, FALSE ) );
} else {
SendMessage( einfo->info->parent, ACCEL_PLEASE_SAVEME, 0,
(LPARAM) einfo->hndl );
}
} else if( ret == IDCANCEL ) {
return( FALSE );
}
}
return( TRUE );
}
Bool WQuerySaveSym( WAccelEditInfo *einfo, Bool force_exit )
{
int ret;
UINT style;
char *title;
char *text;
if( !einfo || !einfo->info->stand_alone ) {
return( TRUE );
}
if( !WRIsHashTableDirty( einfo->info->symbol_table ) ) {
return( TRUE );
}
if( force_exit ) {
style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION;
} else {
style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION;
}
title = WCreateEditTitle( einfo );
text = WAllocRCString( W_UPDATEMODIFIEDSYM );
ret = MessageBox( einfo->edit_dlg, text, title, style );
if( text ) {
WFreeRCString( text );
}
if( title ) {
WMemFree( title );
}
if( ret == IDYES ) {
if( einfo->info->symbol_file == NULL ) {
char *fname;
if( !einfo->file_name ) {
fname = einfo->info->file_name;
} else {
fname = einfo->file_name;
}
einfo->info->symbol_file = WCreateSymName( fname );
}
return( WSaveSymbols( einfo, einfo->info->symbol_table,
&einfo->info->symbol_file, FALSE ) );
} else if( ret == IDCANCEL ) {
return( FALSE );
}
return( TRUE );
}
Bool WHandleWM_CLOSE( WAccelEditInfo *einfo, Bool force_exit )
{
Bool ret;
ret = TRUE;
if( einfo ) {
if( einfo->info->modified ||
WRIsHashTableDirty( einfo->info->symbol_table ) ) {
ret = WQuerySave( einfo, force_exit );
}
if( ret ) {
SendMessage( einfo->info->parent, ACCEL_I_HAVE_CLOSED, 0,
(LPARAM)einfo->hndl );
WUnRegisterEditSession( WGetEditSessionHandle( einfo ) );
}
}
return( ret );
}
void WHandleRename( WAccelEditInfo *einfo )
{
if( einfo != NULL ) {
WSetStatusByID( einfo->wsb, W_RENAMINGACCEL, -1 );
einfo->info->modified |=
WRenameResource( einfo->win, &einfo->info->res_name ,
WAccHelpRoutine );
WSetEditWinResName( einfo );
WSetStatusReadyText( einfo->wsb );
}
}
Bool WQueryClearRes( WAccelEditInfo *einfo )
{
int ret;
UINT style;
char *title;
char *text;
if( einfo ) {
style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION;
text = WAllocRCString( W_ACCELCLEARWARNING );
title = WAllocRCString( W_ACCELCLEARTITLE );
ret = MessageBox( einfo->edit_dlg, text, title, style );
if( text ) {
WFreeRCString( text );
}
if( title ) {
WFreeRCString( title );
}
if( ret == IDYES ) {
return( TRUE );
}
}
return( FALSE );
}
void WHandleClear( WAccelEditInfo *einfo )
{
if( einfo->tbl && ( einfo->tbl->num != 0 ) ) {
if( WQueryClearRes( einfo ) ) {
WResetEditWindow( einfo );
SendDlgItemMessage( einfo->edit_dlg, IDM_ACCEDLIST,
LB_RESETCONTENT, 0, 0 );
WFreeAccelTableEntries ( einfo->tbl->first_entry );
einfo->tbl->first_entry = NULL;
einfo->tbl->num = 0;
einfo->current_entry = NULL;
einfo->current_pos = -1;
einfo->getting_key = FALSE;
if( einfo->info->stand_alone ) {
if( einfo->file_name != NULL ) {
WMemFree( einfo->file_name );
einfo->file_name = NULL;
WSetEditTitle( einfo );
}
if( einfo->info->symbol_table ) {
WRFreeHashTable( einfo->info->symbol_table );
einfo->info->symbol_table = WRInitHashTable();
}
}
einfo->info->modified = TRUE;
SetFocus( einfo->edit_dlg );
WSetStatusByID( einfo->wsb, W_ACCELCLEARMSG, -1 );
}
}
}
void WUpdateScreenPosOpt ( HWND win )
{
RECT rect;
GetWindowRect ( win, &rect );
WSetScreenPosOption ( &rect );
}
void WResizeWindows ( WAccelEditInfo *einfo )
{
RECT rect;
if ( !einfo ) {
einfo = WGetCurrentEditInfo ();
}
if ( einfo && einfo->win ) {
GetClientRect ( einfo->win, &rect );
WResizeAccelEditWindow ( einfo, &rect );
WResizeStatusWindows ( einfo->wsb, &rect );
WResizeRibbon ( einfo, &rect );
}
}
void WDisplayAboutBox ( HINSTANCE inst, HWND parent, UINT msecs )
{
FARPROC lpProcAbout;
lpProcAbout = MakeProcInstance ( (FARPROC) WAbout, inst );
JDialogBoxParam( inst, "WAboutBox", parent, (DLGPROC) lpProcAbout,
(LPARAM) &msecs );
FreeProcInstance ( lpProcAbout );
}
Bool WINEXPORT WAbout( HWND hDlg, WORD message, WPARAM wParam, LPARAM lParam )
{
UINT msecs, timer, start;
HDC dc, tdc;
HBITMAP old;
HWND w666;
RECT rect, arect;
PAINTSTRUCT ps;
WORD w;
char *title;
static BITMAP bm;
static HBITMAP logo;
static HBRUSH brush;
static COLORREF color;
switch( message ) {
case WM_SYSCOLORCHANGE:
WCtl3dColorChange();
break;
case WM_DESTROY:
if( logo ) {
DeleteObject( logo );
}
if( brush ) {
DeleteObject( brush );
}
break;
case WM_INITDIALOG:
msecs = *((UINT *)lParam);
if( msecs ) {
timer = SetTimer( hDlg, ABOUT_TIMER, msecs, NULL );
if( timer ) {
SetWindowLong( hDlg, DWL_USER, (LONG) timer );
ShowWindow( GetDlgItem( hDlg, IDOK ), SW_HIDE );
title = WAllocRCString( W_ACCELAPPTITLE );
SendMessage( hDlg, WM_SETTEXT, 0, (LPARAM)title );
if( title ) {
WFreeRCString( title );
}
}
}
logo = LoadBitmap ( WGetEditInstance(), "AboutLogo" );
//color = RGB(128,128,128);
color = GetSysColor ( COLOR_BTNFACE );
brush = CreateSolidBrush ( color );
GetObject ( logo, sizeof(BITMAP), &bm );
return ( TRUE );
#if 0
#ifdef __NT__
case WM_CTLCOLORSTATIC:
if ( brush ) {
dc = (HDC) wParam;
SetBkColor ( dc, color );
return ( (LRESULT) brush );
}
break;
#else
case WM_CTLCOLOR:
if ( brush ) {
dc = (HDC) wParam;
if ( HIWORD(lParam) == CTLCOLOR_STATIC ) {
SetBkColor ( dc, color );
}
return ( (LRESULT) brush );
}
break;
#endif
case WM_ERASEBKGND:
if ( brush ) {
GetClientRect( hDlg, &rect );
UnrealizeObject( brush );
FillRect( (HDC)wParam, &rect, brush );
return ( TRUE );
}
break;
#endif
case WM_PAINT:
dc = BeginPaint ( hDlg, &ps );
if ( dc ) {
w666 = GetDlgItem ( hDlg, 666 );
GetClientRect ( w666, &rect );
GetClientRect ( hDlg, &arect );
start = ( arect.right - arect.left - bm.bmWidth ) / 2;
MapWindowPoints ( w666, hDlg, (POINT *) &rect, 2 );
tdc = CreateCompatibleDC ( dc );
old = SelectObject ( tdc, logo );
BitBlt ( dc, start, rect.top + 20, bm.bmWidth, bm.bmHeight,
tdc, 0, 0, SRCCOPY );
SelectObject ( tdc, old );
DeleteDC ( tdc );
EndPaint ( hDlg, &ps );
}
break;
case WM_TIMER:
timer = (UINT) GetWindowLong ( hDlg, DWL_USER );
if ( timer ) {
KillTimer ( hDlg, timer );
}
EndDialog ( hDlg, TRUE );
return ( TRUE );
break;
case WM_COMMAND:
w = LOWORD(wParam);
if ( ( w == IDOK ) || ( w == IDCANCEL ) ) {
timer = (UINT) GetWindowLong ( hDlg, DWL_USER );
if ( timer ) {
KillTimer ( hDlg, timer );
}
EndDialog(hDlg, TRUE);
return ( TRUE );
}
break;
}
return ( FALSE );
}
Bool WCleanup ( WAccelEditInfo *einfo )
{
HWND owner;
Bool ok;
ok = ( einfo != NULL );
if ( ok ) {
owner = (HWND)NULL;
if( !einfo->info->stand_alone ) {
owner = GetWindow( einfo->win, GW_OWNER );
}
einfo->getting_key = FALSE;
einfo->win = (HWND)NULL;
WFreeAccelEInfo ( einfo );
if( owner != (HWND)NULL ) {
BringWindowToTop( owner );
}
}
return ( ok );
}
void CALLBACK WAccHelpRoutine( void )
{
WAccelEditInfo *einfo;
einfo = WGetCurrentEditInfo();
if( einfo ) {
WWinHelp( einfo->win, "resacc.hlp", HELP_CONTENTS, 0 );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -