ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform leaving a trail (https://www.excelbanter.com/excel-programming/428536-userform-leaving-trail.html)

Brett

Userform leaving a trail
 
I had some trouble with moving a userform around and using screenupdating =
false because the userform left a trail behind. So, I change the code to:
UF0_QCP.Hide: Sleep 200

where UF0_QCP is the userform. Now, it doesn't leave a trail, but the UF
stays in the old spot with a completely white background whilst
simultaneously displaying properly in the new spot (better, but still not
professional).

I'm sure that someone out there has a tachnique that they's love to share
with me (please). Regards, Brett

RB Smissaert

Userform leaving a trail
 
Simplest is to set Application.ScreenUpdating = True and only set it to
False when it really is needed.
You could otherwise use the Windows API to solve this, but that will get a
bit complex.

The other option is to show the form modeless:

Load UserForm1
UserForm1.Show vbModeless

but that may not suit your particular situation.

RBS


"Brett" wrote in message
...
I had some trouble with moving a userform around and using screenupdating =
false because the userform left a trail behind. So, I change the code to:
UF0_QCP.Hide: Sleep 200

where UF0_QCP is the userform. Now, it doesn't leave a trail, but the UF
stays in the old spot with a completely white background whilst
simultaneously displaying properly in the new spot (better, but still not
professional).

I'm sure that someone out there has a tachnique that they's love to share
with me (please). Regards, Brett



Mike H

Userform leaving a trail
 
Hi,

You'll encounter this with screen updating set to false. Set updatting to
true.

Mike

"Brett" wrote:

I had some trouble with moving a userform around and using screenupdating =
false because the userform left a trail behind. So, I change the code to:
UF0_QCP.Hide: Sleep 200

where UF0_QCP is the userform. Now, it doesn't leave a trail, but the UF
stays in the old spot with a completely white background whilst
simultaneously displaying properly in the new spot (better, but still not
professional).

I'm sure that someone out there has a tachnique that they's love to share
with me (please). Regards, Brett


Brett

Userform leaving a trail
 
Thanks for your response. There's no chance that I can load it modeless on a
few different fronts, and in enough sections it jumps around a few books and
sheets so scr.upd is pretty much essential so...............how complex is
complex using the API? No time like the present (eh?). Brett.

"RB Smissaert" wrote:

Simplest is to set Application.ScreenUpdating = True and only set it to
False when it really is needed.
You could otherwise use the Windows API to solve this, but that will get a
bit complex.

The other option is to show the form modeless:

Load UserForm1
UserForm1.Show vbModeless

but that may not suit your particular situation.

RBS


"Brett" wrote in message
...
I had some trouble with moving a userform around and using screenupdating =
false because the userform left a trail behind. So, I change the code to:
UF0_QCP.Hide: Sleep 200

where UF0_QCP is the userform. Now, it doesn't leave a trail, but the UF
stays in the old spot with a completely white background whilst
simultaneously displaying properly in the new spot (better, but still not
professional).

I'm sure that someone out there has a tachnique that they's love to share
with me (please). Regards, Brett




Brett

Userform leaving a trail
 
Hi again Mike, no chance I'm afraid - it's a case of stop it or you'll go
blind. I'm interested to see what RBS has to say about using the API. Brett

"Mike H" wrote:

Hi,

You'll encounter this with screen updating set to false. Set updatting to
true.

Mike

"Brett" wrote:

I had some trouble with moving a userform around and using screenupdating =
false because the userform left a trail behind. So, I change the code to:
UF0_QCP.Hide: Sleep 200

where UF0_QCP is the userform. Now, it doesn't leave a trail, but the UF
stays in the old spot with a completely white background whilst
simultaneously displaying properly in the new spot (better, but still not
professional).

I'm sure that someone out there has a tachnique that they's love to share
with me (please). Regards, Brett


Harald Staff[_2_]

Userform leaving a trail
 
Put

DoEvents

in your code so that it happens at least every three seconds. It means "take
a short break and listen to the operating system". Allowing windows to
reposition, your orders to interrupt the running code, occational emails to
be delivered, ... Yes it slows down the code, but makes it far less annoying
as a user experience.

HTH. Best wishes Harald


"Brett" wrote in message
...
I had some trouble with moving a userform around and using screenupdating =
false because the userform left a trail behind. So, I change the code to:
UF0_QCP.Hide: Sleep 200

where UF0_QCP is the userform. Now, it doesn't leave a trail, but the UF
stays in the old spot with a completely white background whilst
simultaneously displaying properly in the new spot (better, but still not
professional).

I'm sure that someone out there has a tachnique that they's love to share
with me (please). Regards, Brett



RB Smissaert

Userform leaving a trail
 
Here is one way without any API.
It is not perfect, but is a starting point.

In the UserForm module:
---------------------------

Option Explicit
Private lTop As Long
Private lLeft As Long

Private Sub CommandButton1_Click()
RunLoop
End Sub

Private Sub UserForm_Layout()

If CLng(UserForm1.Top) < lTop Or _
CLng(UserForm1.Left) < lLeft Then
lTop = UserForm1.Top
lLeft = UserForm1.Left
Application.ScreenUpdating = True
Application.ScreenUpdating = False
End If

End Sub

In a normal module:
-----------------------

Option Explicit

Sub StartForm()

Application.ScreenUpdating = False

Load UserForm1
UserForm1.Show vbModal

End Sub

Sub RunLoop()

Dim i As Long

For i = 0 To 100000000
If i Mod 1000000 = 0 Then
DoEvents
End If
Next i

MsgBox "finished loop"

End Sub



RBS




"Brett" wrote in message
...
Thanks for your response. There's no chance that I can load it modeless on
a
few different fronts, and in enough sections it jumps around a few books
and
sheets so scr.upd is pretty much essential so...............how complex is
complex using the API? No time like the present (eh?). Brett.

"RB Smissaert" wrote:

Simplest is to set Application.ScreenUpdating = True and only set it to
False when it really is needed.
You could otherwise use the Windows API to solve this, but that will get
a
bit complex.

The other option is to show the form modeless:

Load UserForm1
UserForm1.Show vbModeless

but that may not suit your particular situation.

RBS


"Brett" wrote in message
...
I had some trouble with moving a userform around and using
screenupdating =
false because the userform left a trail behind. So, I change the code
to:
UF0_QCP.Hide: Sleep 200

where UF0_QCP is the userform. Now, it doesn't leave a trail, but the
UF
stays in the old spot with a completely white background whilst
simultaneously displaying properly in the new spot (better, but still
not
professional).

I'm sure that someone out there has a tachnique that they's love to
share
with me (please). Regards, Brett





Brett

Userform leaving a trail
 
Hi Harald, thank you for that. A quick question (with time zones in mind -
I'm in Oz) before I try some fooling around with that: Should the DoEvents go
just before or just after I'm hiding the UF? How do I get DoEvents to fire
every 3 (or whatever) seconds?

"Harald Staff" wrote:

Put

DoEvents

in your code so that it happens at least every three seconds. It means "take
a short break and listen to the operating system". Allowing windows to
reposition, your orders to interrupt the running code, occational emails to
be delivered, ... Yes it slows down the code, but makes it far less annoying
as a user experience.

HTH. Best wishes Harald


"Brett" wrote in message
...
I had some trouble with moving a userform around and using screenupdating =
false because the userform left a trail behind. So, I change the code to:
UF0_QCP.Hide: Sleep 200

where UF0_QCP is the userform. Now, it doesn't leave a trail, but the UF
stays in the old spot with a completely white background whilst
simultaneously displaying properly in the new spot (better, but still not
professional).

I'm sure that someone out there has a tachnique that they's love to share
with me (please). Regards, Brett





All times are GMT +1. The time now is 10:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com