PRB: Picture Property Not Displayed on THREED ButtonLast reviewed: July 22, 1997Article ID: Q119905 |
1.00 1.50
WINDOWS
kbprg kbprb
The information in this article applies to:
The Microsoft Foundation Classes (MFC) included with: - Microsoft Visual C++ for Windows, version 1.0 and 1.5
SYMPTOMSWhen 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.
CAUSEThere are two primary causes for this problem:
RESOLUTIONAlthough 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 INFORMATIONThe 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 reference words: 1.00 1.50 2.00 2.50
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |