Here is my first attempt at writting a simple class.
ImageWin Class create a child window and can scale the image in it.
ImageWin.inc
////////////////////////////////////////////////////////////////////////////////
// ImageWin Class Definition by Krypt.
////////////////////////////////////////////////////////////////////////////////
class ImageWin:CWindow
{
Declare OnPaint(),int;
Declare ImgCreate(CWindow *parent,int x,int y,int w,int h,string filename,byte scalable);
CImage m_img;
byte m_bScale;
}
ImageWin.src
////////////////////////////////////////////////////////////////////////////////
// ImageWin Methods by Krypt.
////////////////////////////////////////////////////////////////////////////////
#include "ImageWin.inc"
// Create an Image Window
/*
Parent = The Parent Window (Dialog)
X,Y,W,H = Window coordinate
Filename = Path to the Picture file
Scalable = True to scale the picture to the window or False to not
*/
ImageWin::ImgCreate(CWindow *parent,int x,int y,int w,int h,string filename,byte scalable)
{
Create(x,y,w,h,AWS_VISIBLE|AWS_AUTODRAW ,0,"",parent);
m_img.LoadFromFile(filename);
m_bScale = scalable;
OnPaint();
return;
}
ImageWin::OnPaint(),int
{
RECT size;
if m_bScale = 1
{
size = GetClientRect();
m_img.Render(this,0,0,size.right-size.left,size.bottom-size.top);
}
else
{
m_img.Render(this,0,0);
}
return true;
}