Adding Context-menu to Splitbox

Moderator: Rathinagiri

Post Reply
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Adding Context-menu to Splitbox

Post by hmgchang »

Dear HmgLovers,

Adding control context menu to c:\hmg.3.4.4\samples\controls\splitbox\splitbox_1.prg,
does not work as expected. am I missed something ?

Code: Select all

/*
 * HMG - Harbour Win32 GUI library Demo
 *
 * Copyright 2002 Roberto Lopez <mail.box.hmg@gmail.com>
 * http://www.hmgforum.com//
*/

#include "hmg.ch"

Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 800 HEIGHT 600 ;
		TITLE 'HMG SplitBox Demo' ;
		MAIN ;
		FONT 'Arial' SIZE 10 

		DEFINE STATUSBAR
			STATUSITEM 'HMG Power Ready - Click / Drag Grippers And Enjoy !' 
		END STATUSBAR

		DEFINE MAIN MENU 
			POPUP '&File'
				ITEM '&Disable ToolBar Button'		ACTION Form_1.SplitBox.ToolBar_1.Button_1.Enabled := .F.
				ITEM '&Enable ToolBar Button'		ACTION Form_1.SplitBox.ToolBar_1.Button_1.Enabled := .T.
				ITEM 'Get ToolBar Button Caption'	ACTION MsgInfo ( Form_1.SplitBox.ToolBar_1.Button_1.Caption )
				SEPARATOR
				ITEM 'Get EditBox Value'	ACTION MsgInfo ( Form_1.SplitBox.Edit_1.Value ) 
				ITEM 'Get Grid Value'		ACTION MsgInfo ( Str ( Form_1.SplitBox.Grid_1.Value ) ) 
				ITEM 'Get List Value'		ACTION MsgInfo ( Str ( Form_1.SplitBox.List_1.Value ) ) 
				SEPARATOR	
				ITEM 'Set EditBox Value'	ACTION Form_1.SplitBox.Edit_1.Value := 'New Value'
				ITEM 'Set Grid Value'	ACTION Form_1.SplitBox.Grid_1.Value := 2
				ITEM 'Set List Value'	ACTION Form_1.SplitBox.List_1.Value := 5
				SEPARATOR	
				ITEM 'Disable EditBox'	ACTION Form_1.SplitBox.Edit_1.Enabled := .f.
				ITEM 'Disable Grid'	ACTION Form_1.SplitBox.Grid_1.Enabled := .f.
				ITEM 'Disable List'	ACTION Form_1.SplitBox.List_1.Enabled := .f.
				SEPARATOR	
				ITEM 'Enable EditBox'	ACTION Form_1.SplitBox.Edit_1.Enabled := .t.
				ITEM 'Enable Grid'	ACTION Form_1.SplitBox.Grid_1.Enabled := .t.
				ITEM 'Enable List'	ACTION Form_1.SplitBox.List_1.Enabled := .t.
				SEPARATOR	
				ITEM 'Hide EditBox'	ACTION Form_1.SplitBox.Edit_1.Hide()
				ITEM 'Show EditBox'	ACTION Form_1.SplitBox.Edit_1.Show()
				SEPARATOR	
				ITEM 'Exit'		ACTION Form_1.Release
			END POPUP
			POPUP '&Help'
				ITEM 'About'		ACTION MsgInfo ("HMG SplitBox Demo","A COOL Feature ;)") 
			END POPUP
		END MENU
	
		DEFINE SPLITBOX 

			DEFINE TOOLBAR ToolBar_1 BUTTONSIZE 85,85 FLAT

				BUTTON Button_1 CAPTION '&More ToolBars...' PICTURE 'button1.bmp' ACTION MsgInfo('Click! 1')  TOOLTIP 'ONE'

				BUTTON Button_2 CAPTION '&Button 2' PICTURE 'button2.bmp' ACTION MsgInfo('Click! 2')  TOOLTIP 'TWO'

				BUTTON Button_3 CAPTION 'Button &3' PICTURE 'button3.bmp' ACTION MsgInfo('Click! 3')  TOOLTIP 'THREE'

			END TOOLBAR

			LISTBOX List_1 ;
				WIDTH 200 ;
				HEIGHT 400 ;
				ITEMS {'Item 1','Item 2','Item 3','Item 4','Item 5'} ;
				VALUE 3  ;
				TOOLTIP 'ListBox 1' 

			GRID Grid_1 ;
				WIDTH 200 ;
				HEIGHT 400 ;
				HEADERS {'Last Name','First Name'} ;
				WIDTHS {100,100};
				ITEMS { {'Simpson','Homer'} , {'Mulder','Fox'} } VALUE 1 ;
				TOOLTIP 'Grid Control'

			EDITBOX Edit_1 ;
				WIDTH 200 ;
				HEIGHT 400 ;
				VALUE 'EditBox!!' ;
				TOOLTIP 'EditBox' ;
				MAXLENGTH 255 

	
  END SPLITBOX
  [b][color=blue]
  Define_Control_Context_Menu ("ToolBar_1")	
  Define_Control_Context_Menu ("List_1")
  Define_Control_Context_Menu ("Grid_1")
  Define_Control_Context_Menu ("Edit_1")
 [/color][/b]

	END WINDOW

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return Nil

