Les Snippets

Connexion

Supprimer la bordure d'un contrôle

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 27/01/2007 19:05:29 et initié par Charles Racaud [Liste]
Vue : 11146
Catégorie(s) : API, Trucs & Astuces
Langages dispo pour ce code :
- VB6
- C# 1.x, C# 2.x
- VB 2005, VB.NET 1.x
- HTML



Langage : VB6
Date ajout : 27/01/2007
Posté par Charles Racaud [Liste]
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As LongByVal Y1 As LongByVal X2 As LongByVal Y2 As LongAs Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal HWnd As LongByVal hRgn As LongByVal bRedraw As BooleanAs Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As LongAs Long
Private Declare Function GetWindowRect Lib "user32" (ByVal HWnd As Long, lpRect As Rectangle) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal HWnd As Long, lpPoint As Point) As Long
Private Type Point
  X As Long
  Y As Long
End Type
Private Type Rectangle
  Left As Long
  Top As Long
  Right As Long
  Bottom As Long
End Type
Private Sub RemoveControlBorder(HWnd As LongOptional BorderSize As Long = 3)
  Dim Rgn As Long
  Dim Rect As Rectangle
  Call GetWindowRect(HWnd, Rect)
  Dim Size As Point
  Size.X = Rect.Right
  Size.Y = Rect.Bottom
  Call ScreenToClient(HWnd, Size)
  Rgn = CreateRectRgn(BorderSize, BorderSize, Size.X - BorderSize, Size.Y - BorderSize)
  Call SetWindowRgn(HWnd, Rgn, True)
  Call DeleteObject(Rgn)
End Sub
Private Sub Form_Load()
  ' On supprime la bordure du control en passant son hWnd
  Call RemoveControlBorder(Command1.HWnd)
  Call RemoveControlBorder(List1.HWnd)
End Sub
Remarque :
Le ScaleMode doit être en Pixel
Langage : C# 1.x , C# 2.x
Date ajout : 27/01/2007
Posté par Charles Racaud [Liste]

[System.Runtime.InteropServices.DllImport("gdi32.dll")]
private static extern IntPtr CreateRectRgn(int X1, int Y1, int X2, int Y2); 
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr SetWindowRgn(IntPtr hwnd, IntPtr hRgn, bool bRedraw); 
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
private static extern IntPtr DeleteObject(IntPtr hObject); 
private static void RemoveControlBorder(System.Windows.Forms.Control Ctrl, int BorderSize) { 
  IntPtr Rgn = CreateRectRgn(BorderSize, BorderSize, Ctrl.Width - BorderSize, Ctrl.Height - BorderSize);  SetWindowRgn(Ctrl.Handle, Rgn, 
true); 
  DeleteObject(Rgn);

}

private void Form1_Load(object sender, EventArgs e) { 
  RemoveControlBorder(this.button1, 3);
}


Langage : VB.NET 1.x , VB 2005
Date ajout : 27/01/2007
Posté par Charles Racaud [Liste]

Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As IntegerByVal Y1 As IntegerByVal X2 As IntegerByVal Y2 As IntegerAs IntPtr
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As IntPtr, ByVal hRgn As IntPtr, ByVal bRedraw As BooleanAs IntPtr
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As IntPtr) As IntPtr
Private Sub RemoveControlBorder(ByVal Ctrl As System.Windows.Forms.Control, Optional ByVal BorderSize As Integer = 3)
  Dim Rgn As IntPtr = CreateRectRgn(BorderSize, BorderSize, Ctrl.Width - BorderSize, Ctrl.Height - BorderSize)
  Call SetWindowRgn(Ctrl.Handle, Rgn, True)
  Call DeleteObject(Rgn)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  RemoveControlBorder(Me.Button1)
End Sub

Langage : HTML
Date ajout : 06/04/2007
Posté par stfou [Liste]
border=0

OU
style="border:0"
Remarque :
Se rajoute comme attribut dans une balise.

Snippets en rapport avec : Supprimer, Contrôle, Bordure, Border



Codes sources en rapport avec : Supprimer, Contrôle, Bordure, Border

{PHP} TESTEUR DE REGEX
Dans le cadre des champs de formulaire, on contrôle la validité de l'entrée par une regex. Sauf q...

{Delphi} AUTO-COMPLÉTION D'UN CONTRÔLE DE SAISIE
Bonjour, alors voilà, j'avais besoin d'une auto-complétion d'un TEdit en prenant en compte le systè...

{Visual Basic, VB6, VB.NET, VB 2005} CONTRÔLE MARQUEE POUR TEXTE DÉFILANT
Il s'agit d'un contrôle construit sous VB6 comportant diverses possibilités:Défilement d'un texte(to...

{IRC} ......................
.......................................................................................................

{IRC} [DLL] AJOUT D'UN CONTRÔLE RICHEDIT SCINTILLA SUR LES DIALOGBOX MIRC
Bonjour, Ne sachant pas trop quoi faire pour ma première DLL, je me suis dit qu'il pouvait être bon...

{Visual Basic, VB6, VB.NET, VB 2005} REGMANIPULATION
C'est un petit utilitaire servant à restaurer les modifications de quelques clés de registre que cer...

{PHP} CLASS DE CONTRÔLE DE FORMULAIRE
Une petite classe de contrôle de formulaire pour continuer mon apprentissage de la POO, simple et ra...

{Delphi} BAKTPACK (PACK DE COMPOSANTS BACTERIUS)
Bonsoir ! Voici mon pack de composants ! Voici une description de tous ces composants : - Bac...

{Visual Basic, VB6, VB.NET, VB 2005} CONTRÔLE SIMPLE POUR CODE POSTAUX
C'est un contrôle qui hérite de Textbox pour recevoir un code postal. Les codes postaux validés s...

{Flash} CONTRÔLER SES ANIMATIONS
Allez, je continue dans ma lancée et je post une autre source ^^ En fouillant dans mes tiroirs je...