MFC 이미지 버튼 사용하기 > IT Note

본문 바로가기
사이트 내 전체검색

IT Note

MFC 이미지 버튼 사용하기
0

View 31,808  | 작성일2009.11.19 13:41

본문





다이얼로그->버튼 배치->버튼선택 상태에서 ctrl+w
MemberVariables탭에서 변수추가
헤더파일로 이동 

Cbutton 으로 생성된 변수를 CBitmapButton으로 변경해준다

만약 변수명이 m_Play라면

m_Play.LoadBitmaps(IDB_BITMAP1,NULL,NULL,NULL);  
IDB_BITMAP1 은 리소스 창에서 Insert>bitmap 선택후 이미지를 그려주면 된다.


m_Play.SizeToContent();
사이즈 자동조절

버튼 속성에서 Owner draw 체크해준다

msdn 참조

CBitmapButton::LoadBitmaps

BOOL LoadBitmaps( LPCTSTR lpszBitmapResource, LPCTSTR lpszBitmapResourceSel = NULL, LPCTSTR lpszBitmapResourceFocus = NULL, LPCTSTRlpszBitmapResourceDisabled = NULL );

BOOL LoadBitmaps( UINT nIDBitmapResource, UINT nIDBitmapResourceSel = 0, UINT nIDBitmapResourceFocus = 0, UINT nIDBitmapResourceDisabled = 0 );

Return Value

Nonzero if successful; otherwise 0.

Parameters

lpszBitmapResource

Points to the null-terminated string that contains the name of the bitmap for a bitmap button’s normal or “up” state. Required.

lpszBitmapResourceSel

Points to the null-terminated string that contains the name of thebitmap for a bitmap button’s selected or “down” state. May be NULL.

lpszBitmapResourceFocus

Points to the null-terminated string that contains the name of the bitmap for a bitmap button’s focused state. May be NULL.

lpszBitmapResourceDisabled

Points to the null-terminated string that contains the name of the bitmap for a bitmap button’s disabled state. May be NULL.

nIDBitmapResource

Specifies the resource ID number of the bitmap resource for a bitmap button’s normal or “up” state. Required.

nIDBitmapResourceSel

Specifies the resource ID number of the bitmap resource for a bitmap button’s selected or “down” state. May be 0.

nIDBitmapResourceFocus

Specifies the resource ID number of the bitmap resource for a bitmap button’s focused state. May be 0.

nIDBitmapResourceDisabled

Specifies the resource ID number of the bitmap resource for a bitmap button’s disabled state. May be 0.

Remarks

Use this function when you want to load bitmap images identified bytheir resource names or ID numbers, or when you cannot use the AutoLoad function because, for example, you are creating a bitmap button that is not part of a dialog box.

Example

CBitmapButton myButton;

// Create the bitmap button (must include the BS_OWNERDRAW style).
myButton.Create(NULL, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,
CRect(10,10,100,100), pParentWnd, 1);

// Load the bitmaps for this button.



myButton.LoadBitmaps(IDB_UP, IDB_DOWN, IDB_FOCUS, IDB_DISABLE);

CBitmapButton::SizeToContent

void SizeToContent( );

Remarks

Call this function to resize a bitmap button to the size of the bitmap.

Example

CBitmapButton myButton;

// Create the bitmap button (must include the BS_OWNERDRAW style).
myButton.Create(NULL, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,
CRect(10,10,100,100), pParentWnd, 1);

// Load the bitmaps for this button.
myButton.LoadBitmaps(IDB_UP, IDB_DOWN, IDB_FOCUS, IDB_DISABLE);

// Resize the button to be the size of the bitmaps.
myButton.SizeToContent();


댓글목록

등록된 댓글이 없습니다.

IT Tip&Tech 목록

게시물 검색

접속자집계

오늘
897
어제
522
최대
6,399
전체
660,355
Copyright © LittleCandle All rights reserved.
문의메일 : littlecandle99@gmail.com
모바일 버전으로 보기