🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: WM_DRAWITEM

#16668
From: Remy Lebeau (TeamB)
Date: Mon, 05 May 2003 02:52
46 lines
2977 bytes
"JD" <nospam@nospam.com> wrote in message
news:3eb5cb82$1@newsgroups.borland.com...

> In all, there are 3 items that I want displayed as bold
> text. Is there anyway to do this without drawing the
> item myself?

No.  Although you can alter a menu item to include the MFS_DEFAULT state via
the SetMenuItemInfo() function and Windows will then automatically make the
item bold, a menu can only have 1 default item in it at a time.  That
doesn't meet your requirement to have 3 bold items at the same time.

> Also, is there a way to associate a short-cut string with
> an item so that I don't have to draw it myself?

No.  Shortcuts listed inside the Caption are not natively supported by
Windows and thus need to be drawn manually.  Even the VCL does as much
internally.

> Lastly, I'd like to have a common draw function but I
> can't figure out how to locate the the string for the item.
> At the moment I'm brute-forcing it by checking the
> DRAWITEMSTRUCT itemData value and drawing
> a literal.

It is your own responsibility to keep track of the strings you want to
display for each menu item you are custom-drawing.  They are not stored in
the menu item itself.  Menu items are identified in code by a numeric ID,
not a string caption.  The caption is strictly for human readibility
onscreen, that's all.

If you want to make your drawing code generic, then you should utilize the
menu item's dwItemData member of the MENUITEMINFO structure used for calls
to Get/SetMenuItemInfo().  That value is returned as the itemData member of
the DRAWITEMSTRUCT structure during drawing via WM_DRAWITEM.  In that value,
you can store a pointer to your own memory that contains specific
information about that particular menu item.  That way, your generic drawing
code can extract that pointer and thus have direct access to all the
information it needs to draw the menu item.

I strongly suggest you read up in the Win32 API documentation on the
"Creating Owner-Drawn Menu Items" topic for more information.


Gambit
Technical Details
Message-ID: <3eb5d19b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3eb5cb82$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,626cdd602756384
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-04 19:58:04 PST
From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3eb5cb82$1@newsgroups.borland.com>
Subject: Re: WM_DRAWITEM
Date: Sun, 4 May 2003 19:52:46 -0700
Lines: 48
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 207.175.226.26
Message-ID: <3eb5d19b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1052103067 207.175.226.26 (4 May 2003 19:51:07 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail