zoukankan      html  css  js  c++  java
  • MFC禁止改变窗口大小和移动窗口

    一、禁止对话框的移动

    (1)、第一种方法 为这个对话框添加系统消息过虑处理: .h中:

    afx_msg void OnSysCommand(UINT nID, LPARAM lParam);

    ... .cpp中

    BEGIN_MESSAGE_MAP(CXXXDlg, CDialog)

    ... ON_WM_SYSCOMMAND()

    ... END_MESSAGE_MAP()

    void CXXXDlg::OnSysCommand(UINT nID, LPARAM lParam)

    {

       if (nID == SC_MOVE || nID==0xF012)

         return;

      else

       CDialog::OnSysCommand(nID, lParam);

    }

    SC_MOVE就是0xF010。

    参考帖子:http://topic.csdn.net/t/20020821/12/957952.html

    (2)、第二种方法 .h中: ...

    afx_msg UINT OnNcHitTest(CPoint point);

    ... .cpp中

    BEGIN_MESSAGE_MAP(CXXXDlg, CDialog)

    ... ON_WM_NCHITTEST()

    ... END_MESSAGE_MAP()

    UINT CXXXDlg::OnNcHitTest(CPoint point)

    {

       int ret = CDialog::OnNcHitTest(point);

       if( HTCAPTION == ret)

         return HTCLIENT;

      return ret;

    }

    二、禁止对话框改变大小 .h中:

    ... afx_msg UINT OnNcHitTest(CPoint point);

    ... .cpp中 BEGIN_MESSAGE_MAP(CXXXDlg, CDialog)

    ... ON_WM_NCHITTEST()

    ... END_MESSAGE_MAP()

    UINT CXXXDlg::OnNcHitTest(CPoint point)

    {

      int ret = CDialog::OnNcHitTest(point);

       //if语句的前两行是用来禁止改变大小的,最后一行是用来禁止移动的

       if(HTTOP == ret || HTBOTTOM == ret || HTLEFT == ret || HTRIGHT == ret || HTBOTTOMLEFT == ret || HTBOTTOMRIGHT == ret || HTTOPLEFT == ret || HTTOPRIGHT == ret || HTCAPTION == ret)

       return HTCLIENT;

    return ret;

    }

  • 相关阅读:
    SQL注入详解
    Nginx跨域及Https配置
    GET请求和POST请求的request和response的中文乱码问题
    创建Maven工程
    Maven环境变量配置
    Cookie&Session会话技术
    Maven库站
    20191002思维导图工具MindManager 000 033
    20190930-02 Redis持久化方式一:RDB及修改RDB的默认持久化策略 000 032
    Tomcat配置HTTPS方式生成安全证书
  • 原文地址:https://www.cnblogs.com/fei12/p/456s.html
Copyright © 2011-2022 走看看