windows - Delphi FindVCLWindow returning nil -


my application uses mouse wheel scrolling in number of places.

thus i’ve written mouse wheel handler, , handler works out mouse located before calling appropriate object method.

on pcs works fine, have 1 laptop here not. despite handler receiving correct mouse co-ordinates windows, calls findvclwindow returning nil. happening when use laptop’s internal touch pad. external usb mice work fine.

i’ve updated laptop’s touch pad driver latest available manufacturer's web site, no avail.

how else can fix this?

here’s code:

unit mouse_wheel_testing;  interface  uses   windows, messages, sysutils, classes, graphics, controls, forms, dialogs,   stdctrls, extctrls, grids;  type   tform1 = class(tform)     panel1: tpanel;     stringgrid1: tstringgrid;     mouse_coordinates: tedit;     control_name: tedit;     button1: tbutton;     procedure mousewheelhandler(var message: tmessage); override;   private     { private declarations }   public     { public declarations }   end;  var   form1: tform1;  implementation  {$r *.dfm}  procedure tform1.mousewheelhandler(var message: tmessage); var   target_control: twincontrol; begin   twmmousewheel(message)   begin     mouse_coordinates.text := inttostr(xpos) + ', ' + inttostr(ypos);     target_control := findvclwindow(point(xpos, ypos));     if target_control <> nil       control_name.text := target_control.name     else       control_name.text := 'nil';   end; end;  end. 

the reason why findvclwindow returning nil windowfrompoint returning incorrect handle. in turn result of setting in laptop relating behavior of touch pad when in scrolling mode. option needed set correctly correct handle returned.

since application cannot rely on user having laptop set correctly, have written new findcomponent function based upon childwindowfrompointex. following function resides within mouse wheel handler:

function find_control: twincontrol; var   parent: hwnd;   child: hwnd;   position: tpoint; begin { find_control }   result := nil;   parent := self.handle;   twmmousewheel(message)     position := screentoclient(point(xpos, ypos));   child := childwindowfrompointex(parent, position, cwp_skipinvisible);   while (child <> 0) , (child <> parent)   begin     result := findcontrol(child);     position := point(position.x - result.left, position.y - result.top);     parent := child;     child := childwindowfrompointex(parent, position, cwp_skipinvisible);   end; { while (child <> 0) , (child <> parent) } end; { find_control } 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -