Where is the main entry point of a c# dll.

G

Guest

I am using a C# dll (WinForms component) from unmanaged C++. Th
einteroperability is provided by a CCW(Com Callable Wrapper).
To enable visual style(XP-like controls) in a C# application you normally
type following code in the Main() function of the class.
Application.EnableVisualStyles.

Is it possible to enable visual style of a Form that is residing in a dll ??
If so, where can i type this code in WinForms library(dll) - where is the
main entry point of the dll ?

Thanks Bilal
 
J

Jon Skeet [C# MVP]

Bilal said:
I am using a C# dll (WinForms component) from unmanaged C++. Th
einteroperability is provided by a CCW(Com Callable Wrapper).
To enable visual style(XP-like controls) in a C# application you normally
type following code in the Main() function of the class.
Application.EnableVisualStyles.

Is it possible to enable visual style of a Form that is residing in a dll ??
If so, where can i type this code in WinForms library(dll) - where is the
main entry point of the dll ?

There *is* no entry point for a .NET DLL (effectively - there'll be the
native one, but ignore that for the moment).

I don't believe you need to call Application.EnableVisualStyles from
Main though - just call it anywhere before you create any controls.
 
G

Guest

Thanks for the answer Jon.
I have tried to call follwing methods in the constructor of my class. (if I
call only one of the methods nop error occurs but then I get no visual style
on the controls)

Application.EnableVisualStyles();
Application.DoEvents();

It works.. I do get the visual styles, but when I close the main C++
application i get an error in method:

BOOL AfxInternalPreTranslateMessage(MSG* pMsg) in file thrdcore.cpp.
In this part of the method:
// in case of modeless dialogs, last chance route through main
// window's accelerator table
if (pMainWnd != NULL)
{
CWnd* pWnd = CWnd::FromHandle(pMsg->hwnd);
if (pWnd->GetTopLevelParent() != pMainWnd)
return pMainWnd->PreTranslateMessage(pMsg);
}

I know that this is a pretty lousy description of the error :)

Bilal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top