Programming - cpueblo.com

[WTL] CBitmapButton 에 비트맵 이미지 지정


글쓴이 : 유광희 날짜 : 2011-01-14 (금) 11:43 조회 : 21873


// 첨부처럼 생긴 붙어 있는 이미지에 Normal/Overlay 를 적용합니다

CImageList *SetBitmapButtonImage(CBitmapButton *Button, WORD Image)
{
	CImageList *il = new CImageList;

	BITMAP bmBG;
	HBITMAP hImageBG = LoadBitmap(hInstance, MAKEINTRESOURCE(Image));
	GetObject(hImageBG, sizeof(bmBG), &bmBG);

	//
	il->CreateFromImage(Image, bmBG.bmWidth / 2, bmBG.bmHeight, CLR_NONE, IMAGE_BITMAP, LR_CREATEDIBSECTION);
	Button->SetImageList(il->m_hImageList);
	Button->SetImages(0, 1);
	DeleteObject(hImageBG);

	return il;
}

// header
BEGIN_DDX_MAP(CInstallPathSelectDialog)
	DDX_CONTROL(IDC_BTN_CLOSE, btnClose);
END_DDX_MAP()

BEGIN_MSG_MAP(CInstallPathSelectDialog)
	COMMAND_HANDLER_EX(IDC_BTN_CLOSE,	BN_CLICKED, OnbtnCloseClick)
END_MSG_MAP()

CBitmapButton btnClose;

// cpp
SetBitmapButtonImage(&btnClose,		IDB_BITMAP_CANCEL);
btnClose.ModifyStyleEx(0, WS_EX_TRANSPARENT);

Downloads


유광희 2011-01-14 (금) 11:46
/*
// 위 이미지 변환 이후에 버튼의 좌표와 SW_SHOW 등도 설정하도록
SetBitmapButtonImage(&btnClose,   IDB_BITMAP_CLOSE,   429, 12, SW_SHOW);
SetBitmapButtonImage(&btnInstall,  IDB_BITMAP_INSTALL,   154, 193, SW_SHOW);
SetBitmapButtonImage(&btnCancel,  IDB_BITMAP_CANCEL,   229, 193, SW_SHOW);
SetBitmapButtonImage(&btnChangeFolder, IDB_BITMAP_CHANGEFOLDER, 360, 93, SW_SHOW);
*/

CImageList *SetBitmapButtonImage(CBitmapButton *Button, WORD Image, int x1, int y1, int ShowMode)
{
	CImageList *il = new CImageList;

	BITMAP bmBG;
	HBITMAP hImageBG = LoadBitmap(hInstance, MAKEINTRESOURCE(Image));
	GetObject(hImageBG, sizeof(bmBG), &bmBG);

	//
	il->CreateFromImage(Image, bmBG.bmWidth / 2, bmBG.bmHeight, CLR_NONE, IMAGE_BITMAP, LR_CREATEDIBSECTION);
	Button->SetImageList(il->m_hImageList);
	Button->SetImages(0, 1);
	Button->ShowWindow(ShowMode);
	Button->MoveWindow(x1, y1, bmBG.bmWidth / 2, bmBG.bmHeight);
	DeleteObject(hImageBG);

	return il;
}

댓글주소