[b][color=blue]
PROCEDURE Define_Control_Context_Menu (cComponent)

Do Case
   Case cComponent="Label_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "Label 1" ACTION MsgInfo("Label 1")
            ITEM "Label 2" ACTION MsgInfo("Label 2")
            ITEM "Label 3" ACTION MsgInfo("Label 3")
        END MENU
   Case cComponent="Button_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "Button 1" ACTION MsgInfo("Button 1")
            ITEM "Button 2" ACTION MsgInfo("Button 2")
            ITEM "Button 3" ACTION MsgInfo("Button 3")
        END MENU
   Case cComponent="Button_2"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "Button 4" ACTION MsgInfo("Button 4")
            ITEM "Button 5" ACTION MsgInfo("Button 5")
            ITEM "Button 6" ACTION MsgInfo("Button 6")
        END MENU
   Case cComponent="Check_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "Check 1" ACTION MsgInfo("Check 1")
            ITEM "Check 2" ACTION MsgInfo("Check 2")
            ITEM "Check 3" ACTION MsgInfo("Check 3")
        END MENU
   Case cComponent="List_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "List 1" ACTION MsgInfo("List 1")
            ITEM "List 2" ACTION MsgInfo("List 2")
            ITEM "List 3" ACTION MsgInfo("List 3")
        END MENU
   Case cComponent="Combo_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "Combo 1" ACTION MsgInfo("Combo 1")
            ITEM "Combo 2" ACTION MsgInfo("Combo 2")
            ITEM "Combo 3" ACTION MsgInfo("Combo 3")
        END MENU
   Case cComponent="CheckBtn_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "CheckBtn 1" ACTION MsgInfo("CheckBtn 1")
            ITEM "CheckBtn 2" ACTION MsgInfo("CheckBtn 2")
            ITEM "CheckBtn 3" ACTION MsgInfo("CheckBtn 3")
        END MENU
   Case cComponent="Grid_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "Grid 1" ACTION MsgInfo("Grid 1")
            ITEM "Grid 2" ACTION MsgInfo("Grid 2")
            ITEM "Grid 3" ACTION MsgInfo("Grid 3")
        END MENU
   Case cComponent="Slider_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "Slider 1" ACTION MsgInfo("Slider 1")
            ITEM "Slider 2" ACTION MsgInfo("Slider 2")
            ITEM "Slider 3" ACTION MsgInfo("Slider 3")
        END MENU
   Case cComponent="Image_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "Image 1" ACTION MsgInfo("Image 1")
            ITEM "Image 2" ACTION MsgInfo("Image 2")
            ITEM "Image 3" ACTION MsgInfo("Image 3")
        END MENU
   Case cComponent="RadioGroup_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "RadioGroup 1" ACTION MsgInfo("RadioGroup 1")
            ITEM "RadioGroup 2" ACTION MsgInfo("RadioGroup 2")
            ITEM "RadioGroup 3" ACTION MsgInfo("RadioGroup 3")
        END MENU
   Case cComponent="Tab_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "Tab 1" ACTION MsgInfo("Tab 1")
            ITEM "Tab 2" ACTION MsgInfo("Tab 2")
            ITEM "Tab 3" ACTION MsgInfo("Tab 3")
        END MENU
   Case cComponent="ProgressBar_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "ProgressBar 1" ACTION MsgInfo("ProgressBar 1")
            ITEM "ProgressBar 2" ACTION MsgInfo("ProgressBar 2")
            ITEM "ProgressBar 3" ACTION MsgInfo("ProgressBar 3")
        END MENU
   Case cComponent="ToolBar_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "ToolBar 1" ACTION MsgInfo("ToolBar 1")
            ITEM "ToolBar 2" ACTION MsgInfo("ToolBar 2")
            ITEM "ToolBar 3" ACTION MsgInfo("ToolBar 3")
        END MENU
   Case cComponent="StatusBar"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "StatusBar 1" ACTION MsgInfo("StatusBar 1")
            ITEM "StatusBar 2" ACTION MsgInfo("StatusBar 2")
            ITEM "StatusBar 3" ACTION MsgInfo("StatusBar 3")
        END MENU
   Case cComponent="Spinner_1"
        DEFINE CONTROL CONTEXTMENU &cComponent OF Form_1
            ITEM "Spinner 1" ACTION MsgInfo("Spinner 1")
            ITEM "Spinner 2" ACTION MsgInfo("Spinner 2")
            ITEM "Spinner 3" ACTION MsgInfo("Spinner 3")
        END MENU
