PostMessage/SendMessage is not working on Button

Hi All,

I wanted to send/post the WM_LBUTTONDOWN and WM_LBUTTONUP messages to button of my other application.

When I tested this with Check box (which is from same button class), it is working fine with  the above messages(i.e checkbox is getting clicked and unclicked). But when Tested with Button  ("Yes" button), it  is not getting fired through above messages.

What is the problem??



Below is the code
               if (checkWnd != 0)
            {
            //      AfxMessageBox("Check Wnd");
                  h = checkWnd;
                  PostMessage(h, WM_LBUTTONDOWN, 0, 0);
                  PostMessage(h, WM_LBUTTONUP, 0, 0);
            }

             if( YesWnd != 0)
            {
                    //contorl is coming here.
                    // but Post and Send Messages are not working
            //      AfxMessageBox("Yes Wnd");
                  h = YesWnd;
                  //PostMessage(h, WM_LBUTTONDOWN, 0, 0);
                  //PostMessage(h, WM_LBUTTONUP, 0, 0);                  
                  SendMessage(h, WM_LBUTTONDOWN, 0, 0);
                  SendMessage(h, WM_LBUTTONUP, 0, 0);
                  

            }

Thanks
Sudhakar


P.S :- I tested the same in VB using Win API calls  and it is working fine. But I don't want to do this in VB

LVL 14
sudhakar_koundinyaAsked:
Who is Participating?
 
williamcampbellConnect With a Mentor Commented:
Have you tried sending BM_CLICK?
0
 
sudhakar_koundinyaAuthor Commented:
You mean BN_CLICK??

Yes
0
 
sudhakar_koundinyaAuthor Commented:
Sorry it is BM_CLICK only. I Just confused. Let me try
0
 
sudhakar_koundinyaAuthor Commented:
Hi,
I was able to manage with  SendMessage itself. Actually it was pointing to wrong Window. It was my mistake

Thanks
Sudhakar
0
All Courses

From novice to tech pro — start learning today.