Results 1 to 14 of 14

Thread: [RESOLVED] Square Buttons

  1. #1

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Resolved [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
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  2. #2
    Addicted Member
    Join Date
    Dec 2007
    Posts
    186

    Re: Square Buttons

    Can you just disable xp visual styles?


  3. #3

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    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?
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  4. #4
    Addicted Member
    Join Date
    Dec 2007
    Posts
    186

    Re: Square Buttons

    Not that I know of sorry, you could always try creating your own control.

  5. #5

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    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.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  6. #6
    Frenzied Member Bulldog's Avatar
    Join Date
    Jun 2005
    Location
    South UK
    Posts
    1,950

    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.


    • If my post helped you, please Rate it
    • If your problem is solved please also mark the thread resolved

    I use VS2015 (unless otherwise stated).
    _________________________________________________________________________________
    B.Sc(Hons), AUS.P, C.Eng, MIET, MIEEE, MBCS / MCSE+Sec, MCSA+Sec, MCP, A+, Net+, Sec+, MCIWD, CIWP, CIWA
    I wrote my very first program in 1979, using machine code on a mechanical Olivetti teletype connected to an 8-bit, 78 instruction, 1MHz, Motorola 6800 multi-user system with 2k of memory. Using Windows, I dont think my situation has improved.

  7. #7

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: Square Buttons

    Quote Originally Posted by Bulldog View Post
    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 =(
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  8. #8
    Frenzied Member Bulldog's Avatar
    Join Date
    Jun 2005
    Location
    South UK
    Posts
    1,950

    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.


    • If my post helped you, please Rate it
    • If your problem is solved please also mark the thread resolved

    I use VS2015 (unless otherwise stated).
    _________________________________________________________________________________
    B.Sc(Hons), AUS.P, C.Eng, MIET, MIEEE, MBCS / MCSE+Sec, MCSA+Sec, MCP, A+, Net+, Sec+, MCIWD, CIWP, CIWA
    I wrote my very first program in 1979, using machine code on a mechanical Olivetti teletype connected to an 8-bit, 78 instruction, 1MHz, Motorola 6800 multi-user system with 2k of memory. Using Windows, I dont think my situation has improved.

  9. #9

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: Square Buttons

    Quote Originally Posted by Bulldog View Post
    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.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  10. #10
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    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

  11. #11

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    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.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  12. #12
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,051

    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.

  13. #13
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    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.

  14. #14
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,051

    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
  •  



Click Here to Expand Forum to Full Width