二つ以上のMDI子ウィンドウから成るMDIアプリケーションに於いて、利用者が自らの手でそのウィンドウを削除したときに、どのMDI子ウィンドウが削除されたかを知る術はありますか。
もしあったら、その方法も教えてださい。
C++
1#include <windows.h> 2#include <commctrl.h> 3 4#include "resource.h" 5#include "common.h" 6 7#pragma comment(lib,"comctl32.lib") 8 9#define TITLE TEXT("MDI") 10#define MDI_FRAME TEXT("FRAMEWINDOW") 11#define MDI_CHILD TEXT("MDICHILD") 12 13HINSTANCE hIns;//現在のインターフェース 14HWND hCHildWndMap; 15HWND hChildWndTil; 16HWND hToolWnd; 17#define ID_CHILDWND 0x100 18LRESULT CALLBACK FrameProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { 19 static HWND hToolbar; 20 static HBITMAP hBitmap; 21 CLIENTCREATESTRUCT ccsClient; 22 static HWND hClientWindow; 23 switch (msg) 24 { 25 case WM_DESTROY: 26 ... 27 return 0; 28 case WM_CREATE: 29 InitCommonControls(); 30 ccsClient.idFirstChild = ID_CHILDWND; 31 32 hClientWindow = CreateWindow(TEXT("MDICLIENT"), NULL, 33 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | WS_CLIPSIBLINGS, 34 0, 0, 0, 0, hWnd, (HMENU)1, ((LPCREATESTRUCT)lp)->hInstance, &ccsClient 35 ); 36 { 37 RECT wndrct; 38 GetWindowRect(hWnd, &wndrct); 39 40 hCHildWndMap = CreateMDIWindow(MDI_CHILD, TEXT("マップ"), 0, 41 0, 0, 42 300, 300, 43 hClientWindow, hIns, 0 44 ); 45 } 46 ... 47 return 0; 48 case WM_SIZE: 49 ... 50 return 0; 51 case WM_PAINT: 52 53 break; 54 case WM_COMMAND: 55 56 switch (LOWORD(wp)) 57 { 58 case IDM_NEWMINIMAP: 59 //チェックがついている 60 if (GetMenuState(GetMenu(hWnd), IDM_NEWMINIMAP, MF_BYCOMMAND) & MFS_CHECKED) { 61 SendMessage(hClientWindow, WM_MDIDESTROY, (WPARAM)hCHildWndMap, 0); 62 CheckMenuItem(GetMenu(hWnd), IDM_NEWMINIMAP, MFS_UNCHECKED); 63 } 64 else {//ついていない 65 hCHildWndMap = CreateMDIWindow(MDI_CHILD, TEXT("マップ"), 0, 66 0, 0, 67 300, 300, 68 hClientWindow, hIns, 0 69 ); 70 CheckMenuItem(GetMenu(hWnd), IDM_NEWMINIMAP, MFS_CHECKED); 71 } 72 break; 73 } 74 } 75 return DefFrameProc(hWnd, hClientWindow, msg, wp, lp); 76} 77int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 78 PSTR lpCmdLine, int nCmdShow) { 79 HWND hWnd; 80 MSG msg; 81 WNDCLASS winc; 82 hIns = hInstance; 83 84 ... 85 86 winc.lpfnWndProc = DefMDIChildProc; 87 winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); 88 winc.lpszClassName = MDI_CHILD; 89 90 91 if (!RegisterClass(&winc)) return 1; 92 93 hWnd = CreateWindow( 94 MDI_FRAME, TITLE, 95 WS_OVERLAPPEDWINDOW|WS_MAXIMIZE|WS_VISIBLE|WS_CLIPCHILDREN, 96 CW_USEDEFAULT, CW_USEDEFAULT, 97 CW_USEDEFAULT, CW_USEDEFAULT, 98 NULL, NULL, hInstance, NULL 99 ); 100 101 ... 102 103 return msg.wParam; 104}
回答1件
あなたの回答
tips
プレビュー