• 2子窗口


    #include<Windows.h>

    LRESULT CALLBACK WndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
    {
    switch(msg)
    {
    case WM_CREATE:
    /*MessageBox(hWnd,TEXT("窗口已创建"),TEXT("窗口"),MB_OKCANCEL)*/;break;
    case WM_DESTROY:
    PostQuitMessage(0);break;
    case WM_SYSCOMMAND:
    if(wParam==SC_CLOSE)
    {
    int nRect=MessageBox(hWnd,TEXT("确定关闭窗口"),TEXT("窗口"),MB_OKCANCEL);
    if(nRect==IDOK)
    {}
    else
    return 0;
    break;
    }
    }
    return DefWindowProc(hWnd,msg,wParam,lParam);
    }

    void MyRegisterWindowClass(HINSTANCE hInstance,LPCWSTR lpClassName,WNDPROC WndProc)
    {
    WNDCLASS wc={0};
    wc.lpszClassName=lpClassName;
    wc.style=CS_HREDRAW|CS_VREDRAW;
    wc.cbClsExtra=NULL;
    wc.cbWndExtra=NULL;
    wc.hbrBackground=(HBRUSH)COLOR_WINDOW;
    wc.hCursor=NULL;
    wc.hIcon=NULL;
    wc.hInstance=hInstance;
    wc.lpfnWndProc=WndProc;
    wc.lpszMenuName=NULL;
    RegisterClass(&wc);
    }

    int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
    {
    //注册主窗口
    MyRegisterWindowClass(hInstance,TEXT("main"),WndProc);
    //创建主窗口
    HWND hWnd=CreateWindow(TEXT("main"),TEXT("TEXT"),WS_OVERLAPPEDWINDOW,200,200,1000,600,NULL,NULL,hInstance,NULL);
    //注册子窗口
    MyRegisterWindowClass(hInstance,TEXT("child"),WndProc);
    //创建子窗口
    HWND hWnd1=CreateWindow(TEXT("child"),TEXT
    ("TEXT1"),WS_CHILD|WS_VISIBLE|WS_OVERLAPPEDWINDOW/*前两个必备*/,100,200,500,300,hWnd,NULL,hInstance,NULL);
    MoveWindow(hWnd1,100,100,800,400,NULL);
    //显示窗口
    ShowWindow(hWnd,SW_SHOW); //必须显示主窗口
    //ShowWindow(hWnd1,SW_SHOW);
    UpdateWindow(hWnd);
    //消息循环
    MSG msg={0};
    while(GetMessage(&msg,NULL,0,0))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    return 0;
    }

  • 相关阅读:
    二次封装CoreData
    <html>
    [bzoj1031][JSOI2007]字符加密Cipher
    kernel build &amp; preempt-rt patch &amp; xenomai
    java 微信server录音下载到自己server
    shell文本过滤编程(十一):paste命令
    经验总结21--抓取WEB数据,汇率,HtmlAgilityPack
    iOS 获取appstore 版本
    poj 3259 Wormholes 【SPFA&amp;&amp;推断负环】
    【ruby项目,语言提交检查(一)】怎样高速学习ruby ?
  • 原文地址:https://www.cnblogs.com/gd-luojialin/p/7471215.html
Copyright © 2020-2023  润新知