Article View: borland.public.cppbuilder.nativeapi
Article #10905Re: Dialog Boxes and child windows
From: Gary Setter
Date: Sat, 20 Mar 2004 15:52
Date: Sat, 20 Mar 2004 15:52
93 lines
3427 bytes
3427 bytes
"Mark Morrisson" <mark4@NO_SPAMvoila.fr> wrote in message
news:405b53f5$1@newsgroups.borland.com...
> Hi Remy,
> And first off, thanks for your reply. Of course I registered a "WndChart"
> class
> and I used it as first parameter of CreateWindow ! The second parameter
> should
> be the window title (in the title bar, if there is one), shouldn't it ?
>
> Best regards,
> Mark
>
Hi Mark,
What you posted looks ok to me. Here is a complete source that works for me.
Hope this helps
Gary
#include <windows.h>
#pragma hdrstop
#include "resource.h"
static LRESULT CALLBACK Chart_WndProc(HWND hWnd, UINT iMsg, WPARAM wParam,
LPARAM lParam)
{
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
static BOOL CALLBACK DialogProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM
lParam)
{
switch (iMsg) {
case WM_INITDIALOG:
{
HINSTANCE hInst =
reinterpret_cast<HINSTANCE>(GetWindowLong(hWnd,GWL_HINSTANCE));
HWND hWndChart = CreateWindow("WndChart",
"",
WS_CHILD | WS_VISIBLE,
100, 150,
100, 30,
hWnd,
NULL,
hInst,
NULL);
}
return TRUE;
case WM_COMMAND:
switch (HIWORD(wParam)) {
case 0: //menu
switch (LOWORD(wParam)) {
case IDOK:
case IDCANCEL:
EndDialog(hWnd,LOWORD(wParam));
return TRUE;
} //switch menu
break;
}
break;
}//switch
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE ,
LPSTR lpszCmdLine,
int iCmdShow)
{
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = Chart_WndProc; // The child window procedure
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(0, IDC_CROSS);
wc.hbrBackground = (HBRUSH) CreateSolidBrush (PALETTERGB(255,128,128));
wc.lpszMenuName = 0;
wc.lpszClassName = "WndChart";
wc.hIcon = NULL;
ATOM c = RegisterClass(&wc);
HWND dlg =
CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),0,DialogProc);
if (dlg) {
MSG msg;
ShowWindow(dlg, iCmdShow);
//Main messge loop
while (GetMessage(&msg, 0, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
} //while
}
return 0;
}
Technical Details
Message-ID:
<405c6892$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<405b3edd@newsgroups.borland.com> <405b4370$1@newsgroups.borland.com> <405b53f5$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,f7c94584fd5860a5 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-03-20 08:11:08 PST From: "Gary Setter" <setterg@worldnet.att.net> Newsgroups: borland.public.cppbuilder.nativeapi References: <405b3edd@newsgroups.borland.com> <405b4370$1@newsgroups.borland.com> <405b53f5$1@newsgroups.borland.com> Subject: Re: Dialog Boxes and child windows Date: Sat, 20 Mar 2004 09:52:07 -0600 Lines: 94 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 12.74.20.83 Message-ID: <405c6892$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1079797906 12.74.20.83 (20 Mar 2004 07:51:46 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail