The file selector class is simple enough:
#pragma once
#include <string>
using namespace std;
class WL_FSel
{
public:
string sfilename;
OPENFILENAME ofn;
char filename[512];
char szFile[512];
char szDir[512];
char szTitle[512];
char szFilter[512];
WL_FSel(void);
~WL_FSel(void);
void hwnd(HWND hwnd);
bool get();
};
I've just moved the memory allocation into the Constructor() function, the new code now look like this... Still crashing on the Cancel button...
// Lib-test-dll.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
//
// Fileselectory structure here
WL_FSel *myfsel;
//#include <DBPro.hpp>
static char gstring[260];
GlobStruct* g_pGlob;
//HMODULE comctr_lib;
void Constructor ( void ) { // Create memory here
//comctr_lib = LoadLibrary("comctl32.dll");
myfsel = new WL_FSel;
InitCommonControls();
CoInitialize(NULL);
}
void Destructor ( void ) { // Free memory here
//FreeLibrary(comctr_lib);
delete myfsel;
}
void ReceiveCoreDataPtr ( LPVOID pCore ) { // Get Core Data Pointer here
g_pGlob = (GlobStruct*)pCore;
}
// List of DLL's that this plug-in depends on
const char* Dependencies[] =
{
"DBProBasic3DDebug.dll"
};
EXPORT int GetNumDependencies( void )
{
return sizeof(Dependencies) / sizeof(const char*);
}
EXPORT char const* GetDependencyID(int ID)
{
return Dependencies[ID];
}
EXPORTC LPSTR W32_GetPath(LPSTR olds)
{
DBPro::DeleteString( olds );
return DBPro::CreateString( myfsel->filename );
}
EXPORTC void W32_FileFilters( LPSTR filters )
{
strcpy(myfsel->szFilter, filters);
myfsel->ofn.lpstrFilter = myfsel->szFilter;
}
EXPORTC void W32_FilselectorFlags( DWORD flags )
{
myfsel->ofn.Flags = flags;
}
EXPORTC DWORD W32_FileSelector()
{
myfsel->hwnd( NULL );
if ( myfsel->get() )
return true;
else
return false;
}
EXPORTC LPSTR W32_GetCurrentDirectory(DWORD olds)
{
DBPro::DeleteString( (LPCSTR)olds );
GetCurrentDirectory( 260, gstring );
return ( DBPro::CreateString( gstring ) );
}
EXPORTC void W32_SetCurrentDirectory(DWORD news)
{
SetCurrentDirectory( (LPCSTR)news );
}
EXPORTC LPSTR W32_GetRelativeFilename(DWORD olds, LPSTR cdir, LPSTR apath)
{
return ( DBPro::CreateString( GetRelativeFilename(cdir, apath) ) );
}
EXPORTC DWORD W32_MessageBox(LPSTR smessage, LPSTR stitle, int type)
{
return ( MessageBox(0,smessage,stitle,type) );
}
EDIT: Actually it now just crashes... Grrr...
EDIT2: I just changed this bit to cause the imminent crashing...
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
//extern WL_FSel *myfsel;
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
HMODULE win32 = NULL;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
//myfsel = new WL_FSel;
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
//delete myfsel;
break;
}
return TRUE;
}
The fileselector would open if the above memory allocation was in place...
It seems that Constructor() isn't being called...
Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!