Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Are There Certain Rules In Loading And Unload Objects? 4

Status
Not open for further replies.

MrVB50au

Programmer
Mar 16, 2003
326
AU
SCENARIO:

I'm creating some 3D text using Label controls after I had created 2 to 3 word of (eg: 25 deep each) in other words the thickness. My application seems to run a lot slower due to the amount I have per word.

Example:
"The Quick Brown Fox" sentence makes the rest of my canvus really slow to work with until I save it as a picture file and send it to the collection I have on disk as bmp.

After it's saved, it's as if it had been released and everything seems to work smoothly again.

QUESTION:
Is there something that I might be doing wrong when it comes to Loading the labels?

Here's an example of the code I use;
------------------------------------------------------
label1(0).visible = False
For I = 1 to 25
Load Label1(i)
'
'
'
Next i
---------------------------------------------------------

Any suggestions would be greatful,

Thanks in advance.

Andrew.
 
There is a Win32 API you can call (don't remember it right now) that will delay the paint of a form until all your controls have been created. Try doing a search, or look in the FAQs.

When you create the controls one at a time as you're doing, the form repaints after each one, which is very slow. By delaying the paint, you can show them all at once.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
OK thanks, I will try and see if I can find it.
 
strongm
I know this may seem like a silly question but now that I have it, what do I do with it and what does it do?

Thanks,

Andrew.
 
Most standard windows functions are listed and (at least briefly) described in VBHelp. Other potential sources are Google and AllAPI.net.

faq222-2244 gives some guidance on how to do your basic research, especially paragraph 8.

Here is the link to your particular question to get you started:


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Ok, I just found out what LockWindowUpdate does, why would I want to Lock the window while I'm working in it? Wouldn't that prevent me from dragging the 3D Label around on the screen?

Thanks again,

Andrew.

 
Ahhhhh, now I see strongm takes me a little while to cotton onto these things you know........ bit slow LOL

But that's me!

Thanks again guys, you've all been very helpful.

Andrew.

 
The LockWindowUpdate doesn't seem to do anymore than what I'm doing now, unless I'm using it incorrectly, which could be a possibility.

To give a more specific idea what's happen, I have a picture box as my work area. I place Graphics and Label Controls on the Picture Box, I allow the user to create (if they want) 3D Effect on any or all of the Label and Graphics Controls. They can even insert Rotated Text and give them a 3D Effect.

Below is a procedure that I use to create a move for an array of Labels after the user had chosen to use the 3D Effect and moves the word or sentence by holding down the Ctrl key and using the Left Arrow key.
-----------------------------------------------------------
Private Sub Move3DLeft(lbl As Object, HowFast As Integer)
'********************************************************
'THIS PROCEDURE WILL MOVE A BLOCK OF LABELS IN AN ARRAY
'TO THE LEFT IF IT'S COUNT IS GREAT THAN ZERO.
'********************************************************
'
'Check if count is greater than zero first.
If lbl.Count > 0 Then
'
'If count is greater than zero then hide them.
For i = 1 To lbl.Count - 1
lbl(i).Visible = False
Next i
'
'Move them to the left (eg: 50 twips).
For i = 1 To lbl.Count - 1
lbl(i).Left = lbl(i).Left - HowFast
Next i
'
'Show them again after they've been moved.
For i = 1 To lbl.Count - 1
lbl(i).Visible = True
Next i
'
End If
'
End Sub
-----------------------------------------------------------
Is there a way that I can make them visible as one block?

Thanks again,

Andrew.
 
>unless I'm using it incorrectly

You are, trust me

Ok, look. Consider the following:

1) A piece of paper and some crayons
2) A perfect imagination

Also consider that your final presentation needs to be done on paper

Now, let us pretend that you are given a two simple drawing instructions:

1) draw a box filled with the colour red
2) draw a box filled with the colour blue in a different position, and deleting the original red box

Now follow those instructions in:

Scenario 1 (paper and crayons)
Find red crayon
Draw box
Fill it with colour red
Find a crayon same colour as paper
Scribble over box we've just drawn to erase it
Find a blue crayon
Draw a new box in new position
Fill new box with color blue
Finished!

Scenario 2 (imagination)
Imagine a red box
Imagine red box vanished
Imagine blue box
Find crayons to draw what you are imagining
Draw image in imagination
Finished!

Which of these do you think might be quicker?

Scenario 2 is the LockWindowUpdate solution.

Ignoring anyb other drawing you might be doing on a per frame (or clock tick) basis, your Move3Dleft code could be replaced by:
Code:
Private Sub Move3DLeft(lbl As Object, HowFast As Integer)
'********************************************************
'THIS PROCEDURE WILL MOVE A BLOCK OF LABELS IN AN ARRAY
'TO THE LEFT IF IT'S COUNT IS GREAT THAN ZERO.
'********************************************************
    '
    'Check if count is greater than zero first.
    If lbl.Count > 0 Then
        LockWindowUpdate Picture1.hWnd
        For i = 1 To lbl.Count - 1
            lbl(i).Left = lbl(i).Left - HowFast
        Next i
        LockWindowUpdate 0
    End If
End Sub
 
Oh, so that's the way it's done!

Thank you again.

I throught because it had the word Window in it, I thought that I could only use it in forms, I didn't realize that the picturebox had a handle to which can be used.

Thanks again,

Andrew.

 
>the word Window

It is worth remembering that almost every bit of decoration in the Windows interface (capital W), such as a buttons, listboxes, scroll bars, labels, picture boxes, etc., is an example of a window (lower-case w).

Most of the API, when talking about a window, is referring to these lower-case examples...
 
so, correct me if I'm wrong here ok?

Just as long as the control that you are using has a hdc or a hWnd (depending on the function that is being performed) that you can use any API function to manipulate the control or form?

 
Basically, yes. But always check the documentation for the API call. Some of them, for example, are restricted to top-level windows.
 
Top Level Windows? You mean as in the System itself?

Can you suggest any good manuals to buy for API Programming and can a programmer create an application fully depended on API's?

Thanks again,

Andrew.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top