📄 wedit.c
字号:
}
if( ok ) {
entry = (WMenuEntry *)
SendMessage ( lbox, LB_GETITEMDATA, (WPARAM) index, 0 );
ok = ( entry != NULL );
}
if( ok ) {
ok = WMakeClipDataFromMenuEntry( entry, &data, &dsize );
}
if( ok ) {
ok = WCopyClipData( einfo->win, WItemClipbdFormat, data, dsize );
}
if( ok ) {
if( cut ) {
ok = WDeleteMenuEntry( einfo );
}
}
if( data != NULL ) {
WMemFree( data );
}
return( ok );
}
static Bool WQueryChangeEntry( WMenuEditInfo *einfo )
{
int ret;
UINT style;
char *title;
char *text;
style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION;
title = WCreateEditTitle( einfo );
text = WAllocRCString( W_CHANGEMODIFIEDMENUITEM );
ret = MessageBox( einfo->edit_dlg, text, title, style );
if( text ) {
WFreeRCString( text );
}
if( title ) {
WMemFree( title );
}
if( ret == IDYES ) {
return( TRUE );
}
return( FALSE );
}
void WDoHandleSelChange( WMenuEditInfo *einfo, Bool change, Bool reset )
{
HWND lbox;
LRESULT index;
WMenuEntry *entry;
Bool reinit;
Bool mod;
if( !einfo ) {
return;
}
reinit = FALSE;
lbox = GetDlgItem( einfo->edit_dlg, IDM_MENUEDLIST );
if( lbox == (HWND) NULL ) {
return;
}
index = SendMessage( lbox, LB_GETCURSEL, 0, 0 );
if( index != LB_ERR ) {
entry = (WMenuEntry *)
SendMessage( lbox, LB_GETITEMDATA, (WPARAM) index, 0 );
} else {
entry = NULL;
}
if( einfo->current_entry && !reset ) {
mod = WGetEditWindowMenuEntry( einfo, einfo->current_entry, TRUE, NULL );
if( mod && ( einfo->current_pos != -1 ) ) {
if( change || WQueryChangeEntry( einfo ) ) {
WGetEditWindowMenuEntry( einfo, einfo->current_entry, FALSE, &reinit );
einfo->info->modified = TRUE;
if( reinit ) {
WInitEditWindowListBox( einfo );
} else {
SendMessage( lbox, LB_DELETESTRING, einfo->current_pos, 0 );
WAddEditWinLBoxEntry( lbox, einfo->current_entry,
einfo->current_pos );
WModifyEntryInPreview( einfo, einfo->current_entry );
}
}
}
}
WSetEditWindowControls( einfo, entry );
if( entry ) {
if( !change || reinit ) {
WSetEditWindowMenuEntry( einfo, entry );
} else {
uint_16 id;
Bool pop_sep;
MenuFlags flags;
if( entry->item->IsPopup ) {
flags = entry->item->Item.Popup.ItemFlags;
} else {
flags = entry->item->Item.Normal.ItemFlags;
id = entry->item->Item.Normal.ItemID;
}
pop_sep = ( entry->item->IsPopup || ( flags & MENU_SEPARATOR ) );
WSetEditWindowID( einfo->edit_dlg, id, pop_sep, entry->symbol );
}
}
einfo->current_entry = entry;
einfo->current_pos = (index == LB_ERR) ? -1 : index;
if( index != LB_ERR ) {
SendMessage( lbox, LB_SETCURSEL, (WPARAM) index, 0 );
}
}
void WHandleSelChange( WMenuEditInfo *einfo )
{
WDoHandleSelChange( einfo, FALSE, FALSE );
}
static Bool WShiftEntry( WMenuEditInfo *einfo, Bool left )
{
WMenuEntry *prev;
WMenuEntry *parent;
WMenuEntry *entry;
LRESULT ret;
HWND lbox;
Bool entry_removed;
Bool ok;
entry_removed = FALSE;
ok = ( einfo && einfo->edit_dlg );
if( ok ) {
lbox = GetDlgItem( einfo->edit_dlg, IDM_MENUEDLIST );
ok = ( lbox != NULL );
}
if( ok ) {
ret = SendMessage( lbox, LB_GETCURSEL, 0, 0 );
ok = ( ret != LB_ERR );
}
if( ok ) {
entry = (WMenuEntry *)
SendMessage( lbox, LB_GETITEMDATA, (WPARAM)ret, 0 );
ok = ( entry != NULL );
}
if( ok ) {
parent = entry->parent;
prev = entry->prev;
ok = WRemoveMenuEntry( einfo->menu, entry );
if( ok ) {
entry_removed = TRUE;
}
}
if( ok ) {
if( left ) {
ok = WInsertEntryIntoMenu( einfo, parent, parent->parent,
entry, FALSE );
} else {
if( prev->child != NULL ) {
parent = prev;
for( prev=parent->child; prev && prev->next; prev=prev->next );
ok = WInsertEntryIntoMenu( einfo, prev, parent, entry, FALSE );
} else {
ok = WInsertEntryIntoMenu( einfo, prev, parent, entry, TRUE );
}
}
}
if( ok ) {
ok = WInitEditWindowListBox( einfo );
}
if( ok ) {
einfo->info->modified = TRUE;
einfo->current_entry = NULL;
einfo->current_pos = -1;
ret = SendMessage ( lbox, LB_SETCURSEL, (WPARAM)ret, 0 );
ok = ( ret != LB_ERR );
if ( ok ) {
WHandleSelChange ( einfo );
}
}
if( !ok ) {
if( entry_removed ) {
WFreeMenuEntries ( entry->child );
WFreeMenuEntry ( entry );
WInitEditWindowListBox( einfo );
}
}
return( ok );
}
LRESULT WINEXPORT WMenuEditProc ( HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam )
{
WMenuEditInfo *einfo;
HWND win;
RECT r;
POINT p;
LRESULT ret;
WORD wp, cmd;
ret = FALSE;
einfo = (WMenuEditInfo *) GetWindowLong ( hDlg, DWL_USER );
switch ( message ) {
case WM_INITDIALOG:
einfo = (WMenuEditInfo *) lParam;
einfo->edit_dlg = hDlg;
SetWindowLong ( hDlg, DWL_USER, (LONG) einfo );
WRAddSymbolsToComboBox( einfo->info->symbol_table, hDlg,
IDM_MENUEDID, WR_HASHENTRY_ALL );
ret = TRUE;
break;
case WM_SYSCOLORCHANGE:
WCtl3dColorChange ();
break;
#if 0
#ifdef __NT__
case WM_CTLCOLORBTN:
case WM_CTLCOLORDLG:
case WM_CTLCOLOREDIT:
case WM_CTLCOLORLISTBOX:
case WM_CTLCOLORMSGBOX:
case WM_CTLCOLORSCROLLBAR:
case WM_CTLCOLORSTATIC:
#else
case WM_CTLCOLOR:
#endif
return( (LRESULT)WCtl3dCtlColorEx( message, wParam, lParam ) );
#endif
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
case WM_RBUTTONUP:
MAKE_POINT( p, lParam );
win = GetDlgItem ( hDlg, IDM_MENUEDRNAME );
GetWindowRect( win, &r );
MapWindowPoints( HWND_DESKTOP, hDlg, (POINT *)&r, 2 );
if( PtInRect( &r, p ) ) {
WHandleRename( einfo );
}
ret = TRUE;
break;
case WM_SETFOCUS:
if( einfo && ( einfo->preview_window != (HWND)NULL ) ) {
SendMessage( einfo->preview_window, WM_NCACTIVATE, (WPARAM)TRUE, (LPARAM)NULL );
}
break;
#if 0
case WM_PARENTNOTIFY:
cmd = GET_WM_PARENTNOTIFY_EVENT(wParam,lParam);
switch( cmd ) {
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
MAKE_POINT( p, lParam );
win = GetDlgItem ( hDlg, IDM_MENUEDLIST );
GetClientRect( win, &r );
MapWindowPoints( win, hDlg, (POINT *)&r, 2 );
if( PtInRect( &r, p ) ) {
WHandleSelChange( einfo );
}
break;
}
ret = TRUE;
break;
#endif
case WM_COMMAND:
wp = LOWORD(wParam);
cmd = GET_WM_COMMAND_CMD(wParam,lParam);
switch ( wp ) {
case IDM_MENUEDGRAYED:
if ( IsDlgButtonChecked(hDlg, wp) ) {
CheckDlgButton(hDlg, IDM_MENUEDINACTIVE, 0);
}
break;
case IDM_MENUEDINACTIVE:
if( IsDlgButtonChecked(hDlg, wp) ) {
CheckDlgButton(hDlg, IDM_MENUEDGRAYED, 0);
}
break;
#if 0
case IDM_MENUEDID:
if( cmd == CBN_SELCHANGE ) {
einfo->combo_change = TRUE;
WHandleSelChange( einfo );
einfo->combo_change = FALSE;
}
break;
#endif
case IDM_MENUEDINSERT:
WInsertNew( einfo );
break;
case IDM_MENUEDCHANGE:
WDoHandleSelChange( einfo, TRUE, FALSE );
break;
case IDM_MENUEDRESET:
WDoHandleSelChange( einfo, FALSE, TRUE );
break;
case IDM_MENUEDSHIFTLEFT:
WShiftEntry( einfo, TRUE );
break;
case IDM_MENUEDSHIFTRIGHT:
WShiftEntry( einfo, FALSE );
break;
case IDM_MENUEDLIST:
if( cmd == LBN_SELCHANGE ) {
WHandleSelChange( einfo );
}
break;
case IDM_MENUEDSETMENU:
if( einfo->menu && einfo->menu->first_entry ) {
WHandleSelChange( einfo );
} else {
WInsertNew( einfo );
}
break;
}
break;
}
return ( ret );
}
LRESULT WINEXPORT WTestProc( HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam )
{
RECT r;
_wtouch(wParam);
_wtouch(lParam);
if( message == WM_INITDIALOG ) {
GetWindowRect( hDlg, &r );
appWidth = r.right - r.left + 10;
appHeight = r.bottom - r.top + 85;
DestroyWindow( hDlg );
return( TRUE );
}
return( FALSE );
}
void WInitEditDlg( HINSTANCE inst, HWND parent )
{
FARPROC lpProc;
lpProc = MakeProcInstance( (FARPROC) WTestProc, inst );
JCreateDialog( inst, "WMenuEditDLG", parent, (DLGPROC) lpProc );
FreeProcInstance( lpProc );
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -