The way I did it (still working on a few little glitches) was to write an
ActiveX Dll, expose an object, then create that object through a script, passing
it the script "global" object ( which provides access to all the script
functions like newEditor(), ...)

This way your dll is loaded in the same process (and thread) as PSPad, so you
can subclass/api hook/whatever to your heart's content.

For the code explorer window, I'd work like this:

(VB6 examples)

* Have a Form, an instance of which is owned by the loader object. Make this
form a child window of the "real" code explorer (quick SetParent() call). But
invisible to start with.

* On startup, set a CBT hook and watch for HCBT_SETFOCUS events. Whenever a code
pane is activated, for whatever reason, it will be passed the focus, so this is
the best place to be notified of the activation.

* When a pane is activated, get the current filename and check whether the user
wants to override this type. If he doesn't, then make sure the form is hidden.
If he does, load whatever setup you need and show (and z-order) the form.

You can get the code pane's content (for parsing) either through the script
global object [newEditor(); assignActiveEditor(); editor.text()], or by sending
the pane window a WM_GETTEXT message. The latter is probably faster (no
IDispatch calls).

You can reparse on a timer, from a 'refresh' button, or responding to keystrokes
[set a WH_KEYBOARD hook]. Or all of the above.

Remember that to display a non-modal form from a Dll, you have to call
ShowWindow or SetWindowPos API directly, you can't use the .Visible property or
.Show method.

It goes without saying that your lexer/parser should be as fast as possible. A
basic FSM should suffice for most languages, but that's entirely up to you!

-- 
<http://forum.pspad.com/read.php?2,40772,40863>
PSPad freeware editor http://www.pspad.com

Odpovedet emailem