Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to make API call to freeze excel window?


Hi,

Does anyone know how to freeze the active window using windows API?

I tried this:

Class named FreezeWindow:

Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal ClassName As String, ByVal WindowName As String) As Long

Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWndLock As Long) As Long


Public Sub Freeze(Window As Window)

Dim hWnd As Long

hWnd = FindWindow("XLMAIN", Application.Caption)

End Sub

Public Sub Unfreeze()

LockWindowUpdate 0

End Sub

Private Sub Class_Terminate()

Unfreeze

End Sub

and in the macro:

dim FreezeWnd as New FreezeWindow

FreezeWnd.Freeze ActiveWindow

FreezeWnd.Unfreeze


I can't get it to work, don't know what's wrong (still learning VBA).

Thanks in advance
Mik

--
Mikeyhen
-----------------------------------------------------------------------
Mikeyhend's Profile: http://www.excelforum.com/member.php...fo&userid=3340
View this thread: http://www.excelforum.com/showthread.php?threadid=56442

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to make API call to freeze excel window?

Your Freeze method does nothing of any value. All it does is find
the hWnd of XLMain, which you can get more simply with
Application.Hwnd.


Try the following to lock the window,

Dim Res As Long
Res = LockWindowUpdate(Application.Hwnd)

and the following to unlock the window

Dim Res As Long
Res = LockWindowUpdate(0&)



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Mikeyhend"
wrote in
message
...

Hi,

Does anyone know how to freeze the active window using windows
API?

I tried this:

Class named FreezeWindow:

Option Explicit

Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" _
(ByVal ClassName As String, ByVal WindowName As String) As Long

Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWndLock As Long) As Long


Public Sub Freeze(Window As Window)

Dim hWnd As Long

hWnd = FindWindow("XLMAIN", Application.Caption)

End Sub

Public Sub Unfreeze()

LockWindowUpdate 0

End Sub

Private Sub Class_Terminate()

Unfreeze

End Sub

and in the macro:

dim FreezeWnd as New FreezeWindow

FreezeWnd.Freeze ActiveWindow

FreezeWnd.Unfreeze


I can't get it to work, don't know what's wrong (still learning
VBA).

Thanks in advance
Mike


--
Mikeyhend
------------------------------------------------------------------------
Mikeyhend's Profile:
http://www.excelforum.com/member.php...o&userid=33400
View this thread:
http://www.excelforum.com/showthread...hreadid=564429



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to make API call to freeze excel window?

If you want to freeze only one Excel window, rather than the
Application window, use code like

Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String)
As Long
Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWndLock As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias
"FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As
String, _
ByVal lpsz2 As String) As Long

Sub Test()
FreezeWindow W:=ActiveWindow
End Sub


Sub FreezeWindow(W As Window)
Dim WindowHWnd As Long
Dim XLHwnd As Long
Dim DeskHwnd As Long
Dim Res As Long
XLHwnd = Application.HWnd
DeskHwnd = FindWindowEx(XLHwnd, 0&, "XLDESK", vbNullString)
WindowHWnd = FindWindowEx(DeskHwnd, 0&, "EXCEL7",
ActiveWindow.Caption)
Res = LockWindowUpdate(WindowHWnd)
End Sub

Sub UnFreezeWindow()
Dim Res As Long
Res = LockWindowUpdate(0&)
End Sub




--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Mikeyhend"
wrote in
message
...

Hi,

Does anyone know how to freeze the active window using windows
API?

I tried this:

Class named FreezeWindow:

Option Explicit

Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" _
(ByVal ClassName As String, ByVal WindowName As String) As Long

Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWndLock As Long) As Long


Public Sub Freeze(Window As Window)

Dim hWnd As Long

hWnd = FindWindow("XLMAIN", Application.Caption)

End Sub

Public Sub Unfreeze()

LockWindowUpdate 0

End Sub

Private Sub Class_Terminate()

Unfreeze

End Sub

and in the macro:

dim FreezeWnd as New FreezeWindow

FreezeWnd.Freeze ActiveWindow

FreezeWnd.Unfreeze


I can't get it to work, don't know what's wrong (still learning
VBA).

Thanks in advance
Mike


--
Mikeyhend
------------------------------------------------------------------------
Mikeyhend's Profile:
http://www.excelforum.com/member.php...o&userid=33400
View this thread:
http://www.excelforum.com/showthread...hreadid=564429



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to make API call to freeze excel window?


WindowHWnd = FindWindowEx(DeskHwnd, 0&, "EXCEL7",
ActiveWindow.Caption)

should be

WindowHWnd = FindWindowEx(DeskHwnd, 0&, "EXCEL7", W.Caption)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Chip Pearson" wrote in message
...
If you want to freeze only one Excel window, rather than the
Application window, use code like

Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String)
As Long
Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWndLock As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias
"FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As
String, _
ByVal lpsz2 As String) As Long

Sub Test()
FreezeWindow W:=ActiveWindow
End Sub


Sub FreezeWindow(W As Window)
Dim WindowHWnd As Long
Dim XLHwnd As Long
Dim DeskHwnd As Long
Dim Res As Long
XLHwnd = Application.HWnd
DeskHwnd = FindWindowEx(XLHwnd, 0&, "XLDESK", vbNullString)
WindowHWnd = FindWindowEx(DeskHwnd, 0&, "EXCEL7",
ActiveWindow.Caption)
Res = LockWindowUpdate(WindowHWnd)
End Sub

Sub UnFreezeWindow()
Dim Res As Long
Res = LockWindowUpdate(0&)
End Sub




