Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2348
  • Last Modified:

width and scalewidth



Hi,

I am implementing scrollbars for a picturebox and I would like to know the difference between width and scalewidth.

Is scalewidth always smaller than width?

Also, on the picturebox property. The value for width and scalewidth is in pixels or twips?

Thanks
0
TungVan
Asked:
TungVan
  • 6
  • 5
  • 4
  • +5
4 Solutions
 
dambuster99Commented:
Hi,

Scalewidth relates to the size of your form / screen and as such the size will depend on how you set it.
Width is a fixed value


Steve
0
 
pjcrooks2000Commented:
The value is set in Twips not pixels


:)
0
 
ShauliCommented:
Width is from edge to edge, including frames, thickness of borders etcc. Scalewidth is just the interior measurement. So, yes, scalewidth will always ne smaller than width of the same object.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbceide/htm/proprts_225.asp

S
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Carl TawnSystems and Integration DeveloperCommented:
ScaleWidth refers to the Client-Area of your form (i.e. the bits you can draw stuff on) and the Width refers to the total Width of the form.

i.e.

    If you have a form that is 500px wide and you have a 100px wide toolbar docked to its right-hand side, then you have a "Width" of 500px but a "ScaleWidth" of only 400px, because the Toolbar is not part of the Client-Area.

Hope this helps.
0
 
TungVanAuthor Commented:

I have the a mdi form, and on the form, I have a picturebox.

1 picturebox is 1 children map for my program.

The mdi form has scalewidth and scaleheight property AND the picturebox also has scalewidth and scaleheight property

What is the difference between mdi form/picturebox scalewidth and scaleheight property?

0
 
Carl TawnSystems and Integration DeveloperCommented:
Nothing, they both mean the same thing. They both represent the internal measurements of they're respective objects.
0
 
ShauliCommented:
If the picturebox is put directly on the mdi form then it is stretched, thus the scalewidth of the mdi form and the picturebox are the same. Do a simple test. Put a command button on the picture box and run the code below:

Private Sub Command1_Click()
MsgBox "Form: " & Me.Width & " \ " & Me.ScaleWidth & "     " & "Picturebox: " & Picture1.Width & " \ " & Picture1.ScaleWidth
End Sub


S
0
 
TungVanAuthor Commented:

I have different value for form and picturebox...
0
 
TungVanAuthor Commented:

I saw a code example:

Dim window_style As Long

window_style = GetWindowLong(picLayout.hWnd, GWL_STYLE)
window_style = window_style
SetWindowLong picLayout.hWnd, GWL_STYLE, window_style
SetWindowPos picLayout.hWnd, hWnd, 0, 0, 30000, 30000, SWP_NOZORDER Or SWP_NOMOVE Or SWP_DRAWFRAME



Does it size the the picturebox to 30000 X 30000?

And it is in twips?
0
 
fds_fatboyCommented:
>>If the picturebox is put directly on the mdi form then it is stretched, thus the scalewidth of the mdi form and the picturebox are the same. Do a simple test. Put a command button on the picture box and run the code below:

Not necessarily:
If the picturebox has no border and the scalemode of the picturebox is set to vbTwips, the above statement will be true.

If the picturebox has a border, its scalewidth will be the picturebox's width (the MDI form's Scalewidth) minus the width of its 2 vertical borders, expressed in its scalemode units.
0
 
ShauliCommented:
That is because the picture box is aligned left or right, and not top or bottom. Again, ScaleWidth is the interior width of an object. So, in the case the picture box is align top or bottom, then the scalewidth of the mdi and the picture box would be the same. In the case where the picture box is align right or left, then of course the scalewidth of the picture box would be smaller.

mdi form
<                                             width                                                                >
_____________________________________________________________________
|<                       ScaleWidth                                                                           >|
|                                                                                                                       |
| __picturbox____________                                                                                |
||                                    |                                                                                |
||< scalewidth                >|
|______________________|
<        Width                     >

S

0
 
Thibault St john Cholmondeley-ffeatherstonehaugh the 2ndCommented:
As dambuster99 said, scalewidth depends on how you set it.
The default value is the size of the object minus its borders, but you can set the scalewidth to be something more useful to you, such as 100. When you place another object, a point or a line for instance inside the box, if you set its left=50 it will be placed starting half way across the box.

Handy for drawing graphs as you can set your own scales.

The width property of the box depends on the scalewidth of the form it is placed on.


0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Good grief people...

