🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #16608

Problem with window subclassing...

#16608
From: Mark Morrisson
Date: Fri, 09 May 2003 07:57
55 lines
2433 bytes
Hi everyone !
I want to change the text color of a static control, so I tried to subclass
the control but it didn't work. I precise I don't use MFC nor ATL. This
control
is created within a dialog box :

BOOL CALLBACK DlgGraphProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
{
...
 switch (uMsg)
 {
  case WM_INITDIALOG:
...
  label = CreateWindow("STATIC", "", WS_CHILD | WS_VISIBLE | SS_LEFT,
  15, 20, 32, 16, hGrp_Graph, NULL, hInst, NULL);
...

hGrp_Graph is the handle of a group box where the label is created. Later in
the WM_INITDIALOG message handler, I do the subclassing :

oldLabelProc = (WNDPROC) SetWindowLong(label, GWL_WNDPROC, (LONG)
labelProc);

Here is the labelProc procedure :

LRESULT CALLBACK labelProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
{
 switch (uMsg)
 {
  case WM_PAINT:
   PAINTSTRUCT ps;
   HDC hdc = BeginPaint(hwnd, &ps);
   SetTextColor(hdc, RGB(50, 10, 100));
   SetBkColor(hdc, GetSysColor(COLOR_3DFACE));
   EndPaint(hwnd, &ps);
   return 0;
 }

 return CallWindowProc(oldLabelProc, hwnd, uMsg, wParam, lParam);
}

Well, when I run the program, the label doesn't have its color changed !
I've
tried to subclass an inner component of the dialog box (defined in the
resource
file) and it worked ! Though, I don't see the difference with a component
that
is created inside the dialog box... Is there an additional flag I should
specify
in the CreateWindow function in order to subclass the component ?

Thanks for your help,
Mark
Technical Details
Message-ID: <3ebb5ec5$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,2ec9c93be1540300,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-09 01:07:54 PST
From: "Mark Morrisson" <mark4@NO_SPAMvoila.fr>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Problem with window subclassing...
Date: Fri, 9 May 2003 09:57:19 +0200
Lines: 58
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 212.194.68.55
Message-ID: <3ebb5ec5$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1052466885 212.194.68.55 (9 May 2003 00:54:45 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail