FIX: Toolkit 3-D Option & Check Controls Don't Repaint in 3.1

Last reviewed: October 30, 1997
Article ID: Q84475
1.00 2.00 WINDOWS kbprg kbbuglist

The information in this article applies to:

- Professional Edition of Microsoft Visual Basic for Windows, version 2.0 - Microsoft Professional Toolkit for Visual Basic programming system

  for Windows, version 1.0

SYMPTOMS

The 3-D Option Button and 3-D Check Box custom controls in the THREED.VBX file do not paint properly if their Value property is changed while the form is loaded (hidden) before being shown. The caption area appears transparent (not painted) until the user clicks it or until the Value is changed in code after the form is shown. This problem occurs only in Windows version 3.1, not Windows version 3.0.

CAUSE

This problem occurs because of changes in the Windows GDI routines to optimize screen refresh performance. For that reason, Windows version 3.1 eliminates what it considers redundant paints.

WORKAROUND

You can work around this problem by assigning the Caption property of the affected controls to themselves when the form is shown again. This code would be placed after the Form2.Show. For example:

   Form.Control.Caption = Form.Control.Caption

This forces a refresh of the area not being painted. Here are the steps to implement this workaround:

  1. Add the following code to the Command2_Click event:

       Sub Command2_Click ()
          Option3D3.Value=1
          Check3D3.Value=1
          Form2.Show
          Form2.Option3D1.Caption = Form2.Option3D1.Caption
          Form2.Option3D2.Caption = Form2.Option3D2.Caption
          Form2.Option3D3.Caption = Form2.Option3D3.Caption
          Form2.Check3D1.Caption = Form2.Check3D1.Caption
          Form2.Check3D2.Caption = Form2.Check3D2.Caption
          Form2.Check3D3.Caption = Form2.Check3D3.Caption
       End Sub
    
    

  2. Run the program. Change the values by clicking some checks and options.

  3. Click Form2 to hide it.

  4. Click the Second Show and notice that the paint is now handled correctly.

You can also work around this problem by explicitly doing a SetFocus call on the control(s) in question. If you are using control array(s), it should be fairly easy. For example, if you had a five-element control array of Check3D1 check boxes, use this code:

   Sub Form_Paint()
      For a% = 0 to 4
         Check3D1(a%).SetFocus
      Next
   End Sub

RESOLUTION

Sheridan Software, manufacturer of the 3-D Check Box and 3-D Option Button controls, has issued an update to THREED.VBX that corrects the painting problems experienced in Windows version 3.1. To obtain this update, call the Sheridan BBS at (516) 753-5452 (2400 baud) or (516) 753-6510 (9600 baud).

STATUS

Microsoft has confirmed this to be a bug in the products listed above when used in Microsoft Windows version 3.1. This problem was corrected in Microsoft Visual Basic version 3.0 for Windows.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default. Add a second form (Form2).

  2. From the File menu, choose Add File. In the Files box, select the THREED.VBX custom control file. The 3-D tools appear in the Toolbox.

  3. Add the following controls to the forms, and set their properties as indicated:

    Form1:

          Control              Property    Setting
          --------------------------------------------
          Form                 FormName    Form1
          Command button       CtlName     Command1
          Command button       Caption     First Show
          Command button       CtlName     Command2
          Command button       Caption     Second Show
    
       Form2:
    
          Control              Property    Setting
          ------------------------------------------
          Form                 FormName    Form2
          3-D Check box        CtlName     Check3D1
          3-D Check box        CtlName     Check3D2
          3-D Check box        CtlName     Check3D3
          3-D Option button    CtlName     Option3D1
          3-D Option button    CtlName     Option3D2
          3-D Option button    CtlName     Option3D3
    
    

  4. Add the following code to the Command1_Click event procedure for Form1:

       Sub Command1_Click
         Form2.Option3D1.Value=1 ' Set values for first show.
         Form2.Check3D1.Value=1
         Form2.Show
       End Sub
    
    

  5. Add the following code to the Command2_Click event procedure for Form1:

       Sub Command2_Click ()
         Form2.Option3D3.Value=1
         Form2.Check3D3.Value=1
         Form2.Show
       End Sub
    
    

  6. Add the following code to the Form_Click event procedure for Form2:

       Sub Form_Click ()
         Form2.Hide
       End Sub
    
    

  7. Run the program.

When you click the First Show button, the paint occurs properly for all controls, including the controls whose values were changed in code prior to the show. On Form2, click an option box and a check box to change Values.Click on Form2 to hide the form. Click the Second Show button. The controls whose values changed prior to the form being shown are only painted around the area with the check box or option box. The rest of the area is unpainted.

Reference(s):

Sheridan Software Systems, Inc. 65 Maxess Road Melville, NY 11747

Phone: (516) 753-0985 Fax: (516) 293-4155


Additional reference words: buglist1.00 buglist2.00 fixlist3.00 1.00 2.00
3.00 3.10
KBCategory: kbprg kbbuglist
KBSubcategory: PrgCtrlsCus
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.