I have a button (ID_LOADTEXTURE) in a window, and when the button is clicked, I would like to have an open file dialog pop up. I have the following code in the window proc... can someone tell me where I went wrong? (the open dialog doesn't open)
Code:
LRESULT CALLBACK WindowProcedure(HWND hWindow, UINT uMessage, WPARAM wparam, LPARAM lparam)
{
char filename[64];
char fn[256];
char filefilter[]="Bitmaps\0*.bmp\0DDS files\0*.dds\0GIF files
\0*.gif\0JPEGs\0*.jpg\0PNG files\0*.png\0TGA files\0*.tga\0\0\0";
OPENFILENAME fname;
switch (uMessage)
{
case WM_COMMAND:
switch (LOWORD(wparam))
{
/*...*/
case ID_LOADTEXTURE:
fname.lStructSize=sizeof(OPENFILENAME);
fname.hwndOwner=hWindow;
fname.lpstrFilter=filefilter;
fname.nFilterIndex = 1;
fname.lpstrFile = fn;
fname.nMaxFile = sizeof(fn);
fname.lpstrFileTitle = filename;
fname.nMaxFileTitle = sizeof(filename)-1;
fname.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
fname.lpstrCustomFilter = NULL;
fname.lpstrInitialDir = NULL;
fname.lpstrTitle = NULL;
fname.lpstrDefExt = NULL;
fname.lCustData = 0;
if(!GetOpenFileName(&fname))
break;
/*...*/
Thanks