Thread: [Dev-C++] why doesn't this work?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Vlada D. <dj...@im...> - 2002-11-18 11:45:46
|
Hi.
Maybe I'm a little anoying with this, but I'm really confused. I'm =
trying to get an MDI child window to show when I press File->new in the =
menu, but the window does not show, though its name is appnded to Window =
menu every time I press File->New. After I placed the same code in =
WM_CREATE message handler, the window appeared OK. Why is this? Here's a =
piece of my code:
switch(LOWORD(wParam))
{
case ID_FILE_NEW:
{
if(nChildCount=3D=3D0)//if there are no child =
windows
{
CLIENTCREATESTRUCT ccs;
=
SetMenu(hFrameWnd,LoadMenu(g_hInstance,MAKEINTRESOURCE(IDM_MENU)));//set =
another menu
=
ccs.hWindowMenu=3DGetSubMenu(GetMenu(hFrameWnd),1);
ccs.idFirstChild=3DID_FIRST_CHILD;
=20
=
hMDIClient=3DCreateWindowEx(WS_EX_CLIENTEDGE,"MDICLIENT",(LPCTSTR)NULL,WS=
_CHILD|WS_CLIPCHILDREN,
=
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,hFrameWnd,(HMENU)=
ccs.idFirstChild,
g_hInstance,(LPVOID)&ccs);
if(!hMDIClient)
MessageBox(hFrameWnd,"Can't create client =
wnd","error",MB_OK);
ShowWindow(hMDIClient,SW_SHOW);
=20
}
/*create child window*/
=
hChildWnd=3DCreateMDIWindow(g_sChildClass,"Untitled",WS_HSCROLL|WS_VSCROL=
L,CW_USEDEFAULT,
CW_USEDEFAULT, =
300,200,hMDIClient,g_hInstance,lParam);
if(!hChildWnd)
MessageBox(hFrameWnd,"Can't create child =
wnd","error",MB_OK);
ShowWindow(hChildWnd,SW_SHOW);
UpdateWindow(hChildWnd);
nChildCount++;// increase number of MDI child =
windows
}
break;
Regards,
Vlada
|
|
From: Vlada D. <dj...@im...> - 2003-02-20 09:16:53
|
Hi.
This is suppposed to be simple, but I can't get it to work. All I want to do
is display some text using TextOut function, but I get only a blank window.
Here's the code:
HDC hDC;
case WM_CREATE:
{
char str[]="Display text";
hDC=GetDC(hwnd);
TextOut(hDC,100,100,str,lstrlen(str));
ReleaseDC(hwnd,hDC);
}
break;
What am I doing wrong?
------------
Vlada
|
|
From: <cg...@wo...> - 2003-02-20 11:34:07
|
When you process the WM_CREATE, the window is not yet created, so you
cannot work with its hdc, at least, it is what it seems to happen. I did
an experiment like yours and didn't worked, I deleted the code and moved
to another WM_.
Vlada Djurovic wrote:
>Hi.
>This is suppposed to be simple, but I can't get it to work. All I want to do
>is display some text using TextOut function, but I get only a blank window.
>Here's the code:
>
> HDC hDC;
> case WM_CREATE:
> {
> char str[]="Display text";
> hDC=GetDC(hwnd);
> TextOut(hDC,100,100,str,lstrlen(str));
> ReleaseDC(hwnd,hDC);
> }
> break;
>
>What am I doing wrong?
>------------
>Vlada
>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
>The most comprehensive and flexible code editor you can use.
>Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
>www.slickedit.com/sourceforge
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
|
|
From: P.D. v. Z. <pd...@xs...> - 2003-02-20 12:25:14
|
In general, the only place where you should draw anything on your window
is when Windows requests you to, in WM_PAINT ... if you draw anywhere
else, there's a pretty big chance that what you painted on the screen
will get overwritten again when Windows sends a WM_PAINT (since you
don't do anything there, Windows will decide what to do).
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Carlos
Garc=EDa del Monte
Sent: Thursday, February 20, 2003 12:29 PM
To: dev-cpp-users-list
Subject: Re: [Dev-C++] why doesn't this work?
When you process the WM_CREATE, the window is not yet created, so you=20
cannot work with its hdc, at least, it is what it seems to happen. I did
an experiment like yours and didn't worked, I deleted the code and moved
to another WM_.
Vlada Djurovic wrote:
>Hi.
>This is suppposed to be simple, but I can't get it to work. All I want
to do
>is display some text using TextOut function, but I get only a blank
window.
>Here's the code:
>
> HDC hDC;
> case WM_CREATE:
> {
> char str[]=3D"Display text";
> hDC=3DGetDC(hwnd);
> TextOut(hDC,100,100,str,lstrlen(str));
> ReleaseDC(hwnd,hDC);
> }
> break;
>
>What am I doing wrong?
>------------
>Vlada
>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
>The most comprehensive and flexible code editor you can use.
>Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
>www.slickedit.com/sourceforge
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
> =20
>
-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
The most comprehensive and flexible code editor you can use.
Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
www.slickedit.com/sourceforge
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|