May 082016
 

I tried to compile the SarchWiz project by Corbin Dunn, which he describes in the corresponding article which in turn Ondrey Kelle mentioned in his blog post More Subversion.

(The links to code central and edn above are the ones Embarcadero created from the original links to code central and bdn when they were still operated by Borland. Luckily they did not change the article IDs so it was only a matter of converting the urls to the new adresses. Allan Bauer’s example code is here, btw.)

The first problem I ran into was that the original wizard was written for Delphi 5 (yes 5, not XE5). So some package and unit names had changed.

  • The VCL/RTL etc. .dcp files no longer have the version sufix (only the corresponding .bpl files do), so the package requires vcl, vclie and inet rather than vcl50, vclie50 and inet50
  • The dsnide50 package is now called dsignide
  • The unit DsgnIntf no longer exists, but apparently nothing was used from it, so I just removed it from the uses list.

Then, there is TDockableForm, the ancestor of the TSearchWizForm class used in the wizard. Apparently the declarations of LoadWindowState and SaveWindowState have changed. In Delphi 5 the Desktop parameter was a TMemIniFile, nowadays it’s a TCustomIniFile.

// old
procedure LoadWindowState(Desktop: TMemIniFile); override;
procedure SaveWindowState(Desktop: TMemIniFile; isProject: Boolean); override;

// new
procedure LoadWindowState(Desktop: TCustomIniFile); override;
procedure SaveWindowState(Desktop: TCustomIniFile; isProject: Boolean); override;

The last change to get it to compile was changing the WebBrowserBeforeNavigate2 method. In Delphi 5 some parameters were declared as var, they now are const:

// old
procedure WebBrowserBeforeNavigate2(Sender: TObject;
  const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
  Headers: OleVariant; var Cancel: WordBool);

// new
procedure WebBrowserBeforeNavigate2(ASender: TObject;
  const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData,
  Headers: OleVariant; var Cancel: WordBool);

So, I compiled and installed the package without errors, and … nothing happened. Since it is an ancient wizard, I looked into the help menu and found Help -> Help Wizards -> Web Search, which is the menu entry added by the wizard. Clicking on it still didn’t do anything.

After putting a breakpoint in the wizard’s execute method (and setting the host application to the Delphi ide), I found that the window is actually being created and shown. It’s listed in the IDE’s Window menu and I eventually found it on the screen: It was far down behind the task bar (which fortunately in Windows 8.1 is transparent). So, switching to it and pressing Alt+Space gave me the system menu and selecting Maximize finally brought it somewhere sensible. It turned out that the problem was this code:

procedure TSearchWizard.Execute;
begin
  if SearchWizForm = nil then
  begin
    SearchWizForm := TSearchWizForm.Create(Application);
    SearchWizForm.Left := 10;
    SearchWizForm.Top := Application.MainForm.Top +
      Application.MainForm.Height + 10;
  end;

  FocusWindow(SearchWizForm);
end;

Application.MainForm is no longer the small window it was in Delphi 5 which contained only the menu, tool bars and component palette but the whole Window, so setting the form’s top position to MainForm.Top + MainForm.Height + 10 no longer positions it below the component palette but below the normal screen area.

After changing it to simply 10, the wizard window is displayed and can be used.

It’s very strange to see Altavista, Deja.com, Excite and Northern Light in the list of search engines. Apparently Altavista now gets redirected to Yahoo, deja.com is now Google groups, excite.com still exists, but search.excite.com does not work, and northernlight.com is no longer a search engine. I changed the excite entry to the new url and it worked (ignoring some JavaScript errors).

This is what it looks like when sarching excite for “delphi programming” when the wizard is docked to the Delphi 10 IDE:

SearchWiz

Now, you might ask why I went through all this, just to have a web search window in the IDE? It’s connected with my Delphi7Help4Bds expert. It currently uses the Welcome Screen to display its results when configured to call a url. I thought about creating my own browser window and – you know that if you looked at the code – I had started to build something based on some code I got from Simon Stuart before he stopped publishing stuff under open source licenses and shut down his blog in 2012. And since I was unable to get it to work, I googled for other stuff using similar techniques. So I came across Ondrey Kelles’s post and the links there took me to this ancient wizard code. Isn’t it strange what turns life can take?

Sorry, the comment form is closed at this time.

%d bloggers like this: