how do I put an Icon in the menu bar of a form

Using (or providing) components based on the "Win32" framework

how do I put an Icon in the menu bar of a form

Postby ray on Thu Mar 14, 2024 7:47 pm

I wish to place the "NEW" icon for APL onto the menu bar of a windows form.

I have no problem placing it within the body of the form

Code: Select all
test;siz;file;pos
 file←'C:\Users\ray_c\Downloads\APL\apl.png'
 siz←500 500
 pos←50 50
 'icon'⎕WC'Icon'file
 'f'⎕WC'form'('Test')('Posn'pos)('Size'siz)           ⍝ create the form
 'f'⎕WS('Coord' 'pixel')('BCol'(0 0 0))('State' 0)    ⍝ set some settings
 'f.mb'⎕WC'MenuBar'('Data'(⎕AI[3]))                   ⍝ Add a menu bar
 'f.mb.q'⎕WC'MenuItem' 'Quit'('Event' 'Select' 'Stop')⍝ menu button to stop/kill eveything
 'f.i'⎕WC'Image'(pos)('Picture'('icon'))              ⍝ add the icon



But I dont know how I can place it on the MenuBar, as using

Code: Select all
 'f.mb.i'⎕WC'Image'(pos)('Picture'('icon'))      ⍝ add the icon

gives
DOMAIN ERROR
test[9] 'f.mb.i'⎕WC'Image'(pos)('Picture'('icon')) ⍝ add the icon


Is it possible?
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 224
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Re: how do I put an Icon in the menu bar of a form

Postby Vince|Dyalog on Fri Mar 15, 2024 4:28 pm

Hi Ray,

I am trying to do this.

My first attempt is to put a picture on a menuitem.

A menu can have an ImageListObj. A MenuItem can have an ImageIndex.

'f'⎕WC'form'('Test')('Posn'pos)('Size'siz) ⍝ create the form
'f'⎕WS('Coord' 'pixel')('BCol'(0 0 0))('State' 0) ⍝ set some settings
'f.mb'⎕WC'MenuBar'('Data'(⎕AI[3])) ⍝ Add a menu bar
'f.mb.m'⎕WC'menu' 'mymenu'('imagelistobj' '#.f.iml1')

'f.i'⎕WC'Image'(pos)('Picture'('icon')) ⍝ add the icon
'f.iml1'⎕WC'imagelist'
i←1
j←1
:While j<10
('f.iml',(⍕i),'.','b',(⍕j))⎕WC'bitmap'('cbits'(32 32⍴⍳250))
j+←1
:EndWhile
j←1
'f.mb.m.q'⎕WC'MenuItem' 'Quit'('imageindex' 1)('Event' 'Select' 'Stop')⍝ menu button to stop/kill eveything

Regards,

Vince
Vince|Dyalog
 
Posts: 414
Joined: Wed Oct 01, 2008 9:39 am

Re: how do I put an Icon in the menu bar of a form

Postby Vince|Dyalog on Fri Mar 15, 2024 4:35 pm

Hi Ray,

Have you considered using a CoolBand and a ToolBar?

Here is an example I got from the Interface Guide, but I have modified it to get a .ico from my local drive.

⍝ From the Interface Guide,
'F'⎕WC'Form' 'CoolBand Caption and ImageIndex'
'F.IL'⎕WC'ImageList'('Masked' 0)('MapCols' 1)
'F.IL.'⎕WC'Bitmap'('ComCtl32' 120)⍝ STD_SMALL
'F.CB'⎕WC'CoolBar'('ImageListObj' 'F.CB.IL')
'F.CB.IL'⎕WC'ImageList'('Masked' 1)('MapCols' 1)
'F.CB.IL.'⎕WC'Icon'('file' 'c:/pics/house.ico')
'F.CB.IL.'⎕WC'Icon'('file' 'c:/pics/orange.ico')
:With 'F.CB.C1'⎕WC'CoolBand' 'File'('ImageIndex' 1)
'TB'⎕WC'ToolControl'('ImageListObj' '#.F.IL')('Divider' 0)
'TB.B1'⎕WC'ToolButton' 'New'('ImageIndex' 7)
'TB.B2'⎕WC'ToolButton' 'Open'('ImageIndex' 8)
'TB.B3'⎕WC'ToolButton' 'Save'('ImageIndex' 9)
:EndWith
:With 'F.CB.C2'⎕WC'CoolBand' 'Edit'('ImageIndex' 2)
'TB'⎕WC'ToolControl'('ImageListObj' '#.F.IL')('Divider' 0)
'TB.B1'⎕WC'ToolButton' 'Cut'('ImageIndex' 1)
'TB.B2'⎕WC'ToolButton' 'Copy'('ImageIndex' 2)
'TB.B3'⎕WC'ToolButton' 'Paste'('ImageIndex' 3)
'TB.B4'⎕WC'ToolButton' 'Undo'('ImageIndex' 4)
'TB.B5'⎕WC'ToolButton' 'Redo'('ImageIndex' 5)
:EndWith

Regards,

Vince
Vince|Dyalog
 
Posts: 414
Joined: Wed Oct 01, 2008 9:39 am

Re: how do I put an Icon in the menu bar of a form

Postby ray on Thu Mar 28, 2024 1:51 pm

Thanks for your help Vince.

In the end I have simply left the Icon in the top left corner of the main form body, and move the rest of the body to the right a bit.

Thanks anyway.

Ray
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 224
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK


Return to Windows: GUI, COM/OLE/ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest