I'm creating a plugin framework, where my application loads a series of plugin DLL's, then creates a new window and pass this new window's handle to the plugin. The plugin can, then, use this handle to create their own GUI.

Everything seems to be working very well. The only problem is that when I press TAB on a plugin widget (An editbox, for example), it doen't jump to another widget. I figured out that some Windows messages are passed, and some others aren't. The WM_KEYDOWN is passed for other keys, because I can type on the editbox, but this message doesn't handle TAB key.

Hope somebody has a hint.

I'm using Borland VCL with CBuilder, but I think I could use any framework under WIN32 to create these plugins, since they never know how their parent windows were created.


Is the edit box catching your tab presses? Also, are you familiar with WS_TABSTOP?

Judge Maygarden

I believe you'll have to take the following steps:

  1. Subclass your edit controls (and other controls as needed).
  2. Capture the WM_KEYDOWN message in your edit control's WndProc.
  3. Check to see if the shift key is currently held down (using GetKeyState or similar).
  4. Call GetWindow, passing in a handle to your edit control and either GWHWNDPREV or GWHWNDNEXT depending on whether shift is held down. This will give you the handle to the window that should receive focus.
  5. Call SetFocus and pass in the window handle you got in step 4.

Make sure you handle the case where your edit controls are multiline, as you might want to have a real tab character appear instead of moving to the next control.

Hope that helps!

+1  A: 

I believe you suffer from having a different instance of the VCL in each of your dlls and exes. Classes from the dll are not the same as the ones from your exe, even if they are called the same. Also global variables (Application, Screen) are not shared between them. Neither is the memory since they both have their own memory manager.

The solution is to have the dlls and the exe share the VCL library and the memory manager. I am not a BCB developer, but a Delphi developer. In Delphi we would just use the rtl and the vcl as runtime packages. Maybe you could do the BCB equivalent.

Lars Truijens

A DLL has its own TApplication object.

to provide uniform key handling. when the DLL Loads. assign the DLL::TApplication to the EXE::TApplication Be sure to do the reverse on exit.