消息处理函数问题?

5312 2006-02-16 06:33:28
我看一程序时候,它的对话框程序中有WM_QUERYENDSESSION,我用我的CLASSWIZARD里面没有?
怎么才可以把不常用的处理消息添加进去?
谢谢!
...全文
83 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
5312 2006-02-20
  • 打赏
  • 举报
回复
zxw2844(赵轩)
谢谢,我找到了。
zxw2844 2006-02-16
  • 打赏
  • 举报
回复
好多消息是要自己加上去的,怎么加???
......在ClassView窗口,在具体某个类上单击鼠标右键,有个Add Windows Message Handler...
并不是所有的类都这一项,要看类的类型.
smartstar2005 2006-02-16
  • 打赏
  • 举报
回复
一样的啊,
消息函数自己定义也一样。
smartstar2005 2006-02-16
  • 打赏
  • 举报
回复
自己加吧
一样的
5312 2006-02-16
  • 打赏
  • 举报
回复
这个例子在这!!!!
http://cjgg.512j.com/example.rar
5312 2006-02-16
  • 打赏
  • 举报
回复
不是的。好像自己就带了。我看了他们的那CLASSWIZARD,里面的消息确实比我的多的多。
// ExampleDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Example.h"
#include "ExampleDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

BOOL m_AllowExit;
/////////////////////////////////////////////////////////////////////////////
// CExampleDlg dialog

CExampleDlg::CExampleDlg(CWnd* pParent /*=NULL*/)
: CDialog(CExampleDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CExampleDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CExampleDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CExampleDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CExampleDlg, CDialog)
//{{AFX_MSG_MAP(CExampleDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_QUERYENDSESSION()
ON_BN_CLICKED(IDC_RADIO_NO, OnRadioNo)
ON_BN_CLICKED(IDC_RADIO_YES, OnRadioYes)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CExampleDlg message handlers

BOOL CExampleDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here
CButton *pRadion;
pRadion=(CButton *)GetDlgItem(IDC_RADIO_YES);
pRadion->SetCheck(1);
m_AllowExit=TRUE;
return TRUE; // return TRUE unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.

void CExampleDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CExampleDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

BOOL CExampleDlg::OnQueryEndSession()
{
if (!CDialog::OnQueryEndSession())
return FALSE;

// TODO: Add your specialized query end session code here
return m_AllowExit;
}

void CExampleDlg::OnRadioNo()
{
// TODO: Add your control notification handler code here
m_AllowExit=FALSE;
}

void CExampleDlg::OnRadioYes()
{
// TODO: Add your control notification handler code here
m_AllowExit=TRUE;
}
pomelowu 2006-02-16
  • 打赏
  • 举报
回复
用ClassWizzard添加一个消息映射,然后按修改的地方,医葫芦画瓢,自己改。

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