mirror of
https://github.com/italicsjenga/muda.git
synced 2025-02-04 15:16:33 +11:00
fix(Windows): send WM_CLOSE
instead of DestroyWindow
(#55)
This commit is contained in:
parent
88d352033b
commit
f322ad454d
2 changed files with 12 additions and 7 deletions
5
.changes/windows-predefined-close.md
Normal file
5
.changes/windows-predefined-close.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"muda": "patch"
|
||||
---
|
||||
|
||||
On Windows, The `Close` predefined menu item will send `WM_CLOSE` to the window instead of calling `DestroyWindow` to let the developer catch this event and decide whether to close the window or not.
|
|
@ -25,12 +25,12 @@ use windows_sys::Win32::{
|
|||
Shell::{DefSubclassProc, RemoveWindowSubclass, SetWindowSubclass},
|
||||
WindowsAndMessaging::{
|
||||
AppendMenuW, CreateAcceleratorTableW, CreateMenu, CreatePopupMenu,
|
||||
DestroyAcceleratorTable, DestroyWindow, DrawMenuBar, EnableMenuItem, GetMenuItemInfoW,
|
||||
InsertMenuW, MessageBoxW, PostQuitMessage, RemoveMenu, SendMessageW, SetMenu,
|
||||
SetMenuItemInfoW, ShowWindow, TrackPopupMenu, HACCEL, HMENU, MB_ICONINFORMATION,
|
||||
MENUITEMINFOW, MFS_CHECKED, MFS_DISABLED, MF_BYCOMMAND, MF_BYPOSITION, MF_CHECKED,
|
||||
MF_DISABLED, MF_ENABLED, MF_GRAYED, MF_POPUP, MF_SEPARATOR, MF_STRING, MF_UNCHECKED,
|
||||
MIIM_BITMAP, MIIM_STATE, MIIM_STRING, SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE, TPM_LEFTALIGN,
|
||||
DestroyAcceleratorTable, DrawMenuBar, EnableMenuItem, GetMenuItemInfoW, InsertMenuW,
|
||||
MessageBoxW, PostQuitMessage, RemoveMenu, SendMessageW, SetMenu, SetMenuItemInfoW,
|
||||
ShowWindow, TrackPopupMenu, HACCEL, HMENU, MB_ICONINFORMATION, MENUITEMINFOW,
|
||||
MFS_CHECKED, MFS_DISABLED, MF_BYCOMMAND, MF_BYPOSITION, MF_CHECKED, MF_DISABLED,
|
||||
MF_ENABLED, MF_GRAYED, MF_POPUP, MF_SEPARATOR, MF_STRING, MF_UNCHECKED, MIIM_BITMAP,
|
||||
MIIM_STATE, MIIM_STRING, SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE, TPM_LEFTALIGN, WM_CLOSE,
|
||||
WM_COMMAND, WM_DESTROY,
|
||||
},
|
||||
},
|
||||
|
@ -1106,7 +1106,7 @@ unsafe extern "system" fn menu_subclass_proc(
|
|||
ShowWindow(hwnd, SW_HIDE);
|
||||
}
|
||||
PredfinedMenuItemType::CloseWindow => {
|
||||
DestroyWindow(hwnd);
|
||||
SendMessageW(hwnd, WM_CLOSE, 0, 0);
|
||||
}
|
||||
PredfinedMenuItemType::Quit => {
|
||||
PostQuitMessage(0);
|
||||
|
|
Loading…
Add table
Reference in a new issue