Adavesh
Adavesh

Reputation: 559

Why VB6.0 form displays as C# form?

I have a COM DLL which has a form. This DLL is consumed by a C# application. I have enabled Visual Styles for my C# application. I don't want the Visual Styles be applied for COM DLL's form. But when I run my application and lanuch COM DLL's form, it has visual styles applied to it. How will I prevent it?

Many people suggest using a manifest. But, whatever manifests I see on internet, they all use common controls 6. How to create a manifest that uses common controls 5.0 ? Some also suggest using ActivationContext. But, that too needs correct manifest which uses common controls 5.0 right?

Please suggest something.

Upvotes: 37

Views: 1222

Answers (1)

Peter Ruderman
Peter Ruderman

Reputation: 12485

If you have a window handle for the form (from the COM DLL) then you can disable visual styles on that form using the Win32 API:

SetWindowTheme( hwnd, "", "" );

I believe you'll have to P/Invoke the API. Here's the definition:

[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
public static extern int SetWindowTheme(
   IntPtr hWnd,
   String pszSubAppName,
   String pszSubIdList);

Upvotes: 3

Related Questions