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 :

[VCL] Ajouter bouton dans un StatusBar


Sujet :

Composants VCL Delphi

  1. #1
    Rédacteur
    Avatar de Pedro
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    5 411
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 5 411
    Points : 8 078
    Points
    8 078
    Par défaut [VCL] Ajouter bouton dans un StatusBar
    Salut
    bon, je me résoud à vous poser cette question après maintes recherches sur le forum et dans la faq ainsi que dans l'aide Delphi:
    Je voudrais qu'un des panels de ma TStatusBar soit un bouton avec un possibilité de rester Down (un peu comme AutoCAD et la fonction Ortho et les autres pour ceux qui connaissent)...

    Merci d'avance en espèrant avoir bien cherché
    Pedro
    Aucune réponse aux sollicitations techniques par MP

    Faut pas attendre d'en avoir besoin pour s'en servir... (Lucien Stéphane)

    Les pages Source C'est bon. Mangez-en!
    Le défi Delphi
    Règles du forum - FAQ Delphi - Pensez au chtit
    Aéroclub Bastia Saint-Exupéry

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    298
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 298
    Points : 318
    Points
    318
    Par défaut
    Voila un bout de code non testé.

    Code : 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
    Author: Alex Schlecht <alex@bombus.de>
    Homepage: http://www.bombus.de
     
     
    {
    Including Components into a Statusbar
     
    The TStatusbar usually does not allow to place components on itself. But
    sometimes it would be very fine to add -for example- a TProgressBar on a
    Statusbar.
     
    This Article shows how to add components to a TStatusbar and how to fit it
    into one of the Statusbar-Panels.
     
     
    First apologize my bad english: I'm a programmer, not a translator ;-)
     
    There are (at least) two ways to add Components on your Statusbar:
     
     
    1. Create an own Statusbar-Object
    =================================
     
    Create your own Statusbar and allow to add components on it. This is
    possible in overriding the Create-Constructor:
    }
     
    type
     TMyStatusBar = class(TStatusBar)
     public
      constructor Create(AOwner: TComponent); override;
     end;
     
    implementation
     
    constructor TMyStatusBar.Create(AOwner: TComponent);
    begin
     inherited Create(AOwner);
     ControlStyle:= ControlStyle + [csAcceptsControls];
       //that's all !!
    end;
     
    {
    That's all! Now this component accept other components as "Children" and you
    can put them at design-time onto the statusbar!
     
    But I don't like this way very much because you have to use this new
    component. I prefer to use the "old" components and manipulating them a
    little bit. So lets have a look to my favourite way:
     
     
    2. "Adopt" the other component
    ==============================
     
     
    The simplest way to include components to a statusbar is to adopt the
    component! Place the TStatusbar on your Form, also place the Progressbar (or
    other component you wish to include on your Statusbar) on the form (!). Then
    do this in the "OnShow" Event of the Form:
    }
     
         Progressbar1.Parent := statusbar1;
         Progressbar1.top    := 1;
         Progressbar1.left   := 1;
     
    {
    Now the Progressbar is "adopted" by the Statusbar.
     
    But unfortunatley it doesn't look very nice because the Progressbar is
    larger than the panel and the position is not correct. So we have to
    determine the exact position of the Progresbar by using the Statubar's
    border, width and height. (We have to add this code to the "OnShow" Event of
    the form, because in the "OnCreate" event still no Handles are avalible.)
     
    }
     
    procedure TForm1.FormShow(Sender: TObject);
     var r : TRect;
    begin
     Statusbar1.perform(SB_GETRECT,0,integer( @R ));
       //determine the size of panel 1
     
      //SB_GETRECT needs Unit commctrl
      // 0 = first Panel of Statusbar; 1 = the second and so on.
     
     progressbar1.parent := Statusbar1; //adopt the Progressbar
     
     progressbar1.top := r.top; //set size of
     progressbar1.left := r.left; //Progressbar to
     progressbar1.width := r.right-r.left; //fit with panel
     progressbar1.height := r.bottom-r.top;
     
    end;
     
    {
    Now the Progressbar fits exactly into the first panel of the statusbar! If
    you want to use the second or another panel, you only have to change the
    parameter of the "perform" command.
     
     
    Comments and improvements are welcome!!
     
    Alex Schlecht
    Alex.schlecht@skw.com
    }

  3. #3
    Expert éminent
    Avatar de Lung
    Profil pro
    Analyste-programmeur
    Inscrit en
    Mai 2002
    Messages
    2 664
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Analyste-programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 664
    Points : 6 967
    Points
    6 967
    Par défaut
    Moi, je fais ca pour ajouter une ProgressBar :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
       StatusBar.ControlStyle := StatusBar.ControlStyle + [csAcceptsControls];
       ProgressBar.Parent := StatusBar;
       ProgressBar.SetBounds(430, 2, 320, 16);
       ProgressBar.Position := 0;
       ProgressBar.Visible := False;
       PostMessage(ProgressBar.Handle, $0409, 0, clNavy);   //.Couleur de la barre de progression.
       ProgressBar.BringToFront;
    L'urgent est fait, l'impossible est en cours, pour les miracles prévoir un délai. ___ Écrivez dans un français correct !!

    C++Builder 5 - Delphi 6#2 Entreprise - Delphi 2007 Entreprise - Delphi 2010 Architecte - Delphi XE Entreprise - Delphi XE7 Entreprise - Delphi 10 Entreprise - Delphi 10.3.2 Entreprise - Delphi 10.4.2 Entreprise - Delphi 11.1 Entreprise
    OpenGL 2.1 - Oracle 10g - Paradox - Interbase (XE) - PostgreSQL (15.4)

  4. #4
    Rédacteur
    Avatar de Pedro
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    5 411
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 5 411
    Points : 8 078
    Points
    8 078
    Par défaut
    Merci les gars ça devrait me convenir
    Pedro
    Aucune réponse aux sollicitations techniques par MP

    Faut pas attendre d'en avoir besoin pour s'en servir... (Lucien Stéphane)

    Les pages Source C'est bon. Mangez-en!
    Le défi Delphi
    Règles du forum - FAQ Delphi - Pensez au chtit
    Aéroclub Bastia Saint-Exupéry

  5. #5
    Rédacteur
    Avatar de Pedro
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    5 411
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 5 411
    Points : 8 078
    Points
    8 078
    Par défaut
    Citation Envoyé par cpdump
    Voila un bout de code non testé.
    Testé et approuvé. Merci
    Pedro
    Aucune réponse aux sollicitations techniques par MP

    Faut pas attendre d'en avoir besoin pour s'en servir... (Lucien Stéphane)

    Les pages Source C'est bon. Mangez-en!
    Le défi Delphi
    Règles du forum - FAQ Delphi - Pensez au chtit
    Aéroclub Bastia Saint-Exupéry

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. problème ajout bouton dans toolbar
    Par ArnSpin dans le forum GTK+ avec C & C++
    Réponses: 2
    Dernier message: 24/08/2010, 14h27
  2. [WD15] Ajouter Bouton dans une Table
    Par buzz68180 dans le forum WinDev
    Réponses: 4
    Dernier message: 11/03/2010, 20h50
  3. [XL-2007] Ajout Bouton dans barre d accès rapide
    Par Duddy dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 03/01/2010, 11h30
  4. [VB2005]Ajouter boutons dans barre d'outils par code
    Par cd090580 dans le forum Windows Forms
    Réponses: 4
    Dernier message: 14/09/2007, 18h57

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