Owner drawn menus - UPDATED.

Share your advanced PureBasic knowledge/code with the community.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Owner drawn menus - UPDATED.

Post by srod »

Hi,

I've been tinkering with owner drawn menus, searching for an easy mechanism for changing colours and mixing text and icons etc. and have hashed up a little include file which others might find useful.

Features:
  • easily mix text and icons
  • colour individual menu items (text and background)
  • justify the text in individual menu items
  • use multiple fonts
  • set different heights for individual menu items
  • choose to have a border surround the highlighted menu item etc.
I've tested it with regular menus and a little bit with popup menus and all seems to work okay. No documentation I'm afraid, but the example program should make it clear how to use the little library.

The code is based on a routine I found on purearea.net

Click to download
Last edited by srod on Thu Nov 24, 2005 9:00 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

Nice :D
I like logic, hence I dislike humans but love computers.
A.I
User
User
Posts: 16
Joined: Wed Jul 27, 2005 2:09 pm
Location: Finland

Post by A.I »

Can anybody confirm this works on Win9x/Me?
Just curious.

I only have XP systems here, and seems to work like a dream.
Specialized in "AI Programming Games".
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Worked okay on Win 98 when I tried.
I may look like a mule, but I'm not a complete ass.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Pretty nice.

Thanks srod.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi srod,

Very nice. Thank you for this.
@}--`--,-- A rose by any other name ..
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You're welcome.

Credit due to Andreas for posting the code which this is based upon in the Purearea site.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Update: The library now reacts to the usual Purebasic command

Code: Select all

DisableMenuItem()

appropriately by greying the text and refusing to allow the selection of the item etc.
I may look like a mule, but I'm not a complete ass.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Thanks, but one little error : member 'enabled' is missing in structure 'iMenuItem'.

Code: Select all

Structure iMenuItem ;Used to store information on individual menu items.
  id.l
  hMenu.l
  enabled.l ; <- fixed ///////////
  height.l
  lefttextmargin.l
  textcolour.l ;Unselected colour.
  backcolour.l ;Unselected colour.
  hFont.l ;Handle to the font to be used.
  textjustification.l ;One of '#ES_CENTER', '#ES_LEFT', '#ES_RIGHT'.
  hIcon.l ;Handle to the icon to be used.
EndStructure 
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Thanks Gnozal, but that member is not, or should not be used. If any of the code references this member then the code needs removing. I'll have a check and upload a new version if necessary.

Edit: new version uploaded.
I may look like a mule, but I'm not a complete ass.
Seymour Clufley
Addict
Addict
Posts: 1265
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Post by Seymour Clufley »

The link in the OP doesn't work. Does anyone have the include? It would be much appreciated, seems like a useful piece of code.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Hi seymour,

I basically replaced this code with a simpler and more efficient offering and so removed the download some time ago.

Here's a link to the updated code :

http://www.purebasic.fr/english/viewtop ... menu+icons
I may look like a mule, but I'm not a complete ass.
Seymour Clufley
Addict
Addict
Posts: 1265
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Post by Seymour Clufley »

Thanks a lot, Srod. That's much appreciated. :)
Post Reply