🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
5 messages
5 total messages Started by JD Mon, 05 May 2003 02:25
WM_DRAWITEM
#16667
Author: JD
Date: Mon, 05 May 2003 02:25
24 lines
1724 bytes
I've altered the forms default system menu using Win32 API calls
and I've subclassed the forms WindowProc so that I can draw my
additions to the menu.

I found that I had to draw the additions to the menu myself
because one of the items is a 'caption' that I want in bold and
I do not want it selected on MouseOver and the other item which
is also in bold has a short-cut.

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

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

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.

Any help on any of the issues is appreciated.

~ JD
Re: WM_DRAWITEM
#16668
Author: 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
Re: WM_DRAWITEM
#16669
Author: JD
Date: Mon, 05 May 2003 03:16
11 lines
1322 bytes
"Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> wrote:
> [...] I strongly suggest you read up in the Win32 API documentation
>on the "Creating Owner-Drawn Menu Items" topic for more information.

I appreciate the help and the tip pointing me to a source but
even knowing that it's there I still can't find it. I'll keep
looking but in case I can't locate it, could you please tell me
how you found it?

~ JD
Re: WM_DRAWITEM
#16671
Author: Remy Lebeau (TeamB)
Date: Mon, 05 May 2003 05:57
15 lines
1483 bytes
"JD" <nospam@nospam.com> wrote in message
news:3eb5d7a2$1@newsgroups.borland.com...

> I appreciate the help and the tip pointing me to a source
> but even knowing that it's there I still can't find it. I'll keep
> looking but in case I can't locate it, could you please tell
> me how you found it?

As I said earlier, it is located in the Win32 API documentation.  Builder
comes with a copy of it (win32.hlp) or else just look it up at MSDN,
http://msdn.microsoft.com


Gambit
Re: WM_DRAWITEM
#16672
Author: JD
Date: Mon, 05 May 2003 06:32
7 lines
1042 bytes
"Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> wrote:
>  (win32.hlp) 

That's the ticket. Thank You.

~ JD
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads