Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how do i sync two places.sqlite..? Pin
yogish2931-Feb-11 20:17
yogish2931-Feb-11 20:17 
AnswerRe: how do i sync two places.sqlite..? Pin
Niklas L1-Feb-11 21:20
Niklas L1-Feb-11 21:20 
QuestionHow to add a tag like //<AMRIT.AGRAWAL> Added 02/02/2011 on a shortcut key in somewhere in the code Pin
Amrit Agr1-Feb-11 19:37
Amrit Agr1-Feb-11 19:37 
AnswerRe: How to add a tag like // Added 02/02/2011 on a shortcut key in somewhere in the code Pin
_AnsHUMAN_ 1-Feb-11 19:59
_AnsHUMAN_ 1-Feb-11 19:59 
GeneralRe: How to add a tag like // Added 02/02/2011 on a shortcut key in somewhere in the code Pin
Amrit Agr2-Feb-11 16:28
Amrit Agr2-Feb-11 16:28 
GeneralRe: How to add a tag like // Added 02/02/2011 on a shortcut key in somewhere in the code Pin
Stefan_Lang3-Feb-11 7:01
Stefan_Lang3-Feb-11 7:01 
AnswerRe: How to add a tag like // Added 02/02/2011 on a shortcut key in somewhere in the code PinPopular
Stefan_Lang1-Feb-11 22:43
Stefan_Lang1-Feb-11 22:43 
QuestionHow to set Background color, & Icon of CButton & How to use CBitmapButton Pin
pankaj293831-Feb-11 19:08
pankaj293831-Feb-11 19:08 
How to set Background color
Header File "MyButton.h"

#pragma once
#include "afxwin.h"

const COLORREF bkColor= RGB(0,0,0);
//const COLORREF bkColor= RGB(255,255,255);

class CMyButton :
	public CButton
{
public:
	CMyButton(void);
public:
	~CMyButton(void);

protected:
    afx_msg void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);

	DECLARE_MESSAGE_MAP()

};

Cpp File "MyButton.cpp"


#include "StdAfx.h"
#include "MyButton.h"

CMyButton::CMyButton(void)
{
}

CMyButton::~CMyButton(void)
{
}
BEGIN_MESSAGE_MAP(CMyButton, CButton)

	ON_WM_DRAWITEM()
	ON_WM_ERASEBKGND()

END_MESSAGE_MAP()

BOOL CMyButton :: OnEraseBkgnd(CDC* pDC)
{
	CRect rect;
	GetClientRect(rect);
	pDC->FillSolidRect(rect,bkColor);
	return true; 
}

void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {

    //  No Need to write Anything  

}


Now u can use above class in your Dialog As:-

BOOL CChessGameDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon


	// TODO: Add extra initialization here
       
        CMyButton* m_pbtn13 = new CMyButton ();
	m_pbtn13 ->Create(NULL, WS_CHILD | WS_VISIBLE |BS_OWNERDRAW ,CRect(150, 250, 250, 300), this, NZWR_BUTTON_13);


	return TRUE;  // return TRUE  unless you set the focus to a control
}




HOW to set an Icon to CButton

BOOL CChessGameDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon


	// TODO: Add extra initialization here
     
         CButton m_pbtn12 = new CButton ();
	m_pbtn12 ->Create(NULL, WS_CHILD | WS_VISIBLE |BS_ICON ,CRect(150, 50, 250, 200), this, NZWR_BUTTON_12);
	//m_pbtn12->SetBitmap(::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1)) );

if (m_pbtn12->GetIcon() == NULL)
	m_pbtn12->SetIcon(::LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE( IDI_ICON1)));

	return TRUE;  // return TRUE  unless you set the focus to a control
}




How to use CBitmapButton Class

BOOL CChessGameDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon


	// TODO: Add extra initialization here
     
        
	m_pbtn11= new CBitmapButton ();
	m_pbtn11->Create(NULL, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,CRect(50, 50, 200, 200), this, NZWR_BUTTON_11);
	m_pbtn11->LoadBitmaps(IDB_BITMAP2, IDB_BITMAP1, IDB_BITMAP2, IDB_BITMAP1);
	m_pbtn11->SizeToContent();
//	m_pbtn11->SubclassDlgItem(NZWR_BUTTON_11, this);

	return TRUE;  // return TRUE  unless you set the focus to a control
}
/pre;

AnswerRe: How to set Background color, & Icon of CButton & How to use CBitmapButton Pin
Malli_S1-Feb-11 19:56
Malli_S1-Feb-11 19:56 
AnswerRe: How to set Background color, & Icon of CButton & How to use CBitmapButton [modified] Pin
_AnsHUMAN_ 1-Feb-11 19:57
_AnsHUMAN_ 1-Feb-11 19:57 
Questionhow to do function like cout Pin
KARFER1-Feb-11 6:10
KARFER1-Feb-11 6:10 
AnswerRe: how to do function like cout Pin
Richard MacCutchan1-Feb-11 6:16
mveRichard MacCutchan1-Feb-11 6:16 
AnswerRe: how to do function like cout Pin
«_Superman_»1-Feb-11 7:48
professional«_Superman_»1-Feb-11 7:48 
AnswerRe: how to do function like cout Pin
Stefan_Lang1-Feb-11 23:18
Stefan_Lang1-Feb-11 23:18 
QuestionRelease VS Debug compiles Pin
Khan Shere1-Feb-11 3:47
Khan Shere1-Feb-11 3:47 
AnswerRe: Release VS Debug compiles Pin
Chris Losinger1-Feb-11 3:51
professionalChris Losinger1-Feb-11 3:51 
GeneralRe: Release VS Debug compiles Pin
Khan Shere1-Feb-11 3:55
Khan Shere1-Feb-11 3:55 
GeneralRe: Release VS Debug compiles Pin
Richard MacCutchan1-Feb-11 4:21
mveRichard MacCutchan1-Feb-11 4:21 
GeneralRe: Release VS Debug compiles Pin
Khan Shere1-Feb-11 5:01
Khan Shere1-Feb-11 5:01 
GeneralRe: Release VS Debug compiles Pin
Richard MacCutchan1-Feb-11 6:13
mveRichard MacCutchan1-Feb-11 6:13 
AnswerRe: Release VS Debug compiles Pin
Andrew Brock1-Feb-11 4:50
Andrew Brock1-Feb-11 4:50 
GeneralRe: Release VS Debug compiles [modified] Pin
Aescleal1-Feb-11 7:58
Aescleal1-Feb-11 7:58 
AnswerRe: Release VS Debug compiles Pin
User 74293381-Feb-11 10:02
professionalUser 74293381-Feb-11 10:02 
GeneralRe: Release VS Debug compiles Pin
Khan Shere1-Feb-11 20:57
Khan Shere1-Feb-11 20:57 
Questionuse the member pointer via a Get function and allocate memory outside, not clear why in this way Pin
George Nistor1-Feb-11 1:36
George Nistor1-Feb-11 1:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.