本文介绍了如何向对话课发送信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我是MFC的新手,我正在使用线程,并希望使用该线程(ThreadProc)向对话类发送消息,因此我可以使用该线程在对话类中调用函数.请告诉我要使用的消息代码.(Sendmessage(?????????????))

认为我需要发送"ON_CBN_SELCHANGE"且ID为"IDC_PType"(请阅读代码)
坦克
这是代码

Hi,
I am new to MFC, I am using a thread and want to send a message to dialogue class using that thread(ThreadProc) so i can call a function in the dialogue class using that thread. Please tell me the message code to use.(Sendmessage(?????????????))

Think i need to send "ON_CBN_SELCHANGE" and id is "IDC_PType" (Please read the code)
Tanks
Here is the code

// UMKurunegalaDlg.cpp : implementation file
//

#include "stdafx.h"
#include "UMKurunegala.h"
#include "UMKurunegalaDlg.h"
#include "afxdialogex.h"



#ifdef _DEBUG
#define new DEBUG_NEW
#endif
static int Data_Of_Thread_1 = 1;
static HANDLE Handle_Of_Thread = 0;
int val = 0;

void ThreadProc(void *param)// *** The thread i am using
{
    int h=*((int*)param);

	SendMessage(?????????????????????????????????????????????????????);

    _endthread();
}
		/*DWORD WINAPI setBitThread(LPVOID lpParam)
{
	CUMKurunegalaDlg::OnCbnEditchangePtype();
    return 0;
} */

// CAboutDlg dialog used for App About

class CAboutDlg : public CDialogEx
{
public:
	CAboutDlg();

// Dialog Data
	enum { IDD = IDD_ABOUTBOX };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()


// CUMKurunegalaDlg dialog




CUMKurunegalaDlg::CUMKurunegalaDlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(CUMKurunegalaDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CUMKurunegalaDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, teststt, testt);
	DDX_Control(pDX, IDC_VType, vtypec);
	DDX_Control(pDX, IDC_pricest, pricest);
	DDX_Control(pDX, IDC_VBrand, vbrandc);
	DDX_Control(pDX, IDC_VModel, vmodelc);
	DDX_Control(pDX, IDC_VPart, vpartc);
	DDX_Control(pDX, IDC_PType, ptypec);

}

BEGIN_MESSAGE_MAP(CUMKurunegalaDlg, CDialogEx)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_CBN_SELCHANGE(IDC_VType, &CUMKurunegalaDlg::OnCbnSelchangeVtype)
	ON_CBN_SELCHANGE(IDC_VBrand, &CUMKurunegalaDlg::OnCbnSelchangeVbrand)
	ON_CBN_SELCHANGE(IDC_VModel, &CUMKurunegalaDlg::OnCbnSelchangeVmodel)
	ON_CBN_SELCHANGE(IDC_VPart, &CUMKurunegalaDlg::OnCbnSelchangeVpart)
	ON_CBN_SELCHANGE(IDC_PType, &CUMKurunegalaDlg::OnCbnSelchangePtype)
	ON_CBN_EDITCHANGE(IDC_PType, &CUMKurunegalaDlg::OnCbnEditchangePtype)
	ON_CBN_CLOSEUP(IDC_PType, &CUMKurunegalaDlg::OnCbnCloseupPtype)
END_MESSAGE_MAP()

推荐答案

 void ThreadProc(LPVOID lParam)
{
   CCurrentDialog* pDlg = (CCurrentDialog*)lParam;
   SendMessage(pDlg->m_hWnd,ON_CBN_SELCHANGE,NULL,NULL);
}



您可以使用 PostMessage [ ^ ].



You can use PostMessage[^] also.


这篇关于如何向对话课发送信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 20:09