View Single Post
  #9  
Old 02-12-2015, 23:31
BlackWhite BlackWhite is offline
Friend
 
Join Date: Apr 2013
Posts: 85
Rept. Given: 4
Rept. Rcvd 14 Times in 6 Posts
Thanks Given: 14
Thanks Rcvd at 56 Times in 25 Posts
BlackWhite Reputation: 14
I finally figure out why WM_LBUTTON does not trigger message processing of WM_NOTIFY. WM_NOTIFY should be simulated by posting two messages:
WM_LBUTTONDOWN
WM_LBUTTONUP
Here is the code:
Code:
   POINT ap={0x0027, 0x0289}, cp={0x0025, 0x00AE};
   SetFocus((HWND)hTreeView);
   SetCursorPos(ap.x, ap.y);
   ScreenToClient((HWND)hTreeView, &ap);
   cp = ap;
   PostMessage((HWND)hTreeView, WM_LBUTTONDOWN, MK_LBUTTON, cp.y<<16 | cp.x);
   PostMessage((HWND)hTreeView, WM_LBUTTONUP, 0, cp.y<<16 | cp.x);
If I delete SetFocus() or SetCursorPos(), the above code will not work;
If I substitute SendMessage() for PostMessage(), the above code will not work.
So, I'm much indebted to bilbo.
Reply With Quote