delphi - Override the Tab control for a single Object -


i found code override entire class:

{ private declarations }   procedure cmdialogkey(var msg: twmkey) ;   message cm_dialogkey;  procedure tform1.cmdialogkey(var msg: twmkey); begin   if (activecontrol tedit) , (msg.charcode = vk_tab)   begin    //   end else     inherited; end;  procedure tform1.edit1keypress(sender: tobject; var key: char); begin   showmessage('tab pressed!'); end; 

which works fine (for entire class).

is there easy understand code (i'm starting programmer) can use? or can change code above fit needs?

following on comments, 1 way asking make use of tag property every vcl control has. define constant :

const move_next = 123;  

then, in designer, choose whichever control in tabsheet final control triggers page change , set tag property 123. ideally, control highest taborder on page. programmatically, of course.

enter image description here

in method, :

procedure tform1.cmdialogkey(var msg: twmkey); begin   if (activecontrol.tag = move_next) ,      (msg.charcode = vk_tab) ,      (pagecontrol1.activepageindex < pagecontrol1.pagecount - 1)   begin     pagecontrol1.activepageindex := pagecontrol1.activepageindex + 1;     msg.result := 1;     // note : practice set message result 1      // indicate have handled message.   end else     inherited; end; 

the method above cause tab key cycle through of pages, landing @ each control in taborder dictated contained controls. control tag property of 123 trigger selection of next tab. written, cycle through page control once , leave next control on form.

on next cycle around, of course, pagecontrol remain on final page , tab key cycle through controls on final page before moving on. have page control reset first page each time, however, doing similar preceding taborder control on form - example :

procedure tform1.cmdialogkey(var msg: twmkey); begin   if (activecontrol.tag = move_next) ,      (msg.charcode = vk_tab) ,      (pagecontrol1.activepageindex < pagecontrol1.pagecount - 1)   begin     pagecontrol1.activepageindex := pagecontrol1.activepageindex + 1;     msg.result := 1;     exit;   end;    // define new const move_first = 124    if (activecontrol.tag = move_first) , (msg.charcode = vk_tab)   begin     pagecontrol1.activepageindex := 0;     pagecontrol1.setfocus;     msg.result := 1;     exit;   end;    inherited; end; 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -