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

Contribuez Discussion :

récupérer style button checkbox Xp


Sujet :

Contribuez

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre émérite
    Avatar de Montor
    Homme Profil pro
    Autre
    Inscrit en
    Avril 2008
    Messages
    879
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Autre

    Informations professionnelles :
    Activité : Autre

    Informations forums :
    Inscription : Avril 2008
    Messages : 879
    Par défaut récupérer style button checkbox Xp
    récupérer les thèmes utiliser par le système sur la fiche
    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
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
     
    Option Explicit
     
    Private Declare Function OpenThemeData Lib "UxTheme.dll" (ByVal Hwnd As Long, ByVal LPCWSTR As Any) As Long
    Private Declare Function CloseThemeData Lib "UxTheme.dll" (ByVal hTheme As Long) As Long
     
    Private Type Rect
      Left   As Long
      Top    As Long
      Right  As Long
      Bottom As Long
    End Type
     
    Private hdc As Long
     
    Private Declare Function DrawThemeBackground Lib "UxTheme.dll" (ByVal hTheme As Long, _
             ByVal hdc As Long, ByVal iPartId As Long, _
             ByVal iStateId As Long, _
             ByRef pRect As Rect, _
             ByVal pClipRect As Long) As Long
     
     
    Private Declare Function ReleaseDC Lib "user32" (ByVal Hwnd As Long, ByVal hdc As Long) As Long
    Private Declare Function GetDC Lib "user32" (ByVal Hwnd As Long) As Long
    Private Declare Function FindWindowA Lib "user32" _
            (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
     
    Private Function bounds(L As Long, T As Long, W As Long, H As Long) As Rect
      bounds.Left = L
      bounds.Top = T
      bounds.Right = L + W
      bounds.Bottom = T + H
    End Function
     
    Private Sub DrawTheme(T As Long, S As Long, B As Rect, St As String)
     Dim H As Long
     
     H = OpenThemeData(0, StrPtr(St))
     DrawThemeBackground H, hdc, T, S, B, 0
     CloseThemeData (H)
    End Sub
    Public Sub CommandButton1_Click()
    Dim Hwnd As Long
     
    Hwnd = FindWindowA(vbNullString, Me.Caption)
    hdc = GetDC(Hwnd)
     
     
    'Button
      'Normal
      DrawTheme 1, 1, bounds(80 * 0, 10, 70, 30), "button"
      'Hot
      DrawTheme 1, 2, bounds(80 * 1, 10, 70, 30), "button"
      'Pushed
      DrawTheme 1, 3, bounds(80 * 2, 10, 70, 30), "button"
      'Disabled
      DrawTheme 1, 4, bounds(80 * 3, 10, 70, 30), "button"
      'Fucused
      DrawTheme 1, 5, bounds(80 * 4, 10, 70, 30), "button"
     
    'OptionButton
      'Normal
      DrawTheme 2, 1, bounds(80 * 0, 50, 70, 30), "button"
      'Hot
      DrawTheme 2, 2, bounds(80 * 1, 50, 70, 30), "button"
      'Pushed
      DrawTheme 2, 3, bounds(80 * 2, 50, 70, 30), "button"
      'Disabled
      DrawTheme 2, 4, bounds(80 * 3, 50, 70, 30), "button"
      'Fucused
      DrawTheme 2, 5, bounds(80 * 4, 50, 70, 30), "button"
     
    'CheckButton
      'Normal
      DrawTheme 3, 1, bounds(80 * 0, 70, 70, 30), "button"
      'Hot
      DrawTheme 3, 2, bounds(80 * 1, 70, 70, 30), "button"
      'Pushed
      DrawTheme 3, 3, bounds(80 * 2, 70, 70, 30), "button"
      'Disabled
      DrawTheme 3, 4, bounds(80 * 3, 70, 70, 30), "button"
      'Fucused
      DrawTheme 2, 5, bounds(80 * 4, 70, 70, 30), "button"
     
      'spin
      'Normal
      DrawTheme 1, 1, bounds(80 * 0, 100, 20, 20), "spin"
      'Hot
      DrawTheme 1, 2, bounds(80 * 1, 100, 20, 20), "spin"
      'Pushed
      DrawTheme 1, 3, bounds(80 * 2, 100, 20, 20), "spin"
      'Disabled
      DrawTheme 1, 4, bounds(80 * 3, 100, 20, 20), "spin"
      'Fucused
      DrawTheme 1, 5, bounds(80 * 4, 100, 20, 20), "spin"
     
      'spin
      'Normal
      DrawTheme 2, 1, bounds(80 * 0, 130, 20, 20), "spin"
      'Hot
      DrawTheme 2, 2, bounds(80 * 1, 130, 20, 20), "spin"
      'Pushed
      DrawTheme 2, 3, bounds(80 * 2, 130, 20, 20), "spin"
      'Disabled
      DrawTheme 2, 4, bounds(80 * 3, 130, 20, 20), "spin"
      'Fucused
      DrawTheme 2, 5, bounds(80 * 4, 130, 20, 20), "spin"
     
      'progressbar
      'Normal
      DrawTheme 1, 0, bounds(80 * 0, 160, 150, 20), "progress"
      DrawTheme 3, 0, bounds(80 * 2, 160, 150, 20), "progress"
      'Vertical
      DrawTheme 4, 0, bounds(80 * 0, 200, 20, 100), "progress"
      DrawTheme 5, 0, bounds(80 * 2, 200, 20, 100), "progress"
     
      '...
       ReleaseDC Hwnd, hdc
    End Sub

  2. #2
    Invité
    Invité(e)
    Par défaut
    Bonjour

    C'est bien joli de mettre un bout de code, mais il faut penser à tous entre autre :

    Comment l'utiliser.
    Donner un petit exemple qui permet de voir l'effet (copie d'écran ou petit fichier).

    Philippe

  3. #3
    Membre émérite
    Avatar de Montor
    Homme Profil pro
    Autre
    Inscrit en
    Avril 2008
    Messages
    879
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Autre

    Informations professionnelles :
    Activité : Autre

    Informations forums :
    Inscription : Avril 2008
    Messages : 879
    Par défaut
    Bonjour
    Pour tester le code insérer un UserFom et ajouter un Button sur la fiche...
    et bien sur copier le code

  4. #4
    Invité
    Invité(e)
    Par défaut
    Bonjour

    Excuses-moi, c'est joli sur l'UserForm, mais en pratique comment utiliser ces thèmes sur les contrôles ?


    Philippe

  5. #5
    Membre émérite
    Avatar de Montor
    Homme Profil pro
    Autre
    Inscrit en
    Avril 2008
    Messages
    879
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Autre

    Informations professionnelles :
    Activité : Autre

    Informations forums :
    Inscription : Avril 2008
    Messages : 879
    Par défaut
    Excuses-moi, c'est joli sur l'UserForm, mais en pratique comment utiliser ces thèmes sur les contrôles ?
    Bonjour
    Il est difficile pour créer des contrôles ...La limitation imposée par Vb qui n'accepte pas héritage des contrôles...seul moyen que jai essaye c'est de surcharger la WinProc de l'UserForm est gérer les messages WM_Paint,WM_Size... mais ceci peut poser des problème avec l'Excel...la seul chose restante c'est de créer une zone sur la fiche et la considérer comme contrôle

Discussions similaires

  1. Récupérer Style Caractere de Word avec Perl
    Par fafaperl dans le forum Modules
    Réponses: 0
    Dernier message: 25/02/2009, 22h37
  2. Récupérer un tableau checkbox en javacript
    Par persia dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 27/10/2008, 16h32
  3. possible de donner un style à une checkBox?
    Par guns17 dans le forum Mise en page CSS
    Réponses: 6
    Dernier message: 29/11/2007, 08h17
  4. Récupérer les valeurs checkbox
    Par pitxu dans le forum Langage
    Réponses: 15
    Dernier message: 19/09/2007, 15h04

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