Endcase
RETURN
[/color][/b]

Pls advise
TIA

best rgds,
Chang
Just Hmg It !
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Adding Context-menu to Splitbox

Post by hmgchang »

btw... what happen to my BBcode ?
I want to make / show different color to the code I added...
Pls advise how....
TIA
Just Hmg It !
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Adding Context-menu to Splitbox

Post by esgici »

hmgchang wrote: Mon May 28, 2018 8:26 am Adding control context menu to c:\hmg.3.4.4\samples\controls\splitbox\splitbox_1.prg,
does not work as expected. am I missed something ?
Hi Chang

IMHO problem is: SplitBox is a container, not a control :(

Note: If you wondering "what is container ?" frankly I don't know :?

Happy HMGing :D
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Adding Context-menu to Splitbox

Post by mol »

As the same name says container holds its contain, hahaha
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Adding Context-menu to Splitbox

Post by andyglezl »

Si la idea es utilizar SPLITBOX, parece que no se puede.

Haciendolo de la forma "normal" si.
-------------------------------------------------
If the idea is to use SPLITBOX, it seems that you can not.

Doing it in the "normal" way, yes.

Code: Select all

/*
 * HMG - Harbour Win32 GUI library Demo
 *
 * Copyright 2002 Roberto Lopez <mail.box.hmg@gmail.com>
 * http://www.hmgforum.com//
*/

#include "hmg.ch"

Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 800 HEIGHT 600 ;
		TITLE 'HMG SplitBox Demo' ;
		MAIN ;
		FONT 'Arial' SIZE 10 

		DEFINE STATUSBAR
			STATUSITEM 'HMG Power Ready - Click / Drag Grippers And Enjoy !' 
		END STATUSBAR

		DEFINE MAIN MENU 
			POPUP '&File'
				ITEM '&Disable ToolBar Button'		ACTION Form_1.SplitBox.ToolBar_1.Button_1.Enabled := .F.
				ITEM '&Enable ToolBar Button'		ACTION Form_1.SplitBox.ToolBar_1.Button_1.Enabled := .T.
				ITEM 'Get ToolBar Button Caption'	ACTION MsgInfo ( Form_1.SplitBox.ToolBar_1.Button_1.Caption )
				SEPARATOR
				ITEM 'Get EditBox Value'	ACTION MsgInfo ( Form_1.SplitBox.Edit_1.Value ) 
				ITEM 'Get Grid Value'		ACTION MsgInfo ( Str ( Form_1.SplitBox.Grid_1.Value ) ) 
				ITEM 'Get List Value'		ACTION MsgInfo ( Str ( Form_1.SplitBox.List_1.Value ) ) 
				SEPARATOR	
				ITEM 'Set EditBox Value'	ACTION Form_1.SplitBox.Edit_1.Value := 'New Value'
				ITEM 'Set Grid Value'	ACTION Form_1.SplitBox.Grid_1.Value := 2
				ITEM 'Set List Value'	ACTION Form_1.SplitBox.List_1.Value := 5
				SEPARATOR	
				ITEM 'Disable EditBox'	ACTION Form_1.SplitBox.Edit_1.Enabled := .f.
				ITEM 'Disable Grid'	ACTION Form_1.SplitBox.Grid_1.Enabled := .f.
				ITEM 'Disable List'	ACTION Form_1.SplitBox.List_1.Enabled := .f.
				SEPARATOR	
				ITEM 'Enable EditBox'	ACTION Form_1.SplitBox.Edit_1.Enabled := .t.
				ITEM 'Enable Grid'	ACTION Form_1.SplitBox.Grid_1.Enabled := .t.
				ITEM 'Enable List'	ACTION Form_1.SplitBox.List_1.Enabled := .t.
				SEPARATOR	
				ITEM 'Hide EditBox'	ACTION Form_1.SplitBox.Edit_1.Hide()
				ITEM 'Show EditBox'	ACTION Form_1.SplitBox.Edit_1.Show()
				SEPARATOR	
				ITEM 'Exit'		ACTION Form_1.Release
			END POPUP
			POPUP '&Help'
				ITEM 'About'		ACTION MsgInfo ("HMG SplitBox Demo","A COOL Feature ;)") 
			END POPUP
		END MENU

      @ 50,20 BUTTON B1 OF Form_1 CAPTION "cCaption" ACTION NIL WIDTH 50 HEIGHT 50 TOOLTIP "cToolTipText"
      DEFINE CONTROL CONTEXT MENU B1 OF Form_1
            ITEM "Button1.1" ACTION MsgInfo("Button1.1")
            ITEM "Button1.2" ACTION MsgInfo("Button1.2")
            ITEM "Button1.3" ACTION MsgInfo("Button1.3")
      END MENU



	END WINDOW

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return Nil


RETURN
Andrés González López
Desde Guadalajara, Jalisco. México.
EduardoLuis
Posts: 682
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina

Re: Adding Context-menu to Splitbox

Post by EduardoLuis »

Hi HMGCHANG:

Unfortunately it's impossible to perform a context menu on any container.-
Splitbox is a container (as master Esgici said).-
Context menues could be apply to controls.-
With regards
Eduardo
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Adding Context-menu to Splitbox

Post by hmgchang »

Dear Friends,
Thanks ...
Happy Vesak...

@Esgici :
1. there are Context-Menu and Control Context-Menu, but both failed on Splitbox
2. Sure Splitbox is a container. ie. try this : msgDebug( Form_1.Splitbox.List_1.Value) ---> ok
3. as a container : Form_1.handle -> ok, but Splitbox.handle -> not ok
4. as a control : Form_1.List_1.handle -> ok, but Form_1.Splitbox.handle -> not ok
5. my intention is to have a context-menu on control that happen to be in a form that have a Splitbox feature.

TIA

best rgds,
Chang
Just Hmg It !
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Adding Context-menu to Splitbox

Post by esgici »

hmgchang wrote: Mon May 28, 2018 10:42 pm Dear Friends,
Thanks ...
Happy Vesak...

@Esgici :
1. there are Context-Menu and Control Context-Menu, but both failed on Splitbox
2. Sure Splitbox is a container. ie. try this : msgDebug( Form_1.Splitbox.List_1.Value) ---> ok
3. as a container : Form_1.handle -> ok, but Splitbox.handle -> not ok
4. as a control : Form_1.List_1.handle -> ok, but Form_1.Splitbox.handle -> not ok
5. my intention is to have a context-menu on control that happen to be in a form that have a Splitbox feature.

TIA

best rgds,
Chang
Yes, apparently Splitbox is not a window (form) nor a control; so its impossible (at last for now) to define a context menu for it :(

Who know, maybe a day ...

By the way, Ramadan mubarak to you too :D

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Adding Context-menu to Splitbox

Post by hmgchang »

Thank you Mr. Esgici...

I don't need context menu for Splitbox

i want to have Control Context Menu for a control
that happen to be in a form with a splitbox feature.

ps. finally... bbCode works...

TIA

best rgds,
Chang
Just Hmg It !
Post Reply