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);
Categories: General Tags: borland, code, codegear, control, Delphi, double click, enter, faq, free, good, ide, key, key well, Kylix, next, object inspector, onkeypress event, return, shift key, source code, tab key, tedit, tip, trick, vk, wm, working
If you want to include a link to a web page and you want Netscape Navigator to do it you may want to look at this code. This should work with Netscape Navigator. This function has not yet been tested with Netscape Navigator 6.0.
uses
DDEMan, Registry;
...
procedure StartNetscape(const sURL: string);
const
sNETSCAPE = 'Netscape';
var
sLocation: string;
begin
with TRegistry.Create do
try
RootKey := HKEY_CLASSES_ROOT;
if OpenKeyReadOnly(sNETSCAPE + 'MarkupprotocolStdFileEditingserver') then begin
sLocation := ReadString('');
CloseKey;
end;
finally
Free;
end;
with TDDEClientConv.Create(nil) do
try
{ The location of Netscape Navigator }
ServiceApplication := sLocation;
{ Activate Netscape Navigator }
SetLink(sNETSCAPE, 'WWW_Activate');
RequestData('0xFFFFFFFF');
{ Go to the specified URL }
SetLink(sNETSCAPE, 'WWW_OpenURL');
RequestData(sURL + ',,0xFFFFFFFF,0x3,,,');
CloseLink;
finally
Free;
end;
end;
Example: StartNetscape(‘http://www.m3Rlin.org‘);
Categories: General, Internet / LAN Tags: borland, browser, code, codegear, control, control netscape navigator, dde, Delphi, free, hkey, netscape, netscape navigator 6, nil, open, registry, source, start, web page