Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

changing my forms' behavior

sziszi81sziszi81 Member Posts: 80
Hello

i'd like to create a new class from TForm that will behave like:
- the focused control will have different color (so the old and weak eyes will identify easier where the cursor is)
- the Enter button doesn't activate the Default Button but will move the focus to the next control in the Taborder
- the Default Button will activate on pressing Ctrl+Enter in spite of Enter

I checked TButton's SetDefault method, and i see that i should do something with the Form's Perfomr method but i don't really understand how these things work. Can anybody help me? I appreciate any help.

Comments

  • zibadianzibadian Member Posts: 6,349
    : Hello
    :
    : i'd like to create a new class from TForm that will behave like:
    : - the focused control will have different color (so the old and weak eyes will identify easier where the cursor is)
    : - the Enter button doesn't activate the Default Button but will move the focus to the next control in the Taborder
    : - the Default Button will activate on pressing Ctrl+Enter in spite of Enter
    :
    : I checked TButton's SetDefault method, and i see that i should do something with the Form's Perfomr method but i don't really understand how these things work. Can anybody help me? I appreciate any help.
    :
    1: create an OnExit() and OnEnter() event, which changes the Color property of the ActiveControl, and assign those events to all controls on the form.
    2: Enable the KeyPreview of the form. Then in the OnKeyUp() check if the enter has been pressed, but not the ctrl key. If it is, then use FindNextControl() to find the next control in the TabOrder. By assigning that control to the ActiveControl, you can move the focus. And finally clear the Key parameter by assigning 0 to it.
    3: Again in the OnKeyUp() check if ctrl+enter is pressed. If it is, loop through all the components and if the first "default" button is found, call its Click() method. And again clear the Key parameter.
Sign In or Register to comment.