Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How can I change button shape at run time ?

Posted on 2008-06-18
3
Medium Priority
?
427 Views
Last Modified: 2013-11-25
how can u change button shape at run time in VC ++ ?
0
Comment
Question by:ajaygoel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
Norbert earned 200 total points
ID: 21814198
Create new class, Inherit from CButton
class CMyButton:public CButton)
{
public:
    virtual void DrawItem(  LPDRAWITEMSTRUCT lpDrawItemStruct );

    virtual BOOL Create(  LPCTSTR lpszCaption,  DWORD dwStyle,  const RECT& rect,  CWnd* pParentWnd,   UINT nID );

};
BOOL CMyButton::Create(  LPCTSTR lpszCaption,  DWORD dwStyle,  const RECT& rect,  CWnd* pParentWnd,   UINT nID )
{
    DWStyle|=BS_OWNERDRAW;
    CButton::CreatelpszCaption,dwStyle,Rect,ParentWnd,nID);
}
void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// Do your Drawing.
//have a look to online help Function DrawItem for more details
}
0
 
LVL 5

Expert Comment

by:isprabu
ID: 22313319
ajaygoel,
You can easily change the size and/or position of a Button (for that matter any window control) at runtime.
This is true in case of  Window components that inherit from CWnd. CButton is one of them. You can just call MoveWindow() method. An that's it!
See my example code below: (in the parent window/dialog)

Try this and see for yourself!
	CRect rect(10,180,130,210); // left, top, right, bottom
         // m_Button1 is of type CButton
	m_Button1.MoveWindow((LPCRECT) &rect, TRUE);

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question