C,win32:l需要sendmessage函数的帮助 [英] C, win32: l need help with sendmessage function
问题描述
我需要帮助我如何在我的程序中向病例WM_NOTIFY发送消息。我希望当点击一个按钮时(如下面的WM_COMMAND),SendMessage函数激活WM_NOTIFY案例,以便WM_NOTIFY案例中的代码运行。
l已经尽了最大努力,但我只是得不到处理异常错误消息。
以下片段;
Please l need help on how i can send message to case WM_NOTIFY in my program. l want when a button is clicked(as in the case WM_COMMAND below), the SendMessage function activates case WM_NOTIFY so that the codes inside the WM_NOTIFY case will run.
l had tried my best but l only get unhandled exception error messages.
snippet below;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDC_NEXTBTN:
QueNo++;
SendMessage(hWnd,WM_NOTIFY,(int)IDC_NEXTBTN,(NMHDR)lParam);//here l cast wparam to int and wparam to (NMHDR) according to msdn for WM_NOTIFY
break;
......
而在WM_NOTIFY,我有
while in WM_NOTIFY, i have
case WM_NOTIFY:
{
if(lpnmhdr->code==TCN_SELCHANGE||lpnmhdr->hwndFrom==NextBtn){
.....
}
或者还有其他方法可以实现它。
谢谢大家
< b>我尝试了什么:
Or is there any other way l can implement it.
Thanks everyone
What I have tried:
SendMessage(hWnd,WM_NOTIFY,(int)IDC_NEXTBTN,(NMHDR)lParam)
推荐答案
SendMessage函数激活案例WM_NOTIFY,以便WM_NOTIFY案例中的代码运行。
the SendMessage function activates case WM_NOTIFY so that the codes inside the WM_NOTIFY case will run.
我不会这样做。相反,我会将 WM_NOTIFY
case中的代码作为一个函数进行分解并直接调用这样的函数。
I won't do that. Instead I would factor out 'the code inside the WM_NOTIFY
case' as a function and call directly such a function.
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDC_NEXTBTN:
QueNo++;
NMHDR nmh;
nmh.code = NM_CLICK; // Message type defined by control.
nmh.idFrom =IDC_NEXTBTN;
nmh.hwndFrom = NextBtn;
SendMessage(GetParent(NextBtn), WM_NOTIFY, nmh.idFrom, (LPARAM)&nmh);
break;
根据Konfeld提供的链接。
非常感谢所有贡献的人。
@CPallini:我会的,但不会比我想要的好多了。
Based on the link given by Konfeld.
And many thanks to all of you who contributed.
@CPallini: l would have but it wouldn't be much better than as l wanted.
这篇关于C,win32:l需要sendmessage函数的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!