VB MDI Child Custom Control: ScaleMode Defaults to Twips

ID Number: Q83905

1.00

WINDOWS

Summary:

The MDI Child custom control (MDICHILD.VBX) does not have a ScaleMode

property; therefore, child controls of an MDI Child control will

default to twips, regardless of whether the child control has a

ScaleMode property. To confirm this, you can check the Height and

Width properties of the child controls.

This information applies to Microsoft Professional Toolkit for

Microsoft Visual Basic programming system version 1.0 for Windows.

More Information:

Some controls in Visual Basic version 1.0 have a ScaleMode property

(for example, picture box), while other controls do not (for example,

text boxes, label controls, and command buttons).

A child controls (a control placed within other controls) takes many

of its properties from the parent control. In addition, the default

ScaleMode for Visual Basic 1.0 is twips. Because the MDI Child control

does not have its own ScaleMode property, it takes the default Visual

Basic ScaleMode (twips). As a result, whenever you make a control a

child of an MDI Child control, it uses twips as the ScaleMode for its

dimensions (for example, Height and Width properties). However, if you

place a control on a control that is already a child and whose

ScaleMode is set to pixels, it will use pixels as the default

ScaleMode. The example below illustrates this.

Workaround

----------

A workaround is to place a control that has a ScaleMode property (such

as a picture control) inside the MDI Child custom control, change its

ScaleMode to something else (for example, pixels), then place

subsequent controls inside it rather than in the MDI Child custom

control.

Steps to Reproduce Problem

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

1. Run Visual Basic, or from the File menu, choose New Project (ALT,

F, N) if Visual Basic is already running. Form1 is created by

default.

2. From the File menu, choose Add File. In the Files box, select the

MDICHILD.VBX custom control file. The MDI Child tool appears in the

Toolbox.

3. Place an MDI Child control (MDIChild1) on Form1.

4. Size the MDI control for a larger viewable area.

5. Place a picture control in the MDI control. To do this, click once

on the picture control tool in the Toolbox. Place the mouse

cursor in the MDI control. Notice that the cursor changes to

a cross hair when you move it over Form1. Place the cross hair in

MDIChild1, and size the picture control accordingly.

Notice that the Height and Width properties of MDIChild1 and

Picture1 are in twips.

6. Click on Form1 to give it the focus. Set the ScaleMode property to

3 - Pixel.

Notice that the Height and Width properties of MDIChild1 are now

expressed in pixels, while the Height and Width properties of the

Picture control inside MDIChild1 are still expressed in twips.

If you change the ScaleMode of Picture1 to 3 - Pixel and place a

command button control in Picture1, the Height and Width properties of

Command1 will be expressed in pixels. The workaround above uses this

method to work around the MDI Child control's limitation.

Additional reference words: 1.00 MDIChild MDI Child