2015-05-08 16:02:36 +00:00
|
|
|
/*
|
2023-06-23 11:04:32 +00:00
|
|
|
* PROJECT: PAINT for ReactOS
|
|
|
|
* LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
|
|
|
|
* PURPOSE: Window procedure of the main window and all children apart from
|
|
|
|
* hPalWin, hToolSettings and hSelection
|
2023-06-27 18:22:21 +00:00
|
|
|
* COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
|
2023-06-23 11:04:32 +00:00
|
|
|
* Copyright 2017-2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
|
|
|
* Copyright 2018 Stanislav Motylkov <x86corez@gmail.com>
|
2015-05-08 16:02:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
2023-03-16 22:28:01 +00:00
|
|
|
#include <assert.h>
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2023-03-16 22:25:51 +00:00
|
|
|
typedef HWND (WINAPI *FN_HtmlHelpW)(HWND, LPCWSTR, UINT, DWORD_PTR);
|
|
|
|
|
|
|
|
static HINSTANCE s_hHHCTRL_OCX = NULL; // HtmlHelpW needs "hhctrl.ocx"
|
|
|
|
static FN_HtmlHelpW s_pHtmlHelpW = NULL;
|
|
|
|
|
2023-06-17 12:15:35 +00:00
|
|
|
HWND g_hStatusBar = NULL;
|
2023-03-28 13:31:26 +00:00
|
|
|
|
2015-05-08 16:02:36 +00:00
|
|
|
/* FUNCTIONS ********************************************************/
|
|
|
|
|
2023-03-16 22:25:51 +00:00
|
|
|
// A wrapper function for HtmlHelpW
|
|
|
|
static HWND DoHtmlHelpW(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData)
|
|
|
|
{
|
|
|
|
WCHAR szPath[MAX_PATH];
|
|
|
|
|
|
|
|
if (!s_hHHCTRL_OCX && (uCommand != HH_CLOSE_ALL))
|
|
|
|
{
|
|
|
|
// The function loads the system library, not local
|
|
|
|
GetSystemDirectoryW(szPath, _countof(szPath));
|
|
|
|
wcscat(szPath, L"\\hhctrl.ocx");
|
|
|
|
s_hHHCTRL_OCX = LoadLibraryW(szPath);
|
|
|
|
if (s_hHHCTRL_OCX)
|
|
|
|
s_pHtmlHelpW = (FN_HtmlHelpW)GetProcAddress(s_hHHCTRL_OCX, "HtmlHelpW");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!s_pHtmlHelpW)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return s_pHtmlHelpW(hwndCaller, pszFile, uCommand, dwData);
|
|
|
|
}
|
|
|
|
|
2018-04-14 12:42:34 +00:00
|
|
|
BOOL
|
2015-05-08 16:02:36 +00:00
|
|
|
zoomTo(int newZoom, int mouseX, int mouseY)
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
2023-04-08 13:25:27 +00:00
|
|
|
RECT clientRectScrollbox;
|
2023-03-16 22:45:14 +00:00
|
|
|
canvasWindow.GetClientRect(&clientRectScrollbox);
|
2023-04-08 13:25:27 +00:00
|
|
|
|
|
|
|
RECT clientRectImageArea;
|
|
|
|
::SetRect(&clientRectImageArea, 0, 0, imageModel.GetWidth(), imageModel.GetHeight());
|
|
|
|
Zoomed(clientRectImageArea);
|
|
|
|
|
2018-04-14 12:42:34 +00:00
|
|
|
w = clientRectImageArea.right * newZoom / toolsModel.GetZoom();
|
|
|
|
h = clientRectImageArea.bottom * newZoom / toolsModel.GetZoom();
|
|
|
|
if (!w || !h)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
w = clientRectImageArea.right * clientRectScrollbox.right / w;
|
|
|
|
h = clientRectImageArea.bottom * clientRectScrollbox.bottom / h;
|
2015-07-07 11:15:24 +00:00
|
|
|
x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2)) * newZoom / toolsModel.GetZoom();
|
|
|
|
y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2)) * newZoom / toolsModel.GetZoom();
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2015-07-07 11:15:24 +00:00
|
|
|
toolsModel.SetZoom(newZoom);
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2023-03-16 22:45:14 +00:00
|
|
|
canvasWindow.Invalidate(TRUE);
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2023-03-16 22:45:14 +00:00
|
|
|
canvasWindow.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, x), 0);
|
|
|
|
canvasWindow.SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, y), 0);
|
2018-04-14 12:42:34 +00:00
|
|
|
return TRUE;
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
|
|
|
|
2015-07-07 11:02:30 +00:00
|
|
|
void CMainWindow::alignChildrenToMainWindow()
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-03-14 22:29:25 +00:00
|
|
|
RECT clientRect, rc;
|
2015-07-07 11:44:50 +00:00
|
|
|
GetClientRect(&clientRect);
|
2023-03-14 22:29:25 +00:00
|
|
|
RECT rcSpace = clientRect;
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2023-06-17 12:15:35 +00:00
|
|
|
if (::IsWindowVisible(g_hStatusBar))
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-06-17 12:15:35 +00:00
|
|
|
::GetWindowRect(g_hStatusBar, &rc);
|
2023-03-14 22:29:25 +00:00
|
|
|
rcSpace.bottom -= rc.bottom - rc.top;
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
2023-03-14 22:29:25 +00:00
|
|
|
|
|
|
|
HDWP hDWP = ::BeginDeferWindowPos(3);
|
|
|
|
|
|
|
|
if (::IsWindowVisible(toolBoxContainer))
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-04-03 05:34:56 +00:00
|
|
|
if (registrySettings.Bar2ID == BAR2ID_RIGHT)
|
|
|
|
{
|
|
|
|
hDWP = ::DeferWindowPos(hDWP, toolBoxContainer, NULL,
|
|
|
|
rcSpace.right - CX_TOOLBAR, rcSpace.top,
|
|
|
|
CX_TOOLBAR, rcSpace.bottom - rcSpace.top,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION);
|
|
|
|
rcSpace.right -= CX_TOOLBAR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hDWP = ::DeferWindowPos(hDWP, toolBoxContainer, NULL,
|
|
|
|
rcSpace.left, rcSpace.top,
|
|
|
|
CX_TOOLBAR, rcSpace.bottom - rcSpace.top,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION);
|
|
|
|
rcSpace.left += CX_TOOLBAR;
|
|
|
|
}
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
2023-03-14 22:29:25 +00:00
|
|
|
|
2022-01-22 15:59:12 +00:00
|
|
|
if (::IsWindowVisible(paletteWindow))
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-04-04 10:06:06 +00:00
|
|
|
if (registrySettings.Bar1ID == BAR1ID_BOTTOM)
|
|
|
|
{
|
|
|
|
hDWP = ::DeferWindowPos(hDWP, paletteWindow, NULL,
|
|
|
|
rcSpace.left, rcSpace.bottom - CY_PALETTE,
|
|
|
|
rcSpace.right - rcSpace.left, CY_PALETTE,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION);
|
|
|
|
rcSpace.bottom -= CY_PALETTE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hDWP = ::DeferWindowPos(hDWP, paletteWindow, NULL,
|
|
|
|
rcSpace.left, rcSpace.top,
|
|
|
|
rcSpace.right - rcSpace.left, CY_PALETTE,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION);
|
|
|
|
rcSpace.top += CY_PALETTE;
|
|
|
|
}
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
|
|
|
|
2023-03-16 22:45:14 +00:00
|
|
|
if (canvasWindow.IsWindow())
|
2022-01-22 15:59:12 +00:00
|
|
|
{
|
2023-03-16 22:45:14 +00:00
|
|
|
hDWP = ::DeferWindowPos(hDWP, canvasWindow, NULL,
|
2023-03-14 22:29:25 +00:00
|
|
|
rcSpace.left, rcSpace.top,
|
|
|
|
rcSpace.right - rcSpace.left, rcSpace.bottom - rcSpace.top,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION);
|
2022-01-22 15:59:12 +00:00
|
|
|
}
|
2017-05-24 19:31:43 +00:00
|
|
|
|
2023-03-14 22:29:25 +00:00
|
|
|
::EndDeferWindowPos(hDWP);
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
|
|
|
|
2015-07-07 11:02:30 +00:00
|
|
|
void CMainWindow::saveImage(BOOL overwrite)
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-04-08 13:25:27 +00:00
|
|
|
canvasWindow.finishDrawing();
|
2022-01-30 03:05:23 +00:00
|
|
|
|
2023-06-17 12:15:35 +00:00
|
|
|
if (g_isAFile && overwrite)
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-06-17 12:15:35 +00:00
|
|
|
imageModel.SaveImage(g_szFileName);
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
2023-06-17 12:15:35 +00:00
|
|
|
else if (GetSaveFileName(g_szFileName, _countof(g_szFileName)))
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-06-17 12:15:35 +00:00
|
|
|
imageModel.SaveImage(g_szFileName);
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-07 11:02:30 +00:00
|
|
|
void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND window)
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2021-09-13 01:33:14 +00:00
|
|
|
int width = GetDIBWidth(bitmap);
|
|
|
|
int height = GetDIBHeight(bitmap);
|
2015-07-13 14:46:41 +00:00
|
|
|
int curWidth = imageModel.GetWidth();
|
|
|
|
int curHeight = imageModel.GetHeight();
|
|
|
|
|
|
|
|
if (width > curWidth || height > curHeight)
|
|
|
|
{
|
|
|
|
BOOL shouldEnlarge = TRUE;
|
|
|
|
|
2023-06-17 12:15:35 +00:00
|
|
|
if (g_askBeforeEnlarging)
|
2015-07-13 14:46:41 +00:00
|
|
|
{
|
|
|
|
TCHAR programname[20];
|
|
|
|
TCHAR shouldEnlargePromptText[100];
|
|
|
|
|
2023-06-17 12:15:35 +00:00
|
|
|
LoadString(g_hinstExe, IDS_PROGRAMNAME, programname, _countof(programname));
|
|
|
|
LoadString(g_hinstExe, IDS_ENLARGEPROMPTTEXT, shouldEnlargePromptText, _countof(shouldEnlargePromptText));
|
2015-07-13 14:46:41 +00:00
|
|
|
|
|
|
|
switch (MessageBox(shouldEnlargePromptText, programname, MB_YESNOCANCEL | MB_ICONQUESTION))
|
|
|
|
{
|
|
|
|
case IDYES:
|
|
|
|
break;
|
|
|
|
case IDNO:
|
|
|
|
shouldEnlarge = FALSE;
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
2021-09-13 01:33:14 +00:00
|
|
|
return;
|
2015-07-13 14:46:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shouldEnlarge)
|
|
|
|
{
|
|
|
|
if (width > curWidth)
|
|
|
|
curWidth = width;
|
|
|
|
|
|
|
|
if (height > curHeight)
|
|
|
|
curHeight = height;
|
|
|
|
|
|
|
|
imageModel.Crop(curWidth, curHeight, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-18 10:48:20 +00:00
|
|
|
toolsModel.SetActiveTool(TOOL_RECTSEL);
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2023-04-01 13:01:04 +00:00
|
|
|
selectionModel.InsertFromHBITMAP(bitmap, 0, 0);
|
|
|
|
selectionModel.m_bShow = TRUE;
|
2023-06-14 09:51:40 +00:00
|
|
|
imageModel.NotifyImageChanged();
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
|
|
|
|
2021-12-27 13:20:22 +00:00
|
|
|
LRESULT CMainWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
INT zDelta = (SHORT)HIWORD(wParam);
|
|
|
|
|
|
|
|
if (::GetAsyncKeyState(VK_CONTROL) < 0)
|
|
|
|
{
|
|
|
|
if (zDelta < 0)
|
|
|
|
{
|
|
|
|
if (toolsModel.GetZoom() > MIN_ZOOM)
|
|
|
|
zoomTo(toolsModel.GetZoom() / 2, 0, 0);
|
|
|
|
}
|
|
|
|
else if (zDelta > 0)
|
|
|
|
{
|
|
|
|
if (toolsModel.GetZoom() < MAX_ZOOM)
|
|
|
|
zoomTo(toolsModel.GetZoom() * 2, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UINT nCount = 3;
|
|
|
|
if (::GetAsyncKeyState(VK_SHIFT) < 0)
|
|
|
|
{
|
|
|
|
#ifndef SPI_GETWHEELSCROLLCHARS
|
|
|
|
#define SPI_GETWHEELSCROLLCHARS 0x006C // Needed for pre-NT6 PSDK
|
|
|
|
#endif
|
|
|
|
SystemParametersInfoW(SPI_GETWHEELSCROLLCHARS, 0, &nCount, 0);
|
|
|
|
for (UINT i = 0; i < nCount; ++i)
|
|
|
|
{
|
|
|
|
if (zDelta < 0)
|
2023-03-16 22:45:14 +00:00
|
|
|
::PostMessageW(canvasWindow, WM_HSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
|
2021-12-27 13:20:22 +00:00
|
|
|
else if (zDelta > 0)
|
2023-03-16 22:45:14 +00:00
|
|
|
::PostMessageW(canvasWindow, WM_HSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
|
2021-12-27 13:20:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, &nCount, 0);
|
|
|
|
for (UINT i = 0; i < nCount; ++i)
|
|
|
|
{
|
|
|
|
if (zDelta < 0)
|
2023-03-16 22:45:14 +00:00
|
|
|
::PostMessageW(canvasWindow, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
|
2021-12-27 13:20:22 +00:00
|
|
|
else if (zDelta > 0)
|
2023-03-16 22:45:14 +00:00
|
|
|
::PostMessageW(canvasWindow, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
|
2021-12-27 13:20:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
LRESULT CMainWindow::OnDropFiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2015-07-07 10:42:49 +00:00
|
|
|
TCHAR droppedfile[MAX_PATH];
|
2020-04-28 22:44:18 +00:00
|
|
|
|
|
|
|
HDROP hDrop = (HDROP)wParam;
|
2021-12-28 01:44:56 +00:00
|
|
|
DragQueryFile(hDrop, 0, droppedfile, _countof(droppedfile));
|
2020-04-28 22:44:18 +00:00
|
|
|
DragFinish(hDrop);
|
|
|
|
|
|
|
|
ConfirmSave() && DoLoadImageFile(m_hWnd, droppedfile, TRUE);
|
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CMainWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2023-03-28 13:31:26 +00:00
|
|
|
// Loading and setting the window menu from resource
|
2023-06-17 12:15:35 +00:00
|
|
|
m_hMenu = ::LoadMenu(g_hinstExe, MAKEINTRESOURCE(ID_MENU));
|
2023-03-28 13:31:26 +00:00
|
|
|
SetMenu(m_hMenu);
|
|
|
|
|
|
|
|
// Create the status bar
|
|
|
|
DWORD style = SBARS_SIZEGRIP | WS_CHILD | (registrySettings.ShowStatusBar ? WS_VISIBLE : 0);
|
2023-06-17 12:15:35 +00:00
|
|
|
g_hStatusBar = ::CreateWindowEx(0, STATUSCLASSNAME, NULL, style, 0, 0, 0, 0, m_hWnd,
|
|
|
|
NULL, g_hinstExe, NULL);
|
|
|
|
::SendMessage(g_hStatusBar, SB_SETMINHEIGHT, 21, 0);
|
2023-03-28 13:31:26 +00:00
|
|
|
|
|
|
|
// Create the tool box
|
|
|
|
toolBoxContainer.DoCreate(m_hWnd);
|
|
|
|
|
|
|
|
// Create the palette window
|
|
|
|
RECT rcEmpty = { 0, 0, 0, 0 }; // Rely on WM_SIZE
|
|
|
|
style = WS_CHILD | (registrySettings.ShowPalette ? WS_VISIBLE : 0);
|
|
|
|
paletteWindow.Create(m_hWnd, rcEmpty, NULL, style, WS_EX_STATICEDGE);
|
|
|
|
|
|
|
|
// Create the canvas
|
|
|
|
style = WS_CHILD | WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE;
|
|
|
|
canvasWindow.Create(m_hWnd, rcEmpty, NULL, style, WS_EX_CLIENTEDGE);
|
|
|
|
|
|
|
|
// Create and show the miniature if necessary
|
|
|
|
if (registrySettings.ShowThumbnail)
|
|
|
|
{
|
|
|
|
miniature.DoCreate(m_hWnd);
|
|
|
|
miniature.ShowWindow(SW_SHOWNOACTIVATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set icon
|
2023-06-17 12:15:35 +00:00
|
|
|
SendMessage(WM_SETICON, ICON_BIG, (LPARAM) LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON)));
|
|
|
|
SendMessage(WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON)));
|
2023-03-28 13:31:26 +00:00
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CMainWindow::OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2023-03-16 22:26:44 +00:00
|
|
|
registrySettings.WindowPlacement.length = sizeof(WINDOWPLACEMENT);
|
2015-08-16 19:52:37 +00:00
|
|
|
GetWindowPlacement(&(registrySettings.WindowPlacement));
|
2023-03-16 22:25:51 +00:00
|
|
|
|
|
|
|
DoHtmlHelpW(NULL, NULL, HH_CLOSE_ALL, 0);
|
|
|
|
|
|
|
|
if (s_hHHCTRL_OCX)
|
|
|
|
{
|
|
|
|
FreeLibrary(s_hHHCTRL_OCX);
|
|
|
|
s_hHHCTRL_OCX = NULL;
|
|
|
|
s_pHtmlHelpW = NULL;
|
|
|
|
}
|
|
|
|
|
2023-03-28 13:31:26 +00:00
|
|
|
SetMenu(NULL);
|
|
|
|
if (m_hMenu)
|
|
|
|
{
|
|
|
|
::DestroyMenu(m_hMenu);
|
|
|
|
m_hMenu = NULL;
|
|
|
|
}
|
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
PostQuitMessage(0); /* send a WM_QUIT to the message queue */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-28 22:44:18 +00:00
|
|
|
BOOL CMainWindow::ConfirmSave()
|
2015-07-07 10:42:49 +00:00
|
|
|
{
|
2023-04-08 13:25:27 +00:00
|
|
|
canvasWindow.finishDrawing();
|
2022-01-30 03:05:23 +00:00
|
|
|
|
2020-04-28 22:44:18 +00:00
|
|
|
if (imageModel.IsImageSaved())
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
CString strProgramName;
|
|
|
|
strProgramName.LoadString(IDS_PROGRAMNAME);
|
|
|
|
|
|
|
|
CString strSavePromptText;
|
2023-06-17 12:15:35 +00:00
|
|
|
strSavePromptText.Format(IDS_SAVEPROMPTTEXT, PathFindFileName(g_szFileName));
|
2020-04-28 22:44:18 +00:00
|
|
|
|
|
|
|
switch (MessageBox(strSavePromptText, strProgramName, MB_YESNOCANCEL | MB_ICONQUESTION))
|
2015-07-07 10:42:49 +00:00
|
|
|
{
|
2020-04-28 22:44:18 +00:00
|
|
|
case IDYES:
|
|
|
|
saveImage(TRUE);
|
|
|
|
return imageModel.IsImageSaved();
|
|
|
|
case IDNO:
|
|
|
|
return TRUE;
|
|
|
|
case IDCANCEL:
|
|
|
|
return FALSE;
|
2015-07-07 10:42:49 +00:00
|
|
|
}
|
2020-04-28 22:44:18 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CMainWindow::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
if (ConfirmSave())
|
2015-07-07 10:42:49 +00:00
|
|
|
{
|
|
|
|
DestroyWindow();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2023-03-16 22:28:01 +00:00
|
|
|
void CMainWindow::ProcessFileMenu(HMENU hPopupMenu)
|
|
|
|
{
|
2023-06-17 12:15:35 +00:00
|
|
|
LPCTSTR dotext = PathFindExtensionW(g_szFileName);
|
2023-03-16 22:28:01 +00:00
|
|
|
BOOL isBMP = FALSE;
|
|
|
|
if (_tcsicmp(dotext, _T(".bmp")) == 0 ||
|
|
|
|
_tcsicmp(dotext, _T(".dib")) == 0 ||
|
|
|
|
_tcsicmp(dotext, _T(".rle")) == 0)
|
|
|
|
{
|
|
|
|
isBMP = TRUE;
|
|
|
|
}
|
|
|
|
|
2023-07-05 03:06:22 +00:00
|
|
|
UINT uWallpaperEnabled = ENABLED_IF(g_isAFile && isBMP && g_fileSize > 0);
|
|
|
|
::EnableMenuItem(hPopupMenu, IDM_FILEASWALLPAPERPLANE, uWallpaperEnabled);
|
|
|
|
::EnableMenuItem(hPopupMenu, IDM_FILEASWALLPAPERCENTERED, uWallpaperEnabled);
|
|
|
|
::EnableMenuItem(hPopupMenu, IDM_FILEASWALLPAPERSTRETCHED, uWallpaperEnabled);
|
2023-03-16 22:28:01 +00:00
|
|
|
|
|
|
|
for (INT iItem = 0; iItem < MAX_RECENT_FILES; ++iItem)
|
|
|
|
RemoveMenu(hPopupMenu, IDM_FILE1 + iItem, MF_BYCOMMAND);
|
|
|
|
|
|
|
|
if (registrySettings.strFiles[0].IsEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
RemoveMenu(hPopupMenu, IDM_FILEMOSTRECENTLYUSEDFILE, MF_BYCOMMAND);
|
|
|
|
|
|
|
|
INT cMenuItems = GetMenuItemCount(hPopupMenu);
|
|
|
|
|
|
|
|
for (INT iItem = 0; iItem < MAX_RECENT_FILES; ++iItem)
|
|
|
|
{
|
|
|
|
CString& strFile = registrySettings.strFiles[iItem];
|
|
|
|
if (strFile.IsEmpty())
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Condense the lengthy pathname by using '...'
|
|
|
|
#define MAX_RECENT_PATHNAME_DISPLAY 30
|
|
|
|
CPath pathFile(strFile);
|
|
|
|
pathFile.CompactPathEx(MAX_RECENT_PATHNAME_DISPLAY);
|
|
|
|
assert(_tcslen((LPCTSTR)pathFile) <= MAX_RECENT_PATHNAME_DISPLAY);
|
|
|
|
|
|
|
|
// Add an accelerator (by '&') to the item number for quick access
|
|
|
|
TCHAR szText[4 + MAX_RECENT_PATHNAME_DISPLAY + 1];
|
|
|
|
wsprintf(szText, _T("&%u %s"), iItem + 1, (LPCTSTR)pathFile);
|
|
|
|
|
|
|
|
INT iMenuItem = (cMenuItems - 2) + iItem;
|
|
|
|
InsertMenu(hPopupMenu, iMenuItem, MF_BYPOSITION | MF_STRING, IDM_FILE1 + iItem, szText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-19 05:13:43 +00:00
|
|
|
BOOL CMainWindow::CanUndo() const
|
|
|
|
{
|
|
|
|
if (toolsModel.GetActiveTool() == TOOL_TEXT && ::IsWindowVisible(textEditWindow))
|
|
|
|
return (BOOL)textEditWindow.SendMessage(EM_CANUNDO);
|
|
|
|
if (selectionModel.m_bShow && toolsModel.IsSelection())
|
|
|
|
return TRUE;
|
2023-06-21 22:28:15 +00:00
|
|
|
if (ToolBase::s_pointSP != 0)
|
2023-06-19 05:13:43 +00:00
|
|
|
return TRUE;
|
|
|
|
return imageModel.CanUndo();
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CMainWindow::CanRedo() const
|
|
|
|
{
|
|
|
|
if (toolsModel.GetActiveTool() == TOOL_TEXT && ::IsWindowVisible(textEditWindow))
|
|
|
|
return FALSE; // There is no "WM_REDO" in EDIT control
|
2023-06-21 22:28:15 +00:00
|
|
|
if (ToolBase::s_pointSP != 0)
|
2023-06-19 05:13:43 +00:00
|
|
|
return TRUE;
|
|
|
|
return imageModel.CanRedo();
|
|
|
|
}
|
|
|
|
|
2023-06-19 09:59:00 +00:00
|
|
|
BOOL CMainWindow::CanPaste() const
|
|
|
|
{
|
|
|
|
if (toolsModel.GetActiveTool() == TOOL_TEXT && ::IsWindowVisible(textEditWindow))
|
|
|
|
return ::IsClipboardFormatAvailable(CF_UNICODETEXT);
|
|
|
|
|
|
|
|
return (::IsClipboardFormatAvailable(CF_ENHMETAFILE) ||
|
|
|
|
::IsClipboardFormatAvailable(CF_DIB) ||
|
|
|
|
::IsClipboardFormatAvailable(CF_BITMAP));
|
|
|
|
}
|
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
LRESULT CMainWindow::OnInitMenuPopup(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2023-03-28 13:31:26 +00:00
|
|
|
HMENU menu = (HMENU)wParam;
|
2023-06-19 00:56:02 +00:00
|
|
|
BOOL trueSelection = (selectionModel.m_bShow && toolsModel.IsSelection());
|
2023-06-18 10:48:20 +00:00
|
|
|
BOOL textShown = (toolsModel.GetActiveTool() == TOOL_TEXT && ::IsWindowVisible(textEditWindow));
|
2023-06-18 11:34:49 +00:00
|
|
|
DWORD dwStart = 0, dwEnd = 0;
|
2023-06-18 22:51:19 +00:00
|
|
|
if (textShown)
|
2023-06-18 11:34:49 +00:00
|
|
|
textEditWindow.SendMessage(EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd);
|
2023-06-18 10:48:20 +00:00
|
|
|
BOOL hasTextSel = (dwStart < dwEnd);
|
2023-03-16 22:28:01 +00:00
|
|
|
|
2023-06-18 22:51:19 +00:00
|
|
|
//
|
|
|
|
// File menu
|
|
|
|
//
|
|
|
|
if (::GetSubMenu(GetMenu(), 0) == menu)
|
2015-07-07 10:42:49 +00:00
|
|
|
{
|
2023-06-18 22:51:19 +00:00
|
|
|
ProcessFileMenu(menu);
|
2015-07-07 10:42:49 +00:00
|
|
|
}
|
|
|
|
|
2023-06-18 22:51:19 +00:00
|
|
|
//
|
|
|
|
// Edit menu
|
|
|
|
//
|
2023-06-19 05:13:43 +00:00
|
|
|
EnableMenuItem(menu, IDM_EDITUNDO, ENABLED_IF(CanUndo()));
|
|
|
|
EnableMenuItem(menu, IDM_EDITREDO, ENABLED_IF(CanRedo()));
|
2023-06-18 22:51:19 +00:00
|
|
|
EnableMenuItem(menu, IDM_EDITCUT, ENABLED_IF(textShown ? hasTextSel : trueSelection));
|
|
|
|
EnableMenuItem(menu, IDM_EDITCOPY, ENABLED_IF(textShown ? hasTextSel : trueSelection));
|
|
|
|
EnableMenuItem(menu, IDM_EDITDELETESELECTION,
|
|
|
|
ENABLED_IF(textShown ? hasTextSel : trueSelection));
|
|
|
|
EnableMenuItem(menu, IDM_EDITINVERTSELECTION, ENABLED_IF(trueSelection));
|
|
|
|
EnableMenuItem(menu, IDM_EDITCOPYTO, ENABLED_IF(trueSelection));
|
2023-06-19 09:59:00 +00:00
|
|
|
EnableMenuItem(menu, IDM_EDITPASTE, ENABLED_IF(CanPaste()));
|
2023-06-18 22:51:19 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// View menu
|
|
|
|
//
|
|
|
|
CheckMenuItem(menu, IDM_VIEWTOOLBOX, CHECKED_IF(::IsWindowVisible(toolBoxContainer)));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWCOLORPALETTE, CHECKED_IF(::IsWindowVisible(paletteWindow)));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWSTATUSBAR, CHECKED_IF(::IsWindowVisible(g_hStatusBar)));
|
|
|
|
CheckMenuItem(menu, IDM_FORMATICONBAR, CHECKED_IF(::IsWindowVisible(fontsDialog)));
|
|
|
|
EnableMenuItem(menu, IDM_FORMATICONBAR, ENABLED_IF(toolsModel.GetActiveTool() == TOOL_TEXT));
|
2015-07-07 11:15:24 +00:00
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM125, CHECKED_IF(toolsModel.GetZoom() == 125));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM25, CHECKED_IF(toolsModel.GetZoom() == 250));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM50, CHECKED_IF(toolsModel.GetZoom() == 500));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM100, CHECKED_IF(toolsModel.GetZoom() == 1000));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM200, CHECKED_IF(toolsModel.GetZoom() == 2000));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM400, CHECKED_IF(toolsModel.GetZoom() == 4000));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM800, CHECKED_IF(toolsModel.GetZoom() == 8000));
|
2023-06-18 22:51:19 +00:00
|
|
|
CheckMenuItem(menu, IDM_VIEWSHOWGRID, CHECKED_IF(g_showGrid));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWSHOWMINIATURE, CHECKED_IF(registrySettings.ShowThumbnail));
|
|
|
|
|
|
|
|
//
|
|
|
|
// Image menu
|
|
|
|
//
|
|
|
|
EnableMenuItem(menu, IDM_IMAGECROP, ENABLED_IF(selectionModel.m_bShow));
|
|
|
|
EnableMenuItem(menu, IDM_IMAGEDELETEIMAGE, ENABLED_IF(!selectionModel.m_bShow));
|
|
|
|
CheckMenuItem(menu, IDM_IMAGEDRAWOPAQUE, CHECKED_IF(!toolsModel.IsBackgroundTransparent()));
|
|
|
|
|
|
|
|
//
|
|
|
|
// Palette menu
|
|
|
|
//
|
2021-12-28 10:01:31 +00:00
|
|
|
CheckMenuItem(menu, IDM_COLORSMODERNPALETTE, CHECKED_IF(paletteModel.SelectedPalette() == PAL_MODERN));
|
|
|
|
CheckMenuItem(menu, IDM_COLORSOLDPALETTE, CHECKED_IF(paletteModel.SelectedPalette() == PAL_OLDTYPE));
|
2015-07-07 10:42:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CMainWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2015-07-07 11:44:50 +00:00
|
|
|
int test[] = { LOWORD(lParam) - 260, LOWORD(lParam) - 140, LOWORD(lParam) - 20 };
|
2023-06-17 12:15:35 +00:00
|
|
|
if (::IsWindow(g_hStatusBar))
|
2022-01-22 15:59:12 +00:00
|
|
|
{
|
2023-06-17 12:15:35 +00:00
|
|
|
::SendMessage(g_hStatusBar, WM_SIZE, 0, 0);
|
|
|
|
::SendMessage(g_hStatusBar, SB_SETPARTS, 3, (LPARAM)&test);
|
2022-01-22 15:59:12 +00:00
|
|
|
}
|
2015-07-07 11:44:50 +00:00
|
|
|
alignChildrenToMainWindow();
|
2015-07-07 10:42:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CMainWindow::OnGetMinMaxInfo(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2015-07-07 11:44:50 +00:00
|
|
|
MINMAXINFO *mm = (LPMINMAXINFO) lParam;
|
|
|
|
mm->ptMinTrackSize.x = 330;
|
2023-03-21 04:13:53 +00:00
|
|
|
mm->ptMinTrackSize.y = 360;
|
2015-07-07 10:42:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CMainWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2023-06-13 07:31:18 +00:00
|
|
|
HWND hwndCapture;
|
|
|
|
switch (wParam)
|
2015-07-07 10:42:49 +00:00
|
|
|
{
|
2023-06-13 07:31:18 +00:00
|
|
|
case VK_ESCAPE:
|
|
|
|
hwndCapture = GetCapture();
|
|
|
|
if (hwndCapture)
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-06-13 07:31:18 +00:00
|
|
|
if (canvasWindow.m_hWnd == hwndCapture ||
|
|
|
|
fullscreenWindow.m_hWnd == hwndCapture)
|
|
|
|
{
|
2023-06-18 10:48:20 +00:00
|
|
|
::SendMessage(hwndCapture, nMsg, wParam, lParam);
|
2023-06-13 07:31:18 +00:00
|
|
|
}
|
2017-07-27 09:29:42 +00:00
|
|
|
}
|
2023-06-13 07:31:18 +00:00
|
|
|
else if (selectionModel.m_bShow)
|
|
|
|
{
|
2023-06-17 12:15:35 +00:00
|
|
|
selectionModel.HideSelection();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
canvasWindow.cancelDrawing();
|
2023-06-13 07:31:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_LEFT:
|
|
|
|
canvasWindow.MoveSelection(-1, 0);
|
|
|
|
break;
|
|
|
|
case VK_RIGHT:
|
|
|
|
canvasWindow.MoveSelection(+1, 0);
|
|
|
|
break;
|
|
|
|
case VK_UP:
|
|
|
|
canvasWindow.MoveSelection(0, -1);
|
|
|
|
break;
|
|
|
|
case VK_DOWN:
|
|
|
|
canvasWindow.MoveSelection(0, +1);
|
|
|
|
break;
|
2023-06-18 10:48:20 +00:00
|
|
|
default:
|
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
LRESULT CMainWindow::OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
/* Redirect message to common controls */
|
|
|
|
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
|
|
|
|
SendMessage(hToolbar, WM_SYSCOLORCHANGE, 0, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2022-01-30 03:05:23 +00:00
|
|
|
// Disable commands while dragging mouse
|
2023-04-08 13:25:27 +00:00
|
|
|
if (canvasWindow.m_drawing && ::GetCapture())
|
2022-01-30 03:05:23 +00:00
|
|
|
{
|
|
|
|
ATLTRACE("locking!\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-06-18 10:48:20 +00:00
|
|
|
BOOL textShown = (toolsModel.GetActiveTool() == TOOL_TEXT && ::IsWindowVisible(textEditWindow));
|
2015-07-07 10:42:49 +00:00
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDM_HELPINFO:
|
|
|
|
{
|
2023-06-17 12:15:35 +00:00
|
|
|
HICON paintIcon = LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON));
|
2015-07-07 10:42:49 +00:00
|
|
|
TCHAR infotitle[100];
|
|
|
|
TCHAR infotext[200];
|
2023-06-17 12:15:35 +00:00
|
|
|
LoadString(g_hinstExe, IDS_INFOTITLE, infotitle, _countof(infotitle));
|
|
|
|
LoadString(g_hinstExe, IDS_INFOTEXT, infotext, _countof(infotext));
|
2015-07-07 11:44:50 +00:00
|
|
|
ShellAbout(m_hWnd, infotitle, infotext, paintIcon);
|
2015-07-07 10:42:49 +00:00
|
|
|
DeleteObject(paintIcon);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDM_HELPHELPTOPICS:
|
2023-03-16 22:25:51 +00:00
|
|
|
DoHtmlHelpW(m_hWnd, L"%SystemRoot%\\Help\\mspaint.chm", HH_DISPLAY_TOPIC, 0);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case IDM_FILEEXIT:
|
|
|
|
SendMessage(WM_CLOSE, wParam, lParam);
|
|
|
|
break;
|
|
|
|
case IDM_FILENEW:
|
2020-04-28 22:44:18 +00:00
|
|
|
if (ConfirmSave())
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-07-05 03:06:22 +00:00
|
|
|
InitializeImage(NULL, NULL, FALSE);
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
case IDM_FILEOPEN:
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-03-28 13:31:26 +00:00
|
|
|
TCHAR szFileName[MAX_LONG_PATH] = _T("");
|
|
|
|
if (ConfirmSave() && GetOpenFileName(szFileName, _countof(szFileName)))
|
|
|
|
{
|
|
|
|
DoLoadImageFile(m_hWnd, szFileName, TRUE);
|
|
|
|
}
|
|
|
|
break;
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
2015-07-07 10:42:49 +00:00
|
|
|
case IDM_FILESAVE:
|
|
|
|
saveImage(TRUE);
|
|
|
|
break;
|
|
|
|
case IDM_FILESAVEAS:
|
|
|
|
saveImage(FALSE);
|
2015-07-31 17:33:21 +00:00
|
|
|
break;
|
|
|
|
case IDM_FILEPAGESETUP:
|
|
|
|
// DUMMY: Shows the dialog only, no functionality
|
|
|
|
PAGESETUPDLG psd;
|
|
|
|
ZeroMemory(&psd, sizeof(psd));
|
|
|
|
psd.lStructSize = sizeof(psd);
|
|
|
|
psd.hwndOwner = m_hWnd;
|
|
|
|
PageSetupDlg(&psd);
|
|
|
|
break;
|
|
|
|
case IDM_FILEPRINT:
|
2015-08-15 10:13:28 +00:00
|
|
|
// TODO: Test whether it actually works
|
2015-07-31 17:33:21 +00:00
|
|
|
PRINTDLG pd;
|
|
|
|
ZeroMemory(&pd, sizeof(pd));
|
|
|
|
pd.lStructSize = sizeof(pd);
|
|
|
|
pd.hwndOwner = m_hWnd;
|
2015-08-15 10:13:28 +00:00
|
|
|
pd.hDevMode = NULL; // freed by user
|
|
|
|
pd.hDevNames = NULL; // freed by user
|
|
|
|
pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;
|
|
|
|
pd.nCopies = 1;
|
|
|
|
pd.nFromPage = 0xffff;
|
|
|
|
pd.nToPage = 0xffff;
|
|
|
|
pd.nMinPage = 1;
|
|
|
|
pd.nMaxPage = 0xffff;
|
|
|
|
if (PrintDlg(&pd) == TRUE)
|
|
|
|
{
|
|
|
|
BitBlt(pd.hDC, 0, 0, imageModel.GetWidth(), imageModel.GetHeight(), imageModel.GetDC(), 0, 0, SRCCOPY);
|
|
|
|
DeleteDC(pd.hDC);
|
|
|
|
}
|
|
|
|
if (pd.hDevMode)
|
|
|
|
GlobalFree(pd.hDevMode);
|
|
|
|
if (pd.hDevNames)
|
|
|
|
GlobalFree(pd.hDevNames);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case IDM_FILEASWALLPAPERPLANE:
|
2023-06-17 12:15:35 +00:00
|
|
|
RegistrySettings::SetWallpaper(g_szFileName, RegistrySettings::TILED);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case IDM_FILEASWALLPAPERCENTERED:
|
2023-06-17 12:15:35 +00:00
|
|
|
RegistrySettings::SetWallpaper(g_szFileName, RegistrySettings::CENTERED);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case IDM_FILEASWALLPAPERSTRETCHED:
|
2023-06-17 12:15:35 +00:00
|
|
|
RegistrySettings::SetWallpaper(g_szFileName, RegistrySettings::STRETCHED);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
2016-09-26 19:53:42 +00:00
|
|
|
case IDM_FILE1:
|
|
|
|
case IDM_FILE2:
|
|
|
|
case IDM_FILE3:
|
|
|
|
case IDM_FILE4:
|
|
|
|
{
|
2023-03-16 22:28:01 +00:00
|
|
|
INT iFile = LOWORD(wParam) - IDM_FILE1;
|
|
|
|
if (ConfirmSave())
|
|
|
|
DoLoadImageFile(m_hWnd, registrySettings.strFiles[iFile], TRUE);
|
2016-09-26 19:53:42 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-07-07 10:42:49 +00:00
|
|
|
case IDM_EDITUNDO:
|
2023-06-18 10:48:20 +00:00
|
|
|
if (textShown)
|
2023-06-17 12:15:35 +00:00
|
|
|
{
|
|
|
|
textEditWindow.PostMessage(WM_UNDO, 0, 0);
|
2022-01-05 07:26:05 +00:00
|
|
|
break;
|
2023-06-17 12:15:35 +00:00
|
|
|
}
|
2023-04-01 13:01:04 +00:00
|
|
|
if (selectionModel.m_bShow)
|
2022-01-30 03:05:23 +00:00
|
|
|
{
|
2023-06-19 00:56:02 +00:00
|
|
|
if (toolsModel.IsSelection())
|
2022-01-30 03:05:23 +00:00
|
|
|
{
|
2023-04-08 13:25:27 +00:00
|
|
|
canvasWindow.cancelDrawing();
|
2022-01-30 03:05:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-06-21 22:28:15 +00:00
|
|
|
if (ToolBase::s_pointSP != 0) // drawing something?
|
2022-01-30 03:05:23 +00:00
|
|
|
{
|
2023-04-08 13:25:27 +00:00
|
|
|
canvasWindow.cancelDrawing();
|
2022-01-30 03:05:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-07-07 11:56:37 +00:00
|
|
|
imageModel.Undo();
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case IDM_EDITREDO:
|
2023-06-18 10:48:20 +00:00
|
|
|
if (textShown)
|
|
|
|
{
|
2023-06-19 05:13:43 +00:00
|
|
|
// There is no "WM_REDO" in EDIT control
|
2022-01-05 07:26:05 +00:00
|
|
|
break;
|
2023-06-18 10:48:20 +00:00
|
|
|
}
|
2023-06-21 22:28:15 +00:00
|
|
|
if (ToolBase::s_pointSP != 0) // drawing something?
|
2022-01-30 03:05:23 +00:00
|
|
|
{
|
2023-04-08 13:25:27 +00:00
|
|
|
canvasWindow.finishDrawing();
|
2022-01-30 03:05:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-07-07 11:56:37 +00:00
|
|
|
imageModel.Redo();
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case IDM_EDITCOPY:
|
2023-06-18 10:48:20 +00:00
|
|
|
if (textShown)
|
2023-04-09 00:14:32 +00:00
|
|
|
{
|
2023-06-18 10:48:20 +00:00
|
|
|
textEditWindow.SendMessage(WM_COPY);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!selectionModel.m_bShow || !OpenClipboard())
|
|
|
|
break;
|
|
|
|
|
|
|
|
EmptyClipboard();
|
|
|
|
|
|
|
|
selectionModel.TakeOff();
|
|
|
|
|
|
|
|
{
|
|
|
|
HBITMAP hbm = selectionModel.CopyBitmap();
|
|
|
|
if (hbm)
|
2023-06-17 12:15:35 +00:00
|
|
|
{
|
2023-06-18 10:48:20 +00:00
|
|
|
HGLOBAL hGlobal = BitmapToClipboardDIB(hbm);
|
|
|
|
if (hGlobal)
|
|
|
|
::SetClipboardData(CF_DIB, hGlobal);
|
|
|
|
::DeleteObject(hbm);
|
2023-06-17 12:15:35 +00:00
|
|
|
}
|
2023-04-09 00:14:32 +00:00
|
|
|
}
|
2023-06-18 10:48:20 +00:00
|
|
|
|
|
|
|
CloseClipboard();
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case IDM_EDITCUT:
|
2023-06-18 10:48:20 +00:00
|
|
|
if (textShown)
|
|
|
|
{
|
|
|
|
textEditWindow.SendMessage(WM_CUT);
|
|
|
|
break;
|
|
|
|
}
|
2015-07-07 10:42:49 +00:00
|
|
|
/* Copy */
|
|
|
|
SendMessage(WM_COMMAND, IDM_EDITCOPY, 0);
|
|
|
|
/* Delete selection */
|
|
|
|
SendMessage(WM_COMMAND, IDM_EDITDELETESELECTION, 0);
|
|
|
|
break;
|
|
|
|
case IDM_EDITPASTE:
|
2023-06-18 10:48:20 +00:00
|
|
|
if (textShown)
|
|
|
|
{
|
|
|
|
textEditWindow.SendMessage(WM_PASTE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!OpenClipboard())
|
|
|
|
break;
|
|
|
|
|
|
|
|
// In many cases, CF_ENHMETAFILE provides a better image than CF_DIB
|
|
|
|
if (::IsClipboardFormatAvailable(CF_ENHMETAFILE))
|
|
|
|
{
|
|
|
|
HENHMETAFILE hEMF = (HENHMETAFILE)::GetClipboardData(CF_ENHMETAFILE);
|
|
|
|
if (hEMF)
|
|
|
|
{
|
|
|
|
HBITMAP hbm = BitmapFromHEMF(hEMF);
|
|
|
|
::DeleteEnhMetaFile(hEMF);
|
|
|
|
if (hbm)
|
|
|
|
{
|
|
|
|
InsertSelectionFromHBITMAP(hbm, m_hWnd);
|
|
|
|
CloseClipboard();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// In many cases, CF_DIB provides a better image than CF_BITMAP
|
|
|
|
if (::IsClipboardFormatAvailable(CF_DIB))
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-06-18 10:48:20 +00:00
|
|
|
HBITMAP hbm = BitmapFromClipboardDIB(::GetClipboardData(CF_DIB));
|
|
|
|
if (hbm)
|
|
|
|
{
|
|
|
|
InsertSelectionFromHBITMAP(hbm, m_hWnd);
|
|
|
|
CloseClipboard();
|
|
|
|
break;
|
|
|
|
}
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
2023-06-18 10:48:20 +00:00
|
|
|
|
|
|
|
// The last resort
|
|
|
|
if (::IsClipboardFormatAvailable(CF_BITMAP))
|
|
|
|
{
|
|
|
|
HBITMAP hbm = (HBITMAP)::GetClipboardData(CF_BITMAP);
|
|
|
|
if (hbm)
|
|
|
|
{
|
|
|
|
InsertSelectionFromHBITMAP(hbm, m_hWnd);
|
|
|
|
CloseClipboard();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Failed to paste
|
|
|
|
{
|
|
|
|
CString strText, strTitle;
|
|
|
|
strText.LoadString(IDS_CANTPASTE);
|
|
|
|
strTitle.LoadString(IDS_PROGRAMNAME);
|
|
|
|
MessageBox(strText, strTitle, MB_ICONINFORMATION);
|
|
|
|
}
|
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
CloseClipboard();
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
case IDM_EDITDELETESELECTION:
|
|
|
|
{
|
2023-06-18 10:48:20 +00:00
|
|
|
if (textShown)
|
|
|
|
{
|
|
|
|
textEditWindow.SendMessage(WM_CLEAR);
|
|
|
|
break;
|
|
|
|
}
|
2022-01-30 03:05:23 +00:00
|
|
|
switch (toolsModel.GetActiveTool())
|
|
|
|
{
|
|
|
|
case TOOL_FREESEL:
|
|
|
|
case TOOL_RECTSEL:
|
2023-06-17 12:15:35 +00:00
|
|
|
selectionModel.DeleteSelection();
|
2022-01-30 03:05:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TOOL_TEXT:
|
2023-04-08 13:25:27 +00:00
|
|
|
canvasWindow.cancelDrawing();
|
2022-01-30 03:05:23 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
}
|
|
|
|
case IDM_EDITSELECTALL:
|
|
|
|
{
|
2023-06-18 10:48:20 +00:00
|
|
|
if (textShown)
|
2022-01-05 07:26:05 +00:00
|
|
|
{
|
|
|
|
textEditWindow.SendMessage(EM_SETSEL, 0, -1);
|
|
|
|
break;
|
|
|
|
}
|
2015-07-07 10:42:49 +00:00
|
|
|
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
|
2015-07-07 11:44:50 +00:00
|
|
|
SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0));
|
2022-01-01 13:02:36 +00:00
|
|
|
toolsModel.selectAll();
|
2023-04-08 13:25:27 +00:00
|
|
|
canvasWindow.Invalidate(TRUE);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDM_EDITCOPYTO:
|
2023-03-28 13:31:26 +00:00
|
|
|
{
|
2023-07-05 03:06:22 +00:00
|
|
|
WCHAR szFileName[MAX_LONG_PATH] = L"*.png";
|
2023-03-28 13:31:26 +00:00
|
|
|
if (GetSaveFileName(szFileName, _countof(szFileName)))
|
2023-06-17 12:15:35 +00:00
|
|
|
{
|
|
|
|
HBITMAP hbm = selectionModel.CopyBitmap();
|
2023-07-05 03:06:22 +00:00
|
|
|
if (!SaveDIBToFile(hbm, szFileName, FALSE))
|
|
|
|
ShowError(IDS_SAVEERROR, szFileName);
|
2023-06-17 12:15:35 +00:00
|
|
|
::DeleteObject(hbm);
|
|
|
|
}
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
2023-03-28 13:31:26 +00:00
|
|
|
}
|
2015-07-07 10:42:49 +00:00
|
|
|
case IDM_EDITPASTEFROM:
|
2023-03-28 13:31:26 +00:00
|
|
|
{
|
2023-07-05 03:06:22 +00:00
|
|
|
WCHAR szFileName[MAX_LONG_PATH] = L"";
|
2023-03-28 13:31:26 +00:00
|
|
|
if (GetOpenFileName(szFileName, _countof(szFileName)))
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-03-28 13:31:26 +00:00
|
|
|
HBITMAP hbmNew = DoLoadImageFile(m_hWnd, szFileName, FALSE);
|
2020-04-28 22:44:18 +00:00
|
|
|
if (hbmNew)
|
|
|
|
InsertSelectionFromHBITMAP(hbmNew, m_hWnd);
|
2023-07-05 03:06:22 +00:00
|
|
|
else
|
|
|
|
ShowError(IDS_LOADERRORTEXT, szFileName);
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
|
|
|
break;
|
2023-03-28 13:31:26 +00:00
|
|
|
}
|
2015-07-07 10:42:49 +00:00
|
|
|
case IDM_COLORSEDITPALETTE:
|
2023-03-28 13:31:26 +00:00
|
|
|
{
|
|
|
|
COLORREF rgbColor = paletteModel.GetFgColor();
|
|
|
|
if (ChooseColor(&rgbColor))
|
|
|
|
paletteModel.SetFgColor(rgbColor);
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
2023-03-28 13:31:26 +00:00
|
|
|
}
|
2015-07-07 10:42:49 +00:00
|
|
|
case IDM_COLORSMODERNPALETTE:
|
2021-12-28 10:01:31 +00:00
|
|
|
paletteModel.SelectPalette(PAL_MODERN);
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
case IDM_COLORSOLDPALETTE:
|
2021-12-28 10:01:31 +00:00
|
|
|
paletteModel.SelectPalette(PAL_OLDTYPE);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case IDM_IMAGEINVERTCOLORS:
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-06-18 22:51:19 +00:00
|
|
|
if (selectionModel.m_bShow)
|
|
|
|
selectionModel.InvertSelection();
|
|
|
|
else
|
|
|
|
imageModel.InvertColors();
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-07-07 10:42:49 +00:00
|
|
|
case IDM_IMAGEDELETEIMAGE:
|
2023-06-13 14:23:48 +00:00
|
|
|
imageModel.PushImageForUndo();
|
2015-07-23 13:52:02 +00:00
|
|
|
Rect(imageModel.GetDC(), 0, 0, imageModel.GetWidth(), imageModel.GetHeight(), paletteModel.GetBgColor(), paletteModel.GetBgColor(), 0, TRUE);
|
2023-06-14 09:51:40 +00:00
|
|
|
imageModel.NotifyImageChanged();
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case IDM_IMAGEROTATEMIRROR:
|
2017-11-01 13:59:01 +00:00
|
|
|
switch (mirrorRotateDialog.DoModal(mainWindow.m_hWnd))
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2015-07-07 10:42:49 +00:00
|
|
|
case 1: /* flip horizontally */
|
2023-04-01 13:01:04 +00:00
|
|
|
if (selectionModel.m_bShow)
|
2015-07-09 09:48:01 +00:00
|
|
|
selectionModel.FlipHorizontally();
|
2015-07-07 10:42:49 +00:00
|
|
|
else
|
2015-07-23 13:52:02 +00:00
|
|
|
imageModel.FlipHorizontally();
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
case 2: /* flip vertically */
|
2023-04-01 13:01:04 +00:00
|
|
|
if (selectionModel.m_bShow)
|
2015-07-09 09:48:01 +00:00
|
|
|
selectionModel.FlipVertically();
|
2015-07-07 10:42:49 +00:00
|
|
|
else
|
2015-07-23 13:52:02 +00:00
|
|
|
imageModel.FlipVertically();
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
case 3: /* rotate 90 degrees */
|
2023-04-01 13:01:04 +00:00
|
|
|
if (selectionModel.m_bShow)
|
2022-02-14 03:08:34 +00:00
|
|
|
selectionModel.RotateNTimes90Degrees(1);
|
|
|
|
else
|
|
|
|
imageModel.RotateNTimes90Degrees(1);
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
case 4: /* rotate 180 degrees */
|
2023-04-01 13:01:04 +00:00
|
|
|
if (selectionModel.m_bShow)
|
2015-07-09 09:48:01 +00:00
|
|
|
selectionModel.RotateNTimes90Degrees(2);
|
2015-07-07 10:42:49 +00:00
|
|
|
else
|
2015-07-23 13:52:02 +00:00
|
|
|
imageModel.RotateNTimes90Degrees(2);
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
case 5: /* rotate 270 degrees */
|
2023-04-01 13:01:04 +00:00
|
|
|
if (selectionModel.m_bShow)
|
2022-02-14 03:08:34 +00:00
|
|
|
selectionModel.RotateNTimes90Degrees(3);
|
|
|
|
else
|
|
|
|
imageModel.RotateNTimes90Degrees(3);
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_IMAGEATTRIBUTES:
|
|
|
|
{
|
2017-11-01 13:59:01 +00:00
|
|
|
if (attributesDialog.DoModal(mainWindow.m_hWnd))
|
2015-07-07 10:42:49 +00:00
|
|
|
{
|
2017-11-01 13:59:01 +00:00
|
|
|
imageModel.Crop(attributesDialog.newWidth, attributesDialog.newHeight, 0, 0);
|
2015-07-07 10:42:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDM_IMAGESTRETCHSKEW:
|
|
|
|
{
|
2017-11-01 13:59:01 +00:00
|
|
|
if (stretchSkewDialog.DoModal(mainWindow.m_hWnd))
|
2015-07-07 10:42:49 +00:00
|
|
|
{
|
2023-04-01 13:01:04 +00:00
|
|
|
if (selectionModel.m_bShow)
|
2022-02-14 07:18:18 +00:00
|
|
|
{
|
|
|
|
selectionModel.StretchSkew(stretchSkewDialog.percentage.x, stretchSkewDialog.percentage.y,
|
|
|
|
stretchSkewDialog.angle.x, stretchSkewDialog.angle.y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
imageModel.StretchSkew(stretchSkewDialog.percentage.x, stretchSkewDialog.percentage.y,
|
|
|
|
stretchSkewDialog.angle.x, stretchSkewDialog.angle.y);
|
|
|
|
}
|
2015-07-07 10:42:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDM_IMAGEDRAWOPAQUE:
|
2015-07-07 11:15:24 +00:00
|
|
|
toolsModel.SetBackgroundTransparent(!toolsModel.IsBackgroundTransparent());
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case IDM_IMAGECROP:
|
2023-06-17 12:15:35 +00:00
|
|
|
imageModel.PushImageForUndo(selectionModel.CopyBitmap());
|
|
|
|
selectionModel.HideSelection();
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
case IDM_VIEWTOOLBOX:
|
2023-03-18 08:19:56 +00:00
|
|
|
registrySettings.ShowToolBox = !toolBoxContainer.IsWindowVisible();
|
|
|
|
toolBoxContainer.ShowWindow(registrySettings.ShowToolBox ? SW_SHOWNOACTIVATE : SW_HIDE);
|
2015-07-07 10:42:49 +00:00
|
|
|
alignChildrenToMainWindow();
|
|
|
|
break;
|
|
|
|
case IDM_VIEWCOLORPALETTE:
|
2023-03-18 08:12:28 +00:00
|
|
|
registrySettings.ShowPalette = !paletteWindow.IsWindowVisible();
|
|
|
|
paletteWindow.ShowWindow(registrySettings.ShowPalette ? SW_SHOWNOACTIVATE : SW_HIDE);
|
2015-07-07 10:42:49 +00:00
|
|
|
alignChildrenToMainWindow();
|
|
|
|
break;
|
|
|
|
case IDM_VIEWSTATUSBAR:
|
2023-06-17 12:15:35 +00:00
|
|
|
registrySettings.ShowStatusBar = !::IsWindowVisible(g_hStatusBar);
|
|
|
|
::ShowWindow(g_hStatusBar, (registrySettings.ShowStatusBar ? SW_SHOWNOACTIVATE : SW_HIDE));
|
2015-07-07 10:42:49 +00:00
|
|
|
alignChildrenToMainWindow();
|
|
|
|
break;
|
|
|
|
case IDM_FORMATICONBAR:
|
2022-01-05 07:26:05 +00:00
|
|
|
if (toolsModel.GetActiveTool() == TOOL_TEXT)
|
|
|
|
{
|
|
|
|
if (!fontsDialog.IsWindow())
|
|
|
|
{
|
|
|
|
fontsDialog.Create(mainWindow);
|
|
|
|
}
|
2022-01-22 15:59:12 +00:00
|
|
|
registrySettings.ShowTextTool = !::IsWindowVisible(fontsDialog);
|
2022-01-05 07:26:05 +00:00
|
|
|
fontsDialog.ShowWindow(registrySettings.ShowTextTool ? SW_SHOW : SW_HIDE);
|
|
|
|
fontsDialog.SendMessage(DM_REPOSITION, 0, 0);
|
|
|
|
}
|
2017-01-31 12:53:39 +00:00
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
case IDM_VIEWSHOWGRID:
|
2023-06-17 12:15:35 +00:00
|
|
|
g_showGrid = !g_showGrid;
|
2023-04-08 13:25:27 +00:00
|
|
|
canvasWindow.Invalidate(FALSE);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case IDM_VIEWSHOWMINIATURE:
|
2023-03-28 13:31:26 +00:00
|
|
|
registrySettings.ShowThumbnail = !::IsWindowVisible(miniature);
|
|
|
|
miniature.DoCreate(m_hWnd);
|
|
|
|
miniature.ShowWindow(registrySettings.ShowThumbnail ? SW_SHOWNOACTIVATE : SW_HIDE);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
case IDM_VIEWZOOM125:
|
|
|
|
zoomTo(125, 0, 0);
|
|
|
|
break;
|
|
|
|
case IDM_VIEWZOOM25:
|
|
|
|
zoomTo(250, 0, 0);
|
|
|
|
break;
|
|
|
|
case IDM_VIEWZOOM50:
|
|
|
|
zoomTo(500, 0, 0);
|
|
|
|
break;
|
|
|
|
case IDM_VIEWZOOM100:
|
|
|
|
zoomTo(1000, 0, 0);
|
|
|
|
break;
|
|
|
|
case IDM_VIEWZOOM200:
|
|
|
|
zoomTo(2000, 0, 0);
|
|
|
|
break;
|
|
|
|
case IDM_VIEWZOOM400:
|
|
|
|
zoomTo(4000, 0, 0);
|
|
|
|
break;
|
|
|
|
case IDM_VIEWZOOM800:
|
|
|
|
zoomTo(8000, 0, 0);
|
|
|
|
break;
|
2015-08-17 12:03:39 +00:00
|
|
|
|
|
|
|
case IDM_VIEWFULLSCREEN:
|
2023-03-28 13:31:26 +00:00
|
|
|
// Create and show the fullscreen window
|
|
|
|
fullscreenWindow.DoCreate();
|
|
|
|
fullscreenWindow.ShowWindow(SW_SHOWMAXIMIZED);
|
2015-08-17 12:03:39 +00:00
|
|
|
break;
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2023-06-18 22:51:19 +00:00
|
|
|
|
|
|
|
VOID CMainWindow::TrackPopupMenu(POINT ptScreen, INT iSubMenu)
|
|
|
|
{
|
|
|
|
HMENU hMenu = ::LoadMenuW(g_hinstExe, MAKEINTRESOURCEW(ID_POPUPMENU));
|
|
|
|
HMENU hSubMenu = ::GetSubMenu(hMenu, iSubMenu);
|
|
|
|
|
|
|
|
::SetForegroundWindow(m_hWnd);
|
|
|
|
INT_PTR id = ::TrackPopupMenu(hSubMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD,
|
|
|
|
ptScreen.x, ptScreen.y, 0, m_hWnd, NULL);
|
|
|
|
PostMessage(WM_NULL);
|
|
|
|
if (id != 0)
|
|
|
|
PostMessage(WM_COMMAND, id);
|
|
|
|
|
|
|
|
::DestroyMenu(hMenu);
|
|
|
|
}
|