inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -


is possible change .font.style on focus tlabel or tnewstatictext happens cursor when use .cursor?

there no built-in support track mouse hovering in inno setup @ time. however, intercepting window procedure of controls can track yourself. following example need innocallback library:

[setup] appname=my program appversion=1.5 defaultdirname={pf}\my program outputdir=userdocs:inno setup examples output  [files] source: "innocallback.dll"; destdir: "{tmp}"; flags: dontcopy  [code] #ifdef unicode   #define aw "w" #else   #define aw "a" #endif const   gwl_wndproc = -4;   wm_mousemove = $0200;  type   wparam = uint_ptr;   lparam = longint;   lresult = longint;   twindowproc = function(hwnd: hwnd; umsg: uint; wparam: wparam;      lparam: lparam): lresult;  function setcapture(hwnd: hwnd): hwnd;   external 'setcapture@user32.dll stdcall'; function releasecapture: bool;   external 'releasecapture@user32.dll stdcall'; function getmessagepos: dword;   external 'getmessagepos@user32.dll stdcall'; function getwindowrect(hwnd: hwnd; out lprect: trect): bool;   external 'getwindowrect@user32.dll stdcall'; function callwindowproc(lpprevwndfunc: longint; hwnd: hwnd; msg: uint;    wparam: wparam; lparam: lparam): lresult;   external 'callwindowproc{#aw}@user32.dll stdcall'; function setwindowlong(hwnd: hwnd; nindex: integer;    dwnewlong: longint): longint;   external 'setwindowlong{#aw}@user32.dll stdcall';  function wrapwindowproc(callback: twindowproc; paramcount: integer): longword;   external 'wrapcallback@files:innocallback.dll stdcall';  type   tcontrolrec = record     hovered: boolean;     // hovering state     wndproc: longint;     // original window proc     control: twincontrol; // control instance   end;  var   statictext1: tnewstatictext;   statictext2: tnewstatictext;   controllist: array of tcontrolrec;  // helper function finding control handle function getcontrolrec(handle: hwnd): tcontrolrec; var   i: integer; begin   := 0 high(controllist)     if controllist[i].control.handle = handle     begin       result := controllist[i];       exit;     end; end;  // function attaches intercepting window procedure control // , creates , adds control record control list procedure attachwndproc(control: twincontrol; windowproc: twindowproc); begin   setarraylength(controllist, getarraylength(controllist) + 1);   controllist[high(controllist)].hovered := false;   controllist[high(controllist)].control := control;   controllist[high(controllist)].wndproc := setwindowlong(control.handle,     gwl_wndproc, wrapwindowproc(windowproc, 4)); end;  // function restore windows procedures controls in list procedure restorewndprocs; var   i: integer; begin   := 0 high(controllist)     setwindowlong(controllist[i].control.handle, gwl_wndproc, controllist[i].wndproc); end;  // helper function create tpoint structure result of getmessagepos // function call function makepoint(value: dword): tpoint; begin   result.x := value , $ffff;   result.y := value shr 16; end;  // helper function substitutes ptinrect windows api function wasn't // able import reason function pointinrect(const rect: trect; const point: tpoint): boolean; begin   result := (point.x >= rect.left) , (point.x <= rect.right) ,     (point.y >= rect.top) , (point.y <= rect.bottom); end;  // interceptor window procedure function statictextwndproc(hwnd: hwnd; umsg: uint; wparam: wparam;    lparam: lparam): lresult; var   p: tpoint;   r: trect;   controlrec: tcontrolrec; begin   // control record   controlrec := getcontrolrec(hwnd);   // if cursor moves, then...   if umsg = wm_mousemove   begin     // set mouse capture control notified wm_mousemove if     // leave control     setcapture(controlrec.control.handle);     // current cursor position , control rectangle (both screen relative)     p := makepoint(getmessagepos);     getwindowrect(controlrec.control.handle, r);     // check if cursor inside control; if yes, then...     if pointinrect(r, p)     begin       // if hovering flag not yet set, means entered control       // mouse, let's change style , remember hovering state       if not controlrec.hovered       begin         if controlrec.control tnewstatictext           tnewstatictext(controlrec.control).font.style := [fsbold];         controlrec.hovered := true;       end;     end     else     begin       // cursor not on control, let's release mouse capture, set       // style , remember hovering state       releasecapture;       if controlrec.control tnewstatictext         tnewstatictext(controlrec.control).font.style := [];       controlrec.hovered := false;     end;   end;   // call original window procedure   result := callwindowproc(controlrec.wndproc, hwnd, umsg, wparam, lparam); end;  procedure initializewizard; begin   statictext1 := tnewstatictext.create(wizardform);   statictext1.parent := wizardform;   statictext1.left := 12;   statictext1.top := 336;   statictext1.caption := 'hello';    statictext2 := tnewstatictext.create(wizardform);   statictext2.parent := wizardform;   statictext2.left := 43;   statictext2.top := 336;   statictext2.caption := 'world!';    attachwndproc(statictext1, @statictextwndproc);   attachwndproc(statictext2, @statictextwndproc); end;  procedure deinitializesetup; begin   restorewndprocs; end; 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -