Programmers: Using WordWeb from your programs
You can either use the command line, send a message to the system tray icon (which will show WordWeb as though the use had clicked on it on the system tray), or you can call the WordWeb DLL that is installed to the Windows or Windows System folder.
If your software is widely distributed and you add support for WordWeb, please e-mail
[email protected]. to be added to a mailing list so you can be informed of new versions and test compatibility before public release.
Command Line (requires WordWeb version 2.2 or higher)
You can use the Windows RUNDLL32 program to invoke WordWeb thus:
Rundll32 WWEB32.DLL,ShowRunDLL word_to_lookup
Running the above from the command shell would show WordWeb with the word “word_to_lookup” selected. This can be empty, and also a multi-part phrase.
Show from the system tray (requires WordWeb version 2.2 or higher)
[note: must already be running in the notification area - cc]Send the wm_WordWebShowAtom message to the tray window, which is called “WordWeb Tray Icon”. WParam should be a global atom containing the word to look up. LParam should be the handle to the main window of the calling program if you want to enable word replacement, otherwise zero. WordWeb will delete the atom, do not delete it from your code.
If the Copy/Replace button is clicked, and LParam<>0, the LParam window is sent the wm_WordWebShowAtom message (with LParam being the atom containing the replacement word). WordWeb will delete the atom, do not delete it from your code.
Both WParam and LParam can be zero. Here is some sample code:
H:=FindWindow(‘WordWeb Tray Icon’,’WordWeb Tray Icon’);
If H<>0 then
Begin
SetForegroundWindow(H); // So WordWeb can activate
wm_WordWebShowAtom :=RegisterWindowMessage('WordWebShowAtom');
LoopupWord:=’test’;
SendMessage(H,wm_WordWebShowAtom,GlobalAddAtom(PChar(LookupWord)),Self.Handle);
end else {... WordWeb not found}
You then also need to write a message handler for the Self.Handle window to process the wm_WordWebShowAtom message and replace the lookup word with ReplaceWord obtained from GlobalGetAtomName(WParam, ReplaceWord, 255). This should return quickly as the message is sent, not posted.
Using the DLLHere’s what the Borland Pascal/Delphi declarations for the DLL function call look like in case you choose this method to show WordWeb (always produces a new window, even if one is already showing). This is also available in WordWeb version 1.6x.
function ShowModalWordWeb(InP,OutP:PChar; CloseOnCopy:Boolean; AParent:Integer): Boolean; stdcall;
Shows WordWeb modally - i.e. it shows the window but waits for the window to close before returning. InP functions the same as P in ShowWordWeb. OutP points to a buffer to contain any selected word (the buffer should be 255 bytes long). CloseOnCopy determines whether the function returns with the selected word when the user presses the copy button. If this is true, pressing Copy closes the window, OutP contains the selected word and the function returns true. If WordWeb is closed by pressing Close the function returns false.