Your browser does not seem to support CSS. If images appear below, please disregard them.
It appears that you're running an Ad-Blocker. This site is monetized by Advertising and by ">User Donations; we ask that if you find this site helpful that you whitelist us in your Ad-Blocker, or make a ">Donation to help aid in operating costs.
Previous Thread
Next Thread
Print Thread
Rate This Thread
#17770 - 03/13/02 05:29 PM Tips & Tricks - How to make fancy shmancy forms (Part 1)  
Joined: Mar 2002
Posts: 1,273
SilentRage Offline
DollarDNS Owner
SilentRage  Offline
DollarDNS Owner

Joined: Mar 2002
Posts: 1,273
OH, USA
I just read in one of Gizmo's mass emails that moderators are actually supposed to ENCOURAGE conversation in their forum, so huh, guess what, I guess I better get off my lazy mod *** and start thinking of something to say to a group of mostly non-programmers.

Wanna create cool looking windows but don't know how because VB tends to by default give you a plain jane window with a title bar and all windowy features? Well looky here, I'm going to talk about making fancy shmancy windows in VB.

first of all, we need to start with a clean slate. To get a plain square window with no features whatsoever, create a form and set the following properties:

BorderStyle = 0
Caption = ""
ControlBox = False
ShowInTaskbar = True
(ShowInTaskbar is automatically set to false when you set the ControlBox to false - you should set it back to true)

There we go! Now it's borderless and has no title bar whatsoever. Now we need to make it cool looking. I'm going to change the background to black (BackColor = 0) and create a label to be my new title bar. I change the label's background and foreground colors and the font type/size and position it and size it where I want it. I'm also going to use the line control to draw a few lines on the edges of my form to create the effect of a border (for the borders, you may want to consider using the shape controls). Feel free to add any pictures or a background or whatever fits your style.

Now all that is pretty obvious stuff. Now for the REAL tip & trick. You want to have your user move the form around right? I chose to have it so that the custom title bar is draggable, but you can make it so that they can drag any part of the form. Here's the best way to do it:

Declare these functions and constants:

Private Declare Sub ReleaseCapture Lib "user32" ()
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2

Now I choose any control with a MouseMove event to act as my drag-point. I chose my titlebar label, you may choose your form:

Private Sub lblHeader_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'insert code
End Sub

Here's the code:

If Button = 1 Then
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If

Button = 1 will make sure the left button is pressed. ReleaseCapture will release the mouse's capture, and SendMessage will send a message to the window to let it know it needs to be dragged. If you want to be able to drag with either button, say "If Button > 0 Then". Also, I change my cursor to show a user that you can drag (lblHeader.MousePointer = 15)

Example: Pre-release DNS Lookup v2.0

Well that does it! You're well on your way to making fancy shmancy forms. Next time I will tell you how to shape your forms into circles or rounded corners or any shape you want!


Domain Registration, Hosting, Management
http://www.dollardns.net
Sponsored Links
#17771 - 03/13/02 06:25 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)  
Joined: Mar 2002
Posts: 143
olosoft Offline
Member
olosoft  Offline
Member

Joined: Mar 2002
Posts: 143
.
also, heres a simple way of creating custom graphical buttons.

ok, first of all you have to create the images. you need three images for each button: a normal state, hover state, and down state.

once youve create the images open up your project in vb. i always create one form that just holds all the images in one spot for organizations, say, call it frmImages. open that form up and create an Image. for our example well call it imgOK. set that Picture property to your buttons Normal state. now, copy and paste that Image, when it asks you if you wanna create a control array, say yes. the new image should be called imgOK(1). now set the picture to the Hover state. and copy, paste, and set imgOK(2) to the Down state.

aight, go back to your form where you want the button. create an image, well call it cmdOK. set the default picture to the Norm state. now add this code:

Private Sub cmdOK_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
cmdOK = frmImages.imgOK(2)
End Sub

Private Sub cmd_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not Button = 1 Then
cmdOK = frmImages.imgOK(1)
End If
End Sub

and in the Form_MouseMove add cmdOK = frmImages.imgOK(0)

oh, and you might also wanna add the actualy button's code to the cmdOK_Click event.

example: http://olosoft.topcities.com/suite/Calculator.exe 24kb

example code: http://olosoft.topcities.com/suite/Calculator.zip 22kb

#17772 - 03/13/02 06:29 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)  
Joined: Mar 2002
Posts: 143
olosoft Offline
Member
olosoft  Offline
Member

Joined: Mar 2002
Posts: 143
.
err, yea, those links dont work, copy them into like Download Accelertor plus, or go to olosoft.topcities.com and then type those links in... god**** free host

#17773 - 03/13/02 07:39 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)  
Joined: Feb 2002
Posts: 7,198
Gremelin Offline
Community Owner
Gremelin  Offline

Community Owner

Joined: Feb 2002
Posts: 7,198
Likes: 11
Portland, OR; USA
good boy ::rubs yoru head::


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#17774 - 03/13/02 07:43 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)  
Joined: Mar 2002
Posts: 256
ninjaneo Offline
UGN Security Staff
ninjaneo  Offline
UGN Security Staff

Joined: Mar 2002
Posts: 256
Likes: 1
CA, USA
Heh, I guess that means me to hey SR?...

