15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Ownerdraw Listbox Problem

Rajat Singhal -- rajat@corus.com
Monday, September 30, 1996


Environment: MSVC 4.1 under Win95/WinNT

Hi Guys,

We have a problem out here. We have an owner drawn listbox. And we cant
seem to get the measure item message. hence there is no control over the
height of the items that are added to the listbox.  The code seems to be
right. 

Has anybody encountered this problem before? Or is there some other way 
to control the height of the listbox items?

TIA

-Rajat




Paul D. Bartholomew -- PaulDB@datastorm.com
Tuesday, October 01, 1996

[Mini-digest: 5 responses]


Environment: MSVC 4.1 under Win95/WinNT

Rajat wrote:
>>We have a problem out here. We have an owner drawn listbox. And we cant
seem to get the measure item message. hence there is no control over the
height of the items that are added to the listbox.  The code seems to be
right.<<

If you set the style to Owner Draw--Fixed, MeasureItem doesn't get   
called.  For that case, you'll need to explicitly call the SetItemHeight   
function for the listbox.  Calling SetItemHeight with an index of zero   
(assuming that Owner Draw is set to Fixed) will set the height of all of   
the listbox items.

If you set the style to Owner Draw--Variable, MeasureItem should get   
called for each item in the listbox.

Paul Bartholomew
pauldb@datastorm.com

-----From: "Dorie Hannan" 

Check the style of your listbox.  The OwnerDrawn style needs to be 
variable, not fixed in order for you to receive the measure item 
message for each item.
Hope this helps,
Dorie Hannan.

-----From: Raja Segar 

U probably did not specify the style of the ownerdraw list box as Variable.
If you had specified Fixed then u will only get MeasureItem message once.
U can fix this in the resource editor or specify the style in the create
function.
Bye

 (  _ \/ __)(_   )
  )   /\__ \ / /_ 
 (_)\_)(___/(____)@pc.jaring.my

-----From: kitk@mudshark.sunquest.com (Kit Kauffmann)

Try SetItemHeight (LB_SETITEMHEIGHT) - the measure-item message is for 
variable-height listboxes...

If you tied buttered toast to the back of a cat and dropped it from a 
height, what would happen?

-----From: bliu@campbellsoft.com

     You need to set owner draw variable style.
     
     Bill





MHENRY.UMI.COM -- MHENRY@umi.com
Thursday, October 03, 1996

[Mini-digest: 3 responses]

 Well you don't give much information about what you tried or how you know 
it's not working. 
It's pretty simple to do. 
 
Have the class wizard generate an override for MeasureItem. 
void CColorListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)  
{	 
	// all items are of fixed size 
	// must use LBS_OWNERDRAWVARIABLE for this to work 
	lpMeasureItemStruct->itemHeight = 20;  
} 
Voila. 
 
--matt 
/~~~~~~~~~~~~~~~~~~~~~~~~~~~  
  Matthew Henry  -- UMI            
  mhenry@umi.com     (Work)              
  mhenry1384@aol.com (Home)  
~~~~~~~~~~~~~~~~~~~~~~~~~~/  
 
--Boundary-351816-0-0
Content-Type: message/rfc822

Date: 02 Oct 96 18:54:37
From:"Rajat Singhal " 
To: MFC,Mailing,List,mfc-l@netcom.com
Subject: Ownerdraw Listbox Problem
Reply-to: mfc-l@netcom.com
X-Orcl-Application: MIME-Version:  1.0
X-Orcl-Application: Content-Type:  TEXT/PLAIN; charset=US-ASCII
X-Orcl-Application: Sender:  owner-mfc-l@majordomo.netcom.com
X-Orcl-Application: Errors-To:  owner-mfc-l@majordomo.netcom.com
X-Orcl-Application: Precedence:  bulk



Environment: MSVC 4.1 under Win95/WinNT

Hi Guys,

We have a problem out here. We have an owner drawn listbox. And we cant
seem to get the measure item message. hence there is no control over the
height of the items that are added to the listbox.  The code seems to be
right. 

Has anybody encountered this problem before? Or is there some other way 
to control the height of the listbox items?

TIA

-Rajat
-----From: Gabriel Parlea-Visalon 

The quick answer is that there isn't anything wrong with owner-drawn controls 
and the corresponding MFC classes.

In the absence of your code here are some possible explanations. 
You haven't set your listbox to be owner-draw variable, the control is not 
correctly subclassed to the dialog, you have derived from CListBox as you do, 
and have overriden OnChildNotify() without calling the base class 
OnChildNotify(), you don't use a CListBox derived class subclassed to the parent 
dialog and expect the message to go to the parent, you don't override the 
CListBox MeasureItem() in which case you haven't subclassed correctly because 
the default MeasureItem() for owner-drawn listboxes asserts FALSE and finally, 
you are using DDE.

It is always easier to get a correct answer to one's question if one provides 
the necessary code.

I hope this helps you.

Gabriel

-- 
                             Gabriel Parlea-Visalon
                               Software Engineer
                         Derivative Trading Systems Ltd
                           gabriel@derivs.demon.co.uk

-----From: Gerry Sweeney 


Rajat,

I believe that what Paul told you below is wrong. As far as I know, the 
documentation says, and my implementations of owner drawn list boxes tells 
me that the MesaureItem message gets called ONCE when the list box is first 
created when the style of the listbox is owner drawn fixed. For owner drawn 
variable Paul is absolutely correct in saying that it gets called for each 
item before the item is drawn.

I hope this helps

Gerry Sweeney




| Вернуться в корень Архива |