Hello,
I want my program to run as a fullscreen program.I mean the user shouldn't be able to access the task bar.I have a sample to hide it,but it uses user32.dll but CF.NET complaint about this .dll. so what's the way to do this
I want the user to only use my application.he/she mustn't be able to switch another application.I thought hiding the taskbar is the solution for this.is there another way
Thanks in advance

Hiding the taskbar...?
Night_ROamer
Thanks but my problem is different. I want to do something which will make the user not to open the taskbar.If he/she opens the taskbar,he/she can switch to another program from the Start menu. I want to disallow this programmatically.
Thanks again.
Frank Miller
Hi,
you can hide the bar at the bottom, which contains the new button, by removing the mainmenu1 control found by default in any new form.
you can hide the bar at the top, which contains the start menu button, by changing the WindowState property of the form to Maximized.
hope this helps
Robert Gregory Garfinkle
Use coredll.dll instead of user32.dll. Windows CE combines user32.dll, kernel32.dll, and gdi32.dll into coredll.dll.
HTH
Dan
KevMac
e.g. you enable the SIP, from there you can change the SIP options, going in to this makes the start button visible, from here the user can do what they want!
the method I use was to have a list of allowed windows (e.g. 'Phone') and then use a 2sec timer to check the title of the foreground window, if it's not me, or in the list, it gets closed
Crude, but effective. If anyone knows a better way, please share the joy!
btw, I'd recommend using the ShowWindow API call, here's some code
Imports System.Runtime.InteropServices
Module mWindows
#Region "Enumeration Types"
Public Enum SetWindowPosZOrder As Integer
HWND_TOP = 0
HWND_BOTTOM = 1
HWND_TOPMOST = -1
HWND_NOTOPMOST = -2
HWND_MESSAGE = -3
End Enum
Public Enum SetWindowPosFlag As Integer
SWP_NOSIZE = &H1
SWP_NOMOVE = &H2
SWP_NOZORDER = &H4
SWP_NOREDRAW = &H8
SWP_NOACTIVATE = &H10
SWP_FRAMECHANGED = &H20
SWP_SHOWWINDOW = &H40
SWP_HIDEWINDOW = &H80
SWP_NOCOPYBITS = &H100
SWP_NOOWNERZORDER = &H200
SWP_NOSENDCHANGING = &H400
SWP_DRAWFRAME = SWP_FRAMECHANGED
SWP_NOREPOSITION = SWP_NOOWNERZORDER
SWP_DEFERERASE = &H2000
SWP_ASYNCWINDOWPOS = &H4000
End Enum
Public Enum WindowVisibleFlag As Integer
SW_HIDE = 0
SW_SHOW = 5
End Enum
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~ SHFullScreen flags
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Public Const SHFS_SHOWTASKBAR As Integer = &H1
Public Const SHFS_SHOWSIPBUTTON As Integer = &H4
Public Const SHFS_SHOWSTARTICON As Integer = &H10
Public Const SHFS_HIDETASKBAR As Integer = &H2
Public Const SHFS_HIDESIPBUTTON As Integer = &H8
Public Const SHFS_HIDESTARTICON As Integer = &H20
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~ Other constants
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Const SM_CXSCREEN As Long = &H0&
Const SM_CYSCREEN As Long = &H1&
Const HHTASKBARHEIGHT As Long = 26
#End Region
#Region "External Declarations"
<DllImport("coredll.dll")> _
Public Function GetWindowText(ByVal hWnd As IntPtr, ByVal lpString As String, ByVal cch As Int32) As Int32
End Function
<DllImport("coredll.dll")> _
Public Function GetWindowTextLength(ByVal hWnd As IntPtr) As Int32
End Function
<DllImport("coredll.dll")> _
Public Function IsWindowVisible(ByVal hWnd As IntPtr) As Int32
End Function
<DllImport("coredll.dll")> _
Public Function ShowWindow(ByVal hWnd As IntPtr, ByVal WindowVisibleFlag As Integer) As IntPtr
End Function
<DllImport("coredll.dll")> _
Public Function GetParent(ByVal hWnd As IntPtr) As IntPtr
End Function
<DllImport("coredll.dll")> _
Public Function SetActiveWindow(ByVal hWnd As IntPtr) As IntPtr
End Function
<DllImport("coredll.dll")> _
Public Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
End Function
<DllImport("coredll.dll")> _
Public Function PostMessage(ByVal hwnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function
<DllImport("aygshell.dll")> _
Private Function SHFullScreen(ByVal hwndRequester As IntPtr, ByVal dwState As Integer) As Integer
End Function
<DllImport("coredll.dll")> _
Private Function GetCapture() As IntPtr
End Function
<DllImport("coredll.dll")> _
Public Function SetForegroundWindow(ByVal hwnd As IntPtr) As Int32
End Function
<DllImport("coredll.dll")> _
Public Function GetForegroundWindow() As IntPtr
End Function
<DllImport("coredll.dll")> _
Public Function GetActiveWindow() As IntPtr
End Function
<DllImport("coredll.dll")> _
Private Sub Sleep(ByVal dwMilliseconds As Long)
End Sub
<DllImport("coredll.dll")> _
Private Function SetWindowPos(ByVal hwnd As IntPtr, ByVal hWndInsertAfter As SetWindowPosZOrder, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
End Function
<DllImport("coredll.dll")> _
Private Function FindWindow(ByVal className As String, ByVal wndName As String) As IntPtr
End Function
<DllImport("coredll.dll")> _
Public Function FindFirstFileW(ByVal lpFileName As String, ByVal lpFindFileData As String) As Long
End Function
<DllImport("coredll.dll")> _
Public Function FindNextFileW(ByVal hFindFile As Long, ByVal lpFindFileData As String) As Long
End Function
<DllImport("coredll.dll")> _
Public Function FindClose(ByVal hFindFile As Long) As Long
End Function
#End Region
#Region "Window handling functions"
Public Sub SetWindowOnTop(ByVal hwnd As IntPtr)
SetWindowPos(hwnd, SetWindowPosZOrder.HWND_TOP, 0, 0, 0, 0, SetWindowPosFlag.SWP_NOSIZE + SetWindowPosFlag.SWP_NOMOVE)
End Sub
Public Function SetWindowOnBottom(ByVal hwnd As IntPtr) As Integer
Return SetWindowPos(hwnd, SetWindowPosZOrder.HWND_BOTTOM, 0, 0, 0, 0, SetWindowPosFlag.SWP_NOSIZE + SetWindowPosFlag.SWP_NOMOVE)
End Function
Public Sub SetWindowOnTopMost(ByVal frmX As Form)
SetWindowOnTopMost(GetWindowHandle(frmX))
End Sub
Public Sub SetWindowOnTopMost(ByVal hwnd As IntPtr)
SetWindowPos(hwnd, SetWindowPosZOrder.HWND_TOPMOST, 0, 0, 0, 0, SetWindowPosFlag.SWP_NOSIZE + SetWindowPosFlag.SWP_NOMOVE)
End Sub
Public Function SetWindowNotOnTopMost(ByVal hwnd As IntPtr) As Integer
Return SetWindowPos(hwnd, SetWindowPosZOrder.HWND_NOTOPMOST, 0, 0, 0, 0, SetWindowPosFlag.SWP_NOSIZE + SetWindowPosFlag.SWP_NOMOVE)
End Function
Friend Function GetWindowHandle(ByVal frmForm As Form) As IntPtr
frmForm.Capture = True
Dim hwnd As IntPtr = GetCapture()
frmForm.Capture = False
Return hwnd
End Function
Friend Function GetWindowHandle(ByVal strWindowTitle As String) As IntPtr
Return FindWindow(vbNullString, strWindowTitle)
End Function
Friend Sub MakeNotFullScreen(ByVal frmX As Form)
MakeNotFullScreen(GetWindowHandle(frmX))
End Sub
Friend Sub MakeNotFullScreen(ByVal hwnd As IntPtr)
Try
SHFullScreen(hwnd, SHFS_SHOWSTARTICON)
SHFullScreen(hwnd, SHFS_SHOWTASKBAR)
SHFullScreen(hwnd, SHFS_SHOWSIPBUTTON)
Catch ex As Exception
End Try
End Sub
Friend Sub MakeFullScreen(ByVal frmX As Form, ByVal blnShowSip As Boolean, ByVal blnShowTaskBar As Boolean)
MakeFullScreen(GetWindowHandle(frmX), blnShowSip, blnShowTaskBar)
End Sub
Friend Sub MakeFullScreen(ByVal hwnd As IntPtr, ByVal blnShowSip As Boolean, ByVal blnShowTaskBar As Boolean)
Try
SHFullScreen(hwnd, SHFS_HIDESTARTICON)
If blnShowSip Then
SHFullScreen(hwnd, SHFS_SHOWSIPBUTTON)
Else
SHFullScreen(hwnd, SHFS_HIDESIPBUTTON)
End If
If blnShowTaskBar Then
SHFullScreen(hwnd, SHFS_SHOWTASKBAR)
Else
SHFullScreen(hwnd, SHFS_HIDETASKBAR)
End If
Catch ex As Exception
'
End Try
Application.DoEvents()
End Sub
Public Sub BringWindowtoFront(ByVal hwnd As IntPtr)
Try
SetForegroundWindow(hwnd)
Catch ex As Exception
End Try
End Sub
Public Sub Window_Show(ByVal hWnd As IntPtr)
Try
Call ShowWindow(hWnd, WindowVisibleFlag.SW_SHOW)
Catch ex As Exception
End Try
End Sub
Public Sub Window_Hide(ByVal hWnd As IntPtr)
Try
Call ShowWindow(hWnd, WindowVisibleFlag.SW_HIDE)
Catch ex As Exception
End Try
End Sub
Public Function GetParentWindow(ByVal strWinTitle As String) As String
Dim strText As String
Try
Dim hwnD As IntPtr = GetWindowHandle(strWinTitle)
Dim hwnF As IntPtr = GetWindowHandle("Phone")
'MsgBox(strWinTitle & ":" & hwnD.ToString)
Dim hwnP As IntPtr = GetParent(hwnD)
strText = GetTextOfWindow(hwnP)
'MsgBox(strText & ":" & hwnP.ToString)
Dim hwnP2 As IntPtr = GetParent(hwnP)
Dim strText2 As String = GetTextOfWindow(hwnP2)
MsgBox(strWinTitle & ":" & hwnD.ToString & vbCrLf & strText & ":" & hwnP.ToString & vbCrLf & strText2 & ":" & hwnP2.ToString & vbCrLf & "Fone:" & ":" & hwnF.ToString)
'Dim intTextLen As Int32 = GetWindowTextLength(hwnFG) + 1
'strText = Space(intTextLen)
'GetWindowText(hwnFG, strText, intTextLen)
'strText = Mid(strText, 1, intTextLen - 1)
Catch ex As Exception
strText = ""
End Try
Return strText
End Function
Public Function GetTextOfWindow(ByVal hwnd As IntPtr) As String
Dim strText As String
Try
Dim intTextLen As Int32 = GetWindowTextLength(hwnd) + 1
strText = Space(intTextLen)
GetWindowText(hwnd, strText, intTextLen)
strText = Mid(strText, 1, intTextLen - 1)
Catch ex As Exception
strText = ""
End Try
Return strText
End Function
Public Function GetForegroundWindowText() As String
Dim strText As String
Try
Dim hwnFG As IntPtr
hwnFG = GetForegroundWindow()
strText = GetTextOfWindow(hwnFG)
Catch ex As Exception
strText = ""
End Try
Return strText
End Function
Public Function GetFormHandle(ByVal frmToGet As System.Windows.Forms.Form) As IntPtr
Dim ipHandle As IntPtr
Try
frmToGet.Capture = True
ipHandle = GetCapture()
frmToGet.Capture = False
Catch ex As Exception
ipHandle = Nothing
ipHandle = New IntPtr(0)
End Try
Return ipHandle
End Function
Public Sub ShowFullScreen(ByVal frmToBringToFront As System.Windows.Forms.Form)
Try
Dim ipForm As IntPtr = GetFormHandle(frmToBringToFront)
Dim intval As Integer = SetForegroundWindow(ipForm)
SHFullScreen(ipForm, SHFS_HIDETASKBAR)
SHFullScreen(ipForm, SHFS_HIDESIPBUTTON)
SHFullScreen(ipForm, SHFS_HIDESTARTICON)
frmToBringToFront.Refresh()
Catch ex As Exception
'
MsgBox(ex.ToString)
End Try
End Sub
A. Dachauer
hi,
there is no more details that this, it is pretty simple.
you can hide the bar at the bottom, which contains the "new" button, by removing the mainmenu1 control found by default in any new form.
you can hide the bar at the top, which contains the start menu button, by changing the WindowState property of the form to Maximized.
this is using vs.net 2005, cf.net 2.0 application.
jazo ichikawa
Learning VB
Hello,
I set the form as maximized but nothing changes..The user can access the taskbar..I think I misunderstood you.
may you explain in more details if possible
Thanks.