Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Console/Console.rc
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ BEGIN
LTEXT "Key col&or:",IDC_STATIC_KEY_COLOR,19,245,33,8
CONTROL "",IDC_KEY_COLOR,"Static",SS_BLACKFRAME | SS_NOTIFY,54,242,16,14,WS_EX_DLGMODALFRAME
GROUPBOX "Window transparency",IDC_STATIC,0,111,226,154
CONTROL "Hide on Close",IDC_CHECK_STYLE_HIDE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,35,59,10
END

IDD_SETTINGS_TEMP DIALOGEX 0, 0, 611, 555
Expand Down
1 change: 1 addition & 0 deletions Console/DlgSettingsStyles.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class DlgSettingsStyles
DDX_CHECK(IDC_CHECK_STYLE_BORDER, m_stylesSettings.bBorder)
DDX_CHECK(IDC_CHECK_STYLE_TASKBAR, m_stylesSettings.bTaskbarButton)
DDX_CHECK(IDC_CHECK_STYLE_TRAY, m_stylesSettings.bTrayIcon)
DDX_CHECK(IDC_CHECK_STYLE_HIDE, m_stylesSettings.bHideOnClose)
DDX_UINT(IDC_INSIDE_BORDER, m_stylesSettings.dwInsideBorder)
DDX_RADIO(IDC_TRANSPARENCY_TYPE, reinterpret_cast<int&>(m_transparencySettings.transType))
END_DDX_MAP()
Expand Down
99 changes: 59 additions & 40 deletions Console/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,48 +415,17 @@ LRESULT MainFrame::OnEraseBkgnd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPara

LRESULT MainFrame::OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
// save settings on exit
bool bSaveSettings = false;
ConsoleSettings& consoleSettings = g_settingsHandler->GetConsoleSettings();
PositionSettings& positionSettings = g_settingsHandler->GetAppearanceSettings().positionSettings;

if (consoleSettings.bSaveSize)
{
consoleSettings.dwRows = m_dwRows;
consoleSettings.dwColumns = m_dwColumns;

bSaveSettings = true;
}

if (positionSettings.bSavePosition)
{
CRect rectWindow;

GetWindowRect(rectWindow);

positionSettings.nX = rectWindow.left;
positionSettings.nY = rectWindow.top;

bSaveSettings = true;
}

if (bSaveSettings) g_settingsHandler->SaveSettings();
StylesSettings& stylesSettings = g_settingsHandler->GetAppearanceSettings().stylesSettings;

// destroy all views
MutexLock viewMapLock(m_viewsMutex);
for (ConsoleViewMap::iterator it = m_views.begin(); it != m_views.end(); ++it)
if (stylesSettings.bHideOnClose)
{
RemoveTab(it->second->m_hWnd);
if (m_activeView.get() == it->second.get()) m_activeView.reset();
it->second->DestroyWindow();
ShowWindow(SW_HIDE);
return 0;
}

if (g_settingsHandler->GetAppearanceSettings().stylesSettings.bTrayIcon) SetTrayIcon(NIM_DELETE);
BOOL handled;

UnregisterGlobalHotkeys();

DestroyWindow();
PostQuitMessage(0);
OnFileExit(0, 0, m_hWnd, handled);
return 0;
}

