WIDGETS GAMBAS
GAMBAS 3 SOFTWARES
TUTORIALS
VISITS

   visitors

   visitor online

Where, who?
create own software - Popup menu
LES MENUS CONTEXTUELS OU MENU POPUP

menu.png
Aujourd'hui dans cet exemplenous allons voir comment afficher un menu contextuel pour notre application, ce menu qui ragit au clic droit de la souris, appel communment le menu popup.

crons une application et crivons le code ci dessous :

' Gambas class file
remarques du programme
'-----------------------------------
 ' Projet    : Menus contextuels franais
 ' Date      : 09/09
 ' Auteur    : taoteblues (Dr Henri LOQUET)
 ' Dtails   : Cration et utilisation d'un menu contextuel dans Textbox, ValueBox, ComboBox et TextArea
'-----------------------------------

dclaration des variables
PUBLIC letext AS TextBox 'variable pour le groupe Textbox
PUBLIC lechiffre AS ValueBox 'variable pour le groupe ValueBox
PUBLIC lecombo AS ComboBox 'variable pour le groupe ComboBox

PRIVATE montext AS Integer
PRIVATE Textcode AS String
PRIVATE Textdecode AS String

PUBLIC SUB Form_Open()
'curseur sur la premire textbox
TextBox1.SetFocus

ComboBox1.Add("un", 0)
ComboBox1.Add("deux", 1)
ComboBox1.Add("trois", 2)
ComboBox1.Index = 0
ComboBox2.Add("0", 0)
ComboBox2.Add("1", 1)
ComboBox2.Add("2", 2)
ComboBox2.Add("3", 3)
ComboBox2.Add("4", 4)
ComboBox2.Index = 1
'centrer la feuille
ME.Center
END

PUBLIC SUB Button1_Click()

  ME.Close

END
PUBLIC SUB lechiffre_mousedown()
lechiffre = LAST 
  montext = 2

END

PUBLIC SUB letext_Menu()
  popup.Popup
END

PUBLIC SUB letext_mousedown()
  letext = LAST
  montext = 1
END

PUBLIC SUB lechiffre_Menu()
 popup.Popup  
END


PUBLIC SUB lecombo_Menu()
 popup.Popup  
END

PUBLIC SUB lecombo_mousedown()
  lecombo = LAST 
  montext = 3
END

PUBLIC SUB TextArea1_Menu()
mnutext.Popup
END

PUBLIC SUB mnutextredo_Click() 
  TextArea1.Redo
END

PUBLIC SUB mnutextundo_Click() 
  TextArea1.Undo
END

PUBLIC SUB mnutextcouper_Click() 
 ' TextArea1.Cut
 DIM monchiffre AS String

'autre mthode pour couper afin de grer les caractres franais avec les accents
monchiffre = TextArea1.Selection.Text
'changer les caractres spciaux en html
    changercode(monchiffre)
monchiffre = Textcode

Clipboard.copy(monchiffre)
TextArea1.Selection.Text = ""
END

PUBLIC SUB mnutextcopier_Click() 
 ' TextArea1.Copy
  DIM monchiffre AS String

'autre mthode pour copier afin de grer les caractres franais avec les accents
monchiffre = TextArea1.Selection.Text
'changer les caractres spciaux en html
    changercode(monchiffre)
monchiffre = Textcode

Clipboard.copy(monchiffre)

END

PUBLIC SUB mnutextcoller_Click() 
  'TextArea1.Paste
  DIM inserer AS String
inserer = Clipboard.paste()
'remmettre les caractres spciaux avec accents
retourcode(inserer)

  TextArea1.Insert(Textdecode)
END

PUBLIC SUB mnucopier_Click()
DIM monchiffre AS String

SELECT CASE montext
CASE 1
monchiffre = letext.Selection.Text
    changercode(monchiffre)
monchiffre = Textcode

Clipboard.copy(monchiffre)
CASE 2
monchiffre = lechiffre.Selection.Text
    changercode(monchiffre)
monchiffre = Textcode

Clipboard.copy(monchiffre)
CASE 3
monchiffre = lecombo.Selection.Text
    changercode(monchiffre)
monchiffre = Textcode

Clipboard.copy(monchiffre)

END SELECT
END


PUBLIC SUB mnucoller_Click()
DIM inserer AS String
inserer = Clipboard.paste()
retourcode(inserer)
SELECT CASE montext
CASE 1
  letext.Insert(Textdecode)
