|
|
Comments and Discussions
|
|
 |
|

|
First off, I want to say how awesome your control is. It's awesome!
I'm using Visual Studio 2012 and I created a very simple form with some regular buttons, some radio buttons, some hidden elements, etc... It's VERY rudimentary, but it worked. After seeing how ugly the regular buttons are, I found this site.
So here's the issue:
When I go and re-do all the old regular buttons with new Cbuttons, I have an odd event raised (it raises a click event on one of the radio buttons) when the form loads. It's odd because as long as I keep one of the old buttons on the form, I don't get the event, but if the Cbuttons are the only ones present, then the event triggers the radio button's procedure.
As the title states, I'm very new to vb.net. Is there any simple explanation as to how/why this might be happening? Any ideas on where to look for the cause?
|
|
|
|

|
I'm creating an interface where I modify button sizes, locations, colors, etc. at application runtime and restore those settings the next time the app is ran. I'd like to replace my buttons with CButton and be able to invoke the built-in property editor at runtime so I don't have to re-write that as part of my app. The editor I'm referring to is the one titled "CButtons Tasks" that you show in the screenshot. Is this possible?
|
|
|
|

|
I do not believe the Smart Tag can be used at run time. You can use the PropertyGrid to edit the properties, but if you want something like the SmartTag you will have to build it.
SSDiver2112
|
|
|
|

|
Hello,
If I have a button with this palette:
Button_Split.ColorFillBlend.iColor(0) = Color.GreenYellow
Button_Split.ColorFillBlend.iColor(1) = Color.YellowGreen
Button_Split.ColorFillBlend.iColor(2) = Color.DarkGreen
And then in execution time I change the colors to this:
Button_Split.ColorFillBlend.iColor(0) = Color.White
Button_Split.ColorFillBlend.iColor(1) = Color.Red
Button_Split.ColorFillBlend.iColor(2) = Color.DarkRed
Then when I "hovermouse/focus" over the button, the color stills green instead of red
How I can solve this?
PS: Sorry for my english
|
|
|
|

|
The Dim colors are not getting refreshed when you just change the iColor, so you have to force the refresh.
There are different ways to handle this. Some more complicated than others. The Dimmed colors (_HoverColorBlend...) could be moved into the class and updated as the iColor changes, or using the iNotify...
For some simple options you could make this change in the CButton.vb file:
Private Sub UpdateDimBlends() to ---> Public Sub UpdateDimBlends()
Then change the color like this:
Button_Split.ColorFillBlend.iColor(0) = Color.White
Button_Split.ColorFillBlend.iColor(1) = Color.Red
Button_Split.ColorFillBlend.iColor(2) = Color.DarkRed
Button_Split.UpdateDimBlends()
OR if you do not want to change the control code at all you can do it this way:
Button_Split.ColorFillBlend = New CButtonLib.cBlendItems(
New Color() {Color.White,
Color.Red,
Color.DarkRed},
New Single() {Button_Split.ColorFillBlend.iPoint(0),
Button_Split.ColorFillBlend.iPoint(1),
Button_Split.ColorFillBlend.iPoint(2)})
Hope this helped.
SSDiver2112
|
|
|
|

|
Thankyou, i've choosed the first way.
I think this is the last questien after all, I appreciate so much your support.
[OFFTOPIC] There is a link where I can get all your extended controls? [/OFFTOPIC]
|
|
|
|
|

|
Hello,
I can't do this:
If "a" = "a" then Cbutton1.PerformClick()
I can write the method without any exception, but the button isn't clicked
That means I can't use the button like this:
1. A "search bar" + "OnKeyPress" (Enter)
2. When ENTER key is pressed then "Button.performClick"
The method isn't implemented in the source code?
Thanks for read.
|
|
|
|

|
I cannot say why you are having trouble. I put this in the Form1 code of the article demo and it works fine.
Private Sub CButton1_ClickButtonArea(Sender As Object, e As MouseEventArgs) _
Handles CButton1.ClickButtonArea
If "a" = "a" Then CButtonON.PerformClick()
End Sub
SSDiver2112
|
|
|
|

|
I've tried your same example but does nothing:
Public Class Form1
Private Sub CButton1_ClickButtonAre(Sender As Object, e As MouseEventArgs) Handles CButton1.Click
MsgBox("a")
End Sub
Private Sub CButton1_ClickButtonArea(Sender As Object, e As MouseEventArgs) Handles CButton1.ClickButtonArea
If "a" = "a" Then CButton1.PerformClick()
End Sub
End Class
If i add this to the form:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
CButton1.PerformClick()
End Sub
Then i get an exception:
System.StackOverflowException was unhandled
PS: I'm using VS2012
|
|
|
|

