[Bug 19495] DialogBox() returns -1 for Invalid Window Handle, Should Be 0

wine-bugs at winehq.org wine-bugs at winehq.org
Tue Aug 4 22:53:44 CDT 2009


http://bugs.winehq.org/show_bug.cgi?id=19495





--- Comment #16 from robertgonder at embarqmail.com  2009-08-04 22:53:43 ---
(In reply to comment #13)
> Comment #6 has the pointer to the test source.
> 
> hwnd 0 is a notion of a desktop window (HWND_DESKTOP), it's a valid pseudo
> window handle.

Correct.
Did you try the code, or are you just desk-checking it?
Your expectations are my expectations, but reality is different.

I shall re-post the Microsoft entry on this subject:
http://msdn.microsoft.com/en-us/library/ms645452(VS.85).aspx
If the function fails because the hWndParent parameter is invalid, the return
value is zero. The function returns zero in this case for compatibility with
previous versions of Microsoft Windows. If the function fails for any other
reason, the return value is -1. To get extended error information, call 
GetLastError.

Fact: DialogBox returns -1
Fact: GetLastError returns 1400
This is not as-documented.
My conclusion is two-fold:
1) 0 is treated by wine as invalid (assumption).
2) wine is bugged on the return code (seemingly fact).


> Regarding to your test case:
> 
> static int test_DialogBoxReturnProc(HWND hWnd, unsigned message, unsigned
> wParam, LONG lParam)
> 
> dialog callback has wrong calling convention and wrong parameter types.
> If you would try to compile it you would notice that.

My compiler is less strict than yours.
It allows the substitution of post-macro types.

> db = DialogBoxA(g_hinst, "RADIO_TEST_DIALOG", NULL, test_DialogBoxReturnProc );
> le = GetLastError();
> if( -1 == db )
> {
>     ok (le == 1400, "DialogBox Failed to return 0.\n");
>     ok (le != 1400, "test_DialogBoxReturn failed for unknow reason.\n");
> }
> 
> First of all DialogBoxA() will never fail,

You ASUSUME it won't fail.
It DOES! That's the point.
It fails (returns -1) when it shouldn't (should return 0);

> therefore the code under if ()
> statement will never ececute.

But it does. If you would ever actually try it!

> Second which of ok() calls above is supposed
> to test what you want?

The first is the proper test.
1400 is illegal window handle, which you will see if you ever run it.

The second is backup in case something else, like resource not available crops
up.

> Again, reopen once you have an evidence of the bug, and an appropriate test
> case.

I have all the evidence I need.
But just to be complete, I will correct the proc, and remove the second ok to
make you happy.

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list