TMnuComp

Source: source/classes/tmnucomp.prg

Inherits from: TComponent

TMnuComp is a non-visual component that wraps a TMenu object into the TComponent framework for use in the VisualFW form designer. It allows menus to be designed, manipulated, and persisted within the visual designer environment alongside visual controls. The component creates a default menu with sample items and registers it on the parent window.

Key DATA Members

DATATypeDescription
oMenuTMenuThe wrapped TMenu object
cResBmpCharacterOptional bitmap resource name for the menu
cVarNameCharacterVariable name used in the designer (from CLASSDATA aProperties)

Methods

MethodDescription
New( nRow, nCol, oWnd, lDesign, oObject, cResBmp )Create a menu component, wrap the TMenu, and attach it to the window
aItems( aNewItems )SETGET method; replaces all menu items with a new array of item definitions
Destroy()End the wrapped menu, detach from window, and destroy the component

Example: Menu Component in Designer

#include "FiveWin.ch"

function Main()

   local oWnd, oMnuComp

   DEFINE WINDOW oWnd TITLE "VisualFW Designer" SIZE 800, 600

   // TMnuComp is typically instantiated by the VisualFW designer.
   // Here it is shown explicitly:

   oMnuComp := TMnuComp():New( 0, 0, oWnd, .T., , "mybmp" )

   // oMnuComp:oMenu is now the window's menu bar
   // Replace all items at runtime:

   oMnuComp:aItems := { "&File", "&Edit", "&View", "&Help" }

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

See Also