Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Transpanrent Owner Draw Button Collapse All
Subject Author Date
Simon Chung Feb 6, 2004 - 7:32 PM

Is it possible to make transpanrent owner draw button using the CExtButton control?


Thanks.

Sergiy Lavrynenko Feb 7, 2004 - 8:40 AM

Dear Simon,

CExtButton is designed to be used with push-buttons. It is not based on the owner drawing. It even removes the style BS_OWNERDRAW during the window subclassing. Of course, it is possible to repaint it completely by overriding the _RenderImpl() virtual method. You cannot make it transparent directly, but you can fake transparency by invoking the window procedure of the parent window with specifying WM_PAI NT and WM_ERASEBRGND as the message numbers.

If you give me the details of your task, I will help you.

Best regards, Sergiy.

Simon Chung Feb 10, 2004 - 3:35 AM

Thanks for your reply Sergiy.


Actually I would like to create hover buttons with bitmapped image like the MFC CBitmapButton control. The image of the button needs to be changed dynamically.


I tried to use m_extbutton->setBitmap but it didn’t show any image.


Also, because I want to use bitmap, it is necessary to make it transparent.


Thanks again for your help.


 

Technical Support Feb 10, 2004 - 6:48 AM

Dear Simon,

For this purpose, you may use the SetIcon method of the CExtButton class. This method requires an icon handle as its parameter. So, if you need to use a bitmap, convert it to the icon (CExtCmdIcon is quite suitable for this task):

   CExtCmdIcon ico(
      LoadBitmap( AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1) ),
      RGB(255,255,255)
      );
   m_Btn.SetIcon( ico.DetachAsHICON() );


Here is a description of the overloaded version of this method, which may be useful for you (it’s just an excerpt from the Prof-UIS Help also available in the demo version):

SetIcon

Prototype:

void SetIcon( HICON hIconIn, HICON hIconOut = NULL)

Parameters:

HICON hIconIn - Icon descriptor which defines the icon that is displayed when the button gets focus

HICON hIconOut = NULL - Icon descriptor which defines the icon that is displayed when the button loses focus

Description: Assigns (an) icon(s) to the button. The CExtButton class supports up to two icons, which change each other depending on focus. If the hIconOut icon is not defined, the only hIconIn icon is always displayed, regardless whether the control gets or loses focus. If the hIconIn icon is not defined,  the hIconOut icon is displayed only when the button control loses focus.

Example:

...
m_CExtButton.SetIcon(LoadIcon(NULL, MAKEINTRESOURCE(IDC_MYICON)), NULL); 
...