Home All Groups Group Topic Archive Search About

LockWindowUpdate VB 2005

Author
26 May 2006 12:25 PM
Paul Remblance
I have just converted a project from VB 2003 to VB 2005 and the
LockWindowUpdate no longer works!

    Friend Declare Function LockWindowUpdate Lib "user32.dll" (ByVal
hWndLock As Long) As Boolean
        LockWindowUpdate(Me.Handle.ToInt32)
        LockWindowUpdate(0)

Any other ideas how to lock the window in VB 2005?

I have a tab control where I need to 'flick' between tabs in the background.
Seeing each page flash as it goes through is annoying.
Tried: SuspendLayout() with the form and tab control which didn't work.

Author
26 May 2006 12:34 PM
Herfried K. Wagner [MVP]
"Paul Remblance" <p***@remblance.co.uk> schrieb:
>I have just converted a project from VB 2003 to VB 2005 and the
>LockWindowUpdate no longer works!
>
>    Friend Declare Function LockWindowUpdate Lib "user32.dll" (ByVal
> hWndLock As Long) As Boolean
>        LockWindowUpdate(Me.Handle.ToInt32)
>        LockWindowUpdate(0)
>
> Any other ideas how to lock the window in VB 2005?

\\\
Private Declare Function LockWindowUpdate Lib "user32.dll" ( _
    ByVal hWndLock As IntPtr _
) As Boolean
....
LockWindowUpdate(Me.Handle)
///

Note that 'Long' is a 64-bit type in VB.NET opposed to VB6 where it was a
32-bit type.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
26 May 2006 1:28 PM
Paul Remblance
Show quote Hide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:ONvz3CMgGHA.4304@TK2MSFTNGP05.phx.gbl...
> "Paul Remblance" <p***@remblance.co.uk> schrieb:
>>I have just converted a project from VB 2003 to VB 2005 and the
>>LockWindowUpdate no longer works!
>>
>>    Friend Declare Function LockWindowUpdate Lib "user32.dll" (ByVal
>> hWndLock As Long) As Boolean
>>        LockWindowUpdate(Me.Handle.ToInt32)
>>        LockWindowUpdate(0)
>>
>> Any other ideas how to lock the window in VB 2005?
>
> \\\
> Private Declare Function LockWindowUpdate Lib "user32.dll" ( _
>    ByVal hWndLock As IntPtr _
> ) As Boolean
> ...
> LockWindowUpdate(Me.Handle)
> ///
>
> Note that 'Long' is a 64-bit type in VB.NET opposed to VB6 where it was a
> 32-bit type.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>

Many thanks, reached the same conclusion (but a bit slower!)

  Friend Declare Function LockWindowUpdate Lib "user32.dll" (ByVal
    Friend Declare Function LockWindowUpdate Lib "user32.dll" (ByVal
hWndLock As IntPtr) As Boolean
        LockWindowUpdate(Me.Handle.ToInt64)
        LockWindowUpdate(0)

hWndLock As Long  to  hWndLock As IntPtr
Me.Handle.ToInt32  to  Me.Handle.ToInt64

Also tried your LockWindowUpdate(Me.Handle) which also worked.
Author
26 May 2006 6:39 PM
Herfried K. Wagner [MVP]
"Paul Remblance" <p***@remblance.co.uk> schrieb:
> Many thanks, reached the same conclusion (but a bit slower!)
>
>  Friend Declare Function LockWindowUpdate Lib "user32.dll" (ByVal
>    Friend Declare Function LockWindowUpdate Lib "user32.dll" (ByVal
> hWndLock As IntPtr) As Boolean
>        LockWindowUpdate(Me.Handle.ToInt64)
>        LockWindowUpdate(0)
>
> hWndLock As Long  to  hWndLock As IntPtr
> Me.Handle.ToInt32  to  Me.Handle.ToInt64

You do not need 'Me.Handle.ToInt62'.  Handles are 32-bit on 32-bit systems
and 64-bit on 64-bit systems, which is what 'IntPtr' is designed for.  So I
strongly recommend to use the solution I posted!

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>