|
-
Sep 10th, 2006, 05:28 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Form with no Titlebar but with Caption in Taskbar
How can I make a form have no Titlebar, be resizeable, and have a caption in the taskbar?
-
Sep 10th, 2006, 05:58 PM
#2
Lively Member
Re: Form with no Titlebar but with Caption in Taskbar
Can I ask one thing, You do not know that.
Thats the 1st thing I ever did learn lol. An it was easy as pie.
Here. Use google...
Search, Make a boarderless window that can resize
An the title bar tect is done from the title caption on the properties. It will do the same on the taskbar...
-
Sep 10th, 2006, 06:17 PM
#3
Thread Starter
Hyperactive Member
Re: Form with no Titlebar but with Caption in Taskbar
But I also want to be able to resize the window from the sides as well.
-
Sep 10th, 2006, 06:18 PM
#4
Thread Starter
Hyperactive Member
Re: Form with no Titlebar but with Caption in Taskbar
And I was just wondering if theres a simple way to do this without having to use all of those custom controls.
-
Sep 10th, 2006, 06:36 PM
#5
Re: Form with no Titlebar but with Caption in Taskbar
Here is some code I've had laying around a while. I think it is what you are after. For the form style property select 2-Sizeable.
VB Code:
Option Explicit
'API Calls Used To Remove The Title Bar From Window (Make A Sizeable Borderless Form)
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 GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_DLGFRAME = &H400000
'API Calls Used To Move A Form With The Mouse
Private Declare Function ReleaseCapture Lib "user32" () As Long
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
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Form_Load()
'ERASE the Title Bar
SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Move the form with the Left Mouse Button
If Button = vbLeftButton Then
Me.MousePointer = vbSizeAll
Call ReleaseCapture
Call SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
Me.MousePointer = vbArrow
End If
End Sub
-
Sep 10th, 2006, 07:01 PM
#6
Thread Starter
Hyperactive Member
Re: Form with no Titlebar but with Caption in Taskbar
Whoa! Thanks! That was exactly what I was looking for. I think I posted a topic similar to this before but I can't find it.
-
Oct 9th, 2006, 07:59 PM
#7
Addicted Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
is there a way of "deactivating" or returning the form back to normal? i put the code in a "fullscreen" menu button thing.
-
Oct 9th, 2006, 08:06 PM
#8
Thread Starter
Hyperactive Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
Yeah, and also the titlebar reappears after I change the form's caption. How do I avoid that?
-
Oct 15th, 2006, 10:59 PM
#9
Addicted Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
-
Oct 15th, 2006, 11:10 PM
#10
Thread Starter
Hyperactive Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
I guess not
-
Oct 15th, 2006, 11:16 PM
#11
Addicted Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
dang... wheres MarkT?? WHY HAS HE FORESAKEN US?!!! *runs to a corner and cries*
-
Oct 15th, 2006, 11:27 PM
#12
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
Probably when you change the caption it removes the style and shows the title bar again. So I would assume that your could just make another call of the line that removes it.
VB Code:
SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 16th, 2006, 06:12 AM
#13
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
You need to change the style back to its original state before making you changes and then remove the title bar again.
VB Code:
Private Sub Command1_Click()
'Set the style back to where you started
SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) - WS_DLGFRAME
'Change your caption
Me.Caption = "New Caption"
'Remove the title bar
SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
End Sub
-
Oct 16th, 2006, 06:14 AM
#14
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
 Originally Posted by battery
