Problems with SetWindowPos, GetWindowLong (coredll)

J

José Manuel

Hi, I'm trying to translate an application from eVB to Visual Basic .Net
where I have custom keyboards implemented as is described in
http://www.devbuzz.com/content/zinc_evb_skinnable_keyboard_pg1.asp

But I've many problems:

1.- There isn't a Handle propertie for Form class? I can't get it.
Then I use next workaround:

<...>
Public Declare Function FindWindow Lib "Coredll" Alias "FindWindowW" (ByVal
lpClassName As Char(), ByVal lpWindowName As Char()) As IntPtr
<...>
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim nWnd As IntPtr
nWnd = FindWindow(Nothing, Me.Text)
<...>
This seems return the window handle
2.- When I've got the Form handle I call "SetWindowPos" but it raises an
exception:
Public Declare Function mdiSetWindowPos Lib "Coredll" Alias "SetWindowPos" _
(ByVal hwnd As IntPtr, ByVal hWndInsertAfter As Long, ByVal X As Long,
ByVal Y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Boolean
Public Const mdiHWND_NOTOPMOST = -2
Public Const mdiSWP_NOACTIVATE = &H10
Public Const mdiSWP_NOSIZE = &H1
Public Const mdiSWP_NOMOVE = &H2

<...>

Dim nWnd As IntPtr
nWnd = FindWindow(Nothing, Me.Text)

mdiSetWindowPos(nWnd, mdiHWND_NOTOPMOST, 0, 0, 0, 0, mdiSWP_NOMOVE Or
mdiSWP_NOSIZE Or mdiSWP_NOACTIVATE)
' Here I get Unrecognized exception

============================================================================
==========================

Can I use this external functions with Visual Basic .Net?
If yes, what is wrong in my code?

Tanks a lot in advance.
 
A

Alex Feinman [MVP]

You problem is in using Long type. Replace it with Int32
In general you would find it much easier to do interop if you use free
OpenNETCF library which already had definitions for many Windows API
functions (http://www.opennetcf.org)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top