void TrayIcon::RestoreWindowFromTray(bool abIconOnly /*= false*/, bool abDontCallShowWindow /*= false*/) { if (!abIconOnly) { gpConEmu->SetWindowMode(gpConEmu->GetWindowMode()); if (!abDontCallShowWindow && !IsWindowVisible(ghWnd)) { gpConEmu->ShowWindow(SW_SHOW); } apiSetForegroundWindow(ghWnd); } if (IsWindowVisible(ghWnd)) { //EnableMenuItem(GetSystemMenu(ghWnd, false), ID_TOTRAY, MF_BYCOMMAND | MF_ENABLED); HMENU hMenu = gpConEmu->mp_Menu->GetSysMenu(/*ghWnd, false*/); SetMenuItemText(hMenu, ID_TOTRAY, TRAY_ITEM_HIDE_NAME); } //for (int i = 0; i < countof(mn_SysItemId); i++) //{ // EnableMenuItem(hMenu, mn_SysItemId[i], MF_BYCOMMAND | mn_SysItemState[i]); //} if (!gpSet->isAlwaysShowTrayIcon) RemoveTrayIcon(); else UpdateTitle(); }
// Открыть диалог со списком окон/процессов, к которым мы можем подцепиться void CAttachDlg::AttachDlg() { if (!this) { _ASSERTE(this); return; } if (mh_Dlg && IsWindow(mh_Dlg)) { ShowWindow(mh_Dlg, SW_SHOWNORMAL); apiSetForegroundWindow(mh_Dlg); return; } if (!mp_DpiAware) mp_DpiAware = new CDpiForDialog(); bool bPrev = gpConEmu->SetSkipOnFocus(true); // (CreateDialog) SafeFree(mp_Dlg); mp_Dlg = CDynDialog::ShowDialog(IDD_ATTACHDLG, NULL, AttachDlgProc, (LPARAM)this); mh_Dlg = mp_Dlg ? mp_Dlg->mh_Dlg : NULL; gpConEmu->SetSkipOnFocus(bPrev); }
// Открыть диалог со списком окон/процессов, к которым мы можем подцепиться void CAttachDlg::AttachDlg() { if (!this) { _ASSERTE(this); return; } if (mh_Dlg && IsWindow(mh_Dlg)) { ShowWindow(mh_Dlg, SW_SHOWNORMAL); apiSetForegroundWindow(mh_Dlg); return; } bool bPrev = gpConEmu->SetSkipOnFocus(true); mh_Dlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ATTACHDLG), NULL, AttachDlgProc, (LPARAM)this); gpConEmu->SetSkipOnFocus(bPrev); //DWORD_PTR nAttachParm[3] = {}; //int nRc = DialogBoxParam(nAttachParm); //switch (nRc) //{ //case IDC_NEWCONSOLE: // Recreate(FALSE, gpSet->isMultiNewConfirm); // break; //case IDOK: // // [0] Type: 1 - console, 2 - GUI // // [1] PID // // [2] HWND (для GUI) // _ASSERTE((nAttachParm[0] == 1 || nAttachParm[0] == 2) && (nAttachParm[1]) && (nAttachParm[2] || nAttachParm[0] == 1)); // TODO("Ну и сам аттач, собственно"); // break; //} }
bool CConEmuCtrl::key_ShowCaption(const ConEmuChord& VkState, bool TestOnly, const ConEmuHotKey* hk, CRealConsole* pRCon) { if (TestOnly) return true; gpSet->SwitchHideCaptionAlways(); gpConEmu->OnHideCaption(); if (ghOpWnd) { if (gpSetCls->GetPage(CSettings::thi_Ext)) CheckDlgButton(gpSetCls->GetPage(CSettings::thi_Ext), cbHideCaptionAlways, gpSet->isHideCaptionAlways()); apiSetForegroundWindow(ghOpWnd); } return true; }
bool CConEmuCtrl::key_ShowCaption(DWORD VkMod, bool TestOnly, const ConEmuHotKey* hk, CRealConsole* pRCon) { if (TestOnly) return true; gpSet->SwitchHideCaptionAlways(); gpConEmu->OnHideCaption(); if (ghOpWnd) { if (gpSetCls->mh_Tabs[CSettings::thi_Ext]) CheckDlgButton(gpSetCls->mh_Tabs[CSettings::thi_Ext], cbHideCaptionAlways, gpSet->isHideCaptionAlways()); apiSetForegroundWindow(ghOpWnd); } return true; }
LRESULT TrayIcon::OnTryIcon(HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam) { #ifdef _DEBUG wchar_t szMsg[128]; #endif switch (lParam) { case WM_LBUTTONUP: case NIN_BALLOONUSERCLICK: #ifdef _DEBUG _wsprintf(szMsg, SKIPLEN(countof(szMsg)) (lParam==WM_LBUTTONUP) ? L"TSA: WM_LBUTTONUP(%i,0x%08X)\n" : L"TSA: NIN_BALLOONUSERCLICK(%i,0x%08X)\n", (int)wParam, (DWORD)lParam); DEBUGSTRICON(szMsg); #endif if (gpSet->isQuakeStyle) { SingleInstanceShowHideType sih = sih_ShowHideTSA; if (IsWindowVisible(ghWnd)) { if (gpSet->isAlwaysOnTop || (gpSet->isQuakeStyle == 2)) { sih = sih_HideTSA; } else { // Хм. Тут проблема. Если поверх ConEmu есть какое-то окно, то ConEmu нужно поднять? } } gpConEmu->OnMinimizeRestore(sih); } else if (gpSet->isAlwaysShowTrayIcon && IsWindowVisible(ghWnd)) { if (gpSet->isMinToTray()) Icon.HideWindowToTray(); else SendMessage(ghWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); } else { Icon.RestoreWindowFromTray(); } if (m_MsgSource == tsa_Source_Updater) { m_MsgSource = tsa_Source_None; gpConEmu->CheckUpdates(2); } break; case NIN_BALLOONSHOW: #ifdef _DEBUG _wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"TSA: NIN_BALLOONSHOW(%i,0x%08X)\n", (int)wParam, (DWORD)lParam); DEBUGSTRICON(szMsg); #endif mn_BalloonShowTick = GetTickCount(); break; case NIN_BALLOONTIMEOUT: { #ifdef _DEBUG _wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"TSA: NIN_BALLOONTIMEOUT(%i,0x%08X)\n", (int)wParam, (DWORD)lParam); DEBUGSTRICON(szMsg); #endif if (mb_SecondTimeoutMsg || (mn_BalloonShowTick && ((GetTickCount() - mn_BalloonShowTick) > MY_BALLOON_TICK))) { m_MsgSource = tsa_Source_None; Icon.RestoreWindowFromTray(TRUE); } else if (!mb_SecondTimeoutMsg && (mn_BalloonShowTick && ((GetTickCount() - mn_BalloonShowTick) > MY_BALLOON_TICK))) { mb_SecondTimeoutMsg = true; } } break; case WM_RBUTTONUP: { #ifdef _DEBUG _wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"TSA: WM_RBUTTONUP(%i,0x%08X)\n", (int)wParam, (DWORD)lParam); DEBUGSTRICON(szMsg); #endif POINT mPos; GetCursorPos(&mPos); apiSetForegroundWindow(ghWnd); gpConEmu->mp_Menu->ShowSysmenu(mPos.x, mPos.y); PostMessage(hWnd, WM_NULL, 0, 0); } break; #ifdef _DEBUG default: _wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"TSA: OnTryIcon(uMsg, wParam=%i, lParam=0x%04X)\n", messg, (int)wParam, (DWORD)lParam); DEBUGSTRICON(szMsg); #endif } return 0; }
LRESULT TrayIcon::OnTryIcon(HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam) { #ifdef _DEBUG wchar_t szMsg[128]; #endif switch (lParam) { case WM_LBUTTONUP: case NIN_BALLOONUSERCLICK: #ifdef _DEBUG _wsprintf(szMsg, SKIPLEN(countof(szMsg)) (lParam==WM_LBUTTONUP) ? L"TSA: WM_LBUTTONUP(%i,0x%08X)\n" : L"TSA: NIN_BALLOONUSERCLICK(%i,0x%08X)\n", (int)wParam, (DWORD)lParam); DEBUGSTRICON(szMsg); #endif if (gpSet->isQuakeStyle) { bool bJustActivate = false; SingleInstanceShowHideType sih = sih_QuakeShowHide; SingleInstanceShowHideType sihHide = gpSet->isMinToTray() ? sih_HideTSA : sih_Minimize; if (IsWindowVisible(ghWnd) && !gpConEmu->isIconic()) { if (gpSet->isAlwaysOnTop || (gpSet->isQuakeStyle == 2)) { sih = sihHide; } else { UINT nVisiblePart = gpConEmu->IsQuakeVisible(); if (nVisiblePart >= QUAKEVISIBLELIMIT) { sih = sihHide; } else { // Если поверх ConEmu есть какое-то окно, то ConEmu нужно поднять? // Не "выезжать" а просто "вынести наверх", если видимая область достаточно большая bJustActivate = (nVisiblePart >= QUAKEVISIBLETRASH) && !gpConEmu->isIconic(); } } } if (bJustActivate) { SetForegroundWindow(ghWnd); } else { gpConEmu->DoMinimizeRestore(sih); } } else if (gpSet->isAlwaysShowTrayIcon() && IsWindowVisible(ghWnd)) { if (gpSet->isMinToTray()) Icon.HideWindowToTray(); else SendMessage(ghWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); } else { Icon.RestoreWindowFromTray(); } switch (m_MsgSource) { case tsa_Source_Updater: m_MsgSource = tsa_Source_None; gpConEmu->CheckUpdates(2); break; case tsa_Push_Notify: gpConEmu->mp_PushInfo->OnNotificationClick(); m_MsgSource = tsa_Source_None; break; } break; case NIN_BALLOONSHOW: #ifdef _DEBUG _wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"TSA: NIN_BALLOONSHOW(%i,0x%08X)\n", (int)wParam, (DWORD)lParam); DEBUGSTRICON(szMsg); #endif mn_BalloonShowTick = GetTickCount(); break; case NIN_BALLOONTIMEOUT: { #ifdef _DEBUG _wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"TSA: NIN_BALLOONTIMEOUT(%i,0x%08X)\n", (int)wParam, (DWORD)lParam); DEBUGSTRICON(szMsg); #endif if (mb_SecondTimeoutMsg || (mn_BalloonShowTick && ((GetTickCount() - mn_BalloonShowTick) > MY_BALLOON_TICK))) { m_MsgSource = tsa_Source_None; Icon.RestoreWindowFromTray(TRUE); } else if (!mb_SecondTimeoutMsg && (mn_BalloonShowTick && ((GetTickCount() - mn_BalloonShowTick) > MY_BALLOON_TICK))) { mb_SecondTimeoutMsg = true; } } break; case WM_RBUTTONUP: { #ifdef _DEBUG _wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"TSA: WM_RBUTTONUP(%i,0x%08X)\n", (int)wParam, (DWORD)lParam); DEBUGSTRICON(szMsg); #endif POINT mPos; GetCursorPos(&mPos); gpConEmu->SetIgnoreQuakeActivation(true); apiSetForegroundWindow(ghWnd); LogString(L"ShowSysmenu called from (TSA)"); gpConEmu->mp_Menu->ShowSysmenu(mPos.x, mPos.y); gpConEmu->SetIgnoreQuakeActivation(false); PostMessage(hWnd, WM_NULL, 0, 0); } break; #ifdef _DEBUG default: _wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"TSA: OnTryIcon(uMsg, wParam=%i, lParam=0x%04X)\n", messg, (int)wParam, (DWORD)lParam); DEBUGSTRICON(szMsg); #endif } return 0; }