is there a way of "deactivating" or returning the form back to normal? i put the code in a "fullscreen" menu button thing.
Menu options or command buttons
-
Oct 16th, 2006, 11:28 AM
#15
Thread Starter
Hyperactive Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
-
Oct 16th, 2006, 02:33 PM
#16
Addicted Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
i stuck in in a menu option and im trying to adapt it into my project
-
Oct 16th, 2006, 03:26 PM
#17
Addicted Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
arg it fails - heres my code... please make it work :P
VB Code:
Private Sub mnuflashfs_Click()
Dim t As Integer, l As Integer, w As Integer, h As Integer
fs = False
If fs = False Then
If mnuflashfs.Caption = "Fullscreen" Then
t = Top
l = Left
w = Width
h = Height
Top = 0
Left = 0
frmflash.Height = Screen.Height + 450
frmflash.Width = Screen.Width
flashplayer.Height = Screen.Height
flashplayer.Width = Screen.Width
mnuflashfs.Caption = "Normal"
SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
fs = True
End If
End If
If fs = False Then
If mnuflashfs.Caption = "Normal" Then
SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) - WS_DLGFRAME
SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
Top = t
Left = l
Width = w
Height = h
flashplayer.Height = Height
flashplayer.Width = Width
mnuflashfs.Caption = "Fullscreen"
fs = True
End If
End If
fs = False
End Sub
i dont know why it doesnt wanna work
i made a buncha variables (t,l,w,h) as the settings prior to the fullscreening, so when they de-fullscreen it , the form goes back to the prior size.. plz help
-
Oct 21st, 2006, 12:48 PM
#18
Addicted Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
its been 5 days.. does no one have an answer to my inquiry?????
-
Oct 21st, 2006, 01:31 PM
#19
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
If you want the title bar back then just update the formcaption
-
Oct 31st, 2006, 06:35 PM
#20
Addicted Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
doesnt work 
i did all that stuff and it doesnt wanna work
i added in the caption thing and still nothing
-
Oct 31st, 2006, 06:39 PM
#21
Addicted Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
it says a form cant be maximized/minimized bla bla bla - if i take out the t,l,w,h it doesnt do anything but change the caption of the menu
-
Oct 31st, 2006, 08:23 PM
#22
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
If all you are trying to do is change between fulls creen and normal form size then just change the windowstate property.
VB Code:
Option Explicit
'API Calls Used To Remove The Title Bar From Window (Make A Sizeable Borderless Form)
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 GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_DLGFRAME = &H400000
'API Calls Used To Move A Form With The Mouse
Private Declare Function ReleaseCapture Lib "user32" () As Long
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
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Dim t As Integer, l As Integer, w As Integer, h As Integer
Dim fs As Boolean
Private Sub Form_Load()
'ERASE the Title Bar
SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
mnuflashfs.Caption = "Fullscreen"
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Move the form with the Left Mouse Button
If Button = vbLeftButton Then
Me.MousePointer = vbSizeAll
Call ReleaseCapture
Call SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
Me.MousePointer = vbArrow
End If
End Sub
Private Sub mnuflashfs_Click()
If mnuflashfs.Caption = "Fullscreen" Then
Me.WindowState = vbMaximized
mnuflashfs.Caption = "Normal"
Else
Me.WindowState = vbNormal
mnuflashfs.Caption = "Fullscreen"
End If
End Sub
-
Oct 31st, 2006, 11:23 PM
#23
Addicted Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
it sorta works, cept that when the form loads it starts without the title bar (borderstyle 0 or whatever) - i'd like for it to start with the border, then when the user clicks the fs menu thing then it ditches the border - when the click it again, to make the form normal, it add back the border thing
-
Oct 31st, 2006, 11:30 PM
#24
Addicted Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
heres what i've adapted:
VB Code:
Private Sub mnuflashfs_Click()
' all of this is pretty obvious but i'll explain anyway...
If mnuflashfs.Caption = "Fullscreen" Then
'store the top,left,width, and heigh prior to fullscreening
t = Top
l = Left
w = Width
h = Height
'set the top and left to the top left corner of the screen - didnt do that before
Me.Top = 0
Me.Left = 0
flashplayer.Height = Screen.Height
flashplayer.Width = Screen.Width
'and heres your stuff
Me.WindowState = vbMaximized
SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
mnuflashfs.Caption = "Normal"
Else
'reapply prior settings
Width = w
Height = h
Top = t
Left = l
'your stuff once more
Me.WindowState = vbNormal
mnuflashfs.Caption = "Fullscreen"
End If
End Sub
my code doesnt work - when it's fullscreened when you click it just makes a beep sound when you click (like when you have a popup and when you click off it - that sound)
-
Nov 2nd, 2006, 07:11 AM
#25
Member
-
Jan 4th, 2007, 09:14 PM
#26
Thread Starter
Hyperactive Member
Re: [RESOLVED] Form with no Titlebar but with Caption in Taskbar
I've run into a slight problem with the code. When I maximize the window, the window fills up the entire screen, including the taskbar (I have the taskbar set to stay on top of other windows and the test window isn't set to stay on top of other windows). Is there a way for the window to stop at the taskbar? Thanks
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
|