嵌入式下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)
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)
相关文章推荐
- 2哥学Vb.net--VBS 操作VB.net dll
- 在asp.net(vb)中,应用ajaxpro.dll操作Session出现错误的解决方法
- vb.net的多窗体操作
- VB.NET下窗体继承的简单操作方法
- VB.net——窗体相互操作的问题解决
- VB.NET窗体操作技巧两则
- 自己写的文件操作的function和Sub vb.net dll
- WINCE中dll的使用(VB.net)操作另一个窗口句柄
- 学习心得之-----VB.NET 的自定义带窗体的DLL文件
- 自己写的文件操作的function和Sub vb.net dll
- VB.NET窗体操作技巧两则
- VB.NET操作WORD(VBA)
- 可用在Excel、Access、WinWord、VB.NET的通用条形码控件TBarCode ActiveX/DLL
- vb.net操作Excel表格类
- VB.NET窗体继承
- 一个数据库操作的类.0.1 (vb.net)
- 图片批量缩略图组件(dll),支持asp,asp.net,vb,vb.net等调用
- vb.net对excel的操作------感谢:就爱小毛虫
- Henry的VB.NET之旅(一)—失踪的窗体
- VB.NET(2005)中关于dll调用的错误信息(转)