|
-
Jan 23rd, 2005, 12:16 PM
#1
Thread Starter
New Member
borderless form help
I have a form with no border (and has to stay that way). But I want to be able to move the form around by clicking on it and dragging it around or something, and it should also show up in the taskbar, which it doesn't when borderstyle = 0.
Thanks.
-
Jan 23rd, 2005, 12:25 PM
#2
Re: borderless form help
There isn't any conventional way to accomplish this task so use of some api will be in order:
VB Code:
Private Const GWL_STYLE = (-16)
Private Const WS_SYSMENU = &H80000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
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 Form_Load()
'=======================
Dim lStyle As Long
'ensure taskbar icon visibility
lStyle = GetWindowLong(hwnd, GWL_STYLE) Or WS_SYSMENU Or WS_MINIMIZEBOX
SetWindowLong hwnd, GWL_STYLE, lStyle
End Sub
Private Sub Form_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
-
May 24th, 2006, 08:50 PM
#3
Member
-
May 24th, 2006, 09:16 PM
#4
Re: borderless form help
Cool!
-
Jul 24th, 2011, 03:41 PM
#5
Junior Member
Re: borderless form help
Can you help me how to put this in my form?
-
Jul 24th, 2011, 05:08 PM
#6
Re: borderless form help
What kind of help do you expect? I don't suppose you're asking someone to copy/paste code sample for you, do you?
-
Jul 24th, 2011, 10:27 PM
#7
Re: borderless form help
Rhino,
There isn't any conventional way to accomplish this task so use of some api will be in order:
just in curious i m asking, is this method doing the right job?
Code:
Dim x1 As Single, y1 As Single
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
x1 = X
y1 = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Me.Left = Me.Left - (x1 - X)
Me.Top = Me.Top - (y1 - Y)
End If
End Sub
and we can chage the ShowInTaskBar property at design time according to the need,
am i right rhino?
edited: just code changed abt left button click
Last edited by seenu_1st; Jul 24th, 2011 at 10:37 PM.
-
Jul 25th, 2011, 04:29 AM
#8
New Member
Re: borderless form help
Hey Seenu_1st,
You are right and I've been using this code since last three years... Me and my friend made it on our own The problem with this code is that the form is always visible while moving (even if you have a theme that show only borders while moving a window). The ShowInTaskbar can be set to true in design time but it won't be able to minimize/restore/close/maximize as a normal program in taskbar does... Like if you click on it's taskbar icon, it is minimized and if you right click, you find various options (close/maximize, etc.)
-
Jul 25th, 2011, 06:42 AM
#9
Re: borderless form help
ATH, thanks for the info, so the diff is taskbar proprties.
Rhino, i got it.
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
|