À©µµ¿ì ÇÁ·Î±×·¡¹Ö ÀÚ·á |
---|
Á¦¸ñ | [MFC] Bitmap Button 1998/07/29 (09:43) |
À̸§ | swindler |
¹øÈ£ | 43 |
Á¶È¸ | 383 |
º»¹® |
Bitmap ButtonÀ» À§ÇÑ Class´Â CButtonÀÇ ÇÏÀ§ Ŭ·¡½º·Î CBitmap ButtonÀÌ ÀÖ´Ù. To create a bitmap-button control in a window's client area, follow these steps: 1.Create one to four bitmap images for the button. 2.Construct the CBitmapButton object. 3.Call the Create function to create the Windows button control and attach it to the CBitmapButton object. 4.Call the LoadBitmaps member function to load the bitmap resources after the bitmap button is constructed. To include a bitmap-button control in a dialog box, follow these steps: 1.Create one to four bitmap images for the button. 2.Create a dialog template with an owner-draw button positioned where you want the bitmap button. The size of the button in the template does not matter. 3.Set the button's caption to a value such as "MYIMAGE" and define a symbol for the button such as IDC_MYIMAGE. 4.In your application's resource script, give each of the images created for the button an ID constructed by appending one of the letters "U," "D," "F," or "X" (for up, down, focused, and disabled) to the string used for the button caption in step 3. For the button caption "MYIMAGE," for example, the IDs would be "MYIMAGEU," "MYIMAGED," "MYIMAGEF," and "MYIMAGEX." You must specify the ID of your bitmaps within double quotes. Otherwise the resource editor will assign an integer to the resource and MFC will fail when loading the image. 5.In your application's dialog class (derived from CDialog), add a CBitmapButton member object. 6.In the CDialog object's OnInitDialog routine, call the CBitmapButton object's AutoLoad function, using as parameters the button's control ID and the CDialog object's this pointer. CButton::Create BOOL Create( LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID ); example) CBitmapButton::LoadBitmaps BOOL LoadBitmaps( LPCTSTR lpszBitmapResource, LPCTSTR lpszBitmapResourceSel = NULL, LPCTSTR lpszBitmapResourceFocus = NULL, LPCTSTR lpszBitmapResourceDisabled = NULL ); BOOL LoadBitmaps( UINT nIDBitmapResource, UINT nIDBitmapResourceSel = 0, UINT nIDBitmapResourceFocus = 0, UINT nIDBitmapResourceDisabled = 0 ); CBitmapButton::AutoLoad BOOL AutoLoad( UINT nID, CWnd* pParent ); CBitmapButton::SizeToContent void SizeToContent( ); example) Resource¿¡ bitmapÀ» Ãß°¡ÇÏ°í, "COPYU","COPYD","COPYF","COPYE" ¸¦ ÀûÀýÈ÷ ¸¸µç´Ù. CBitmapButton m_editCopy; ¸¦ class¿¡ Ãß°¡ÇÑ´Ù. OnInitDialog()¾È¿¡ m_editCopy.AutoLoad(IDC_BUTTON1,this); ¸¦ Ãß°¡ÇÑ´Ù. ¿©±â¼, IDC_BUTTON1Àº ButtonÀÇ IDÀ̸ç, ¹öÆ°ÀÇ ¼Ó¼º¿¡ Owner Draw¸¦ Ãß°¡ÇØ¾ß ÇÑ´Ù. Button's CaptionÀÌ ºñÆ®¸ÊÀÇ ID¿Í ÀÏÄ¡ÇØ¾ß ÇÑ´Ù. ¿©±â¼´Â COPY¶ó°í ÇØ¾ß ÇÑ´Ù. (AutoLoad¸¦ ÀÌ¿ëÇϸé, Caption°ú ÀÏÄ¡ÇÏ´Â ºñÆ®¸ÊÀ» ã´Â´Ù.) VERITY(m_editCopy.AutoLoad(IDC_BUTTON1,this)); ·Î Çϸé, ºñÆ®¸ÊÀ» ¸ø ãÀ»½Ã¿¡, ¸Þ½ÃÁö ¹Ú½º¸¦ Ãâ·ÂÇÑ´Ù. |