GetOpenFileName wont close?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Okay, so heres my problem. I have my menu set up so that you click File at the top, and it gives you a dropdown menu, where you can pick a number of different types of files to load. Everything works, EXCEPT, when I click to close the
dialog box created by GetOpenFileName, the box closes then instantly opens itself again. Ive searched and Ive hunted but I cant seem to find what the cause is. Heres the WM_COMMAND message from my WndProc:

<div style="color:black; background-color:white
<pre><span style="color:blue case WM_COMMAND:
<span style="color:blue switch (LOWORD(wParam))
{
<span style="color:blue case FILE_EXIT:
gQuit = <span style="color:blue true;
<span style="color:blue break; <span style="color:green // FILE_EXIT

<span style="color:blue case IMPORT_3DS:
{
<span style="color:green //printf("Youre trying to import a .3dsn");
OPENFILENAME ofn;
<span style="color:blue wchar_t FileName[MAX_PATH] = L<span style="color:#a31515 "";
memset(&ofn, 0, <span style="color:blue sizeof(OPENFILENAME));

ofn.lStructSize = <span style="color:blue sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.lpstrFilter = L<span style="color:#a31515 "Meshes (*.3ds)*.3dsAll Files(*.*)*.*";
ofn.lpstrFile = FileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = L<span style="color:#a31515 "3ds";

<span style="color:blue if (GetOpenFileName(&ofn))
{
<span style="color:blue int count = WideCharToMultiByte(CP_ACP, 0, FileName, <span style="color:blue sizeof(FileName), 0, 0, 0, 0);
<span style="color:blue char* cStr = <span style="color:blue new <span style="color:blue char [count];
WideCharToMultiByte(CP_ACP, 0, FileName, <span style="color:blue sizeof(FileName), cStr, count, 0, 0);
Load3DS(cStr);
<span style="color:blue delete[] cStr;
}
}
<span style="color:blue break; <span style="color:green // IMPORT_3DS
}
<span style="color:blue break; <span style="color:green // WM_COMMAND
[/code]


Any hints?
EDIT: I should note that, at least in this case, Load3DS() does work as desired, and the file is loaded properly. Except the Open File dialog box doesnt close, so I cant really do anything else with my application.<br/>

View the full article
 
Back
Top