Expand Down Expand Up @@ -566,8 +535,16 @@ LRESULT MainFrame::OnHotKey(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOO
{
case IDC_GLOBAL_ACTIVATE :
{
ShowWindow(SW_RESTORE);
PostMessage(WM_ACTIVATEAPP, TRUE, 0);
if (IsWindowVisible())
{
ShowWindow(SW_HIDE);
PostMessage(WM_ACTIVATEAPP, FALSE, 0);
}
else
{
ShowWindow(SW_RESTORE);
PostMessage(WM_ACTIVATEAPP, TRUE, 0);
}

POINT cursorPos;
CRect windowRect;
Expand Down Expand Up @@ -1369,7 +1346,49 @@ LRESULT MainFrame::OnPrevTab(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*

LRESULT MainFrame::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
PostMessage(WM_CLOSE);
// save settings on exit
bool bSaveSettings = false;
ConsoleSettings& consoleSettings = g_settingsHandler->GetConsoleSettings();
PositionSettings& positionSettings = g_settingsHandler->GetAppearanceSettings().positionSettings;
StylesSettings& stylesSettings = g_settingsHandler->GetAppearanceSettings().stylesSettings;

if (consoleSettings.bSaveSize)
{
consoleSettings.dwRows = m_dwRows;
consoleSettings.dwColumns = m_dwColumns;

bSaveSettings = true;
}

if (positionSettings.bSavePosition)
{
CRect rectWindow;

GetWindowRect(rectWindow);

positionSettings.nX = rectWindow.left;
positionSettings.nY = rectWindow.top;

bSaveSettings = true;
}

if (bSaveSettings) g_settingsHandler->SaveSettings();

// destroy all views
MutexLock viewMapLock(m_viewsMutex);
for (ConsoleViewMap::iterator it = m_views.begin(); it != m_views.end(); ++it)
{
RemoveTab(it->second->m_hWnd);
if (m_activeView.get() == it->second.get()) m_activeView.reset();
it->second->DestroyWindow();
}

if (g_settingsHandler->GetAppearanceSettings().stylesSettings.bTrayIcon) SetTrayIcon(NIM_DELETE);

UnregisterGlobalHotkeys();

DestroyWindow();
PostQuitMessage(0);
return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions Console/SettingsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ StylesSettings::StylesSettings()
, bBorder(true)
, dwInsideBorder(2)
, bTrayIcon(false)
, bHideOnClose(false)
, crSelectionColor(RGB(255, 255, 255))
{
}
Expand All @@ -479,6 +480,7 @@ bool StylesSettings::Load(const CComPtr<IXMLDOMElement>& pSettingsRoot)
XmlHelper::GetAttribute(pStylesElement, CComBSTR(L"border"), bBorder, true);
XmlHelper::GetAttribute(pStylesElement, CComBSTR(L"inside_border"), dwInsideBorder, 2);
XmlHelper::GetAttribute(pStylesElement, CComBSTR(L"tray_icon"), bTrayIcon, false);
XmlHelper::GetAttribute(pStylesElement, CComBSTR(L"hide_on_close"), bHideOnClose, false);

CComPtr<IXMLDOMElement> pSelColorElement;

Expand Down Expand Up @@ -506,6 +508,7 @@ bool StylesSettings::Save(const CComPtr<IXMLDOMElement>& pSettingsRoot)
XmlHelper::SetAttribute(pStylesElement, CComBSTR(L"border"), bBorder);
XmlHelper::SetAttribute(pStylesElement, CComBSTR(L"inside_border"), dwInsideBorder);
XmlHelper::SetAttribute(pStylesElement, CComBSTR(L"tray_icon"), bTrayIcon);
XmlHelper::SetAttribute(pStylesElement, CComBSTR(L"hide_on_close"), bHideOnClose);

CComPtr<IXMLDOMElement> pSelColorElement;

Expand All @@ -529,6 +532,7 @@ StylesSettings& StylesSettings::operator=(const StylesSettings& other)
bBorder = other.bBorder;
dwInsideBorder = other.dwInsideBorder;
bTrayIcon = other.bTrayIcon;
bHideOnClose = other.bHideOnClose;
crSelectionColor= other.crSelectionColor;

return *this;
Expand Down
1 change: 1 addition & 0 deletions Console/SettingsHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ struct StylesSettings : public SettingsBase
bool bBorder;
DWORD dwInsideBorder;
bool bTrayIcon;
bool bHideOnClose;
COLORREF crSelectionColor;
};

Expand Down
1 change: 1 addition & 0 deletions Console/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
#define ID_NEXT_TAB 2200
#define ID_PREV_TAB 2201
#define IDC_DUMP_BUFFER 3000
#define IDC_CHECK_STYLE_HIDE 4321
#define IDS_ERR_CANT_START_SHELL 5000
#define IDS_ERR_CANT_START_AS_USER 5001
#define IDS_ERR_CANT_START_SHELL_AS_USER 5001
Expand Down