0

First of all, here's my config:

VS2010/Debug/C++ Win32 Project/Vista Home Premium

Invoking GetOpenFileName via a button (CreateWindow) in a window (CreateWindow) gets me no problem: The Open Dialog works fine, I can click, navigate to another folder etc...

Now, I replace my CreateWindow with a DialogBoxParam (that should call CreateWindow behind the scenes), with the same (DLGPROC)WndProc and invoke the same GetOpenFileName. Here, the Open dialog is behaving strangely: looks like only the mouse double-click works (= populating ofn.lpstrFile and closing the Open dialog). Not able to click the Open and Cancel buttons and not able to navigate.

Anyone having experienced this before? Any known reasons for the Open dialog to kind of "freeze". Belong to a parent or not (ofn.hwndOwner = hwnd; ofn.hwndOwner = NULL;) gives the same problem.

Thanks N

Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
Nestor
  • 15
  • 1
  • 4

1 Answers1

2

You wrote

with the same (DLGPROC)WndProc

That's your bug. A dialog procedure and a window procedure are not the same thing. They follow different rules, and if you follow WndProc rules when you should be following DlgProc rules, then bad things will happen.

Raymond Chen
  • 44,448
  • 11
  • 96
  • 135
  • The classic "cast to fix it" solution [strikes again](http://blogs.msdn.com/b/oldnewthing/archive/2004/01/15/58973.aspx) :) – Anders Jan 09 '12 at 02:51
  • Ok, you are right. A DefWindowProc is not a DefDlgProc . Thank you. (+1 if i could) – Nestor Jan 09 '12 at 04:54