Кто нибудь может подсказать,что можно сделать,чтоб основное окно не закрывалось при закрытии всплывающего?Код Ниже:
Код | TCHAR WinClassMessageName[MAX_LOADSTRING] = _T("ABC"); LRESULT CALLBACK WndGraph(HWND, UINT, WPARAM, LPARAM);
ATOM RegisterMessageClass() { WNDCLASSEX wcgraph = {0}; wcgraph.cbSize = sizeof(WNDCLASSEX); wcgraph.style = CS_HREDRAW | CS_VREDRAW; wcgraph.lpfnWndProc = WndGraph; wcgraph.hInstance = hInst; wcgraph.hCursor = LoadCursor(NULL, IDC_CROSS); wcgraph.hbrBackground = (HBRUSH) (COLOR_WINDOW+1); wcgraph.lpszClassName = WinClassMessageName; wcgraph.hIconSm = LoadIcon(hInst,MAKEINTRESOURCE(IDI_SMALL)); return RegisterClassEx(&wcgraph); } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hGraph; static int sx,sy; PAINTSTRUCT ps; HDC hdc;
switch (message) { case WM_SIZE: sx=LOWORD(lParam); sy=HIWORD(lParam); break; case WM_RBUTTONDOWN: RegisterMessageClass(); hGraph = CreateWindow(WinClassMessageName, _T("xy-график"), WS_SYSMENU | WS_POPUP | WS_VISIBLE | WS_THICKFRAME | WS_CAPTION, 300,300, 100, 100, hWnd,0, hInst, NULL); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
LRESULT CALLBACK WndGraph(HWND hGraph, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; static int cx,cy; switch(message) { case WM_SIZE: cx=LOWORD(lParam)/2; cy=HIWORD(lParam)/2; break; case WM_PAINT: hdc = BeginPaint(hGraph, &ps); Ellipse(hdc,cx+30,cy+30,cx-30,cy-30); EndPaint(hGraph,&ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hGraph, message, wParam, lParam);
} return 0;
}
|
|