|
From: Dreamjunky <li...@dr...> - 2002-12-05 19:21:47
|
Okay everybody, here's my newest problem. I can't figure it out. I =
could of course solve it by not using a variable and taking up more =
space.. but I'm just plain curious now. I'm calling CreateWindow and =
instead of having all the styles in the function call I wanted to put =
them into a DWORD first and pass that in. I attempted to do so with the =
following code:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
DWORD style =3D WS_CHILD | WS_VISIBLE;
CreateWindow(TEXT("EDIT"), NULL, style , 0, 0, CW_USEDEFAULT, =
CW_USEDEFAULT, handle, (HMENU) FIELD_URL, NULL, NULL);
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
Of course, it has more styles than that, but you don't need to see them =
all. At any rate, when I try to compile this is my error:
Improper use of typedef 'DWORD' in function WndProc
Statement missing ; in function WndProc
Undefined symbol 'style' in function WndProc
Any ideas? I tried playing around with putting parenthesis around it, =
seperating the declaration and assignment into two statements.... no =
dice either way. I could really use some help on this. Thanks
Tvienti
|
|
From: Bosso <han...@gm...> - 2002-12-05 20:05:18
|
Could you send some more code.
Hannes
On Thu, 5 Dec 2002 14:20:55 -0500
"Dreamjunky" <li...@dr...> wrote:
> Okay everybody, here's my newest problem. I can't figure it out. I could of course solve it by not using a variable and taking up more space.. but I'm just plain curious now. I'm calling CreateWindow and instead of having all the styles in the function call I wanted to put them into a DWORD first and pass that in. I attempted to do so with the following code:
>
> =====================================================
> DWORD style = WS_CHILD | WS_VISIBLE;
>
> CreateWindow(TEXT("EDIT"), NULL, style , 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, handle, (HMENU) FIELD_URL, NULL, NULL);
> =====================================================
>
> Of course, it has more styles than that, but you don't need to see them all. At any rate, when I try to compile this is my error:
>
> Improper use of typedef 'DWORD' in function WndProc
> Statement missing ; in function WndProc
> Undefined symbol 'style' in function WndProc
>
> Any ideas? I tried playing around with putting parenthesis around it, seperating the declaration and assignment into two statements.... no dice either way. I could really use some help on this. Thanks
>
> Tvienti
>
|
|
From: Zodiaq <zo...@ac...> - 2002-12-05 20:44:23
|
Hello Dreamjunky and all Dev-C++ users,
Thursday, December 5, 2002, 8:20:55 PM, Dreamjunky wrote as follows:
D> =====================================================
D> DWORD style = WS_CHILD | WS_VISIBLE;
D> CreateWindow(TEXT("EDIT"), NULL, style , 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, handle, (HMENU) FIELD_URL, NULL, NULL);
D> =====================================================
D> Of course, it has more styles than that, but you don't need to see them all. At any rate, when I try to compile this is my error:
D> Improper use of typedef 'DWORD' in function WndProc
D> Statement missing ; in function WndProc
D> Undefined symbol 'style' in function WndProc
It looks like compiler doesn't see what DWORD is... have you included
windows.h??? DWORD is defind in one of other headers included from
<windows.h>, exactly in <windef.h> as:
typedef unsigned long DWORD;
D> Any ideas? I tried playing around with putting parenthesis around it, seperating the declaration and assignment into two statements.... no dice either way. I could really use some help on this.
D> Thanks
D> Tvienti
--
regards, Zodiaq
|
|
From: Dreamjunky <li...@dr...> - 2002-12-06 02:26:24
|
> It looks like compiler doesn't see what DWORD is... have you included
> windows.h??? DWORD is defind in one of other headers included from
> <windows.h>, exactly in <windef.h> as:
> typedef unsigned long DWORD;
>
Hello again,
Yeah I have windows included. And if anybody needs it, here's the entire
function that the code's in:
========================================
LRESULT CALLBACK WndProc(HWND handle, UINT msg, WPARAM wp, LPARAM lp) {
switch(msg) {
case WM_CREATE: // create
DWORD style;
style = (WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER |
ES_LEFT | ES_AUTOHSCROLL | ES_AUTOVSCROLL);
CreateWindow(TEXT("EDIT"), NULL, style , 0, 0, CW_USEDEFAULT,
CW_USEDEFAULT, handle, (HMENU) FIELD_URL, NULL, NULL);
case WM_DESTROY: // close
PostQuitMessage(0);
return 0;
default: // default
return DefWindowProc(handle,msg,wp,lp);
break;
}
}
=======================================
Doesn't look to pretty in email but any ideas I'd greatly appreciate. I'm
still stumped (for two days now)
Thanks
Tvienti
|
|
From: Anders E. <am...@sw...> - 2002-12-06 16:23:38
|
Hello Dreamjunky,
Friday, December 6, 2002, 3:26:03 AM, you wrote:
D> ========================================
D> LRESULT CALLBACK WndProc(HWND handle, UINT msg, WPARAM wp, LPARAM lp) {
D> switch(msg) {
D> case WM_CREATE: // create
D> DWORD style;
D> style = (WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER |
D> ES_LEFT | ES_AUTOHSCROLL | ES_AUTOVSCROLL);
D> CreateWindow(TEXT("EDIT"), NULL, style , 0, 0, CW_USEDEFAULT,
D> CW_USEDEFAULT, handle, (HMENU) FIELD_URL, NULL, NULL);
D> case WM_DESTROY: // close
D> PostQuitMessage(0);
D> return 0;
D> default: // default
D> return DefWindowProc(handle,msg,wp,lp);
D> break;
D> }
D> }
D> =======================================
You can't introduce new variables in a switch! Move the DWORD style;
outside and above the switch statement. E.g.
LRESULT CALLBACK WndProc(HWND handle, UINT msg, WPARAM wp, LPARAM lp)
{
DWORD style;
switch(msg)
{
case WM_CREATE:
style = (WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL | ES_AUTOVSCROLL);
CreateWindow(TEXT("EDIT"), NULL, style , 0, 0, CW_USEDEFAULT,CW_USEDEFAULT, handle, (HMENU) FIELD_URL, NULL, NULL);
case WM_DESTROY: // close
PostQuitMessage(0);
return 0;
default: // default
return DefWindowProc(handle,msg,wp,lp);
break;
}
}
--
Best regards,
Anders mailto:am...@sw...
|
|
From: <or...@vp...> - 2002-12-06 19:01:12
|
Hello!
Anders Eriksson wrote:
> You can't introduce new variables in a switch! Move the DWORD style;
> outside and above the switch statement.
Well, that is not exactly true, because you can intorduce variables
wherever you want. You only need to put the declaration with the
corresponding code into a block. So this is also valid:
switch(msg) {
case WM_CREATE:
{ /* --- start of block --- */
DWORD style;
style = (WS_CHILD | WS_VISIBLE); //and others
// ... other code
} /* --- end of block --- */
case WM_DROPFILES:
// ... other code
}
This way you can use local variables, but be aware that the variable you
declared this way is only valid until the end of the block, which it is
in (this case, until the end of the case).
Also this way is better, than putting things before the switch, because
it will be very annoying to scroll up to the beginning of the switch,
when it is VERY long. (Trust me, it WILL be very long)
Of course you are still restricted to place your declarations at the
beginning of the blocks.
If you want to declare anywhere, anytime without blocks, and
restrictions, use C++ :)
--
Best regards
OROSZI Balázs
|
|
From: <or...@vp...> - 2002-12-06 19:25:06
|
Hi again!
I forgot to tell, that the declaration works for any kind of block.
E.g. these is also valid:
if {
int i;
//...
}
and others...
Hope I could help.
--
Best regards
OROSZI Balázs
|