Hack Forums
[.NET] [ Clean ][ Ekin0x_ Buttons ][ For Clean GUI ] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] [ Clean ][ Ekin0x_ Buttons ][ For Clean GUI ] (/showthread.php?tid=2717959)

Pages: Pages 1 2


[ Clean ][ Ekin0x_ Buttons ][ For Clean GUI ] - Ekin0x_ - Jul 27, 2012

[Image: YZQ82.png]
[Image: 7ADlq.png]
[Image: Y4xG8.png]
[Image: eBYgi.png]
[Image: JYKxH.gif]
[Image: GcvK1.png]

Send me a PM and i send a Link !



* - Jeff. - Jul 27, 2012

Could you please send me a link. I would like to test out your buttons and maybe for the future use in one of my applications :].

A very good job done btw ! Thanks in advance for the share.


* - RichPrince100 - Jul 27, 2012

Id like this thanks :)
Message to short


* - Learnax - Jul 27, 2012

Looks really good :) i wouldn't mind testing these on just a play-around project @OP!


* - Ekin0x_ - Jul 27, 2012

i create a .gif for the demonstration of buttons "input" .


* - sh@rp - Jul 27, 2012

This control already exists in the "VistaControls" Library (http://windowsformsaero.codeplex.com/). It's called "CommandLink Button" :

[img]http://imabox.fr/u19/1227071617WcAHv921.png[/img]

Code
Imports System.ComponentModel
Imports System.Runtime.InteropServices

<ToolboxBitmap(GetType(Button))> _
Public Class CommandLink
    Inherits Button

    Public Sub New()
  MyBase.FlatStyle = FlatStyle.System
    End Sub

    Private _icon As Icon
    Private _image As Bitmap
    Private _note As String = String.Empty
    Private _showshield As Boolean
    Private _useicon As Boolean = True

    <DllImport("user32.dll", CharSet:=CharSet.Auto)> _
    Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
    End Function

    <Description("Refreshes the image displayed on the button.")> _
    Public Sub SetImage()
  Dim zero As IntPtr = IntPtr.Zero
  If Not Me._useicon Then
    If (Not Me._image Is Nothing) Then
    zero = Me._image.GetHicon
    End If
  ElseIf (Not Me._icon Is Nothing) Then
    zero = Me.Icon.Handle
  End If
  CommandLink.SendMessage(MyBase.Handle, NativeMethods.BM_SETIMAGE, 1, CInt(zero))
    End Sub

    <Description("Sets the note displayed on the button.")> _
    Private Sub SetNote(ByVal NoteText As String)
  NativeMethods.SendMessage(MyBase.Handle, NativeMethods.BCM_SETNOTE, IntPtr.Zero, NoteText)
    End Sub

    Public Sub SetShield(ByVal Value As Boolean)
  NativeMethods.SendMessage(MyBase.Handle, NativeMethods.BCM_SETSHIELD, IntPtr.Zero, New IntPtr(If(Me._showshield, 1, 0)))
    End Sub

    Protected Overrides ReadOnly Property CreateParams As CreateParams
  Get
    Dim createParam As CreateParams = MyBase.CreateParams
    createParam.Style = (createParam.Style Or 14)
    Return createParam
  End Get
    End Property

    <Category("Appearance"), Description("Gets or sets the icon that is displayed on a button control."), DefaultValue(CStr(Nothing))> _
    Public Property Icon As Icon
  Get
    Return Me._icon
  End Get
  Set(ByVal value As Icon)
    Me._icon = value
    If (Not Me._icon Is Nothing) Then
    Me._useicon = True
    End If
    Me.SetShield(False)
    Me.SetImage()
  End Set
    End Property

    <Category("Appearance"), Description("Gets or sets the image that is displayed on a button control."), DefaultValue(CStr(Nothing))> _
    Public Overloads Property Image As Bitmap
  Get
    Return Me._image
  End Get
  Set(ByVal value As Bitmap)
    Me._image = value
    If (Not value Is Nothing) Then
    Me._useicon = False
    Me.Icon = Nothing
    End If
    Me.SetShield(False)
    Me.SetImage()
  End Set
    End Property

    <Description("Gets or sets the note that is displayed on a button control."), Category("Appearance"), DefaultValue("")> _
    Public Property Note As String
  Get
    Return Me._note
  End Get
  Set(ByVal value As String)
    Me._note = value
    Me.SetNote(Me._note)
  End Set
    End Property

    <Description("Gets or sets whether if the control should use an elevated shield icon."), DefaultValue(False), Category("Appearance")> _
    Public Property ShowShield As Boolean
  Get
    Return Me._showshield
  End Get
  Set(ByVal value As Boolean)
    Me._showshield = value
    Me.SetShield(value)
    If Not value Then
    Me.SetImage()
    End If
  End Set
    End Property

End Class

Friend Class NativeMethods
    <DllImport("user32.dll", CharSet:=CharSet.Unicode)> _
    Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInt32, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    End Function

    Public Const BCM_SETNOTE As Integer = 5641
    Public Const BCM_SETSHIELD As Integer = 5644
    Public Const BM_SETIMAGE As Integer = 247
End Class

A+


* - P4R4DiSi4C - Jul 27, 2012

Ah merci ekinox :)
Merci beaucoup
Cordialement
Paradisiac


* - Gr0wlit - Jul 27, 2012

They looks cool, i don't really understand the PM feature, but can you send me this? Buttons looks better than the "command link" of "Vista Controls". Thank you.


* - sh@rp - Jul 28, 2012

(Jul 27, 2012 03:44 PM)para0411 Wrote:  Ah merci ekinox :)
Merci beaucoup
Cordialement
Paradisiac

This is not a french board ! Please write your answers in English according of the rules.

Cordially.

(Jul 27, 2012 03:59 PM)Gr0wlit Wrote:  They looks cool, i don't really understand the PM feature, but can you send me this? Buttons looks better than the "command link" of "Vista Controls". Thank you.

The Vista commandLink button has an image property that you can modify and add your own. Not reallly hard to set.😉


* - Hacker_Adi - Jul 28, 2012

Hey Ekin0x can you send me its soource.


* - Jeff. - Jul 28, 2012

(Jul 28, 2012 12:37 AM)wallace87000 Wrote:  The Vista commandLink button has an image property that you can modify and add your own. Not reallly hard to set.😉

But with Ekin0x his buttons this is also possible if you even had a look into it you would see?


* - sh@rp - Jul 28, 2012

(Jul 28, 2012 05:00 AM)21st Century Kid Wrote:  But with Ekin0x his buttons this is also possible if you even had a look into it you would see?

No need to look I know that he has the same property ... That's why it's unnecessary to provide the same control. What's really the difference ?
He has the choice beetween different Icon in the property grid ?
NO ! Ok it's the same. This is not a creation but a copy/paste from..


* - sickoryy - Jul 29, 2012

Hey, this looks rly nice, may i get it? :d


* - superchunk - Jul 29, 2012

looks nice, may i have it please? :D


* - Les Frères - Jul 29, 2012

Would love to get this, thanks! Good job!