MiniUtilityFramework(八):CImage和IMAGE

//========================================================================
//TITLE:
// MiniUtilityFramework(八):CImage和IMAGE
//AUTHOR:
// norains
//DATE:
// Thursday 26-February-2009
//Environment:
// VISUAL STUDIO 2005 + WINDOWS CE 5.0
//========================================================================

CImage是控件中最简单的一个,IMAGE是配置文件中也属于简单的一位。这简单的两者组合起来,就构成了程序中图片的显示。

CImage的头文件定义如下:

// Image.h: interface for the CImage class. // // #pragma once #include "..//Table//imageTabBase.h" class CImage { public: //Before using you must call the function //-------------------------------------------------------------------- //Description: // Set image table object // //------------------------------------------------------------------- void SetImgTab(CImageTabBase &imgTab); public: //-------------------------------------------------------------------- //Description: // Set the button position // //------------------------------------------------------------------- void SetImgPosition(const RECT &rcWndImg); //-------------------------------------------------------------------- //Description: // Set the visible // //Parameters: // bVisible:[in] // TRUE - visible // FALSE - invisible // //-------------------------------------------------------------------- void SetVisible(BOOL bVisible); //-------------------------------------------------------------------- //Description: // Set the transparent mode // //Parameters: // bTran:[in] // TRUE - Don't draw the transparent color // FALSE - Draw all the color // //------------------------------------------------------------------- void SetTransparent(BOOL bTran); //-------------------------------------------------------------------- //Description: // Set the transparent color // //------------------------------------------------------------------- void SetTransparentColor(COLORREF crColor); //-------------------------------------------------------------------- //Description: // Draw the button // //------------------------------------------------------------------- BOOL Draw(HDC hdc); //-------------------------------------------------------------------- //Description: // Set the image index // //------------------------------------------------------------------- void SetImgIndex(TSTRING strIndex); //-------------------------------------------------------------------- //Description: // Get the image index // //------------------------------------------------------------------- TSTRING GetImgIndex(); public: CImage(); virtual ~CImage(); private: RECT m_rcWndImg; COLORREF m_crTranColor; BOOL m_bTran; BOOL m_bVisible; TSTRING m_ImgIndex; CImageTabBase *m_pImgTab;

CImage的大部分函数,都和配置文件相关,由MUF读取然后自动调用,用户基本上不必进行干预。在实际的程序中,大概可能用到的也就只有两个函数,分别是SetVisible和SetImgIndex。顾名思义,前者是设置该控件是否可用,后者则是显示图片的序号(该序号是在配置文件中定义的)。

配置文件也非常简单,只有简简单单的四项:

TYPE:控件类型,这里只能为IMAGE

RECT_POS:在窗口的位置

IMAGE_FILE:图片的序列

TRANSPARENT_MODE:取值为TRUE或FALSE。当为TRUE时,不绘制透明色。


简单的一个配置文件的例子:

[CIMG_BOOK]
TYPE=IMAGE
RECT_POS=0,0,480,272
IMAGE_FILE=IMG_BOOK
TRANSPARENT_MODE=TRUE

[IMG_BOOK]
TYPE=IMAGE_FILE
RECT_FILE=48,135,95,179
FILE_NAME="%STARTUP_PATH%/UIImage/book.bmp"
TRANSPARENT_COLOR=255,0,255


对于上述的配置文件,MUF其实会自动调用如下函数:

//伪代码
CImage::SetImgPosition(RECT(0,0,480,272));
CImage::SetTransparent(TRUE);
CImage::SetTransparentColor(RGB(255,0,255));
CImage::SetImgIndex(IMG_BOOK)

除非用户在后续中对此会有更改,一般这些函数都不必再次调用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值