intptr_t ExcDlgProc(Dialog* Dlg,intptr_t Msg,intptr_t Param1,void* Param2) { switch (Msg) { case DN_CTLCOLORDLGITEM: { FarDialogItem di; Dlg->SendMessage(DM_GETDLGITEMSHORT,Param1,&di); if (di.Type==DI_EDIT) { auto Color = colors::PaletteColorToFarColor(COL_WARNDIALOGTEXT); auto Colors = static_cast<FarDialogItemColors*>(Param2); Colors->Colors[0] = Color; Colors->Colors[2] = Color; } } break; case DN_CONTROLINPUT: { const INPUT_RECORD* record=(const INPUT_RECORD *)Param2; if (record->EventType==KEY_EVENT) { int key = InputRecordToKey(record); if (Param1==10 && (key==KEY_LEFT || key == KEY_NUMPAD4 || key==KEY_SHIFTTAB)) { Dlg->SendMessage(DM_SETFOCUS,12,0); return TRUE; } else if (Param1==12 && (key==KEY_RIGHT || key == KEY_NUMPAD6 || key==KEY_TAB)) { Dlg->SendMessage(DM_SETFOCUS,10,0); return TRUE; } } } break; case DN_CLOSE: { if (Param1 == 11) // debug { // It's better to attach debugger ASAP, closing the dialog causes too much work in window manager attach_debugger(); return FALSE; } } break; default: break; } return Dlg->DefProc(Msg,Param1,Param2); }
intptr_t VMenu2::Run(const std::function<int(int Key)>& fn) { if(!fn) return RunEx(nullptr); return RunEx([&](int Msg, void *param)->int { int key=KEY_NONE; if(Msg==DN_INPUT) { auto ir = static_cast<INPUT_RECORD*>(param); key=ir->EventType==WINDOW_BUFFER_SIZE_EVENT ? KEY_CONSOLE_BUFFER_RESIZE : InputRecordToKey(ir); } return fn(key); }); }
INT_PTR WINAPI ExcDlgProc(HANDLE hDlg,int Msg,int Param1,void* Param2) { switch (Msg) { case DN_CTLCOLORDLGITEM: { FarDialogItem di; SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,Param1,&di); if (di.Type==DI_EDIT) { FarColor Color=ColorIndexToColor(COL_WARNDIALOGTEXT); FarDialogItemColors* Colors = static_cast<FarDialogItemColors*>(Param2); Colors->Colors[0] = Color; Colors->Colors[2] = Color; } } break; case DN_CONTROLINPUT: { const INPUT_RECORD* record=(const INPUT_RECORD *)Param2; if (record->EventType==KEY_EVENT) { int key = InputRecordToKey(record); if (Param1==10 && (key==KEY_LEFT || key == KEY_NUMPAD4 || key==KEY_SHIFTTAB)) { SendDlgMessage(hDlg,DM_SETFOCUS,11,0); return TRUE; } else if (Param1==11 && (key==KEY_RIGHT || key == KEY_NUMPAD6 || key==KEY_TAB)) { SendDlgMessage(hDlg,DM_SETFOCUS,10,0); return TRUE; } } } break; default: break; } return DefDlgProc(hDlg,Msg,Param1,Param2); }
intptr_t VMenu2::VMenu2DlgProc(Dialog* Dlg, intptr_t Msg, intptr_t Param1, void* Param2) { _DIALOG(CleverSysLog CL(L"VMenu2::VMenu2DlgProc()")); _DIALOG(SysLog(L"hDlg=%p, Msg=%s, Param1=%d (0x%08X), Param2=%d (0x%08X)",Dlg,_DLGMSG_ToName(Msg),Param1,Param1,Param2,Param2)); switch(Msg) { case DN_CTLCOLORDIALOG: { FarColor *color=(FarColor*)Param2; *color=colors::PaletteColorToFarColor(COL_MENUBOX); return true; } case DN_CTLCOLORDLGLIST: { FarDialogItemColors *colors=(FarDialogItemColors*)Param2; PaletteColors MenuColors[]= { COL_MENUBOX, // подложка COL_MENUBOX, // рамка COL_MENUTITLE, // заголовок - верхний и нижний COL_MENUTEXT, // Текст пункта COL_MENUHIGHLIGHT, // HotKey COL_MENUBOX, // separator COL_MENUSELECTEDTEXT, // Выбранный COL_MENUSELECTEDHIGHLIGHT, // Выбранный - HotKey COL_MENUSCROLLBAR, // ScrollBar COL_MENUDISABLEDTEXT, // Disabled COL_MENUARROWS, // Arrow COL_MENUARROWSSELECTED, // Выбранный - Arrow COL_MENUARROWSDISABLED, // Arrow Disabled COL_MENUGRAYTEXT, // "серый" COL_MENUSELECTEDGRAYTEXT, // выбранный "серый" }; for(size_t i=0; i<colors->ColorsCount && i<ARRAYSIZE(MenuColors); ++i) colors->Colors[i]=colors::PaletteColorToFarColor(MenuColors[i]); return true; } case DN_CLOSE: if(!ForceClosing && !Param1 && GetItemFlags() & (LIF_GRAYED|LIF_DISABLE)) return false; if(Call(Msg, (void*)(Param1<0 ? Param1 : GetSelectPos()))) return false; break; case DN_LISTHOTKEY: if (!Call(Msg, Param2)) Dlg->SendMessage( DM_CLOSE, -1, nullptr); break; case DN_DRAWDLGITEMDONE: //??? case DN_DRAWDIALOGDONE: if(DefRec.EventType) { INPUT_RECORD rec=DefRec; ClearStruct(DefRec); if(!Call(DN_INPUT, &rec)) Dlg->SendMessage( DM_KEY, 1, &rec); } break; case DN_CONTROLINPUT: case DN_INPUT: if(!cancel) { if (Msg==DN_CONTROLINPUT) { auto ir = static_cast<INPUT_RECORD*>(Param2); int key=InputRecordToKey(ir); if(ListBox().ProcessFilterKey(key)) return true; } if(Call(DN_INPUT, Param2)) return Msg==DN_CONTROLINPUT; } break; case DN_LISTCHANGE: case DN_ENTERIDLE: if(!cancel) { if(Call(Msg, Param2)) return false; } break; case DN_RESIZECONSOLE: if(!cancel) { INPUT_RECORD ReadRec={WINDOW_BUFFER_SIZE_EVENT}; ReadRec.Event.WindowBufferSizeEvent.dwSize=*(COORD*)Param2; if(Call(DN_INPUT, &ReadRec)) return false; else Resize(); } break; default: if(Global->CloseFARMenu) ProcessKey(Manager::Key(KEY_ESC)); break; } return Dlg->DefProc(Msg, Param1, Param2); }
intptr_t WINAPI MsgDlgProc(HANDLE hDlg,intptr_t Msg,intptr_t Param1,void* Param2) { switch (Msg) { case DN_INITDIALOG: { FarDialogItem di; for (int i=0; SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,i,&di); i++) { if (di.Type==DI_EDIT) { COORD pos={}; SendDlgMessage(hDlg,DM_SETCURSORPOS,i,&pos); } } } break; case DN_CTLCOLORDLGITEM: { FarDialogItem di; SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,Param1,&di); if (di.Type==DI_EDIT) { FarColor Color=ColorIndexToColor(IsWarningStyle?COL_WARNDIALOGTEXT:COL_DIALOGTEXT); FarDialogItemColors* Colors = static_cast<FarDialogItemColors*>(Param2); Colors->Colors[0] = Color; Colors->Colors[2] = Color; } } break; case DN_CONTROLINPUT: { const INPUT_RECORD* record=(const INPUT_RECORD *)Param2; if (record->EventType==KEY_EVENT) { int key = InputRecordToKey(record); switch(key) { case KEY_F3: if(IsErrorType) { string Txt[2]; GetWin32ErrorString(LastError, Txt[0]); GetNtErrorString(NtStatus, Txt[1]); DialogBuilder Builder(MError, nullptr); Builder.AddConstEditField(FormatString() << L"LastError: 0x" << fmt::MinWidth(8) << fmt::FillChar(L'0') << fmt::Radix(16) << LastError << L" - " << Txt[0], 65); Builder.AddConstEditField(FormatString() << L"NTSTATUS: 0x" << fmt::MinWidth(8) << fmt::FillChar(L'0') << fmt::Radix(16) << NtStatus << L" - " << Txt[1], 65); Builder.AddOK(); Builder.ShowDialog(); } break; case KEY_TAB: case KEY_RIGHT: case KEY_NUMPAD6: if(Param1==LastButtonIndex) { SendDlgMessage(hDlg,DM_SETFOCUS,FirstButtonIndex,0); return TRUE; } break; case KEY_SHIFTTAB: case KEY_LEFT: case KEY_NUMPAD4: if(Param1==FirstButtonIndex) { SendDlgMessage(hDlg,DM_SETFOCUS,LastButtonIndex,0); return TRUE; } break; case KEY_CTRLC: case KEY_RCTRLC: case KEY_CTRLINS: case KEY_RCTRLINS: case KEY_CTRLNUMPAD0: case KEY_RCTRLNUMPAD0: { string* strText = reinterpret_cast<string*>(SendDlgMessage(hDlg, DM_GETDLGDATA, 0, 0)); CopyToClipboard(*strText); } break; } } } break; default: break; } return DefDlgProc(hDlg,Msg,Param1,Param2); }
void HMenu::ProcessSubMenu(MenuDataEx *Data,int DataCount, const wchar_t *SubMenuHelp,int X,int Y,int &Position) { Position=-1; SubMenu=new VMenu2(L"",Data,DataCount); SubMenu->SetBoxType(SHORT_DOUBLE_BOX); SubMenu->SetFlags(VMENU_WRAPMODE); SubMenu->SetHelp(SubMenuHelp); SubMenu->SetPosition(X,Y,0,0); SubMenu->SetMacroMode(MACRO_MAINMENU); bool SendMouse=false; MOUSE_EVENT_RECORD MouseEvent; int SendKey=0; Position=SubMenu->RunEx([&](int Msg, void *param)->int { if(Msg!=DN_INPUT) return 0; INPUT_RECORD &rec=*static_cast<INPUT_RECORD*>(param); int Key=InputRecordToKey(&rec); if (Key==KEY_CONSOLE_BUFFER_RESIZE) { LockScreen LckScr; ResizeConsole(); Show(); return 1; } else if (rec.EventType==MOUSE_EVENT) { if (!TestMouse(&rec.Event.MouseEvent)) { MouseEvent=rec.Event.MouseEvent; SendMouse=true; SubMenu->Close(-1); return 1; } if (rec.Event.MouseEvent.dwMousePosition.Y==Y1) return 1; } else { if (Key == KEY_LEFT || Key == KEY_RIGHT ||Key == KEY_TAB || Key == KEY_NUMPAD4 || Key == KEY_NUMPAD6 || Key == KEY_MSWHEEL_LEFT || Key == KEY_MSWHEEL_RIGHT) { SendKey=Key; SubMenu->Close(-1); return 1; } } return 0; }); delete SubMenu; SubMenu=nullptr; if(SendMouse) ProcessMouse(&MouseEvent); if(SendKey) { ProcessKey(SendKey); ProcessKey(KEY_ENTER); } }