www.digitalmars.com         C & C++   DMDScript  

D - strange bug

reply imr1984 <imr1984_member pathlink.com> writes:
ok when my program calls CreateWindowExA it throws an exception, which just says
"Object" as usual. When I change the class name literal from WINDOW_CLASS
(defined as "WndClass") to "tinky winky" it runs properly, but of course
CreateWindowExA returns saying it cant find the window class name . For example:

CreateWindowExA(dwExStyle, WINDOW_TITLE, WINDOW_CLASS, ... //throws exception

CreateWindowExA(dwExStyle, WINDOW_TITLE, "tinky winky", ...//works

Even stranger is that a few lines before I store the class name in a WNDCLASSEX
struct like so:

wc.lpszClassname = WINDOW_CLASS;

and if i change that to:

wc.lpszClassname = "tinky winky";

then CreateWindowExA with the correct class name DOESNT throw an exception, but
of course cant find the class name "tinky winky" because it isnt registered.

Can someone tell me what could cause this. Its driving me nuts as you can see...
Feb 04 2004
parent reply "davepermen" <davepermen hotmail.com> writes:
"strings" like this get converted implicit to a 0-terminated string if you
pass them to a char* function.

WINDOW_CLASS doesn't, i guess, as it's a full D string.

oh, and, you can write twice the same name, to create the window. "thinky
winky" for the wc.lpszClassName, and for CreateWindowEx(..,..,"thinky
winky",...)

else, toStringz in the std.string library helps

i guess.....

"imr1984" <imr1984_member pathlink.com> schrieb im Newsbeitrag
news:bvqk6o$mjj$1 digitaldaemon.com...
 ok when my program calls CreateWindowExA it throws an exception, which

 "Object" as usual. When I change the class name literal from WINDOW_CLASS
 (defined as "WndClass") to "tinky winky" it runs properly, but of course
 CreateWindowExA returns saying it cant find the window class name . For

 CreateWindowExA(dwExStyle, WINDOW_TITLE, WINDOW_CLASS, ... //throws

 CreateWindowExA(dwExStyle, WINDOW_TITLE, "tinky winky", ...//works

 Even stranger is that a few lines before I store the class name in a

 struct like so:

 wc.lpszClassname = WINDOW_CLASS;

 and if i change that to:

 wc.lpszClassname = "tinky winky";

 then CreateWindowExA with the correct class name DOESNT throw an

 of course cant find the class name "tinky winky" because it isnt

 Can someone tell me what could cause this. Its driving me nuts as you can


Feb 04 2004
parent reply imr1984 <imr1984_member pathlink.com> writes:
actually WINDOW_CLASS is declared like this:

const char[] WINDOW_CLASS = "WndClass";

so its a string literal. Anyway i disasembled teh program and both methods
produce code that "pushes" a null terminated string literal to CreateWindowExA. 

so i still dont know whats going on.

In article <bvqkc1$msj$1 digitaldaemon.com>, davepermen says...
"strings" like this get converted implicit to a 0-terminated string if you
pass them to a char* function.

WINDOW_CLASS doesn't, i guess, as it's a full D string.

oh, and, you can write twice the same name, to create the window. "thinky
winky" for the wc.lpszClassName, and for CreateWindowEx(..,..,"thinky
winky",...)

else, toStringz in the std.string library helps

i guess.....

"imr1984" <imr1984_member pathlink.com> schrieb im Newsbeitrag
news:bvqk6o$mjj$1 digitaldaemon.com...
 ok when my program calls CreateWindowExA it throws an exception, which

 "Object" as usual. When I change the class name literal from WINDOW_CLASS
 (defined as "WndClass") to "tinky winky" it runs properly, but of course
 CreateWindowExA returns saying it cant find the window class name . For

 CreateWindowExA(dwExStyle, WINDOW_TITLE, WINDOW_CLASS, ... //throws

 CreateWindowExA(dwExStyle, WINDOW_TITLE, "tinky winky", ...//works

 Even stranger is that a few lines before I store the class name in a

 struct like so:

 wc.lpszClassname = WINDOW_CLASS;

 and if i change that to:

 wc.lpszClassname = "tinky winky";

 then CreateWindowExA with the correct class name DOESNT throw an

 of course cant find the class name "tinky winky" because it isnt

 Can someone tell me what could cause this. Its driving me nuts as you can



Feb 04 2004
parent reply "davepermen" <davepermen hotmail.com> writes:
something else:D

is the code short enough to post? :D

"imr1984" <imr1984_member pathlink.com> schrieb im Newsbeitrag
news:bvqmcs$qav$1 digitaldaemon.com...
 actually WINDOW_CLASS is declared like this:

 const char[] WINDOW_CLASS = "WndClass";

 so its a string literal. Anyway i disasembled teh program and both methods
 produce code that "pushes" a null terminated string literal to

 so i still dont know whats going on.

 In article <bvqkc1$msj$1 digitaldaemon.com>, davepermen says...
"strings" like this get converted implicit to a 0-terminated string if


pass them to a char* function.

WINDOW_CLASS doesn't, i guess, as it's a full D string.

oh, and, you can write twice the same name, to create the window. "thinky
winky" for the wc.lpszClassName, and for CreateWindowEx(..,..,"thinky
winky",...)

else, toStringz in the std.string library helps

i guess.....

"imr1984" <imr1984_member pathlink.com> schrieb im Newsbeitrag
news:bvqk6o$mjj$1 digitaldaemon.com...
 ok when my program calls CreateWindowExA it throws an exception, which

 "Object" as usual. When I change the class name literal from



 (defined as "WndClass") to "tinky winky" it runs properly, but of



 CreateWindowExA returns saying it cant find the window class name . For

 CreateWindowExA(dwExStyle, WINDOW_TITLE, WINDOW_CLASS, ... //throws

 CreateWindowExA(dwExStyle, WINDOW_TITLE, "tinky winky", ...//works

 Even stranger is that a few lines before I store the class name in a

 struct like so:

 wc.lpszClassname = WINDOW_CLASS;

 and if i change that to:

 wc.lpszClassname = "tinky winky";

 then CreateWindowExA with the correct class name DOESNT throw an

 of course cant find the class name "tinky winky" because it isnt

 Can someone tell me what could cause this. Its driving me nuts as you



see...



Feb 04 2004
parent reply imr1984 <imr1984_member pathlink.com> writes:
Ar solved it at last. The exception was thrown because I did not have a default
handler in the switch statement of my WndProc. Dammit I wish the Error strings
were a bit more descriptive then "Object". I could have solved it in 2 minutes
instead of hours, if they were.

In article <bvqn72$rrc$1 digitaldaemon.com>, davepermen says...
something else:D

is the code short enough to post? :D

"imr1984" <imr1984_member pathlink.com> schrieb im Newsbeitrag
news:bvqmcs$qav$1 digitaldaemon.com...
 actually WINDOW_CLASS is declared like this:

 const char[] WINDOW_CLASS = "WndClass";

 so its a string literal. Anyway i disasembled teh program and both methods
 produce code that "pushes" a null terminated string literal to

 so i still dont know whats going on.

 In article <bvqkc1$msj$1 digitaldaemon.com>, davepermen says...
"strings" like this get converted implicit to a 0-terminated string if


pass them to a char* function.

WINDOW_CLASS doesn't, i guess, as it's a full D string.

oh, and, you can write twice the same name, to create the window. "thinky
winky" for the wc.lpszClassName, and for CreateWindowEx(..,..,"thinky
winky",...)

else, toStringz in the std.string library helps

i guess.....

"imr1984" <imr1984_member pathlink.com> schrieb im Newsbeitrag
news:bvqk6o$mjj$1 digitaldaemon.com...
 ok when my program calls CreateWindowExA it throws an exception, which

 "Object" as usual. When I change the class name literal from



 (defined as "WndClass") to "tinky winky" it runs properly, but of



 CreateWindowExA returns saying it cant find the window class name . For

 CreateWindowExA(dwExStyle, WINDOW_TITLE, WINDOW_CLASS, ... //throws

 CreateWindowExA(dwExStyle, WINDOW_TITLE, "tinky winky", ...//works

 Even stranger is that a few lines before I store the class name in a

 struct like so:

 wc.lpszClassname = WINDOW_CLASS;

 and if i change that to:

 wc.lpszClassname = "tinky winky";

 then CreateWindowExA with the correct class name DOESNT throw an

 of course cant find the class name "tinky winky" because it isnt

 Can someone tell me what could cause this. Its driving me nuts as you



see...




Feb 04 2004
parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
 Ar solved it at last. The exception was thrown because I did not have a

 handler in the switch statement of my WndProc. Dammit I wish the Error

 were a bit more descriptive then "Object". I could have solved it in 2

 instead of hours, if they were.

Good evidence that the compiler should insist on the default, rather than causing developer or, worse, user consternation. Cyrille the SmartArse
Feb 04 2004