2

I'm using Win32 with C++ to make an app that can load the contents of files through a dialog with the GetOpenFileName function. Everything works fine, except when I close the main window and the app quits and prints this to the console:

The thread 'Win32 Thread' (0xa50) has exited with code 0 (0x0).

But the main process keeps running and I have to kill it explicitly in Visual Studio of the task manager, and I get this output:

The program '[2620] DBSCAN.exe: Native' has exited with code -1073741510 (0xc000013a).

Does the GetOpenFileName create a new thread that I have to terminate myself ? I've checked out the msdn and a few tutorials, I don't seem to be doing anything different than the standard usage, open a file, read content, close file.

I can post some code if needed, any help would be welcome.

Thanks

dotminic
  • 1,135
  • 2
  • 14
  • 28
  • Do you use hook (OFN_ENABLEHOOK)? – Dewfy Oct 25 '10 at 14:19
  • nope, just using OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_READONLY flags – dotminic Oct 25 '10 at 14:22
  • 1
    Are you sure this is what's preventing your process from terminating? Maybe sharing some code would be helpful (I've just used this API and didn't run into any problems). – yonilevy Oct 25 '10 at 15:01
  • 1
    Try use following debug technique. When you got 'Win32 Thread' (0xa50) has exited with code 0 (0x0). Click in debugger 'pause' and walk over existing threads. Look attentively at stack for each threads, if some thread contains part of your code. – Dewfy Oct 25 '10 at 15:15
  • Well I found the problem, I feel stupid, but I specified the Console (/SUBSYSTEM:CONSOLE) subSystem option so that I could output to the console, and forgot to remove it in the release config. Thanks for the tips anyway! – dotminic Oct 25 '10 at 15:21
  • @__dominic, you should add your last comment as an answer, in case someone else runs into the same problem. A proper answer is more visible than a comment... – Jörgen Sigvardsson Dec 16 '10 at 20:08

1 Answers1

0

try not setting an owner( ofnflags.hwndOwner = NULL ).

if you do set an owner, the occurring window will be threaded as a child window of the owner, which in turn would result in the behavior you are describing.

P47RICK
  • 136
  • 2