Darn, I lost my whole post. Don't know what happened. Trying again.
What is a Sunday without 10 hours of futile programming
As I mentioned, I am trying to put menu option text and click commands in the same place, in this case in a form method, looking like this:
Visual Fox Pro
* Method "Set_up_menu" in form "frmMainmenu"
Local ix, ixxx, lnButtonHeight, lnButtonWidth, lnRecCnt, lnContTop, lnContLeft, lnTopPart, ;
lcClick1, lcClick2, lcClick3, lcClick4, lcClick5, lcClick6, lcClick7, lcClick8, lcClick9
Store 0 To lnRecCnt
lnContTop = 200 && Top of container
lnContLeft = 500 && Left of container
* lnButtonHeight = 30 && Height of buttons
lnButtonWidth = 0 && Will become width of all butttons
lnBtwButtons = 15 && Distance between buttons as well as between buttons and top/bottom of commandgroup
lnTopPart = 60 && Distane between top of container and top of commandgroup
lcFrmBackColor = "RGB(211,223,254)"
lcCntBackColor = "RGB(205,200,245)"
lcCmgBackColor = "RGB(191,166,191)"
lcCmdForeColor = "RGB(255,255,255)"
lcCmdBackColor = "RGB(0,0,100)"
lcLblForeColor = "RGB(0,0,0)"
*
* CREATE CURSOR BUTTON GROUP
*
Create Cursor curCommandGroup (ButtonCaption c(25)) && Max 25 characters, max 9 menu options.
Insert Into curCommandGroup Values ('\<')
Insert Into curCommandGroup Values ('\<Applications')
Insert Into curCommandGroup Values ('\<')
Insert Into curCommandGroup Values ('\<')
Insert Into curCommandGroup Values ('\<Hardware')
Insert Into curCommandGroup Values ('\<')
Insert Into curCommandGroup Values ('\<')
Insert Into curCommandGroup Values ('\<Settings') && This must be next to the last menu option.
Insert Into curCommandGroup Values ('\<Exit') && This must be the last menu option.
* ============================ Code in click method ==========
TEXT TO lcClick1 && Code for 1st button above
Just any command.
ENDTEXT
* --------------------------------------------
TEXT TO lcClick2 && Code for 2nd button above
Just any command.
ENDTEXT
* --------------------------------------------
TEXT TO lcClick3 && Code for 3rd button above
Just any command.
ENDTEXT
* --------------------------------------------
TEXT TO lcClick4 && Code for 4th button above
THISFORM.Release
CLEAR EVENTS
ENDTEXT
* --------------------------------------------
TEXT TO lcClick5 && Code for 5th button above
[No commands here or later, because I only need 4 buttons in this menu]
ENDTEXT
* --------------------------------------------
TEXT TO lcClick6 && Code for 6th button above
ENDTEXT
* --------------------------------------------
TEXT TO lcClick7 && Code for 7th button above
ENDTEXT
* --------------------------------------------
TEXT TO lcClick8 && Code for 8th button above
ENDTEXT
* --------------------------------------------
TEXT TO lcClick9 && Code for 9th button above
ENDTEXT
* ==============================================================================================
Thisform.Newobject('cntMenuContainer','Container') && Creating a container
Thisform.Newobject('lblAppdescr','Label') && Creating an application description label
Thisform.Newobject('lblCopyright','Label') && Creating a copyright label
Thisform.cntMenuContainer.Newobject('lblMainmenu','Label') && Creating Label
Thisform.cntMenuContainer.Newobject('linMainmenu','Line') && Creating Line
* ==============================================================================================
SCAN FOR LEN(TRIM(ButtonCaption)) > 2
lnRecCnt = lnRecCnt + 1
lnRecCnt_C = STR(lnRecCnt,1)
lcCaption&lnRecCnt_C = TRIM(ButtonCaption)
ENDSCAN
*
DO TwsMainMenu.prg WITH lcClick1, lcClick2, lcClick3, lcClick4, lcClick5, lcClick6, lcClick7, lcClick8, lcClick9, lnRecCnt
*
THISFORM.cntMenuContainer.NewObject('cmgMenuGroup','clCommandGroup','twsmainmenu.prg')
FOR ix = 1 TO lnRecCnt
WITH THISFORM.cntMenuContainer.cmgMenuGroup.buttons[m.ix]
ixxx = STR(ix,1)
.Caption = lcCaption&ixxx
.AutoSize = .T.
.Forecolor = &lcCmdForeColor
.Backcolor = &lcCmdBackColor
.Top = ((m.ix - 1) * 1.5 * .Height) + lnBtwButtons
.Left = 10
lnButtonHeight = .Height
IF lnButtonWidth < .Width
lnButtonWidth = .Width
ENDIF
.AutoSize = .F.
ENDWITH
ENDFOR
FOR ix = 1 TO lnRecCnt
THISFORM.cntMenuContainer.cmgMenuGroup.buttons[m.ix].Width = lnButtonWidth && Setting (same) width for all buttons
ENDFOR
*
* SET VALUES FOR COMMANDGROUP
*
WITH THISFORM.cntMenuContainer.cmgMenuGroup && CommandGroup
.Backcolor = &lcCmgBackColor
.Top = lnTopPart && From container top
.Left = 10 && From container left
.Height = (.ButtonCount * lnButtonHeight) + ((.ButtonCount + 1) * lnBtwButtons)
.Width = lnButtonWidth + 20
.SetAll('Visible',.T.)
.Visible = .T.
ENDWITH
*
* SET VALUES FOR CONTAINER, LABEL & LINE
*
WITH THISFORM.cntMenuContainer && Container
.Backcolor = &lcCntBackColor
.Top = lnContTop && Container top
.Left = lnContLeft && Container left
.Height = .cmgMenuGroup.Height + 75 && Container height
.Width = .cmgMenuGroup.Width + 20 && Container width
.Visible = .T. && Container visible
*
WITH .lblMainmenu && Label ("MAIN MENU")
.Caption = 'MAIN MENU'
.BackStyle = 0
.ForeColor = &lcLblForeColor
.FontSize = 12
.AutoSize = .T.
.Top = (lnTopPart /2) - (.Height/2)
.Left = (Thisform.cntMenuContainer.Width/2) - (.Width/2)
.Alignment = 2
.Visible = .T.
ENDWITH
*
WITH .linMainmenu && Line
.Top = 50
.Left = 0
.Height = 0
.Width = Thisform.cntMenuContainer.Width
.Visible = .T.
ENDWITH
ENDWITH
*
* SETTING VALUES FOR FORM LABELS (2)
*
WITH Thisform.lblAppdescr
.Caption = 'TERMINOLOGY WEB SEARCH'
.BackStyle = 0
.FontSize = 16
.AutoSize = .T.
.Top = lnContTop - 50
.Left = lnContLeft + (Thisform.cntMenuContainer.Width/2) - (.Width/2)
.Alignment = 2
.Visible = .T.
ENDWITH
*
WITH Thisform.lblCopyright
.Caption = '© Copyright TransManage Software 2010'
.Backstyle = 0
.FontSize = 8
.AutoSize = .T.
.Top = lnContTop + Thisform.cntMenuContainer.Height + 50
.Left = lnContLeft + (Thisform.cntMenuContainer.Width/2) - (.Width/2)
.Alignment = 2
.Visible = .T.
ENDWITH
Thisform.BackColor = &lcFrmBackColor
The file that is called from the method is twsmainmenu.prg (I have changed the names a little and cleaned up here and there). It looks like this:
Visual Fox Pro
* twsmainmenu.prg
LPARAMETERS lcClick1, lcClick2, lcClick3, lcClick4, lcClick5, lcClick6, lcClick7, lcClick8, lcClick9, lnRecCnt
LOCAL ixx &&, lcMyClass
* SET TEXTMERGE TO Memvar lcMyClass Noshow
* SET TEXTMERGE ON
*
DEFINE CLASS clCommandGroup AS CommandGroup
*
ButtonCount = lnRecCnt
*
PROCEDURE Click
DO CASE
FOR ixx = 1 TO m.lnRecCnt
CASE This.Value = EVALUATE(m.ixx)
EVALUATE( 'm.lcClick' + LTRIM(STR( m.ixx )))
ENDFOR
ENDCASE
ENDPROC
ENDDEFINE
*SET TEXTMERGE TO
*SET TEXTMERGE OFF
*RETURN m.lcMyClass
I know that you had "\" and "\\" and "textmerge" and stuff, and I tried it, but still did not get the click event to work. The reason I do not call a procedure, but rather a prg file, from the form method is that an error message eons ago told me that I could not define a class within a procedure. And, still, your code has a define class within a procedure. I am confused about that, but it does not matter, because these days, it is a constant state of my mind.
The only reason I do not cry at this stage is that I am a man, and men do not cry
Any way to get the click events to work based on what I have, with appropriate changes, of course?
Thanks for you immense patience.
Hans L