[comp.os.os2.programmer] HELP!!! OWNERDRAW hItem

marc@metapyr.UUCP ( The Karate Kid ) (08/03/90)

Let the gods be favorable and someone answer my plea...


I have a LS_OWNERDRAW styled list box and have yet to figure out the
method of drawing text in response to the WM_DRAWITEM message for this
listbox.  The books don't help at all.  The only clue is that the hItem
part of the OWNERITEM structure "specifies an application-defined item
handle" (pg 512 of Volume 2, Micorsoft OS/2 Programmer's Ref.)  I've tried
to pass a pointer to a string, pointer to a structure that contains a string
 but to no avail.  Has anyone had success in this quandry?  I just want to
know what to pass as the mp2 of the LM_INSERTITEM message.

Thanks in advance.

Marc Paige

----------------------------------------------------------------------------
"tired and shagged out from a prolonged squawk" - mpfc the parrot sketch

ie15@vaxb.acs.unt.edu (09/01/90)

In article <953@metapyr.UUCP>, marc@metapyr.UUCP ( The Karate Kid ) writes:
> 
> I have a LS_OWNERDRAW styled list box and have yet to figure out the
> method of drawing text in response to the WM_DRAWITEM message for this
> listbox.  The books don't help at all.  The only clue is that the hItem
> part of the OWNERITEM structure "specifies an application-defined item
> handle" (pg 512 of Volume 2, Micorsoft OS/2 Programmer's Ref.)  I've tried
> to pass a pointer to a string, pointer to a structure that contains a string
>  but to no avail.  Has anyone had success in this quandry?  I just want to
> know what to pass as the mp2 of the LM_INSERTITEM message.
> 
I haven't an answer since I've yet to work own owner draw stuff yet. However,
the IBM Programmer's Toolkt has a great example of an ownerdraw listbox in
the sample program that shows Extended Attributes. The filepath is:
   x:\toolkt12\c\samples\bse\ealist\ealist.c	

If you hack thru it long enough you should be able to figure out what you need.	

Ken Tabor
University of Noth Texas

hill@evax.arl.utexas.edu (Col. Ames and Pixel) (09/02/90)

  HAHAHAHAHAHA!!! A OS/2 question I can answer.
  
  
  I  played for many moons with OWNERDRAW. Currently I am not at my friends
OS/2 box so I can look at the code. All of this is from memory.
  
  First:
 
    You need to send a LM_SETITEMHEIGHT to the LB to set the height of your
text (I use lEmHeight in the FONTMETRICS structure) 
  
    When you send text to a LB the iItem is the way to get at THAT piece of 
text. Send a LM_QUERYITEMTEXT using the iItem you get out of the OWNERITEM
structure to the list box to get the text (That wasn't rendered b'cause of the 
LS_OWNERDRAW attribute) that the LM_DRAWITEM sends you.
  
    Next set up the fonts in the Presentation Space. Clear the PS then use the
rclItem.x and .y in a GpiCharStringAt() to place the text.
  
  REMEMBER!!!!!!
  
1) You have to deal with a WM_INITDLG when there is nothing in the box.

2) You have to deal with the fsState and fsStateOld flags.
   
   a) One condidtion means DRAWME.
   b) One means HILITE me.
   c) One means UNHILITE me
   e) SET the flag to let the system know you HAVE done the "right thing".
      If you dont the system will do it for you and the LB will redraw itself
      a few times. (This is annoying during developement)

3) You will violate the 1/10 of sec rule, if you dont spawn a thread (At LEAST
   when you get a WM_INITDLG.)

   
   A few gotchas:

1) FATTR_HILITE (or what ever it is ) doesn't seem to work. Use GpiSetColor and
   GpiSetBackColor before you clear the PS.

2) Until you implement ALL fsState/fsStateOld logic, the system will redraw 
   the list box in its own way, thus selecting and unselecting will be ugly.



 I hope this helps. I used it to do multi-column justified text in a LB. LB's
dont have settable fonts and don't KNOW tabs (Hint to the OS/2 developement 
people at IBM.) I will post source when I get a chance to, but there is NO 
OS/2 term prg that will work with EMACS (If you know of a free/share one let 
me know)
 
  
 adam hill ... 
-- 


***************************************************************************
   adam hill                           Some Words Of .wisdom: