QMenu   by Jordi Ramos 

Ownerdrawn MenuItems

 QMenu  Properties

Descrip AS WORD  
Panel AS WORD  
Font AS QFONT  
imgs AS QIMAGELIST  List of images for menu


Examples

$TYPECHECK ON

$INCLUDE "RAPIDQ.INC"
$INCLUDE "QMENU.INC"
'Also Api.inc is needed
$RESOURCE New_bmp as "New.bmp"
$RESOURCE Open_bmp as "Open.bmp"
$RESOURCE Save_bmp as "Save.bmp"
$RESOURCE Exit_bmp as "Exit.bmp"
$RESOURCE Cut_bmp as "Cut.bmp"
$RESOURCE Copy_bmp as "Copy.bmp"
$RESOURCE Paste_bmp as "Paste.bmp"

Declare Sub FormClose (Action As integer)
Declare Sub NewItemClick (Sender As QMENUITEM)
Declare Sub ExitItemClick (Sender As QMENUITEM)

CREATE Form2 As QFORM
    Caption = "New Form"
    Width = 200
    Height = 100
    Center
END CREATE

CREATE Form As QForm
   Width = 400
   Center
   Caption = "Ownerdraw Menus"
   onClose = FormClose
   
   CREATE MainMenu As QMainMenu
      CREATE FileMenu As QMenuItem
         Caption = "&File"
         CREATE NewItem As QMenuItem
            Caption = "&New"
            Hint = "New"
            onclick = NewItemClick
         END CREATE
         CREATE OpenItem As QMenuItem
            Caption = "&Open..."
            Hint = "Open"
            ShortCut = "Ctrl+O"
         END CREATE
         CREATE SaveItem As QMenuItem
            Caption = "&Save"
            Hint = "Save"
         END CREATE
         CREATE SaveASItem As QMenuItem
            Caption = "Sa&ve as..."
            Hint = "Save as"
         END CREATE
         CREATE BreakItem As QMenuItem
            Caption = "-"
         END CREATE
         CREATE ExitItem As QMenuItem
            Caption = "E&xit"
            onclick = ExitItemClick
         END CREATE
      END CREATE
      CREATE EditMenu As QMenuItem
         Caption = "&Edit"
         CREATE CutItem As QMenuItem
             Caption = "Cu&t"
             ShortCut = "Ctrl+X"
         END CREATE
         CREATE CopyItem As QMenuItem
             Caption = "&Copy"
         END CREATE
         CREATE PasteItem As QMenuItem
             Caption = "&Paste"
         END CREATE

      END CREATE
      CREATE SearchMenu As QMenuItem
         Caption = "&Search"
         CREATE FindItem As QMenuItem
             Caption = "&Find"
         END CREATE
         CREATE ReplaceItem As QMenuItem
             Caption = "&Replace"
         END CREATE
       END CREATE
    END CREATE
    
    CREATE StatusBar As QStatusBar
       AddPanels "QMenu by Jordi Ramos",""
       panel(0).Width = 120
    END CREATE

END CREATE

dim imglst as qimagelist                'List of images for menu 
   imglst.masked = False
   imglst.addbmphandle New_bmp,0
   imglst.addbmphandle Open_bmp,0
   imglst.addbmphandle Save_bmp,0
   imglst.addbmphandle Exit_bmp,0
   imglst.addbmphandle Cut_bmp,0
   imglst.addbmphandle Copy_bmp,0
   imglst.addbmphandle Paste_bmp,0
   
DIM OwnerMenu as QMENU
   OwnerMenu.Set Form 
   
   OwnerMenu.Descrip = TRUE
   OwnerMenu.Panel = 1
   
   OwnerMenu.Imgs.Handle = imglst.handle
   
   OwnerMenu.OwnerDraw FileMenu, NewItem, 0, "Creates a new document"
   OwnerMenu.OwnerDraw FileMenu, OpenItem, 1, "Opens a Document"
   OwnerMenu.OwnerDraw FileMenu, SaveItem, 2, "Save Document"
   OwnerMenu.OwnerDraw FileMenu, ExitItem, 3, "Exits Program"
   OwnerMenu.OwnerDraw EditMenu, CutItem, 4, "Cuts Selection to Clipboard"
   OwnerMenu.OwnerDraw EditMenu, CopyItem, 5, "Copies Selection to Clipboard"
   OwnerMenu.OwnerDraw EditMenu, PasteItem, 6, "Pastes Contents of Clipboard"

   OwnerMenu.Description SaveAsItem, "Save Document as"
   OwnerMenu.Description FindItem, "Search for a text string"
   OwnerMenu.Description ReplaceItem, "Replace a character string by another"

Form.ShowModal


SUB NewItemClick (Sender AS QMENUITEM)
   Form2.ShowModal
end Sub 

SUB ExitItemClick (Sender AS QMENUITEM)
   Form.close
end Sub 

sub FormClose (Action as integer)
   OwnerMenu.Close
end Sub
 
Hosted by uCoz