How to Focus the Next Control After Pressing Enter

Posted on December 15th, 1999 in General | No Comments »

By default the focus is passed to the next control by pressing the Tab key. Well, sometimes (when filling out forms) you may want to pass to the next control after pressing Enter. Well, here’s the code: For TEdit controls only:
Select all the TEdit controls you want to include (using the Shift key), then select the Object Inspector, choose the Events tab and double click the OnKeyPress event. This way all the selected TEdit controls will use the same code. In the code editor write this code:

if Key = #13 then begin
  Perform(WM_NEXTDLGCTL, 0, 0);
  Key := #0; { Eat the key }
end;

For all the controls on the form:
This method will work for all controls because the form will take care of the event. All you have to do is set the form’s KeyPreview property to True and add this code to your form’s KeyUp event:

if (Key = VK_RETURN) and (Shift = []) then
  Perform(WM_NEXTDLGCTL, 0, 0);

How to Obtain all Characters in Delphi 4+ IDE

Posted on December 15th, 1999 in Delphi / Kylix IDE | No Comments »

Starting with Delphi 4 certain shortcuts have changes and/or been added that make it hard to put certain letters into the Code Editor or Object Inspector. For example the Polish letter “ś” is entered by pressing Alt + S. Well, Delphi doesn’t make this possible because Alt + S is already assigned as an IDE shortcut. You can either:

  1. Copy the letter in another application and then paste it in Delphi ;-) .
  2. Use the Alt + character code method to create the letter.
  3. Disable Alt shortcuts in Delphi. This is the preferred way ;-) by programmers who have to create non-English applications every day. To turn the shortcuts off launch the Registry Editor (regedit.exe) and find the following key: HKEY_CURRENT_USER\SOFTWARE\Borland\Delphi\4.0 (or whatever version you are using)\Editor\Options. Now create a string value named “NoCtrlAltKeys” and set it’s value to “1″. If you have Delphi running remember to restart it.