file dialog help... pleas?!

  • From: "Littlefield, Tyler" <compgeek13@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 11 Sep 2007 16:52:46 -0600

OK... I looked at the link ken gave me.
I didn't get much luck. I had had that one before... and his samples seem to be 
using a lot of mfc, something which I'm avoiding at the moment.
I'm getting memory errors. I think I might have fixed the access viloation... 
Help appriciated. Code below
UINT_PTR CALLBACK fileProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {

LPOFNOTIFY lpofn;

int cbLength=0;

switch(msg) {

case WM_NOTIFY:

NMHDR *nmsg;

nmsg=(NMHDR*) lParam;

switch (nmsg->code) {

case CDN_SELCHANGE:

cbLength = CommDlg_OpenSave_GetSpec(GetParent(hwnd), NULL, 0);

cbLength += _MAX_PATH;

if (fn.nMaxFile < cbLength) {

if (fname) {

delete fname;

TCHAR *fname=new TCHAR[cbLength+16];

ZeroMemory(&fname, sizeof(fname));

if (fname) {

fn.lpstrFile = fname;

fn.nMaxFile = cbLength+16;

}

}

}

break;

}

default:

return (0);

}

return (0);

}

//fdlg: caled when the user hits open

BOOL fdlg() {

OPENFILENAME fn;

ZeroMemory(&fn, sizeof(fn));

fn.lStructSize=sizeof(fn);

fn.hwndOwner=hwnd;

fn.lpstrFile =fname;

//fn.lpstrFile[0] = '\0';

fn.nMaxFile = sizeof(fname);

fn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";

fn.nFilterIndex = 1;

fn.lpstrFileTitle = NULL;

fn.nMaxFileTitle = 0;

fn.lpstrInitialDir = NULL;

fn.Flags = OFN_PATHMUSTEXIST | 
OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLESIZING|OFN_EXPLORER;

fn.lpfnHook=fileProc;

GetOpenFileName(&fn);

delete audio;

audio=new snd;

MessageBox(NULL, "Window Registration Failed!", fname, MB_ICONEXCLAMATION | 
MB_OK);

audio->play(fn.lpstrFile);

return 1;

} 

Thanks,
Tyler Littlefield.
Vertigo head coder
"My programs don't have bugs, just randomly added features."
msn: compgeek134@xxxxxxxxxxx
email: compgeek13@xxxxxxxxx
aim: st8amnd2005
skype: st8amnd127

Other related posts:

  • » file dialog help... pleas?!