--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Mikeyhend"
wrote
in message
...

Hi,

Does anyone know how to freeze the active window using windows
API?

I tried this:

Class named FreezeWindow:

Option Explicit

Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" _
(ByVal ClassName As String, ByVal WindowName As String) As
Long

Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWndLock As Long) As Long


Public Sub Freeze(Window As Window)

Dim hWnd As Long

hWnd = FindWindow("XLMAIN", Application.Caption)

End Sub

Public Sub Unfreeze()

LockWindowUpdate 0

End Sub

Private Sub Class_Terminate()

Unfreeze

End Sub

and in the macro:

dim FreezeWnd as New FreezeWindow

FreezeWnd.Freeze ActiveWindow

FreezeWnd.Unfreeze


I can't get it to work, don't know what's wrong (still
learning VBA).

Thanks in advance
Mike


--
Mikeyhend
------------------------------------------------------------------------
Mikeyhend's Profile:
http://www.excelforum.com/member.php...o&userid=33400
View this thread:
http://www.excelforum.com/showthread...hreadid=564429





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default How to make API call to freeze excel window?

Why not use Application.ScreenUpdating?

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Mikeyhend" wrote in
message ...

Hi,

Does anyone know how to freeze the active window using windows API?

I tried this:

Class named FreezeWindow:

Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal ClassName As String, ByVal WindowName As String) As Long

Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWndLock As Long) As Long


Public Sub Freeze(Window As Window)

Dim hWnd As Long

hWnd = FindWindow("XLMAIN", Application.Caption)

End Sub

Public Sub Unfreeze()

LockWindowUpdate 0

End Sub

Private Sub Class_Terminate()

Unfreeze

End Sub

and in the macro:

dim FreezeWnd as New FreezeWindow

FreezeWnd.Freeze ActiveWindow

FreezeWnd.Unfreeze


I can't get it to work, don't know what's wrong (still learning VBA).

Thanks in advance
Mike


--
Mikeyhend
------------------------------------------------------------------------
Mikeyhend's Profile:
http://www.excelforum.com/member.php...o&userid=33400
View this thread: http://www.excelforum.com/showthread...hreadid=564429





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to make API call to freeze excel window?


Chip,

Thanks, the code works fine,

but doesn't solve my problem.

I was trying to put a combobox in a cell on doubleclick.

In the example code I have, a line to create the combobox click event
is written in the VBE after the combobox is put on the screen.

I needed the code to hide the screen flickering when the VBE is
switched on and back off, but when I put 'unfreezeWindow' line after
the 'CreateEventProc' for the Combobox click event it raises an error.

Is there a solution for this problem?

Thanks
Mike


--
Mikeyhend
------------------------------------------------------------------------
Mikeyhend's Profile: http://www.excelforum.com/member.php...o&userid=33400
View this thread: http://www.excelforum.com/showthread...hreadid=564429

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to make API call to freeze excel window?

You need to lock the VBA Editor's main window, not an Excel
Window object. Try code like the following:

Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" _
(ByVal ClassName As String, ByVal WindowName As String) As
Long
Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWndLock As Long) As Long

Sub TestIt()
Dim VBCodeMod As Object
Dim VBEHwnd As Long
Application.VBE.MainWindow.Visible = False
VBEHwnd = FindWindow("wndclass_desked_gsk", _
Application.VBE.MainWindow.Caption)
If VBEHwnd Then
LockWindowUpdate VBEHwnd
End If
Set VBCodeMod =
ThisWorkbook.VBProject.VBComponents("Sheet1").Code Module
VBCodeMod.InsertLines _
VBCodeMod.CreateEventProc("Click", "CommandButton1") + 1, _
"Msgbox ""OK"""
Application.VBE.MainWindow.Visible = False

LockWindowUpdate (0&)

End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Mikeyhend"
wrote in
message
...

Chip,

Thanks, the code works fine,

but doesn't solve my problem.

I was trying to put a combobox in a cell on doubleclick.

In the example code I have, a line to create the combobox click
event
is written in the VBE after the combobox is put on the screen.

I needed the code to hide the screen flickering when the VBE is
switched on and back off, but when I put 'unfreezeWindow' line
after
the 'CreateEventProc' for the Combobox click event it raises an
error.

Is there a solution for this problem?

Thanks
Mike


--
Mikeyhend
------------------------------------------------------------------------
Mikeyhend's Profile:
http://www.excelforum.com/member.php...o&userid=33400
View this thread:
http://www.excelforum.com/showthread...hreadid=564429



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to make API call to freeze excel window?


Chip,

Thanks, this one does the trick.

Mike


--
Mikeyhend
------------------------------------------------------------------------
Mikeyhend's Profile: http://www.excelforum.com/member.php...o&userid=33400
View this thread: http://www.excelforum.com/showthread...hreadid=564429

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I freeze/ unfreeze a window pane in Excel 2007? Bombarded_avec_change Excel Discussion (Misc queries) 2 July 7th 09 08:12 PM
view excel worksheet & freeze internet window synchronously John H. Herrlinger Excel Worksheet Functions 0 April 26th 09 11:14 AM
Window Tool Bar - Freeze pane does not appear dford Excel Discussion (Misc queries) 2 July 20th 07 04:46 AM
Excel: find Window in which I can freeze panes 4most New Users to Excel 3 July 8th 06 10:55 PM
Excel should allow me to freeze pane in a split window MGB Excel Worksheet Functions 1 March 29th 05 05:50 PM


All times are GMT +1. The time now is 11:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"