There is no correlation between smaller/bigger with respect to Width and ScaleWidth in a PictureBox.  You cannot say that ScaleWidth will always be bigger or smaller than the Width.

The responses so far have been only partially correct in stating that the ScaleWidth is the interior size of the PictureBox.  In fact, the term "size" is a bad choice and causes much confusion.  It is not the interior size, but the CUSTOM interior SCALE that you are specify with ScaleWidth().  The ScaleWidth has nothing to do with the physical size of the PictureBox.  If you change the ScaleWidth it will in no way affect the external Width of your PictureBox!

So what exactly does it mean to specify an internal scale for a PictureBox?  What you are defining is the number of LOGICAL units to divide the PictureBox into.  Let's say that you specify a ScaleWidth of 100.  If you then draw something at the X coordinate of 50, it will appear halfway across the PictureBox.  It doesn't matter then if your PictureBox is 25 pixels wide or 25,000 pixels wide...if the ScaleWidth is 100 and you draw at 50 then it will still appear halfway across the PictureBox!

Hope this clears things up a bit...

~IM
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Sorry RobinD, I didn't refresh before submitting my post...

Glad to see we agree!

=)
0
 
Thibault St john Cholmondeley-ffeatherstonehaugh the 2ndCommented:
We even agree on 50 being half of 100 :7)
0
 
ShauliCommented:
Actually, Idle_Mind, the difference between width and scalewidth (in addition to the most important one - that is the interior vs. exterior), is that width (for rorms) is always in twips, while for scalewidth it can be changed. BUT, they both for the same purpose, one for external and one for internal. As in MSDN:


Use the Height, Width, Left, and Top properties for operations or calculations based on an object's total area, such as sizing or moving the object. Use the ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth properties for operations or calculations based on an object's internal area, such as drawing or moving objects within another object.

S
0
 
TungVanAuthor Commented:


I have vertical and horizontal scrollbars on my picturebox. When I move the scrollbar, how do i know the value of the HScroll.value is in pixels or twips?


0
 
TungVanAuthor Commented:

I use scalewidth and scaleheight to calculate the position of my scrollbars when i move it...


Private Sub scrVert_Scroll()
   
    If scrVert.value <> 0 Then
        Me.picLayout.Top = 0 - scrVert.value
    Else
        Me.picLayout.Top = 0
    End If
   
    Call RedrawScrollBar(scrHorz.value, scrVert.value)
   
End Sub

Public Sub RedrawScrollBar(ByVal Hval As Integer, ByVal Vval As Integer)

    'vertical
    Me.scrVert.Top = 0 + Vval
    Me.scrVert.Left = Me.ScaleWidth - Me.scrVert.Width + Hval
    Me.scrVert.Height = Me.ScaleHeight - Me.scrHorz.Height
   
    'horizontal
    Me.scrHorz.Top = Me.ScaleHeight - Me.scrHorz.Height + Vval
    Me.scrHorz.Left = 0 + Hval
    Me.scrHorz.Width = Me.ScaleWidth - Me.scrVert.Width

End Sub



------------------------------------------------------------------------------------------------------

Me.ScaleWidth is the scalewidth of the form.

But i don't know if i should use Me.picLayout.ScaleWidth of Me.ScaleWidth to calculate the new position of scrollbars...
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Alright...I better clarify my statements:

If the ScaleMode is set to "0 - User", then there is no correlation between the value returned from ScaleWidth and Width.  If you change the ScaleWidth (either at run-time or design-time, then the ScaleMode will be changed to 0 (zero) automatically).

Even if your ScaleMode is not zero (let's say you leave it in Twips), ScaledWidth is still not always smaller than Width.  It is then a reflection of how much internal space you have.  If you have PictureBox with a border and 3D appearance turned on, then yes, ScaleWidth will be smaller than Width.  If you turn off the border and make the PictureBox flat then ScaleWidth and Width will be the same.
0
 
ShauliCommented:
TungVan:
That depend on the picturebox ScaleMode. You can set it at desing time and at run time.

Idle,
With that I totally agree.

S
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
TungVan,

To answer your question I think we would need to have a better understand of what your app is doing and how you want the PictureBox to react when the ScrollBars are moved.

What should happen to the PictureBox with respect to the MDI Form?

Describe in more detail the layout of your app and what it does...
0
 
TungVanAuthor Commented:
My program looks like Paint program of Windows, except that it is a MDI version.

Like Paint, in each of my child windows, I have the picturebox to draw or drop objects on the picturebox. And also, it has scrollbars...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 5
  • 4
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now