zoukankan      html  css  js  c++  java
  • 简单的 win32对话框程序 c++ 模式对话框 非模式对话框 2

    模式对话框程序:

    LRESULT CALLBACK DialogProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
    {
      switch(uMsg)
      {
        case WM_INITDIALOG:
          //MoveWindow(hWnd,100,100,500,300,FALSE);
          SetWindowPos(hWnd,NULL,200,200,0,0,SWP_NOSIZE);
          return TRUE; // 表示已经初始化
        case WM_COMMAND:

          if(LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
          {
            EndDialog(hWnd,TRUE); //只用于模式对话框
            return TRUE;
          }
          break;
      }

      return FALSE;//消息没有被处理,交给父窗口继续处理
    }

    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int nShowCmd)
    {

      DialogBox(hInstance, (LPCTSTR)(IDD_DIALOG1), NULL, (DLGPROC)DialogProc);//IDD_DIALOG1是对话框资源的ID 

      return 0;
    }

    非模式对话框程序:

    LRESULT CALLBACK DialogProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
    {
      switch(uMsg)
      {
        case WM_INITDIALOG:
          //MoveWindow(hWnd,100,100,500,300,FALSE);
          SetWindowPos(hWnd,NULL,200,200,0,0,SWP_NOSIZE);
          return TRUE; // 表示已经初始化

        case WM_COMMAND:

          if(LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 

          {
            PostQuitMessage(0);
            return TRUE;
          }
          break;

        case WM_DESTROY:
          PostQuitMessage(0);
          break;
        //可以试试加上此段代码的效果!
        //default:
        // return DefWindowProc(hWnd, uMsg, wParam, lParam);
      }
      return FALSE;//消息没有被处理,交给父窗口继续处理
    }

    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int nShowCmd)
    {

      HWND hDialog =
        CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)DialogProc);

      ShowWindow(hDialog, SW_SHOW);
      UpdateWindow(hDialog);

      MSG msg;

      while(GetMessage(&msg, NULL, 0, 0))
      {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
      }

      return 0;
    }


  • 相关阅读:
    Digital Video Stabilization and Rolling Shutter Correction using Gyroscope 论文笔记
    Distortion-Free Wide-Angle Portraits on Camera Phones 论文笔记
    Panorama Stitching on Mobile
    Natural Image Stitching with the Global Similarity Prior 论文笔记 (三)
    Natural Image Stitching with the Global Similarity Prior 论文笔记(二)
    Natural Image Stitching with the Global Similarity Prior 论文笔记(一)
    ADCensus Stereo Matching 笔记
    Efficient Large-Scale Stereo Matching论文解析
    Setting up caffe on Ubuntu
    Kubernetes配置Secret访问Harbor私有镜像仓库
  • 原文地址:https://www.cnblogs.com/sikale/p/2396337.html
Copyright © 2011-2022 走看看