Umm... I could show you guys how to make rounf forms.. If you want to know go ahead ans ask me. :rolleyes:

Sponsored Links
#17775 - 03/13/02 09:01 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)  
Joined: Mar 2002
Posts: 143
olosoft Offline
Member
olosoft  Offline
Member

Joined: Mar 2002
Posts: 143
.
sure, tell us how to make rounf forms wink
/me isnt a big fan of that whole BitBlt thing tho...

#17776 - 03/14/02 09:37 AM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)  
Joined: Mar 2002
Posts: 6
GeneX Offline
Junior Member
GeneX  Offline
Junior Member

Joined: Mar 2002
Posts: 6
Sample to make round form (put this behind form):
---------------------------------------------
Private Declare Function CreateEllipticRgn Lib "gdi32" _
(ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, _
ByVal Y2 As Long) As Long

Private Declare Function SetWindowRgn Lib "user32" _
(ByVal hWnd As Long, ByVal hRgn As Long, _
ByVal bRedraw As Boolean) As Long

Private Sub Form_Load()
SetWindowRgn hWnd, CreateEllipticRgn(0, 0, Form1.Width * 15, Form1.Heigth * 15), True
End Sub

#17777 - 03/15/02 06:20 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)  
Joined: Mar 2002
Posts: 256
ninjaneo Offline
UGN Security Staff
ninjaneo  Offline
UGN Security Staff

Joined: Mar 2002
Posts: 256
Likes: 1
CA, USA
Well, I guess that would work my way was a little bit different and you could control roundness of corners and hiegth / width of forum... :rolleyes:

#17778 - 04/08/03 08:06 AM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)  
Joined: Apr 2003
Posts: 27
nomel Offline
Junior Member
nomel  Offline
Junior Member

Joined: Apr 2003
Posts: 27
CA, USA
Fancy Buttons!

You can make nice buttons with labels.
Just set the border option to single and do the normal name_click() function for it. Makes nice little flat buttons.

I like making everything Flat instead of 3D too...


Written using the Dvorak keyboard layout.
#17779 - 04/08/03 12:40 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)  
Joined: Mar 2002
Posts: 1,273
SilentRage Offline
DollarDNS Owner
SilentRage  Offline
DollarDNS Owner

Joined: Mar 2002
Posts: 1,273
OH, USA
I have fixed the link in the first post to the example form. of course, now DNS Lookup v2 is no longer pre release. smile


Domain Registration, Hosting, Management
http://www.dollardns.net
Sponsored Links
#17780 - 04/08/03 07:15 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)  
Joined: Mar 2002
Posts: 599
BackSlash Offline
UGN's Resident Homo
BackSlash  Offline
UGN's Resident Homo

Joined: Mar 2002
Posts: 599
TN
i think you could make the form draggable without api if you did the following....
Code
Dim lastx, lasty

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
lastx = X
lasty = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Form1.Left = Form1.Left + (X - lastx)
Form1.Top = Form1.Top + (Y - lasty)
End If
End Sub  
you could put that code for a label instead of the form to drag the form with the title bar.


"It's better to burn out, than to fade away."
#17781 - 04/08/03 09:37 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)  
Joined: Mar 2002
Posts: 1,273
SilentRage Offline
DollarDNS Owner
SilentRage  Offline
DollarDNS Owner

Joined: Mar 2002
Posts: 1,273
OH, USA
yes, but that requires more code than the API technique. And besides, why reinvent the wheel? Just use technology already in place. It's more efficient.


Domain Registration, Hosting, Management
http://www.dollardns.net

Member Spotlight
Crime
Crime
SC, usa
Posts: 506
Joined: March 2002
Show All Member Profiles 
Forum Statistics
Forums45
Topics33,913
Posts69,055
Members2,164
Average Daily Posts3
Members2,164
Most Online1,567
Apr 25th, 2010
Latest Postings
shopping for jewelry with something above
by mikejoey on 04/12/17 08:01 AM
PANDORA North The usa
by mikejoey on 04/12/17 07:38 AM
Pandora’s birthstone products will always
by mikejoey on 04/12/17 07:14 AM
the newest Pandora necklaces crafting facility
by mikejoey on 04/12/17 06:53 AM
an Air Jordan 4 by Off White is in
by mikejoey on 04/12/17 06:35 AM
belonging to the adidas NMD XR1
by mikejoey on 04/12/17 05:50 AM
Other detailsThe adidas Originals Celebrity
by mikejoey on 04/12/17 05:35 AM
The DNA on the NMD model is actually
by mikejoey on 04/12/17 05:18 AM
in which adidas NMD XR1 “Zebra” supplying
by mikejoey on 04/12/17 04:05 AM
Blackbeard.....
by Gremelin on 01/14/17 07:03 PM
Top Posters(All Time)
UGN Security 41,138
Gremelin 7,198
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Liked Users (All Time)
§intå× Likes: 3
Black Beard Likes: 1
Cold Sunn Likes: 1
Crime Likes: 1
Cyrez Likes: 1
fleshwound Likes: 1
Ghost Likes: 2
Gremelin Likes: 12
Ice Likes: 1
ninjaneo Likes: 1
Top Liked Users (30 Days)
No Data Found
Powered by UBB.threads™ PHP Forum Software 7.6.0
(Snapshot build 20170206)