PRB: Picture Property Not Displayed on THREED Button

ID: Q119905


The information in this article applies to:


SYMPTOMS

When the function CVBControl::Create() is used to create a Visual Basic custom control (VBX) and a AfxSetPict() is used to set the picture property (as described in MFC Tech Note #27), the picture is not displayed.


CAUSE

There are two primary causes for this problem:


RESOLUTION

Although the control will work properly, you must specify the BS_OWNERDRAW style for your picture to be displayed. For example, the standard styles that would be passed as the dwStyle parameter when calling CVBControl::Create() to create a button are as follows:


MORE INFORMATION

The sample code below shows how you can create a THREED SSCommand button with a displayed picture property.

NOTE: This problem does not occur when the control is created by the dialog manager (that is, using App Studio to place the control on a dialog-box template). The reason for this is that the BS_OWNERDRAW style is included as one of the default initialization parameters in the model style that is included in the DLGINIT resource in the .RC file.

Sample Code


/* Compile options needed: Default AppWizard options
*/ 

   BOOL CAboutDlg::OnInitDialog()
   {
       CDialog::OnInitDialog();
       CVBControl *pControl = new CVBControl();
       pControl->Create( "THREED.VBX; SSCommand; Command3D1",
           WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_OWNERDRAW,
           CRect(10,10,50,50),this,IDC_COMMAND3D1,NULL,TRUE);
       HPIC hPic;
       HBITMAP hBmp = LoadBitmap(AfxGetInstanceHandle(),
           MAKEINTRESOURCE(IDB_BITMAP1));
       PIC picture;
       picture.picData.bmp.hbitmap = hBmp;
       picture.picType = PICTYPE_BITMAP;
       hPic = AfxSetPict( NULL, &picture );
       pControl->SetPictureProperty( "picture", hPic );
       return TRUE;
   } 

Additional query words: 1.00 1.50 2.00 2.50


Keywords          : kb16bitonly 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: July 23, 1999