消息的传送问题
dsli 2001-09-15 10:09:49 消息的传送问题
我画了一个对话框
放了一个listbox
和三个button
然后写了如下代码:
//manager.cpp
//----------------------------------------
#include "stdafx.h"
#include "manager.h"
#define LOWORD(l) ((WORD)(l))
int CALLBACK DlgProc(HWND hwndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_CLOSE:
PostQuitMessage(0);
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_NEW:
MessageBox(hwndDlg,"new","hello",MB_OK);
break;
case IDC_DEL:
MessageBox(hwndDlg,"delete","hello",MB_OK);
break;
case IDC_PROPER:
MessageBox(hwndDlg,"property","hello",MB_OK);
break;
default: break;
}
}
return 0;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
DialogBox(hInstance,MAKEINTRESOURCE(DLG_MAIN),0, DlgProc);
return 0;
}
//----------------------------------------------------------
//-res.h
#ifndef _RES_H_
#define _RES_H_
#define DLG_MAIN 101
#define IDC_DEL 1001
#define IDC_NEW 1002
#define IDC_PROPER 1003
#endif
//----------------
//manager.h
#ifndef _MANAGERH_
#define _MANAGERH_
#include <windows.h>
#include "res.h"
#endif
结果,只有当按下New按钮时才有消息发出
且每次都是IDC_PROPER 即每次都是1003
请指点