April 19, 2024, 04:34:35 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


ImageWin Class

Started by ExMember001, September 02, 2006, 10:31:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ExMember001

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;
}