Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to change the client area of a TListBox Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
27-Aug-02
Category
VCL-General
Language
Delphi 2.x
Views
49
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I have created my own listbox control as a descendant of TListBox. What I want to 
be able to do is to change the client area of the listbox so that I can draw a 
label above the list box area. I can change the client rect by overriding the 
CreateWnd method like this:

1   procedure TMyListBox.CreateWnd;
2   begin
3     inherited CreateWnd;
4     ClientHeight := Height - 20;
5   end;


But I can't move the client rect down (ie change the origin). Using ClientOrigin.X 
:= 20 does not work as the ClientOrigin property is read only. I'm thinking maybe I 
need to override the CreateParams method to do this. Any ideas?

Answer:

You have to respond to the WM_NCCALCSIZE message:
6   
7   procedure TREDCustomListBox.WMNCCalcSize(var Msg: TWMNCCALCSIZE);
8   begin
9     inherited;
10    Inc(MSG.CalcSize_Params^.rgrc[0].Top, FHeader.Height);
11  end;


That is a the method within my own listbox which does exactly what you want to do. 
Notice how I'm incrementing the client area by the height of the header (which I 
implemented as a separate class so I can do the same thing in other controls). It 
was a fun exercise.

Another clue: You have to paint the header in WM_NCPAINT

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC