Hello all,
I've got a question but maybe its just because vb is slow...
-> Q: Is there a way to suppend messages that may hinder the speed of a
section of code?
I have a form with a bunch of labels and textboxes and when the user clicks
a button I re-arange them all to new positions that resemble a new screen
for data entry. However, I'm trying to make it faster because it slugs a
little bit, and practially all I'm doing is positioning and resizing the
controls.
There's 30 Labels Max and 40 Text boxes Max per screen
And they are being repositioned ontop of a user control
Right now I make them all invisible then position them and then go back and
make them visible again. That made things much faster, but it still seems
awfully slow. Is this a vb thing?
I thought of the LockWindowUpdate API but I've experianced flickering when I
use that API for very breif intervals of locking the update and I heard
someplace that It's one of the those "Don't use it, even though its there"
API's..??
I get the impression that paint messages or something are still being
processed because there was not a great difference in speed when I tested it
on a 1.3 GHz XP vs. a Pentuim II Win98SE
Any insight would be very much appriciated,
Thanks,
-Philip
Jakob Bieling - 28 Feb 2004 07:59 GMT
> There's 30 Labels Max and 40 Text boxes Max per screen
> And they are being repositioned ontop of a user control
>
> [..] it still seems
> awfully slow. Is this a vb thing?
No, it's a design thing.
> I get the impression that paint messages or something are still being
> processed because there was not a great difference in speed when I tested it
What you are doing is probably a .Left = x and .Top = y or a single
.Move (x, y) on every single control, correct? Now Windows tries to
immediately move every control when it is requested. That is why it gets
slow. Have a look at the BeginDeferWindowPos, DeferWindowPos and
EndDeferWindowPos API functions. There all windows will be moved at once in
a single screen-refresh.
But since you are circumventing the VB internal positioning functions, I
do not know if VB will be able to handle it, if you later use the VB
positioning functions. Maybe someone else can step in?
--
jb
(replace y with x if you want to reply by e-mail)
J French - 28 Feb 2004 10:58 GMT
>Hello all,
>
[quoted text clipped - 15 lines]
>make them visible again. That made things much faster, but it still seems
>awfully slow. Is this a vb thing?
Have you tried putting them all on a Frame
- making the Frame invisible, shunting stuff, then making it visible
again
BeastFish - 28 Feb 2004 17:44 GMT
You mention they're on a UserControl, I'm assuming its their container. You
can try as Jerry suggested, make the UC invisible before moves then visible
after moves. Do you have your UserControl providing the hWnd property?
Instead of LockWindowUpdate, maybe you can give the DefWindowProc API with
the WM_SETREDRAW message...
(Declarations)
Private Declare Function DefWindowProc Lib "user32" _
Alias "DefWindowProcA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Const WM_SETREDRAW = &HB
(Code)
DefWindowProc MyContainer.hWnd, WM_SETREDRAW, ByVal 0&, ByVal 0&
' Move your stuff here
DefWindowProc MyContainer.hWnd, WM_SETREDRAW, ByVal 1&, ByVal 0&
HTH
> Hello all,
>
[quoted text clipped - 27 lines]
> Thanks,
> -Philip