Guidance
指路人
g.yi.org
software / rapidq / Examples / QObject / QTButton / QTButton_FullExamples.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'-- Différentes possibilités/A more complete examples
     $RESOURCE btn_BMP AS "Boutons.bmp"' -- Remplacez-le par une image que vous possèdez
     $RESOURCE btn_BMP1 AS "Boutons_Plat.bmp"' -- Utiliser celui-ci pour créer un bouton
                                        '    plat.

     DIM ico_BMP AS QBITMAP
     WITH ico_BMP
      .Width = 18
      .Height = 18
      .Circle (1,1,17,17, -1, &HFFAADD)
      .Line(6,4,6,7,0)
      .Line(7,4,7,7,0)
      .Line(10,4,10,7,0)
      .Line(11,4,11,7,0)
      .Line(5,10,5,10,0)
      .Line(12,10,12,10,0)
      .Line(4,9,4,9,0)
      .Line(13,9,13,9,0)
      .Line(6,11,11,11,0)
     END WITH

     $INCLUDE "QTButton87.inc"' -- Corrigez le chemin si nécessaire

'QTBtnBMP.BMPHandle = btn_BMP1

     DECLARE SUB Boutons_Click(Sender AS QTButton)
     DECLARE SUB Boutons_MouseMove(X AS INTEGER, Y AS INTEGER, Shift AS INTEGER, Sender AS QBUTTON)
     DECLARE SUB QBouton_MouseMove(X AS INTEGER, Y AS INTEGER, Shift AS INTEGER, Sender AS QBUTTON)
     DECLARE SUB QBouton_MouseUp(btn AS INTEGER, X AS INTEGER, Y AS INTEGER, Shift AS INTEGER, Sender AS QBUTTON)

     DECLARE SUB Enjolivure_Click(Sender AS QTButton)

     CREATE Form AS QFORM
      CAPTION = "Examples de QTButton Examples"
      ClientWidth = 329
      ClientHeight = 260
      Center
      CREATE TButton AS QTButton
       Left = 8
       Top = 8
       NumBMPs =4
       CAPTION = "Sélectionné"
       OnClick = Boutons_Click
       OnMouseMove = Boutons_MouseMove
      END CREATE
      CREATE TButton2 AS QTButton
       Left = 8
       Top = 38
       CAPTION = "Normal"
       NumBMPs =4
       OnClick = Boutons_Click
       OnMouseMove = Boutons_MouseMove
      END CREATE
      CREATE TButton3 AS QTButton
       Enabled = 0
       Left = 8
       Top = 68
       NumBMPs =4
       CAPTION = "Désactivé"
       OnClick = Boutons_Click
       OnMouseMove = Boutons_MouseMove
      END CREATE
      CREATE TButton4 AS QTButton
       Default = 1
       Left = 8
       Top = 98
       CAPTION = "Défaut"
       NumBMPs =4
       OnClick = Boutons_Click
       OnMouseMove = Boutons_MouseMove
      END CREATE
      CREATE TButton5 AS QTButton
       Default = 1
       Left = 8
       Top = 128
       CAPTION = "&Sous-ligné"
       NumBMPs =4
       OnClick = Boutons_Click
       OnMouseMove = Boutons_MouseMove
       Hint = "Appuyez simultanément ALT+S pour voir ce qui arrivera"
       ShowHint = 1
      END CREATE
      CREATE TButton6 AS QTButton
       Left = 98
       Top = 8
       Height = 60
       NumBMPs =4
       CAPTION = "Multi-Lignes" +CHR$(10) +"Retaillé" +CHR$(10) +"Multi-Lines"
       OnClick = Boutons_Click
       OnMouseMove = Boutons_MouseMove
       Hint = "Pour créer un effet multi-lignes ajoutez chr$(10) " +CHR$(10) +_
        "entre les mots où vous voulez créer l'effet."
       ShowHint = 1
      END CREATE
      CREATE TButton7 AS QTButton
       Left = 98
       Top = 98
       Height = 20
       Width = 20
       CAPTION = "..."
       NumBMPs =4
       OnClick = Boutons_Click
       OnMouseMove = Boutons_MouseMove
      END CREATE
      CREATE TButton8 AS QTButton
       Left = 128
       Top = 98
       Height = 20
       Width = 20
       NumBMPs =4
       Hint = "Vide"
       ShowHint = 1
       OnClick = Boutons_Click
       OnMouseMove = Boutons_MouseMove
      END CREATE
      CREATE TButton9 AS QTButton
       BMP = ico_BMP.BMP
       Spacing = 1
       Left = 158
       Top = 98
       Height = 20
       Width = 20
       NumBMPs =4
       Hint = "Avec uniquement une image"
       ShowHint = 1
       OnClick = Boutons_Click
       OnMouseMove = Boutons_MouseMove
      END CREATE
      CREATE TButton10 AS QTButton
       kind = 2
       Left = 188
       Top = 8
       NumBMPs =4
       CAPTION = "Fermer"
       Hint = "Un QTButton avec Kind = 1"
       ShowHint = 1
       OnClick = Boutons_Click
       OnMouseMove = Boutons_MouseMove
      END CREATE
      CREATE TButton11 AS QBUTTON
       kind = 2
       Left = 188
       Top = 38
       CAPTION = "Fermer"
       Hint = "Un bouton classic avec Kind = 1"
       ShowHint = 1
       OnMouseMove = QBouton_MouseMove
       OnMouseUp = QBouton_MouseUp
       OnClick = Boutons_Click
      END CREATE
      CREATE TButton12 AS QBUTTON
       Left = 188
       Top = 68
       CAPTION = "&Classique"
       Hint = "Un bouton classic"
       ShowHint = 1
       OnMouseMove = QBouton_MouseMove
       OnMouseUp = QBouton_MouseUp
       OnClick = Boutons_Click
      END CREATE
      CREATE TButton13 AS QTButton
       Left = 188
       Top = 98
       BMP = ico_BMP.BMP
        'BMPHandle = ico_BMP
       NumBMPs = 4
       CAPTION = "Bitmap"
       Hint = "Un bouton avec une image"
       ShowHint = 1
       OnClick = Boutons_Click
       OnMouseMove = Boutons_MouseMove
      END CREATE
      CREATE TButton14 AS QTButton
       Layout = 2
       Left = 188
       Top = 128
       BMP = ico_BMP.BMP
        'BMPHandle = ico_BMP
       Height = 40
       Spacing = 3
       NumBMPs = 4
       CAPTION = "Au dessus"
       Hint = "Un bouton avec une image placée au dessus du texte"
       ShowHint = 1
       OnClick = Boutons_Click
       OnMouseMove = Boutons_MouseMove
      END CREATE
      CREATE TButton15 AS QTButton
       Layout = 2
       Left = 302
       Top = 8
       Height = 20
       Width = 20
       Spacing = 3
       NumBMPs = 4
       Font.Bold = 1
       CAPTION = ">"
       Hint = "Alterner l'enjolivure"
       ShowHint = 1
       OnClick = Enjolivure_Click
       OnMouseMove = Boutons_MouseMove
      END CREATE
      CREATE TButton16 AS QTButton
       Left = 288
       Top = 48
       Width = 23
       Height = 22
       NumBMPs = 4
       GroupIndex = 1
      END CREATE
      CREATE TButton17 AS QTButton
       Left = 288
       Top = 72
       Width = 23
       Height = 22
       NumBMPs = 4
       GroupIndex = 1
      END CREATE
      CREATE TButton18 AS QTButton
       Left = 288
       Top = 96
       Width = 23
       Height = 22
       NumBMPs = 4
       GroupIndex = 1
      END CREATE
      CREATE TButton19 AS QTButton
       Left = 288
       Top = 128
       Width = 23
       Height = 22
       NumBMPs = 4
       GroupIndex = 2
      END CREATE
      CREATE TButton20 AS QTButton
       Left = 288
       Top = 152
       Width = 23
       Height = 22
       NumBMPs = 4
       GroupIndex = 2
      END CREATE
      CREATE Image AS QIMAGE
       AutoSize = 1
       Top = 128
       Left = 98
       BMP = QTBtnBMP.BMP
      END CREATE
      CREATE Label1 AS QLABEL
       Top = 158
       Left = 8
       CAPTION = "Image du bouton / Button bitmap :"
      END CREATE
      CREATE Image1 AS QIMAGE
       AutoSize = 1
       Top = 174
       Left = 8
       BMP = QTBtnBMP.BMP
      END CREATE
     END CREATE

     SUB Boutons_Click
      SHOWMESSAGE "Vous avez cliqué sur le bouton :  " +sender.CAPTION +CHR$(10)+_
       "You've clicked on button :  " +sender.CAPTION
      Image1.BMP = Sender.BMP
     END SUB
     SUB Boutons_MouseMove

    ' Now that we've insert MouseMove inside our program the internal MouseMove have been
    ' canceled, to combine the new MouseMove event with the internal one, simply add these
    ' lines; ObjectName.InheritOnMouseMove(x,y,shift)
    ' But what happen when more than one Object use the same SUB event, we need to detect
    ' which Object call the event, since if we only add ;
    ' ObjectName.InheritOnMouseMove(x,y,shift)
    ' ObjectName2.InheritOnMouseMove(x,y,shift)
    ' ObjectName2 MouseMove event will also fireup when Mouving over ObjectName to resolve
    ' this we use conditional statements; if , elseif, select case.

    ' Fireup internal mousemove event for the current object
      SELECT CASE Sender.Handle' We use Handle since Caption will not be returned when using
                             ' btns without caption
      CASE TButton.Handle: TButton.InheritOnMouseMove(x,y,shift)
      CASE TButton2.Handle: TButton2.InheritOnMouseMove(x,y,shift)
      CASE TButton3.Handle: TButton3.InheritOnMouseMove(x,y,shift)
      CASE TButton4.Handle: TButton4.InheritOnMouseMove(x,y,shift)
      CASE TButton5.Handle: TButton5.InheritOnMouseMove(x,y,shift)
      CASE TButton6.Handle: TButton6.InheritOnMouseMove(x,y,shift)
      CASE TButton7.Handle: TButton7.InheritOnMouseMove(x,y,shift)
      CASE TButton8.Handle: TButton8.InheritOnMouseMove(x,y,shift)
      CASE TButton9.Handle: TButton9.InheritOnMouseMove(x,y,shift)
      CASE TButton10.Handle: TButton10.InheritOnMouseMove(x,y,shift)
      CASE TButton13.Handle: TButton13.InheritOnMouseMove(x,y,shift)
      CASE TButton14.Handle: TButton14.InheritOnMouseMove(x,y,shift)
      CASE TButton15.Handle: TButton15.InheritOnMouseMove(x,y,shift)
      END SELECT

    ' Now our new event
      Image1.BMP = Sender.BMP
     END SUB

     SUB QBouton_MouseMove
      IF (X < 0) OR (Y < 0) OR (X > sender.Width) _
       OR (Y > Sender.Height) THEN
        ' le pseudo-evénement MOUSELEAVE
        ' the MOUSELEAVE pseudo-event
       ReleaseCapture_QTBtn
        ' dans cet example, on retourne le caption à la normal
        ' in this example revert the caption to normal
       Sender.Font.Bold = 0
       Sender.Font.COLOR = -2147483630

      ELSEIF GetCapture_QTBtn() <> Sender.Handle THEN
        ' le pseudo-evénement MOUSEENTER
        ' the MOUSEENTER pseudo-event
       SetCapture_QTBtn Sender.Handle
        ' dans cet example, on met le caption en gras
        ' in this example, make the caption bold
       Sender.Font.Bold = 1
       Sender.Font.COLOR = -2147483635
       Image1.BMP = Sender.BMP
      END IF
     END SUB

     SUB QBouton_MouseUp
      ReleaseCapture_QTBtn
      Sender.Font.Bold = 0
      Sender.Font.COLOR = -2147483630
     END SUB

     SUB Enjolivure_Click(Sender AS QTButton)
      STATIC curSkin AS INTEGER

      IF curSkin < 1 THEN
       QTBtnBMP.BMPHandle = btn_BMP1
       curSkin = 1
      ELSE
       QTBtnBMP.BMPHandle = btn_BMP
       curSkin = 0
      END IF
      TButton.ReDraw
      TButton2.ReDraw
      TButton3.ReDraw
      TButton4.ReDraw
      TButton5.ReDraw
      TButton6.ReDraw
      TButton7.ReDraw
      TButton8.ReDraw
      TButton9.ReDraw
      TButton10.ReDraw
      TButton13.ReDraw
      TButton14.ReDraw
      TButton15.ReDraw

     END SUB

     Form.SHOWMODAL
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2023-2-2  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:50:38