On Aug 15, 9:18 am, vfr <v...@discussions.microsoft.com> wrote:
I have an application which integrates new .NET GUI in Usercontrols hosted in
MFC modeless dialogs. When using a .NET TabControl in a Usercontrol the
application freezes when switching between applications on the desktop,
having focus set to one of the controls contained in the tab control. I have
posted another question about this using the MFC04 WinForm integration sample
program, see :
(http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1840198&SiteID=1)
By using SPY.exe I can see that the TabControl is busy handling
WM_GETDLGCODE, fuDlgCode:DLGC_WANTARROWS|DLGC_WANTCHARS messages continuously.
I found a PRB describing this behaviour for CPropertySheet and CDialog (MFC):
PRB: Child CPropertySheet Hangs If Focus Is Switched. http://support.microsoft.com/kb/149501
It seems like this bug/feature is continued in the new .NET controls. Is
there a workaround or is this bug/feature fixed in a service pack?
How can ModifyStyleEx be used in managed C# code? I cannot find a
WS_EX_CONTROLPARENT style in the resource editor.
I'm using VS2005 (without SP1)
I got around with the same problem (but a different kind of control)
by subscribing to the HandleCreated event of the problematic control
and setting the style of the problem control, as in:
this.ggc.HandleCreated += new
EventHandler(ggc_HandleCreated);
followed by...
void ggc_HandleCreated(object sender, EventArgs e)
{
if (this.ggc.Handle != IntPtr.Zero)
{
HandleRef hr = new HandleRef(this.ggc,
this.ggc.Handle);
SetWindowLong(
hr,
GWL_EXSTYLE,
GetWindowLong(hr, GWL_EXSTYLE) |
WS_EX_CONTROLPARENT);
}
}
const int GWL_EXSTYLE = -20;
const int WS_EX_CONTROLPARENT = 0x00010000;
[DllImport("user32.dll", SetLastError = true)]
static extern int GetWindowLong(HandleRef hwnd, int idx);
[DllImport("user32.dll")]
static extern int SetWindowLong(HandleRef hwnd, int idx, int
newval);
(gcc would be your tabbed control)
Thank you for your response. Your answer will solve the problem. We have
controls , where the new class overrides CreateParams.
The DataGridView Control has exactly the same prioblem.