Initial Commit
This commit is contained in:
103
common/BMPLNK.HPP
Normal file
103
common/BMPLNK.HPP
Normal file
@@ -0,0 +1,103 @@
|
||||
#ifndef _COMMON_LINKEDBITMAP_HPP_
|
||||
#define _COMMON_LINKEDBITMAP_HPP_
|
||||
#ifndef _COMMON_DRAWBITMAP_HPP_
|
||||
#include <common/drawbmp.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class LinkedBitmap : public DrawBitmap
|
||||
{
|
||||
public:
|
||||
LinkedBitmap(void);
|
||||
LinkedBitmap(int ctlID,String &bitmapName,HINSTANCE hLibrary);
|
||||
LinkedBitmap(const LinkedBitmap &someLinkedBitmap);
|
||||
virtual ~LinkedBitmap();
|
||||
WORD drawBitmap(HDC hDC,RECT locationRect);
|
||||
WORD drawBitmap(void);
|
||||
int referenceCount(void)const;
|
||||
void referenceCount(int newCount);
|
||||
bool operator==(const LinkedBitmap &someLinkedBitmap)const;
|
||||
bool operator==(int ctlID)const;
|
||||
DWORD width(void)const;
|
||||
DWORD height(void)const;
|
||||
HBITMAP getHBITMAP(void)const;
|
||||
bool isOkay(void)const;
|
||||
bool loadBitmap(const String &strBitmapName,HINSTANCE hInstance=::GetModuleHandle(0));
|
||||
private:
|
||||
void getBitmapInfo(void);
|
||||
void destroy(void);
|
||||
|
||||
int mCtlID;
|
||||
HBITMAP mhBitmap;
|
||||
BITMAP mBitmapInfo;
|
||||
String mBitmapName;
|
||||
int mReferenceCount;
|
||||
HINSTANCE mhLibrary;
|
||||
};
|
||||
|
||||
inline
|
||||
int LinkedBitmap::referenceCount(void)const
|
||||
{
|
||||
return mReferenceCount;
|
||||
}
|
||||
|
||||
inline
|
||||
void LinkedBitmap::referenceCount(int newCount)
|
||||
{
|
||||
mReferenceCount=newCount;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LinkedBitmap::operator==(const LinkedBitmap &someLinkedBitmap)const
|
||||
{
|
||||
return (mCtlID==someLinkedBitmap.mCtlID);
|
||||
}
|
||||
|
||||
inline
|
||||
bool LinkedBitmap::operator==(int ctlID)const
|
||||
{
|
||||
return mCtlID==ctlID;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LinkedBitmap::loadBitmap(const String &strBitmapName,HINSTANCE hInstance)
|
||||
{
|
||||
destroy();
|
||||
mhBitmap=::LoadBitmap(hInstance,strBitmapName.str());
|
||||
if(!mhBitmap)return false;
|
||||
getBitmapInfo();
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
void LinkedBitmap::getBitmapInfo(void)
|
||||
{
|
||||
::GetObject(mhBitmap,sizeof(BITMAP),(LPSTR)&mBitmapInfo);
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD LinkedBitmap::width(void)const
|
||||
{
|
||||
return mBitmapInfo.bmWidth;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD LinkedBitmap::height(void)const
|
||||
{
|
||||
return mBitmapInfo.bmHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
HBITMAP LinkedBitmap::getHBITMAP(void)const
|
||||
{
|
||||
return mhBitmap;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LinkedBitmap::isOkay(void)const
|
||||
{
|
||||
return mhBitmap?true:false;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user