Les Snippets

Connexion

Ajouter l'icone UAC sur vos boutton

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 29/09/2009 20:42:20 et initié par Willi [Liste]
Vue : 1947
Catégorie(s) : Trucs & Astuces, Système, Control
Langages dispo pour ce code :
- C# 2.x, C# 3.x
- VB 2005, VB 2008
- Delphi 5



Langage : C# 2.x , C# 3.x
Date ajout : 29/09/2009
Posté par Willi [Liste]

public static void UAC_EnableElevateIcon(System.Windows.Forms.Button button)
{
    const uint BCM_SETSHIELD = 0x0000160C;
    if (button == null)
        return;
    button.Image = null;
    button.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    button.FlatStyle = System.Windows.Forms.FlatStyle.System;
    // Send the BCM_SETSHIELD message to the button control
    SendMessage(new HandleRef(button, button.Handle),
        BCM_SETSHIELD, IntPtr.Zero, new IntPtr(1));
}
Remarque :
Ce snippet appel la fonction SendMessage, voici sa déclaration:

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
Langage : VB 2005 , VB 2008
Date ajout : 12/10/2009
Posté par Willi [Liste]
Public Shared Sub UAC_EnableElevateIcon(ByVal button As System.Windows.Forms.Button) 

  Const  BCM_SETSHIELD As UInteger = 5644 
  If button Is Nothing Then 
    Return 
  End If 
  button.Image = Nothing 
  button.TextAlign = System.Drawing.ContentAlignment.MiddleCenter 
  button.FlatStyle = System.Windows.Forms.FlatStyle.System 
  ' Send the BCM_SETSHIELD message to the button control 
  SendMessage(New HandleRef(button, button.Handle), BCM_SETSHIELD, IntPtr.Zero, New IntPtr(1)) 
End Sub

Remarque :
'Ce snippet appel la fonction SendMessage, voici sa déclaration:

_
Shared Function SendMessage(ByVal hWnd As HandleRef, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function
Langage : Delphi 5
Date ajout : 28/11/2009
Posté par Bacterius [Liste]

const
 { Constante à envoyer au bouton pour afficher l'icône }
 BCM_SETSHIELD = 5644;
function SetUACShield(Button: TButton; pSet: Boolean): Boolean;
begin
 { Si le bouton existe, on lui envoie le message BCM_SETSHIELD avec comme lParam 0 pour retirer l'icône et 1 pour l'afficher }
 if Assigned(Button) then Result := (SendMessage(Button.Handle, BCM_SETSHIELD, 0, Integer(pSet)) = 1);
end;


Remarque :
- Passez pSet = True pour afficher l'icône, pSet= False sinon.
- La fonction renvoie True si tout s'est bien passé, False sinon.
- Les thèmes Vista doivent être activés et votre application doit disposer d'un manifeste de thème valide.

Snippets en rapport avec : Icon, Uac, Elevation, Button



Codes sources en rapport avec : Icon, Uac, Elevation, Button

{Graphisme} CUSTOMISATION DE BUTTON TAGS AUTOMATIQUE
Une base de travail pour mettre en forme des balises BUTTON automatiquement. L'intérêt est que pour...

{Delphi} TRAYICON - VOTRE ICONE DANS LA BARRE DES TACHES
Bonjour ! Vous connaissez sûrement tous le CoolTrayIcon, un bon composant (quoique un peu lourdingu...

{C / C++ / C++.NET} PACMAN_DESKTOP
Voici un petit programme qui crée une icone sur le bureau en forme de pacman et qui cherche à manger...

{Javascript / DHTML} INTERFACE.BUTTON - 2ÈME ÉLÉMENT DE LA LIBRAIRIE INTERFACE.
voici Interafce.Button, toujours basé sur kernel.js je m'attarde pas à vous expliquer en détail , c...

{Delphi} UAC (USER ACCOUNT CONTROL) - EXÉCUTER UNE APPLICATION EN TANT QU'ADMINISTRATEUR SOUS WINDOWS VISTA
L'UAC (User Account Control) est une protection inhérente à Windows Vista, permettant de protéger le...

{ASP / ASP.NET} AJOUTER UNE IMAGE À UN BOUTON
J'ai lu pas mal de post concernant des personnes désireuses d'utiliser les boutons mais en leur ajou...

{Visual Basic, VB6, VB.NET, VB 2005} EXTRAIRE TOUS LES ICONES D'UN ÉXÉCUTABLE OU D'UNE DLL
un simple projet contenant deux classes pour l'extraction d'icones code original en C# http:/...

{Visual Basic, VB6, VB.NET, VB 2005} COOL CAPTURE BMP TO ICO
Juste pour s’amuser. Mais peut être utile ! Une form transparente qui capture l’image se trouvant d...

{C# / C#.NET} THREAD, COMPOSANTS DYNAMIQUES, ASTUCES DE WINFORM
C'est un petit Soft qui permet d'obtenir un effet d'alpha sur des boutons. J'ai utiliser des thread ...

{ASP / ASP.NET} CRÉATION D'UN GRIDVIEW DANS UN REPEATER
Bonjour, L'exemple suivant à pour but de répondre (de façon simple) à deux questions qui ressorte...