Hi I'm writting a new program which i can run on the back ground but under c ertain conditions i want the program to get focus into the front from homesc reen or what ever its state is. Any idea Thanks.
Public Declare Function FindWindow Lib "coredll.dll" (ByVal className As String, ByVal wndName As String) As IntPtr
is the code and i tried to change the inputs with different stuff butit just doesnt like it. I am not sure what im doing wrong. It is getting frustrating i just cant see an easy method not happing for this. Thanks for the help. IF any idea to make this work i would like some more help. ty
yes, you need to give SHFullScreen the handle of the form you want to manipulate, not intPtr.Zero!
Use me.Handle to get the form handle from within your app. You can also get any window handle with FindWindow(vbNullString, strWindowTitle)
<DllImport("coredll.dll")> _ Private Function FindWindow(ByVal className As String, ByVal wndName As String) As IntPtr End Function
Hope this helps. BTW, Public Declare Function is the VB6 way of declaring a API call, you should really be using P/Invoke, i.e. <DllImport..., although both methods work (I think!)
i used the sound play code which uses the dllimport codes and i did some changes to make your code look like it here is what i have
Public Declare Function SHFullScreen Lib "aygshell.dll" Alias "PlaySound" (ByVal hwndRequester As IntPtr, ByVal dwState As Integer) As Integer
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
and to call the code
sHFullScreen(IntPtr.Zero, SHFS_HIDESTARTICON)
SHFullScreen(IntPtr.Zero, SHFS_SHOWTASKBAR)
SHFullScreen(IntPtr.Zero, SHFS_HIDESIPBUTTON)
But i still get this error : missingmethodexception any ideas
you need this... <DllImport("aygshell.dll")> _ Private Function SHFullScreen(ByVal hwndRequester As IntPtr, ByVal dwState As Integer) As Integer End Function
and a few of these... 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
and one of these 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 End Sub
Focusing on my running program
Najam-x
FindWindow does work!
ancu
Gil Kozlowski
How do i use the p invoke thing you wrote. I think i need that because bringtofront does not work.
giskard73
if 1. then
Use me.BringToFront
else
Use p/Invoke SHFullscreen
endif
horatiu
SHFullScreen(FindWindow(nothing, "MainScreen"), SHFS_HIDESTARTICON)
this is what i did and it just didnt work.
I noticed the findwindow didnt work.
Public Declare Function FindWindow Lib "coredll.dll" (ByVal className As String, ByVal wndName As String) As IntPtris the code and i tried to change the inputs with different stuff butit just doesnt like it. I am not sure what im doing wrong. It is getting frustrating i just cant see an easy method not happing for this. Thanks for the help. IF any idea to make this work i would like some more help. ty
John avis
Use me.Handle to get the form handle from within your app. You can also get any window handle with FindWindow(vbNullString, strWindowTitle)
<DllImport("coredll.dll")> _
Private Function FindWindow(ByVal className As String, ByVal wndName As String) As IntPtr
End Function
Hope this helps. BTW, Public Declare Function is the VB6 way of declaring a API call, you should really be using P/Invoke, i.e. <DllImport..., although both methods work (I think!)
Simon M
i used the sound play code which uses the dllimport codes and i did some changes to make your code look like it here is what i have
Public Declare Function SHFullScreen Lib "aygshell.dll" Alias "PlaySound" (ByVal hwndRequester As IntPtr, ByVal dwState As Integer) As Integer 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 = &H20and to call the code
sHFullScreen(IntPtr.Zero, SHFS_HIDESTARTICON)
SHFullScreen(IntPtr.Zero, SHFS_SHOWTASKBAR)SHFullScreen(IntPtr.Zero, SHFS_HIDESIPBUTTON)
But i still get this error : missingmethodexception any ideas
Mike H726
I don't know how to make that any plainer!
Darshan Pandit
<DllImport("aygshell.dll")> _
Private Function SHFullScreen(ByVal hwndRequester As IntPtr, ByVal dwState As Integer) As Integer
End Function
and a few of these...
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
and one of these
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
End Sub