Click here to Skip to main content
16,014,662 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
xqhrs2328-May-08 21:12
xqhrs2328-May-08 21:12 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
Mark Salsbery9-May-08 6:51
Mark Salsbery9-May-08 6:51 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
xqhrs23210-May-08 16:12
xqhrs23210-May-08 16:12 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. [modified] Pin
Mark Salsbery10-May-08 17:07
Mark Salsbery10-May-08 17:07 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
xqhrs23213-May-08 3:28
xqhrs23213-May-08 3:28 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
Mark Salsbery13-May-08 4:45
Mark Salsbery13-May-08 4:45 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
xqhrs23213-May-08 20:38
xqhrs23213-May-08 20:38 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
Mark Salsbery14-May-08 5:53
Mark Salsbery14-May-08 5:53 
xqhrs232 wrote:
Because the MFC message is a way,the win32 Messge is another way


What do you mean? They are all Windows messages - there's no MFC messages.


xqhrs232 wrote:
you think that my win32 message way is wrong?


Not wrong, just unnecessary. You're using MFC - why use a Win32 style Window proc
when MFC handles that for you? If you do that, then all MFC is, is an expensive wrapper
around an HWND.


xqhrs232 wrote:
if i want to use the WM_COMMAND message to dispose the common control's press message.what can i do?


Again, what do you mean? Your original problem was closing the dialog on a
button press, right? I showed you MFC style code that does that. If you want
to use the WM_COMMAND message instead of the button click notification message,
then use it. Same effect. Here's the WM_COMMAND version:
BEGIN_MESSAGE_MAP(CSettingDlg, CDialog)
	ON_COMMAND(IDC_Btn_SetEsc, &CMFCTesterDlg::OnBtn_SetEscCommand)
	ON_WM_CLOSE()
END_MESSAGE_MAP()


LRESULT CSettingDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
//	switch(message)
//	{
//		case WM_COMMAND:
//
//			//I use the button to exit the dialog,which is static create by me!
//			if(wID==IDC_Btn_SetEsc) //static create the button
//			{
//				this->SendMessage(WM_CLOSE,NULL,NULL);
//				return TRUE;
//		
//				//break;
//			}
//
//		case WM_CLOSE:
//			// case WM_DESTROY://2008--4--24 xqh_xg
//			DeleteObjects(); //free the used object
//			break;
//
//	}//switch(message)

	return CDialog::WindowProc(message, wParam, lParam);
} 


void CSettingDlg::OnBtn_SetEscCommand()
{
	PostMessage(WM_CLOSE);
}

void CSettingDlg::OnClose()
{
	DeleteObjects(); //free the used object

	CDialog::OnClose();
}

Anyway, you missed my point in my original post, which was that you needed
to POST the WM_CLOSE message, not SEND it.

Mark

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
xqhrs23214-May-08 17:13
xqhrs23214-May-08 17:13 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
Mark Salsbery14-May-08 18:00
Mark Salsbery14-May-08 18:00 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
xqhrs23215-May-08 0:16
xqhrs23215-May-08 0:16 
QuestionTaking advantage of multi-core procesors?? Pin
97C5ENVY8-May-08 11:13
97C5ENVY8-May-08 11:13 
AnswerRe: Taking advantage of multi-core procesors?? Pin
CPallini8-May-08 12:33
mveCPallini8-May-08 12:33 
AnswerRe: Taking advantage of multi-core procesors?? Pin
toxcct8-May-08 21:48
toxcct8-May-08 21:48 
AnswerRe: Taking advantage of multi-core procesors?? Pin
Michael Schubert8-May-08 21:51
Michael Schubert8-May-08 21:51 
GeneralRe: Taking advantage of multi-core procesors?? Pin
Mark Salsbery9-May-08 6:54
Mark Salsbery9-May-08 6:54 
GeneralRe: Taking advantage of multi-core procesors?? Pin
Michael Schubert9-May-08 11:02
Michael Schubert9-May-08 11:02 
GeneralRe: Taking advantage of multi-core procesors?? Pin
Mark Salsbery9-May-08 12:18
Mark Salsbery9-May-08 12:18 
GeneralRe: Taking advantage of multi-core procesors?? Pin
Michael Schubert9-May-08 13:48
Michael Schubert9-May-08 13:48 
GeneralRe: Taking advantage of multi-core procesors?? Pin
Mark Salsbery9-May-08 14:40
Mark Salsbery9-May-08 14:40 
GeneralRe: Taking advantage of multi-core procesors?? Pin
97C5ENVY16-May-08 8:35
97C5ENVY16-May-08 8:35 
QuestionProgress indictor while copying files using CopyFileEx Pin
itsh118-May-08 11:05
itsh118-May-08 11:05 
AnswerRe: Progress indictor while copying files using CopyFileEx Pin
David Crow8-May-08 16:19
David Crow8-May-08 16:19 
QuestionSockets and resource limit per thread Pin
bob169728-May-08 8:22
bob169728-May-08 8:22 
AnswerRe: Sockets and resource limit per thread Pin
Randor 8-May-08 8:51
professional Randor 8-May-08 8:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.