#include <stdio.h>
#include <easyx.h>
#include <conio.h>
WNDPROC EasyXProcess;
LRESULT MyWindowProcess(HWND handle, UINT message, WPARAM wparam, LPARAM lparam)
{
switch (message)
{
case WM_CLOSE:
closegraph();
case WM_DESTROY:
return 0;
break;
}
return EasyXProcess(handle, message, wparam, lparam);
}
int main() {
initgraph(900, 900, EW_SHOWCONSOLE);
printf("Console");
EasyXProcess = (WNDPROC)GetWindowLongPtr(GetHWnd(), GWLP_WNDPROC);
SetWindowLongPtr(GetHWnd(), GWLP_WNDPROC, (LONG_PTR)MyWindowProcess);
_getch();
return 0;
}
如上,实现了用户点击关闭窗口后,控制台仍然保留的功能。
修改自:https://qa.codebus.cn/question/2260