🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Problem with window subclassing...

#16489
From: Mark Morrisson
Date: Sat, 10 May 2003 16:24
56 lines
2853 bytes
Hi Gary,
You're right, my error was that I didn't actually write text in the WM_PAINT
message
handler... But what intrigued me is that text was displayed all the same...
In fact, it's the
SetWindowText function that drew the text. I guess it uses a function like
TextOut cause
it doesn't call WM_PAINT to display the text. So, I tried to intercept the
WM_SETTEXT
message in order to prevent Windows from displaying the text out of the
WM_PAINT
handler. Here is the new labelProc :

LRESULT CALLBACK labelProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
{
 switch (uMsg)
 {
  case WM_SETTEXT:
   SetWindowLong(hwnd, GWL_USERDATA, (LONG) strdup((char *) lParam));
   return 0;

  case WM_PAINT:
   HDC hdc = BeginPaint(hwnd, &ps);
...
   char *text = (char *) GetWindowLong(hwnd, GWL_USERDATA);
   DrawText(hdc, text, -1, &rect, DT_LEFT);
...
   EndPaint(hwnd, &ps);
   return 0;
 }

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

The SetWindowLong function is the only method I found (with SetProp) to
store the
text of a label and get it again later. Since the label procedure is unique
for all the
labels, I couldn't store the text in a static variable : I needed a
different place for
all the labels. Though, I don't know when to free the string duplicated
(with strdup).

About the multiple labels, of course it prevents me from using the
CTLCOLORSTATIC
methos because it forces me to put lots of "case" statements in the switch
statement...
Since all variables tested in the "case" statements will be HWND, I don't
see any
way to determine its associated color in one instruction... I mean, I'm not
certain
that all these HWND's will form a serie (like 41001, 41002, 41003, etc).

Have a nice day,
Mark
Technical Details
Message-ID: <3ebd2733@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3ebb5ec5$1@newsgroups.borland.com> <3ebb9f7b$1@newsgroups.borland.com> <3ebbd08b@newsgroups.borland.com> <3ebcfa09@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,2ec9c93be1540300
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-10 09:27:19 PST
From: "Mark Morrisson" <mark4@NO_SPAMvoila.fr>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3ebb5ec5$1@newsgroups.borland.com> <3ebb9f7b$1@newsgroups.borland.com> <3ebbd08b@newsgroups.borland.com> <3ebcfa09@newsgroups.borland.com>
Subject: Re: Problem with window subclassing...
Date: Sat, 10 May 2003 18:24:44 +0200
Lines: 59
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.98.243
Message-ID: <3ebd2733@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1052583731 212.194.98.243 (10 May 2003 09:22:11 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail