<p>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.</p>

<p>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.</p>

<p>Hope somebody has a hint.</p>

<p>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.</p>

[{'answer_id': 15449, 'author': 'OJ.', 'author_id': 611, 'author_profile': 'https://Stackoverflow.com/users/611', 'pm_score': 0, 'selected': False, 'text': '<p>I believe you\'ll have to take the following steps:</p>\n\n<ol>\n<li><a href="http://msdn.microsoft.com/en-us/library/ms997565.aspx" rel="nofollow noreferrer">Subclass</a> your edit controls (and other controls as needed).</li>\n<li>Capture the <a href="http://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx" rel="nofollow noreferrer">WM_KEYDOWN</a> message in your edit control\'s WndProc.</li>\n<li>Check to see if the shift key is currently held down (using <a href="http://msdn.microsoft.com/en-us/library/ms646301(VS.85).aspx" rel="nofollow noreferrer">GetKeyState</a> or similar).</li>\n<li>Call <a href="http://msdn.microsoft.com/en-us/library/ms633515(VS.85).aspx" rel="nofollow noreferrer">GetWindow</a>, passing in a handle to your edit control and either GW_HWNDPREV or GW_HWNDNEXT depending on whether shift is held down. This will give you the handle to the window that should receive focus.</li>\n<li>Call <a href="http://msdn.microsoft.com/en-us/library/ms646312(VS.85).aspx" rel="nofollow noreferrer">SetFocus</a> and pass in the window handle you got in step 4.</li>\n</ol>\n\n<p>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.</p>\n\n<p>Hope that helps!</p>\n'}, {'answer_id': 16080, 'author': 'Serge', 'author_id': 1007, 'author_profile': 'https://Stackoverflow.com/users/1007', 'pm_score': 1, 'selected': False, 'text': '<p>It\'s very complex matter indeed.</p>\n\n<p>When you hit TAB focus jumps to another control only when these controls belong to a Modal Dialog Box. In fact there are some buttons like ESC, LEFT, RIGHT, DOWN, UP, TAB which modal dialog message function treats in a special way. If you want these keys to behave in similar way with modeless dialog box or any other window you should change you message processing function and use IsDialogMessage inside. You\'ll find more information about <a href="http://msdn.microsoft.com/en-us/library/ms645498(VS.85).aspx" rel="nofollow noreferrer">IsDialogMessage</a> function in MSDN also to better understand this stuff you may check as well <a href="http://msdn.microsoft.com/en-us/library/ms632588(VS.85).aspx" rel="nofollow noreferrer">Dialog Boxes</a> section.</p>\n\n<p>And, as was mentioned before, you should set <a href="http://msdn.microsoft.com/en-us/library/czada357(VS.80).aspx" rel="nofollow noreferrer">WS_TABSTOP</a> and <a href="http://msdn.microsoft.com/en-us/library/czada357(VS.80).aspx" rel="nofollow noreferrer">WS_GROUP</a> styles when needed.</p>\n\n<p>Good luck!</p>\n'}, {'answer_id': 29967, 'author': 'Lars Truijens', 'author_id': 1242, 'author_profile': 'https://Stackoverflow.com/users/1242', 'pm_score': 0, 'selected': False, 'text': '<p>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.</p>\n\n<p>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.</p>\n'}, {'answer_id': 476410, 'author': 'Michael', 'author_id': 56751, 'author_profile': 'https://Stackoverflow.com/users/56751', 'pm_score': 0, 'selected': False, 'text': '<p>A DLL has its own TApplication object.</p>\n\n<p>to provide  uniform key handling. when the DLL Loads.\nassign the DLL::TApplication to the EXE::TApplication \nBe sure to do the reverse on exit.</p>\n\n<p>--</p>\n\n<p>Michael</p>\n'}]
['https://Stackoverflow.com/questions/15398', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']