wxDynamicLibrary and class

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
DeadSinn
In need of some credit
In need of some credit
Posts: 1
Joined: Wed May 24, 2006 5:07 pm
Location: my pc
Contact:

wxDynamicLibrary and class

Post by DeadSinn » Wed May 24, 2006 5:20 pm

HI, i have a little question xD
I Maked a DLL and inside that i have got a class : "DllClass".
I maked it without problem, but when i want call the class member/function i dont know how i can do this.

Code: Select all


typedef DllClass* (* DllClass_v)(void); 
wxDynamicLibrary dyn;

if( dyn.Load (LIB_NAME, wxDL_VERBATIM) )
{ 
    wxMessageBox ( _T ("#Worked") , _T("DLL LOaded") , wxICON_INFORMATION | wxOK ) ;
}
else
{
    wxMessageBox ( _T ("#ARgh, i cant open it") , _T("DLL Error") , wxICON_INFORMATION | wxOK ) ;
}

wxDYNLIB_FUNCTION ( DllClass_v , CreateTest , dyn ) ;

if ( ! pfnCreateTest )
{
    wxMessageBox ( _T ( "NO FUNCTION" ) , _T ( "NO FUNCTION" ) , wxICON_INFORMATION | wxOK ) ;
}
else
{
    wxMessageBox ( _T ( "FUNCTION" ) , _T ( "FUNCTION" ) , wxICON_INFORMATION | wxOK ) ;
                
}
With this code, i know ( i thing ) thath inside "pfnCreateTest" there is the class , but, How i can use this ?
DLL CODE

Code: Select all

BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}

extern "C" __declspec (dllexport) DllClass* CreateTest()
{
    //Nothing
}

Thanks

Cursor
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Aug 29, 2004 3:09 pm
Location: Grenoble, France
Contact:

Post by Cursor » Thu May 25, 2006 7:43 am

Do I understand correctly ?
You want to create a dll with a class implementation. You want to load this dll at runtime, create an instance of this class (by a factory function) and call functions from this instance from the main program ?

If it is that, you must declare the class prototype (or at least the interface of your class) in order to precise what function the compiler must envisage.
What is little and green, witch go up and down ??
Yoda playing with the force.

Post Reply