www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - winsamp.d examples does not work when compiled -release

reply Russell Wilkins <rwilkins grovestarsoftware.com> writes:
The following example shows the problem,  it's a stripped down version 
of winsamp.d.  If its compiled without -release it works fine,  it you 
compile it with -release the value hWnd is 0 after the CreateWindow 
call.  This works fine on 106,  but fails on 108/109.  What's going on?


import std.c.windows.windows;

extern(Windows)
int WindowProc(HWND hWnd, uint uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	    case WM_DESTROY:
		PostQuitMessage(0);
		break;
	    default:
		break;
	}
	return DefWindowProcA(hWnd, uMsg, wParam, lParam);
}


extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE 
hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	
     try
     {
	WNDCLASS wc;
	wc.lpszClassName = "DWndClass";
	wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = &WindowProc;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIconA(cast(HINSTANCE) null, IDI_APPLICATION);
	wc.hCursor = LoadCursorA(cast(HINSTANCE) null, IDC_CROSS);
	wc.hbrBackground = cast(HBRUSH) (COLOR_WINDOW + 1);
	wc.lpszMenuName = null;
	wc.cbClsExtra = wc.cbWndExtra = 0;
	assert(RegisterClassA(&wc));
	
	HWND hWnd = CreateWindowA("DWndClass", "Just a window", WS_THICKFRAME |
		WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_VISIBLE,
		CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, HWND_DESKTOP,
		cast(HMENU) null, hInstance, null);
	assert(hWnd);

	MSG msg;
	while (GetMessageA(&msg, cast(HWND) null, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessageA(&msg);
	}

     }

     catch (Object o)
     {

	return 1;
     }

     return 0;
}
Dec 05 2004
next sibling parent reply J C Calvarese<jcc7 cox.net> writes:
In article <couv61$20pu$1 digitaldaemon.com>, Russell Wilkins says...
The following example shows the problem,  it's a stripped down version 
of winsamp.d.  If its compiled without -release it works fine,  it you 
compile it with -release the value hWnd is 0 after the CreateWindow 
call.  This works fine on 106,  but fails on 108/109.  What's going on?
Could it be the issue discussed here? http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2358 I would think that this assert(RegisterClassA(&wc)); would turn into this: RegisterClassA(&wc); but maybe it turns into this: ; In any case, it has to be a compiler bug.
	assert(RegisterClassA(&wc));
jcc7
Dec 05 2004
parent Russell Wilkins <rwilkins grovestarsoftware.com> writes:
J C Calvarese wrote:
 In article <couv61$20pu$1 digitaldaemon.com>, Russell Wilkins says...
 
The following example shows the problem,  it's a stripped down version 
of winsamp.d.  If its compiled without -release it works fine,  it you 
compile it with -release the value hWnd is 0 after the CreateWindow 
call.  This works fine on 106,  but fails on 108/109.  What's going on?
Could it be the issue discussed here? http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2358 I would think that this assert(RegisterClassA(&wc)); would turn into this: RegisterClassA(&wc); but maybe it turns into this: ; In any case, it has to be a compiler bug.
	assert(RegisterClassA(&wc));
jcc7
You are correct, removing the assert around the RegisterClass fixes the problem.
Dec 05 2004
prev sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Russell Wilkins wrote:
 The following example shows the problem,  it's a stripped down version 
 of winsamp.d.  If its compiled without -release it works fine,  it you 
 compile it with -release the value hWnd is 0 after the CreateWindow 
 call.  This works fine on 106,  but fails on 108/109.  What's going on?
*** This bug has been marked as a duplicate of http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2271 *** Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Dec 06 2004
parent "Walter" <newshound digitalmars.com> writes:
"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message
news:cp1dn5$241c$1 digitaldaemon.com...
 Russell Wilkins wrote:
 The following example shows the problem,  it's a stripped down version
 of winsamp.d.  If its compiled without -release it works fine,  it you
 compile it with -release the value hWnd is 0 after the CreateWindow
 call.  This works fine on 106,  but fails on 108/109.  What's going on?
*** This bug has been marked as a duplicate of http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2271 ***
It's also been fixed now.
Dec 06 2004