UGN Security Forums
My ProfileMember DirectoryLogin
Search our ForumsView our FAQView our Site Rules
View our CalendarView our Active TopicsGo to our Main Page

UGN Security Store
 

Network Sites UGN Security, The GoNix Initiative, Elite Web Gamers, Back of the Web, EveryDay Helper, VNC Web Design & Development
November
Su M Tu W Th F Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
Sponsored Links
Latest Postings
Latest Reviews
Topic Options
Rate This Topic
#17770 - 03/13/02 12:29 PM Tips & Tricks - How to make fancy shmancy forms (Part 1)
SilentRage Offline
DollarDNS Owner

Registered: 03/04/02
Posts: 1273
Loc: 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

Top
Sponsored Links
      
#17771 - 03/13/02 01:25 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)
olosoft Offline
Member

Registered: 03/02/02
Posts: 143
Loc: .
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

Top
#17772 - 03/13/02 01:29 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)
olosoft Offline
Member

Registered: 03/02/02
Posts: 143
Loc: .
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

Top
#17773 - 03/13/02 02:39 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
good boy ::rubs yoru head::
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
#17774 - 03/13/02 02:43 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)
ninjaneo Offline
UGN Security Staff

Registered: 03/06/02
Posts: 256
Loc: 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:

Top
#17775 - 03/13/02 04:01 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)
olosoft Offline
Member

Registered: 03/02/02
Posts: 143
Loc: .
sure, tell us how to make rounf forms
/me isnt a big fan of that whole BitBlt thing tho...

Top
#17776 - 03/14/02 04:37 AM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)
GeneX Offline
Junior Member

Registered: 03/03/02
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

Top
#17777 - 03/15/02 01:20 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)
ninjaneo Offline
UGN Security Staff

Registered: 03/06/02
Posts: 256
Loc: 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:

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

Registered: 04/08/03
Posts: 27
Loc: 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.

Top
#17779 - 04/08/03 08:40 AM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)
SilentRage Offline
DollarDNS Owner

Registered: 03/04/02
Posts: 1273
Loc: 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.
_________________________
Domain Registration, Hosting, Management
http://www.dollardns.net

Top
#17780 - 04/08/03 03:15 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)
BackSlash Offline
UGN's Resident Homo

Registered: 03/16/02
Posts: 599
Loc: 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."

Top
#17781 - 04/08/03 05:37 PM Re: Tips & Tricks - How to make fancy shmancy forms (Part 1)
SilentRage Offline
DollarDNS Owner

Registered: 03/04/02
Posts: 1273
Loc: 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

Top

Featured Member
Registered: 08/22/14
Posts: 1
Forum Stats
2150 Members
46 Forums
35721 Topics
70891 Posts

Max Online: 1567 @ 04/25/10 05:20 AM
Top Posters
UGN Security 28882
Gremelin 7193
§intå× 3255
SilentRage 1273
Ice 1146
pergesu 1136
Infinite 1041
jonconley 955
Girlie 908
unreal 860
Newest Members
golqm, Tim050, Gecko666, defghi795767, Devo60
2149 Registered Users
Who's Online
0 registered (), 373 Guests and 338 Spiders online.
Key: Admin, Global Mod, Mod
Latest News
luxury goods sales at $405B by 2019
by golqm
10/28/14 05:19 AM


Donate
  Get Firefox!
Get FireFox!