|
-
Mar 25th, 2005, 08:38 PM
#1
Thread Starter
Fanatic Member
HomeMade Title Bar [Resolved]
I'd like to implement a title bar using only a picturebox, how can I go about doing this? I've tried moving the form invoking the picturebox_mousemove event, but it gives a weird lag and kind of smears the form across the screen. The mousemove event also doesn't appear to be totally consistent either. I'm sure this has been done before, any pointers?
Last edited by Nove; Mar 25th, 2005 at 10:12 PM.
-
Mar 25th, 2005, 09:41 PM
#2
Re: HomeMade Title Bar
I would use the MID() statement, like this.
VB Code:
Option Explicit
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Dim titlebar%
Dim title$
Dim z As Long
Dim ichange
Dim stitle$
Dim istart%, iend%
Dim endflag As Boolean
Private Sub Command1_Click()
If endflag = True Then
endflag = False
Else
endflag = True
End If
If endflag = False Then
istart = 1
Do While endflag = False
If istart + titlebar < Len(title) + 1 Then
stitle = Mid(title, istart, titlebar)
Else
ichange = Len(title) - istart
stitle = Mid(title, istart, ichange) & Mid(title, 1, titlebar - ichange)
End If
Label1.Caption = stitle
DoEvents
If istart < Len(title) Then istart = istart + 1 Else istart = 1
Sleep 200
Loop
End If
End Sub
Private Sub Form_Load()
endflag = True
title = "This is a test. This is only a test..." ' Bar is 10 characters
titlebar = 10
End Sub
It can be improved slightly, I just whipped it up.
-
Mar 25th, 2005, 09:50 PM
#3
Re: HomeMade Title Bar
 Originally Posted by Nove
I'd like to implement a title bar using only a picturebox, how can I go about doing this? I've tried moving the form invoking the picturebox_mousemove event, but it gives a weird lag and kind of smears the form across the screen. The mousemove event also doesn't appear to be totally consistent either. I'm sure this has been done before, any pointers?
If you're talking about moving borderless form then here is a sample:
VB Code:
Option Explicit
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub pctTitlebar_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
ReleaseCapture
SendMessageLong Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If
End Sub
-
Mar 25th, 2005, 10:12 PM
#4
Thread Starter
Fanatic Member
Re: HomeMade Title Bar
Thanks RhinoBull, works perfectly, and alot easier than I would've thought.
Dglienna, I'm not quite sure what you were trying to do...
-
Mar 25th, 2005, 10:14 PM
#5
Fanatic Member
Re: HomeMade Title Bar [Resolved]
Code:
Private Sub Form_Load()
Picture1.BackColor = vbBlue
Picture1.Move Me.ScaleLeft, Me.ScaleTop, Me.Width, 320
End Sub
and then use RhinoBulls's code to move it around
-
Mar 25th, 2005, 10:16 PM
#6
Re: HomeMade Title Bar
 Originally Posted by Nove
Thanks RhinoBull, works perfectly, and alot easier than I would've thought. ...
Sounds good to me.
-
Mar 25th, 2005, 10:19 PM
#7
Re: HomeMade Title Bar [Resolved]
Somehow I got a scrolling marquee type thing out of that. It must be Friday, or something!
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
|