CASE 2
 lechiffre.Insert(Textdecode)
CASE 3
 lecombo.Insert(Textdecode)
END SELECT



END

PUBLIC SUB mnucouper_Click()
DIM monchiffre AS String

SELECT CASE montext
CASE 1
monchiffre = letext.Selection.Text
    changercode(monchiffre)
monchiffre = Textcode

Clipboard.copy(monchiffre)
letext.Selection.Text = ""
CASE 2
Clipboard.copy(lechiffre.Selection.Text)
lechiffre.Selection.Text = ""
CASE 3
monchiffre = lecombo.Selection.Text
    changercode(monchiffre)
monchiffre = Textcode

Clipboard.copy(monchiffre)
lecombo.Selection.Text = ""
END SELECT

END
PRIVATE SUB changercode(mettre AS String)

     'Les A
    '-------
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")

    'Les C
    '-------
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")

    'Les E
    '-------
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")

    'Les I
    '------
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")

    'Les O
    '------
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")

    'Les U
    '-------
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")


    'Les fractions
    '----------------
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")

    'TM, COPYRIGHT, REG
    '--------------------------
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")

    'Divers
    '--------
    mettre = Replace(mettre, "", "&nfnof;")
    mettre = Replace(mettre, " ", "")
    mettre = Replace(mettre, " ", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")
    mettre = Replace(mettre, "", "")

  Textcode = mettre
END

PRIVATE SUB retourcode(remettre AS String)

    'Les A
    '-------
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")

    'Les C
    '-------
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")

    'Les E
    '-------
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "") 
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")

    'Les I
    '------
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")

    'Les O
    '------
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")

    'Les U
    '-------
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")


    'Les fractions
    '----------------
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")

    'TM, COPYRIGHT, REG
    '--------------------------
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")

    'Divers
    '--------
    remettre = Replace(remettre, "&nfnof;", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")
    remettre = Replace(remettre, "", "")

  Textdecode = remettre
END

PUBLIC SUB TextBox3_Menu()
 'ne pas avoir de menu
  STOP EVENT
 END

PUBLIC SUB mnutext_Show()
'voir ou ne pas voir copier, coller, couper en fonction du presse papier
IF TextArea1.Selection.Text <> "" THEN
mnutextcopier.enabled = TRUE
mnutextcouper.enabled = TRUE
ELSE
mnutextcopier.enabled = FALSE
mnutextcouper.enabled = FALSE
ENDIF

IF Clipboard.Paste() <> "" THEN
mnutextcoller.enabled = TRUE
ELSE
mnutextcoller.enabled = FALSE
ENDIF

END

PUBLIC SUB popup_Show()
DIM monchiffre AS String

monchiffre = Clipboard.Paste()

'voir ou ne pas voir copier, coller, couper en fonction du presse papier

SELECT CASE montext
CASE 1
IF letext.Selection.Text <> "" THEN
mnucopier.Enabled = TRUE
mnucouper.Enabled = TRUE
ELSE
mnucopier.Enabled = FALSE
mnucouper.Enabled = FALSE
ENDIF
IF monchiffre <> "" THEN
mnucoller.Enabled = TRUE
ELSE
mnucoller.Enabled = FALSE
ENDIF
CASE 2
IF lechiffre.Selection.Text <> "" THEN
mnucopier.Enabled = TRUE
mnucouper.Enabled = TRUE
ELSE
mnucopier.Enabled = FALSE
mnucouper.Enabled = FALSE
ENDIF
IF monchiffre
mnucoller.Enabled = TRUE
ELSE
mnucoller.Enabled = FALSE
ENDIF
CASE 3
IF lecombo.Selection.Text <> "" THEN
mnucopier.Enabled = TRUE
mnucouper.Enabled = TRUE
ELSE
mnucopier.Enabled = FALSE
mnucouper.Enabled = FALSE
ENDIF
IF monchiffre <> "" THEN
mnucoller.Enabled = TRUE
ELSE
mnucoller.Enabled = FALSE
ENDIF
END SELECT  
END
voil pour aujourd'hui.




Creation date : 02/10/2009 @ 22:16
Last update : 03/10/2009 @ 10:43
Category : create own software
Page read 3685 times


Print the article Print the article


react.gifReactions to this article

Nobody gave a comment yet.
Be the first one to do it!


QUICK MENU
SEARCH




GAMBAS 2 SOFTWARES
LANGUAGE
Other

^ Top ^