IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Composants VCL Delphi Discussion :

Image d'un bouton qui se retaille


Sujet :

Composants VCL Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2003
    Messages
    356
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2003
    Messages : 356
    Par défaut Image d'un bouton qui se retaille
    bonjour,

    existe t-il un bouton dans la vcl standard ou JVCL , ou l'image a une propriété genre "stretch", pour qu'elle se retaille suivant la taille du bouton ?
    j'ai parcouru mais rien vu.

    cdmt

    exyacc

  2. #2
    Expert éminent
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    14 093
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 14 093
    Par défaut
    Non par en VCL Standard, même avec le ScaleBy où cela permet de faire un Zoom comme Vista le propose (100%, 125%, 150%) mais on peut ajouter du coup des zoom maison (pour le moment, j'ai ajouté 175% et 200%)
    Et l'icone des boutons restent petit !

    En JVCL, je l'ignore

    La seule fois, où j'ai fait un truc de ce genre,
    c'était pour un écran d'accueil d'une application en BCB2007
    je changerais l'ImageList manuellement

    J'avais donc une ImageList en 16x16, 32x32 et 64x64
    Je remplaçais l'image du bouton par celle de l'imagelist correspond à la taille en cours

    Mais c'est maintenant inclus dans Utilisation de bitmaps multi-résolution FMX et Editeur MultiResBitmap



    Voici le code brouillon
    Je faisais un test comparatif entre le TSpeedButton et le TdxfColorButton (tout pourri, Anchors et un tas de propriétés publiques n'étaient pas publiées)

    Code c++ : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
      SetWindowLong(PanelCarroussel->Handle, GWL_STYLE,
        GetWindowLong(PanelCarroussel->Handle, GWL_STYLE) | WS_SIZEBOX);
      PanelCarrousselOldWindowProc = PanelCarroussel->WindowProc;
      PanelCarroussel->WindowProc = PanelCarrousselNewWindowProc;
      PanelCarroussel->DoubleBuffered = true;
      CheckBoxPanelCarrousselSelectionDoubleBuffered->Checked = true;
      PanelCarroussel->Width += 1; // C'est le seul truc efficace pour que WS_SIZEBOX soit pris en compte, Invalidate, SetWindowPos, rien ne passe à part cette bidouille

    Code c++ : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
     
    void __fastcall TVCLManipForm::PanelCarrousselNewWindowProc(Messages::TMessage &Message)
    {
      if (Message.Msg != WM_ERASEBKGND || ! PanelCarroussel->DoubleBuffered)
        PanelCarrousselOldWindowProc(Message);
    }
     
    //---------------------------------------------------------------------------
    void __fastcall TVCLManipForm::PanelCarrousselResize(TObject *Sender)
    {
      if ((PanelCarroussel->Height > 400) && (PanelCarroussel->Width > 600))
      {
        if ((PanelCarroussel->Height > 600) && (PanelCarroussel->Width > 800))
        {
          if (PanelCarroussel->Tag != 64)
          {
            for (int i = 0; i < PanelCarroussel->ControlCount; i++)
            {
              TControl *Ctrl =  PanelCarroussel->Controls[i];
              if (Ctrl->InheritsFrom(__classid(TSpeedButton)))
              {
                TSpeedButton *Btn = (TSpeedButton*)Ctrl;
     
                Btn->Height = 64 + 16;
                Btn->Width = 64 + 16;
     
                if (Btn->Tag > 0)
                {
                  Graphics::TBitmap *Bm = new Graphics::TBitmap();
                  try
                  {
                    ImageListCarroussel64->GetBitmap(Btn->Tag - 1, Bm);
                    Btn->Glyph = Bm;
                  }
                  __finally
                  {
                    delete Bm;
                  }
                }
              }
     
              if (Ctrl->InheritsFrom(__classid(TdxfColorButton)) && CheckBoxCarrousselColorButtonResize->Checked)
              {
                TdxfColorButton *Btn = (TdxfColorButton*)Ctrl;
     
                Btn->Height = 80 + 16;
                Btn->Width = 200 + 16;
              }
            }
            PanelCarroussel->Tag = 64;
          }
        }
        else
        {
          if (PanelCarroussel->Tag != 32)
          {
            for (int i = 0; i < PanelCarroussel->ControlCount; i++)
            {
              TControl *Ctrl =  PanelCarroussel->Controls[i];
              if (Ctrl->InheritsFrom(__classid(TSpeedButton)))
              {
                TSpeedButton *Btn = (TSpeedButton*)Ctrl;
     
                Btn->Height = 32 + 16;
                Btn->Width = 32 + 16;
     
                if (Btn->Tag > 0)
                {
                  Graphics::TBitmap *Bm = new Graphics::TBitmap();
                  try
                  {
                    ImageListCarroussel32->GetBitmap(Btn->Tag - 1, Bm);
                    Btn->Glyph = Bm;
                  }
                  __finally
                  {
                    delete Bm;
                  }
                }
              }
              if (Ctrl->InheritsFrom(__classid(TdxfColorButton)) && CheckBoxCarrousselColorButtonResize->Checked)
              {
                TdxfColorButton *Btn = (TdxfColorButton*)Ctrl;
     
                Btn->Height = 60 + 16;
                Btn->Width = 150 + 16;
              }
            }
            PanelCarroussel->Tag = 32;
          }
        }
      }
      else
      {
        if (PanelCarroussel->Tag != 16)
        {
          for (int i = 0; i < PanelCarroussel->ControlCount; i++)
          {
            TControl *Ctrl =  PanelCarroussel->Controls[i];
            if (Ctrl->InheritsFrom(__classid(TSpeedButton)))
            {
              TSpeedButton *Btn = (TSpeedButton*)Ctrl;
     
              Btn->Height = 16 + 16;
              Btn->Width = 16 + 16;
     
              if (Btn->Tag > 0)
              {
     
                Graphics::TBitmap *Bm = new Graphics::TBitmap();
                try
                {
                  ImageListCarroussel16->GetBitmap(Btn->Tag - 1, Bm);
                  Btn->Glyph = Bm;
                }
                __finally
                {
                  delete Bm;
                }
              }
            }
            if (Ctrl->InheritsFrom(__classid(TdxfColorButton)) && CheckBoxCarrousselColorButtonResize->Checked)
            {
              TdxfColorButton *Btn = (TdxfColorButton*)Ctrl;
     
              Btn->Height = 40 + 16;
              Btn->Width = 100 + 16;
            }
          }
        }
        PanelCarroussel->Tag = 16;
      }
    }

    Code dfm : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
     
      object PanelCarroussel: TPanel
        Left = 0
        Top = 0
        Width = 500
        Height = 288
        Constraints.MinHeight = 32
        Constraints.MinWidth = 32
        TabOrder = 0
        OnResize = PanelCarrousselResize
        DesignSize = (
          500
          288)
        object ImageCarroussel: TImage
          Left = 1
          Top = 1
          Width = 498
          Height = 286
          Align = alClient
          Center = True
          IncrementalDisplay = True
          Proportional = True
          Stretch = True
          OnDblClick = ImageCarrousselDblClick
          ExplicitLeft = 39
          ExplicitTop = 0
        end
        object SpeedButtonCarroussel1: TSpeedButton
          Tag = 1
          Left = 229
          Top = 11
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 328
          ExplicitTop = 29
        end
        object SpeedButtonCarroussel2: TSpeedButton
          Tag = 2
          Left = 277
          Top = 20
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 395
          ExplicitTop = 45
        end
        object SpeedButtonCarroussel3: TSpeedButton
          Tag = 3
          Left = 338
          Top = 25
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
        end
        object SpeedButtonCarroussel4: TSpeedButton
          Tag = 1
          Left = 376
          Top = 41
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 534
          ExplicitTop = 81
        end
        object SpeedButtonCarroussel5: TSpeedButton
          Tag = 2
          Left = 415
          Top = 73
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 588
          ExplicitTop = 136
        end
        object SpeedButtonCarroussel6: TSpeedButton
          Tag = 3
          Left = 437
          Top = 121
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 619
          ExplicitTop = 217
        end
        object SpeedButtonCarroussel7: TSpeedButton
          Tag = 1
          Left = 432
          Top = 163
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
        end
        object SpeedButtonCarroussel8: TSpeedButton
          Tag = 2
          Left = 394
          Top = 201
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 558
          ExplicitTop = 354
        end
        object SpeedButtonCarroussel9: TSpeedButton
          Tag = 3
          Left = 341
          Top = 228
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 485
          ExplicitTop = 401
        end
        object SpeedButtonCarroussel10: TSpeedButton
          Tag = 1
          Left = 277
          Top = 236
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 395
          ExplicitTop = 414
        end
        object SpeedButtonCarroussel11: TSpeedButton
          Tag = 2
          Left = 229
          Top = 242
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 328
          ExplicitTop = 425
        end
        object SpeedButtonCarroussel12: TSpeedButton
          Tag = 3
          Left = 173
          Top = 242
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
        end
        object SpeedButtonCarroussel13: TSpeedButton
          Tag = 1
          Left = 128
          Top = 228
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 185
          ExplicitTop = 401
        end
        object SpeedButtonCarroussel14: TSpeedButton
          Tag = 2
          Left = 66
          Top = 201
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 100
          ExplicitTop = 354
        end
        object SpeedButtonCarroussel15: TSpeedButton
          Tag = 3
          Left = 39
          Top = 163
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
        end
        object SpeedButtonCarroussel16: TSpeedButton
          Tag = 3
          Left = 30
          Top = 121
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 48
          ExplicitTop = 217
        end
        object SpeedButtonCarroussel17: TSpeedButton
          Tag = 1
          Left = 56
          Top = 73
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 85
          ExplicitTop = 136
        end
        object SpeedButtonCarroussel18: TSpeedButton
          Tag = 2
          Left = 86
          Top = 41
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 126
          ExplicitTop = 81
        end
        object SpeedButtonCarroussel19: TSpeedButton
          Tag = 3
          Left = 128
          Top = 25
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 185
          ExplicitTop = 55
        end
        object SpeedButtonCarroussel20: TSpeedButton
          Tag = 1
          Left = 173
          Top = 11
          Width = 32
          Height = 32
          Anchors = []
          Flat = False
          ExplicitLeft = 249
          ExplicitTop = 29
        end
        object CheckBoxCarrousselColorButtonResize: TCheckBox
          Left = 11
          Top = 11
          Width = 97
          Height = 17
          Caption = 'Color Resize'
          TabOrder = 5
        end
        object PanelCarrousselSelection: TPanel
          Left = 39
          Top = 34
          Width = 71
          Height = 86
          TabOrder = 6
          OnMouseDown = PanelCarrousselSelectionMouseDown
          object ShapeCarrousselSelection: TShape
            Left = 1
            Top = 1
            Width = 69
            Height = 84
            Align = alClient
            Brush.Style = bsClear
            Pen.Style = psDot
            OnMouseDown = ShapeTransparentPanelSelectorMouseDown
            ExplicitLeft = 31
            ExplicitTop = 27
            ExplicitWidth = 65
            ExplicitHeight = 65
          end
        end
        object CheckBoxPanelCarrousselSelectionDoubleBuffered: TCheckBox
          Left = 12
          Top = 34
          Width = 97
          Height = 17
          Caption = 'DoubleBuffered'
          TabOrder = 7
          OnClick = CheckBoxPanelCarrousselSelectionDoubleBufferedClick
        end
      end
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2003
    Messages
    356
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2003
    Messages : 356
    Par défaut
    en fait j'ai fait une applic pour remplacer un bouton d'une application externe qui marche pas, donc je cherche les coordonnées et la taille du bouton a remplacer avec son handle, et ma form se "pose" dessus avec juste un bouton dedans. mais suivant la resolution de l'ecran, le bouton et plus ou moins petit, et par exemple sur un portable, il manque qd meme un gros bout de l'image...., soit je mets un dessin plus petit d'emblé ou alors je le retaille ...

Discussions similaires

  1. Image d'un slideshow qui influence un bouton
    Par Geinoch dans le forum Général JavaScript
    Réponses: 15
    Dernier message: 27/11/2012, 00h24
  2. [XAML] Bouton qui change d'image dans OnMouseOver
    Par Nixeus dans le forum Windows Presentation Foundation
    Réponses: 3
    Dernier message: 28/01/2011, 22h14
  3. Bouton qui change d'image en survolant
    Par Madmata dans le forum Mise en page CSS
    Réponses: 3
    Dernier message: 06/12/2010, 10h04
  4. Image de bouton qui s'affiche pas
    Par LaDeveloppeuse dans le forum Visual Studio
    Réponses: 0
    Dernier message: 30/07/2008, 21h15

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo