|
-
Mar 21st, 2009, 03:07 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Square Buttons
I was wondering if it was possible to somehow use (or import if I have to) the square buttons that you sometimes see as the default System button on older Windows computers, and use it instead of the new Windows XP rounded kind with the white background.
I tried looking here to simply make the square button myself:
http://www.codeproject.com/KB/buttons/CButton.aspx
But it makes 0 sense to me.
Also I don't want Flatstyle as it makes the button 2D and I want the old square but 3D buttons, like the OK and Display button in this picture.
http://www.java2s.com/Tutorial/VBIma...ttonAction.PNG
-
Mar 21st, 2009, 03:13 PM
#2
Addicted Member
Re: Square Buttons
Can you just disable xp visual styles?
-
Mar 21st, 2009, 03:24 PM
#3
Thread Starter
Fanatic Member
Re: Square Buttons
I didn't think of that. That works and I may go with it, however, I don't want all of my buttons the be the square kind.
Is there a way to only disable the XP styles for certain buttons?
-
Mar 21st, 2009, 03:26 PM
#4
Addicted Member
Re: Square Buttons
Not that I know of sorry, you could always try creating your own control.
-
Mar 25th, 2009, 08:11 PM
#5
Thread Starter
Fanatic Member
Re: Square Buttons
Does anyone have anymore ideas? I would really like to be able to do it for specific controls only. I'm still searching for anything to do this. For now I'll just use the disable windows xp styles, Thanks Banjo.
-
Mar 25th, 2009, 08:14 PM
#6
Re: Square Buttons
You can always assign an image to a button, if you hide the BorderStyle and use a FlatStyle, the button will look like the image.
-
Mar 25th, 2009, 08:21 PM
#7
Thread Starter
Fanatic Member
Re: Square Buttons
 Originally Posted by Bulldog
You can always assign an image to a button, if you hide the BorderStyle and use a FlatStyle, the button will look like the image.
I considered doing that but then I would have to also add an image for the mouse down event and focus event etc. I'm hoping theres a simpler way to do it.
Oh, and not to mention I would need different images for every different sized button =(
-
Mar 25th, 2009, 08:29 PM
#8
Re: Square Buttons
Well... maybe not. It depends how much work you want to do but you could keep the buttons as basic placeholders and draw the text, shadow etc. onto them with GDI. Then scaling or needing multiple images wouldnt be such an issue. Never tried this myself but I might try it just to se what the issues are.
-
Mar 25th, 2009, 08:31 PM
#9
Thread Starter
Fanatic Member
Re: Square Buttons
 Originally Posted by Bulldog
Well... maybe not. It depends how much work you want to do but you could keep the buttons as basic placeholders and draw the text, shadow etc. onto them with GDI. Then scaling or needing multiple images wouldnt be such an issue. Never tried this myself but I might try it just to se what the issues are.
It sounds reasonable, but with the code I have on the mouse up and down events, it would get confusing trying to incorporate the change in images. Still possible though, so let me know if you test it out and find a good way to do it. I don't know how to draw text/shadow so I would never figure it out on my own.
-
Mar 25th, 2009, 08:47 PM
#10
Re: Square Buttons
If you want to disable visual styles on a single control, you can create your own control and then use code like this. It is for a Progressbar, but the same concept should work for a button:
Code:
Public Class MyPB
Inherits ProgressBar
Public Declare Unicode Function SetWindowTheme Lib "uxtheme.dll" (ByVal hWnd As IntPtr, ByVal pszSubAppName As String, ByVal pszSubIdList As String) As Integer
Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
SetWindowTheme(Me.Handle, "", "")
MyBase.OnHandleCreated(e)
End Sub
End Class
-
Mar 25th, 2009, 08:54 PM
#11
Thread Starter
Fanatic Member
Re: Square Buttons
How would I apply that to a button. I'm new to classes so I don't understand how I can add that to a button. I don't have to literally create my own button class do I? The good news is that the buttons I want to be square are created during runtime, so if you can help me figure this out it may work.
-
Mar 25th, 2009, 08:56 PM
#12
Frenzied Member
Re: Square Buttons
For your needs Banjo's suggestion would work best.
Just make your own control. Easier said than done. But you'll end up with exactly what you want.
-
Mar 25th, 2009, 08:57 PM
#13
Re: Square Buttons
Create a new class that inherits from a button. Then use that code that I posted. Once you compile, your new button will show up in your toolbox. Then you can add it just like any other control.
-
Mar 25th, 2009, 09:06 PM
#14
Frenzied Member
Re: Square Buttons
You can create a Class and inherit from Control.
At that point, you'll already have most of the functionality that you want.
Next, you'll handle the drawing of the control in the OnPaint method.
There's going to be many things to consider. Like changing the appearance of the Button for various conditions.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|