PRB: Picture Property Not Displayed on THREED ButtonID: Q119905
|
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.
There are two primary causes for this problem:
Q104642 DOCERR: How to Manage VBX Picture Properties with MFC 2.0
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:
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.
/* 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