• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Hiding Application Title Bar?

We're able to view a sheet in fullscreen mode with everything completely hidden except for the title bar.


Is it possible to hide the title bar at the very top also?
 
A quick Google search produced numerous links with the code you need:


http://www.mrexcel.com/forum/showthread.php?t=6148

http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/736155c6-1e55-415c-add0-8d95d3e29212/

http://www.eileenslounge.com/viewtopic.php?f=27&t=1986
 
Thanks JP ! : )


I pasted this code to possibly help someone else from the mr.excel first link you posted.

<br />
Option Explicit</p>
<p>Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _<br />
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long</p>
<p>Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _<br />
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long</p>
<p>Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _<br />
(ByVal hwnd As Long, ByVal nIndex As Long) As Long</p>
<p>Private Const GWL_STYLE = (-16)<br />
Private Const WS_CAPTION = &HC00000<br />
Private Const WS_MAXIMIZEBOX = &H10000<br />
Private Const WS_MINIMIZEBOX = &H20000<br />
Private Const WS_SYSMENU = &H80000</p>
<p>Private Declare Function SetWindowPos Lib "user32" _<br />
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _<br />
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _<br />
ByVal cy As Long, ByVal wFlags As Long) As Long</p>
<p>Private Enum ESetWindowPosStyles<br />
SWP_SHOWWINDOW = &H40<br />
SWP_HIDEWINDOW = &H80<br />
SWP_FRAMECHANGED = &H20<br />
SWP_NOACTIVATE = &H10<br />
SWP_NOCOPYBITS = &H100<br />
SWP_NOMOVE = &H2<br />
SWP_NOOWNERZORDER = &H200<br />
SWP_NOREDRAW = &H8<br />
SWP_NOREPOSITION = SWP_NOOWNERZORDER<br />
SWP_NOSIZE = &H1<br />
SWP_NOZORDER = &H4<br />
SWP_DRAWFRAME = SWP_FRAMECHANGED<br />
HWND_NOTOPMOST = -2<br />
End Enum</p>
<p>Private Declare Function GetWindowRect Lib "user32" _<br />
(ByVal hwnd As Long, lpRect As RECT) As Long</p>
<p>Private Type RECT<br />
Left As Long<br />
Top As Long<br />
Right As Long<br />
Bottom As Long<br />
End Type</p>
<p>Sub Title_Show()<br />
ShowTitleBar True<br />
With ActiveWindow<br />
.DisplayHorizontalScrollBar = True<br />
.DisplayVerticalScrollBar = True<br />
.DisplayWorkbookTabs = True<br />
End With<br />
With Application<br />
.DisplayFullScreen = False<br />
.DisplayStatusBar = True<br />
.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"<br />
End With<br />
End Sub</p>
<p>Sub Title_Hide()<br />
ShowTitleBar False<br />
With ActiveWindow<br />
.DisplayHorizontalScrollBar = False<br />
.DisplayVerticalScrollBar = False<br />
.DisplayWorkbookTabs = False<br />
End With<br />
With Application<br />
.DisplayFullScreen = True<br />
.DisplayStatusBar = False<br />
.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"<br />
End With<br />
End Sub</p>
<p>Sub ShowTitleBar(bShow As Boolean)<br />
Dim lStyle As Long<br />
Dim tRect As RECT<br />
Dim sWndTitle As String<br />
Dim xlhnd</p>br /><p>'// Untested should perhaps look for the class ?!<br />
sWndTitle = "Microsoft Excel - " & ActiveWindow.Caption<br />
xlhnd = FindWindow(vbNullString, sWndTitle)</p>
<p>'// Get the window's position:<br />
GetWindowRect xlhnd, tRect</p>
<p>'// Show the Title bar ?<br />
If Not bShow Then<br />
lStyle = GetWindowLong(xlhnd, GWL_STYLE)<br />
lStyle = lStyle And Not WS_SYSMENU<br />
lStyle = lStyle And Not WS_MAXIMIZEBOX<br />
lStyle = lStyle And Not WS_MINIMIZEBOX<br />
lStyle = lStyle And Not WS_CAPTION<br />
Else<br />
lStyle = GetWindowLong(xlhnd, GWL_STYLE)<br />
lStyle = lStyle Or WS_SYSMENU<br />
lStyle = lStyle Or WS_MAXIMIZEBOX<br />
lStyle = lStyle Or WS_MINIMIZEBOX<br />
lStyle = lStyle Or WS_CAPTION<br />
End If</p>
<p>SetWindowLong xlhnd, GWL_STYLE, lStyle</p>
<p>Application.DisplayFullScreen = Not bShow</p>
<p>'// Ensure the style is set and makes the xlwindow the<br />
'// same size, regardless of the title bar.<br />
SetWindowPos xlhnd, 0, tRect.Left, tRect.Top, tRect.Right - tRect.Left, _<br />
tRect.Bottom - tRect.Top, SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED</p>
<p>End Sub<br />
 
Back
Top