Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why VB6.0 form displays as C# form?

Tags:

c#

winforms

vb6

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.

like image 315
Adavesh Avatar asked Nov 28 '12 14:11

Adavesh


1 Answers

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); 
like image 92
Peter Ruderman Avatar answered Sep 23 '22 05:09

Peter Ruderman