您的位置:首页 > 编程语言 > VB

嵌入式下VB.NET窗体操作 DLL

2009-11-01 16:28 309 查看
SetWindowPos
returns a Boolean value. Also under VB.NET
a Long value is 64 bits and not 32 which was the case in previous versions of VB. This is why you are getting an exception. In VB.NET
Integer is 32 bits, Short is 16 and Byte is 8.

Also check that all the constants you are passing to SetWindowPos
are Integers and not Long values.

I'm also assuming you're trying to initiate fullscreen mode. To do this use the following code (includes p/invoke definitions) :

Imports System.Runtime.InteropServices

<DllImport
("coredll
.dll", EntryPoint:="SetForegroundWindow", SetLastError:=True)> _

Private Function SetForegroundWindow( _

ByVal hwnd As IntPtr) As Boolean

End Function

<DllImport
("coredll
.dll", EntryPoint:="SetWindowPos
", SetLastError:=True)> _

Private Function SetWindowPos
( _

ByVal hwnd As IntPtr, _

ByVal hWndInsertAfter As IntPtr, _

ByVal X As Integer, _

ByVal Y As Integer, _

ByVal cx As Integer, _

ByVal cy As Integer, _

ByVal uFlags As Integer) As Boolean

End Function

<DllImport
("aygshell.dll", EntryPoint:="SHFullScreen", SetLastError:=True)> _

Private Function SHFullScreen( _

ByVal hwndRequester As IntPtr, _

ByVal dwState As Integer) As Boolean

End Function

Private Const SHFS_HIDETASKBAR As Integer = &H2

Private Const SWP_NOZORDER As Integer = &H4

SetForegroundWindow(hwnd)

SHFullScreen(hwnd, SHFS_HIDETASKBAR)

SetWindowPos
(hwnd, IntPtr.Zero, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, SWP_NOZORDER)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: