C, Win32 API: Help with SendMessage

Please l need help on how i can send message to WM_NOTIFY case 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;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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;
		case IDC_PREVBTN:
			QueNo--;
			SendMessage(hWnd,WM_NOTIFY,wParam,lParam);
			break;
......


while in WM_NOTIFY, i have

1
2
3
4
5
6
case WM_NOTIFY:
		{
		
		if(lpnmhdr->code==TCN_SELCHANGE||lpnmhdr->hwndFrom==NextBtn||lpnmhdr->hwndFrom==PrevBtn){
			
.....



please can someone help me out.
Thanks everyone
Last edited on
No one to help yet?
I think the problem is on line 9: (NMHDR)lParam

Inside WM_COMMAND lParam is the handle of the button, you can't just cast it into a NMHDR.

What do you actually want to do?
@Thomas1965: Thanks. But l got the solution on this link: https://msdn.microsoft.com/en-us/library/windows/desktop/bb775583%28v=vs.85%29
Yes when you receive a WM_NOTIFY message. This type of message is send from the child control to the parent. For example: when you have a listbox on your main windows and click on it it will send the WM_NOTIFY to its parent - in this case the main window.
Topic archived. No new replies allowed.