I've wrapped it up in a class very quickly and probably needs some tweaking but it works great.
Main: (shows how simple it is to use)
#include "DarkGDK.h"
#include "globstruct.h"
#include <stdio.h>
#include "WL_FSel.h"
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
WL_FSel fs;
fs.hwnd(g_pGlob->hWnd);
fs.ofn.lpstrFilter="All\0*.*\0DB Object\0*.dbo\0";
fs.get();
while ( LoopGDK ( ) )
{
dbText(0,0,fs.filename);
dbSync ( );
}
return;
}
WL_FSel.h: (to include in your code)
#pragma once
#include "windows.h"
#include <string>
#include "DarkGDK.h"
#include "globstruct.h"
using namespace std;
class WL_FSel
{
public:
string sfilename;
OPENFILENAME ofn;
char filename[260];
char szFile[260];
WL_FSel(void);
~WL_FSel(void);
void hwnd(HWND hwnd);
bool get();
};
WL_FSel.cpp: (compiled to create the object)
#include "WL_FSel.h"
WL_FSel::WL_FSel(void)
{
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
}
WL_FSel::~WL_FSel(void)
{
}
void WL_FSel::hwnd(HWND hwnd)
{
ofn.hwndOwner=hwnd;
}
bool WL_FSel::get()
{
if (GetOpenFileName(&ofn)==TRUE)
{
int loop, len;
sfilename.assign(ofn.lpstrFile);
strcpy(filename,sfilename.c_str());
len=strlen(filename);
for (loop=0; loop<len; loop++)
{
if (filename[loop]=='\\')
{
filename[loop]='/';
}
}
return true;
}
else
{
sfilename.clear();
filename[0]=0;
return false;
}
}
More snippets to come to help anyone out...
Warning! May contain Nuts!