zoukankan      html  css  js  c++  java
  • 孙鑫MFC学习笔记7:对话框编程(上)

    1.DoModal创建模态对话框

    2.Create创建非模态对话框(需要用ShowWindow显示出来)

                模态:对话框显示,程序会暂停,直到对话框关闭

                非模态:对话框显示,程序继续执行

    3.对于模态对话框,点击确定/取消对话框被销毁,而对于模态对话框,只是被隐藏

    4.对于模态对话框,需要在自己的类中覆盖OnOK这个虚函数,在OnOK中调用DestroyWindow

    5.GetWindowText获取窗口文本

    6.GetDlgItem获取对话框控件指针

    7.SetWindowText设置窗口文本

    8.静态文本框(标签)不能接收通知消息,除非把notify复选上

    9.GetDlgItemText获取控件文本

    10.SetDlgItemText设置控件文本

    11.GetDlgItemInt获取控件数字

    12.SetDlgItemInt设置控件数字

    13.UpdateData参数为TRUE,获取数据,参数为FALSE,设置数据

                在类向导里添加关联成员变量

    14.WM_GETTEXT消息获取控件文本

    An application sends a WM_GETTEXT message to copy the text that corresponds to a window into a buffer provided by the caller.

     

    To send this message, call the SendMessage function with the following parameters.

     

    SendMessage(

      (HWND) hWnd,              // handle to destination window

      WM_GETTEXT,               // message to send

      (WPARAM) wParam,          // number of characters to copy

      (LPARAM) lParam           // text buffer

    );

     

    15.WM_SETTEXT设置控件文本

                wParam必须为0

    16.SendDlgItemMessage向控件发送消息

     

    17.EM_SETSEL

    EM_SETSEL

    The EM_SETSEL message selects a range of characters in an edit control. You can send this message to either an edit control or a rich edit control.

     

    To send this message, call the SendMessage function with the following parameters.

     

    SendMessage(

      (HWND) hWnd,              // handle to destination window

      EM_SETSEL,                // message to send

      (WPARAM) wParam,          // starting position

      (LPARAM) lParam          // ending position

    );

     

    18.EM_GETSEL

    EM_GETSEL

    The EM_GETSEL message retrieves the starting and ending character positions of the current selection in an edit control. You can send this message to either an edit control or a rich edit control.

     

    To send this message, call the SendMessage function with the following parameters.

     

    SendMessage(

      (HWND) hWnd,              // handle to destination window

      EM_GETSEL,                // message to send

      (WPARAM) wParam,          // starting position (LPDWORD)

      (LPARAM) lParam          // ending position (LPDWORD)

    );

    19.SetFocus设置焦点

    20.GetFocus  获取焦点所在窗口

    21.

     

    22.IsRectEmpty判断矩形区域面积是否为0

    23IsRectNull判断矩形区域四个参数是否都为0

    24.

     

    25.

     

    26.

     

     

    27.SetWindowPos可以改变窗口大小、z-order等状态

    28.SetWindowLong设置窗口属性

    29.WM_INITDIALOG在对话框创建前产生

    30.GetNextWindow获取下一个窗口句柄

    31.GetWindow获取窗口句柄

    32.GetNextDlgTabItem获取下一个tab窗口

    33.IDOK是OK按钮的缺省消息ID,不是IDC_OK

     

     

     

    菊子曰 用菊子曰博客,就是爽!
  • 相关阅读:
    立则存
    如何在UI控件上绑定一个变量
    欢迎大家使用www.eugene.org.cn访问我的blog
    属性与字段变量的区别
    在C#中联合Excel的Com编程入门
    我和我的土匪奶奶 全集 全 下载 txt
    大菲波数
    Hat's Fibonacci
    Fibonacci 取余,直接做超时
    How Many Fibs? 字符串转换处理
  • 原文地址:https://www.cnblogs.com/SkyFireITDIY/p/4371656.html
Copyright © 2011-2022 走看看