How to make a custom title bar.

Discussion in 'Programming & Scripting' started by Mizwax, Dec 24, 2008 with 9 replies and 430 views.

  1. Mizwax

    Mizwax Member

    Messages:
    3,777
    Ratings:
    217
    This is really pretty simple. it consists of a picturebox and a small chunk of code to go with it. It will show you how to make your form be able to "drag and drop", but without a form border and titlebar.

    First, you will need to make a title bar. I made mine to look like a Mac.
    [​IMG]

    my titlebar is 546x22, so im going to make a form with the width of 546 and however tall i need it. then change Form1's properties for the FormBorderStyle to "None"

    Now add a picturebox and resize it to fit your titlebar image you made, and put the image in there. then center the picturebox and square it up at the top fo the form or where ever else you may want it.

    Now go to your form's codes, and create a mouse down event for your picturebox. in my case it is picturebox1. Then make it look like this:
    [​IMG]


    Notice how in the first line of my code, it says "Picturebox1.Capture = False" the word Picturebox1 needs to be replaced with whatever your picturebox is. (example: picturebox5, picturebox99, steve (if thats what you named your picturebox...) or anything else)

    Now start debugging and you should be able to drag and drop your form by clicking and holding on your picturebox that you put that code on.

    See how nice and simple that is? now you can make full on custom GUI's if you want.
    Here is an example of one i made a while back durring the summer:
    [​IMG]


    Also, you can add the click-and-drag properties to whatever you want. if you wanted to add them to Form1, just make a mouse down event on Form1, then replace Picturebox1.Capture = False with Form1.Capture = False and it should all work out right. :thumbup:

    and its late and i worked all day, so im really tired and i had to go back and type haft of my sentences because i noticed i messedup because i am so tired. so there is probably still quite a few errors. sorry. haha.

    ~miz
     
    • Like Like x 3
  2. Ibdc

    Ibdc Retired Retired

    Messages:
    5,100
    Ratings:
    2,072
    Good tut bro, definitely useful to some people out there.
     
  3. dramatick

    dramatick Newbie

    Messages:
    37
    Ratings:
    0
    It can be simpler than that too, Just screeny a window with your 'dream' title bar and put into photoshop as .bmp then open it and cut the title bar out and slice it.. then give the slices (exit button, ect) custom commands, (form1.close....ect)

    :tongue: Hope this could help

    ~Dramatick
     
  4. Ibdc

    Ibdc Retired Retired

    Messages:
    5,100
    Ratings:
    2,072
    ^ That's basically what he did, but he just didn't add the buttons, he just made it so the form was draggable by the titlebar. That's exactly what he did in the app he used as the example.
     
  5. OP
    Mizwax

    Mizwax Member

    Messages:
    3,777
    Ratings:
    217
    yeah, ill add in the part for exit buttons later. i was too tired last night so i posted what i had. lol.
    if you want to see my example program first-hand, ill upload it for you and let you play around with it so you can see what all i did. but im not gonna give the source.
     
  6. Nothinbeter2do

    Nothinbeter2do Banned

    Messages:
    2,425
    Ratings:
    526
  7. OP
    Mizwax

    Mizwax Member

    Messages:
    3,777
    Ratings:
    217
  8. dramatick

    dramatick Newbie

    Messages:
    37
    Ratings:
    0

    Lol. I don't need any help at all, I've been coding vb for about 3 years now. But yeah.. Whateva.
     
  9. OP
    Mizwax

    Mizwax Member

    Messages:
    3,777
    Ratings:
    217
    cool! maybe you could help me out sometime if i need it?
     
  10. dramatick

    dramatick Newbie

    Messages:
    37
    Ratings:
    0