|
The error on the load is to be expected. Everything needs to be created first.
This code should toggle the CButtonON red and green.
Private Sub CButton1_ClickButtonArea(Sender As Object, e As MouseEventArgs) _
Handles CButton1.ClickButtonArea
If "a" = "a" Then CButtonON.PerformClick()
End Sub
I designed the button to use the not the Click event. The Click still works, but it will fire if you click the control anywhere and the ClickButtonArea only fires when you click the button part of the control (i.e. the Sponge Bob Button). If you did this:
Private Sub Form1_Click(sender As Object, e As EventArgs) Handles Me.Click
CButton1.PerformClick()
End Sub
Private Sub CButton1_Click(Sender As Object, e As MouseEventArgs) Handles CButton1.Click
MsgBox("A")
End Sub
Private Sub CButton1_ClickButtonArea(Sender As Object, e As MouseEventArgs) Handles CButton1.ClickButtonArea
MsgBox("B")
End Sub
You will only see MessageBox "B"
If you are not seeing this behavior I cannot say at this point why.
If you need a work around until you get it figured out I would suggest putting all the button click code in a Sub:
Private Sub Form1_Click(sender As Object, e As EventArgs) Handles Me.Click
DoStuff()
End Sub
Private Sub CButton1_ClickButtonArea(Sender As Object, e As MouseEventArgs) Handles CButton1.ClickButtonArea
DoStuff()
End Sub
Private Sub DoStuff()
MsgBox("B")
End Sub
SSDiver2112
|
|
|
|

|
All is right now, I understand, the click method is now the clickbuttonarea,
Thankyou again for your time, excellent control!
|
|
|
|

|
I am using the dll and now I am getting this error ,I develope application for green screen
and now I can not work on the app , I am using visual Basic 10 and I need to get it work
even for short time to remove the button and to replace them with standard button , the control looks good but I can not afford the problem like this andI am trying to reach the author last 2 weeeks ..please help email me back at samavakian@gmail.com. I did read the author fix but it is not clear were to put it and what if I am using the dll only , it was working before and for some reason start doing it even his sample app does it
|
|
|
|

|
I have the same problem in VS2012, the DLL is incompatible when you try to change the colors, the Designer goes KABOOM, PLEASE SOMEONE IT'S TIME TO FIC THE PROBLEM,
PLEASE UPDATE THE SOURCE FOR US, SOMEONE PLEASE GIVE US A FIX!
|
|
|
|

|
I just added the 2012 version to the article download. This has the latest fixes and colorblender improvements. If you had an older version of the button and are changing to the new one and are still having issues with the designer it is because of the significant changes to the properties. It may be painful but you will either have to delete and/or update the offending designer errors or just delete all the button instances in the designer and then re-add the new button back onto the form. I had to do the this to all my older programs too, oh well the price of progress.
SSDiver2112
|
|
|
|

|
Thankyou SO MUCH for your time!
EDIT: I've deleted my other comments, sorry for the spam but i was dessesperated, it's a great extended control!
|
|
|
|

|
Can you drop the compiled dll also online please,
I want to use it in C#.
I'm using the old version now,
that is also very good.
|
|
|
|

|
Hi,
I get the error on this line with: Global.CButton.My.MySettings
And then I get the following code in CButtonlib:
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
#Region "Funktion zum automatischen Speichern von My.Settings"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.CButton.My.MySettings
Get
Return Global.CButton.My.MySettings.Default
End Get
End Property
End Module
End Namespace
How can I avoid this errors:
The type Global.CButton.My.MySettings is not defined.
and
"CButton" is not a member of "".
Regards
Dietrich
modified 25 Oct '12 - 17:01.
|
|
|
|

|
Great usercontrol! Looks great and has a lot of options.
|
|
|
|

