huidong

首页 | 会员登录 | 关于争取 2022 寒假做出汇东网 Ver3.0.0 !
搜索文章


#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 



返回首页


Copyright (C) 2018-2024 huidong