|
Excellent project!
Thank you for this control.
Is it possible to have a button with rounded corners but not as steep UpperRight values, etc. LowerLeft.
I tried different method to draw an angle instead of a bow, but the result is not at all convincing
Thank you
Essais :
Private Function GetRoundedRectPath(ByVal BaseRect As RectangleF) As GraphicsPath
Dim ArcRect As RectangleF
Dim MyPath As New Drawing2D.GraphicsPath()
If Corners.All = -1 Then
With MyPath
If Corners.UpperLeft = 0 Then
.AddLine(BaseRect.X, BaseRect.Y, BaseRect.X, BaseRect.Y)
Else
If CornersType = CornerType.Round Then
ArcRect = New RectangleF(BaseRect.Location, New SizeF(Corners.UpperLeft * 2, Corners.UpperLeft * 2))
.AddArc(ArcRect, 180, 90)
End If
If CornersType = CornerType.Ligne Then
.AddLine(New PointF(BaseRect.X, BaseRect.Y + Corners.UpperLeft), New Point(BaseRect.X, BaseRect.Y + Corners.UpperLeft))
End If
End If
If Corners.UpperRight = 0 Then
.AddLine(BaseRect.X + (Corners.UpperLeft), BaseRect.Y, BaseRect.Right - (Corners.UpperRight), BaseRect.Top)
Else
If CornersType = CornerType.Round Then
ArcRect = New RectangleF(BaseRect.Location, New SizeF(Corners.UpperRight * 2, Corners.UpperRight * 2))
ArcRect.X = BaseRect.Right - (Corners.UpperRight * 2)
.AddArc(ArcRect, 270, 90)
End If
If CornersType = CornerType.Ligne Then
.AddLine(New PointF(BaseRect.X + Corners.UpperLeft, BaseRect.Y), New Point(BaseRect.Right - Corners.UpperRight, BaseRect.Top))
End If
End If
If Corners.LowerRight = 0 Then
.AddLine(BaseRect.Right, BaseRect.Top + (Corners.UpperRight), BaseRect.Right, BaseRect.Bottom - (Corners.LowerRight))
Else
If CornersType = CornerType.Round Then
ArcRect = New RectangleF(BaseRect.Location, New SizeF(Corners.LowerRight * 2, Corners.LowerRight * 2))
ArcRect.Y = BaseRect.Bottom - (Corners.LowerRight * 2)
ArcRect.X = BaseRect.Right - (Corners.LowerRight * 2)
.AddArc(ArcRect, 0, 90)
End If
If CornersType = CornerType.Ligne Then
.AddLine(BaseRect.Right, BaseRect.Top + (Corners.UpperRight), BaseRect.Right, BaseRect.Bottom - (Corners.LowerRight))
End If
End If
If Corners.LowerLeft = 0 Then
.AddLine(BaseRect.Right - (Corners.LowerRight), BaseRect.Bottom, BaseRect.X - (Corners.LowerLeft), BaseRect.Bottom)
Else
If CornersType = CornerType.Round Then
ArcRect = New RectangleF(BaseRect.Location, New SizeF(Corners.LowerLeft * 2, Corners.LowerLeft * 2))
ArcRect.Y = BaseRect.Bottom - (Corners.LowerLeft * 2)
.AddArc(ArcRect, 90, 90)
End If
If CornersType = CornerType.Ligne Then
.AddLine(BaseRect.Right - Corners.LowerLeft, BaseRect.Bottom, BaseRect.X + Corners.LowerLeft, BaseRect.Bottom)
End If
End If
...
|
|
|
|

|
A ma question voici ma solution
Private Function GetRoundedRectPath(ByVal BaseRect As RectangleF) As GraphicsPath
Dim ArcRect As RectangleF
Dim MyPath As New Drawing2D.GraphicsPath()
If CornersType = CornerType.Ligne Then
Return AddAnglesCorners(BaseRect)
End If
...
Public Function AddAnglesCorners(ByVal BaseRect As RectangleF) As GraphicsPath
Dim MyPath As New Drawing2D.GraphicsPath()
Dim points(7) As Point
points(0) = New Point(CInt(BaseRect.Left + Corners.UpperLeft), CInt(BaseRect.Top))
points(1) = New Point(CInt(BaseRect.Right - Corners.UpperRight), CInt(BaseRect.Top))
points(2) = New Point(CInt(BaseRect.Right), CInt(BaseRect.Top + Corners.UpperRight))
points(3) = New Point(CInt(BaseRect.Right), CInt(BaseRect.Bottom - Corners.LowerRight))
points(4) = New Point(CInt(BaseRect.Right - Corners.LowerRight), CInt(BaseRect.Bottom))
points(5) = New Point(CInt(BaseRect.Left + Corners.LowerLeft), CInt(BaseRect.Bottom))
points(6) = New Point(CInt(BaseRect.Left), CInt(BaseRect.Bottom - Corners.LowerLeft))
points(7) = New Point(CInt(BaseRect.Left), CInt(BaseRect.Top + Corners.UpperLeft))
With MyPath
.AddLines(points)
.CloseFigure()
End With
Return MyPath
End Function
|
|
|
|

|
I have been using this control for several months without any problems. It provides some customization that makes my application unique. Thanks!
|
|
|
|

|
I see a lot of questions asking for help dealing with "The object of type System.Int32 can not be converted to an object System.Int16". I believe this is happening because the designer needs to run the Initialization code for the control at design time. Given this belief I went in and for every public property in the cbutton.vb module I added the line of code below, cleaned and recompiled the cButton project, cleaned my test app and voila, it works as advertised and the sample app included with the project now loads the form at design time with no errors.
<System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)> _
I'm using VS2010 and I recompiled targeting .net framework 4.0 but I've also used VS2012 and targeted the 4.5 framework with the same success.
HTH
Pat
|
|
|
|

|
I forgot to mention that you will have to code for all those properties in your app because they will no longer appear in the designers property window. Kind of a bummer but IMHO a better solution than the 68 errors I was getting
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
This is a simple to use custom button control, but with a lot of visual design options.
| Type | Article |
| Licence | CPOL |
| First Posted | 3 Jun 2008 |
| Views | 238,272 |
| Downloads | 12,892 |
| Bookmarked | 182 times |
|
|