Исходный текст программы
#include <owl\applicat.h>
#include <owl\framewin.h>
class TMyApp: public TApplication
{
public:
TMyApp():TApplication("Hello Windows !"){};
void InitMainWindow()
{
MainWindow=new TFrameWindow(0,"Hello, hello!!");
}
};
int OwlMain(int, char* [])
{
return TMyApp().Run();
}
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dc.h>
class TMyWindow : public TFrameWindow
{
public:
TMyWindow(char *title):TFrameWindow(0,title)
{}
protected:
void EvLButtonDown(UINT,TPoint&);
DECLARE_RESPONSE_TABLE(TMyWindow);
};
DEFINE_RESPONSE_TABLE1(TMyWindow,TFrameWindow)
EV_WM_LBUTTONDOWN,
END_RESPONSE_TABLE;
void TMyWindow::EvLButtonDown(UINT,TPoint &point)
{
TClientDC dc(HWindow);
TColor forecolor(TColor::LtCyan);
dc.SetTextColor(forecolor);
char buf[20];
wsprintf(buf,"[%d,%d]",point.x,point.y);
dc.TextOut(point.x,point.y,buf);
}
class TMyApp : public TApplication
{
public:
TMyApp():TApplication()
{}
void InitMainWindow()
{
MainWindow=new TMyWindow("Use the left mouse button");
}
};
int OwlMain(int, char *[])
{
TMyApp app;
return app.Run();
}
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dc.h>
#include <owl\scrollba.h>
class TMyWin : public TFrameWindow
{
public:
TPoint pn,pk;
TScrollBar *sb;
TMyWin() : TFrameWindow(0,"The Paint function")
{
sb=new TScrollBar(this,1,350,100,20,125,FALSE);
pn.x=100;
pn.y=40;
pk.x=300;
pk.y=pn.y;
}
protected:
void Paint(TDC&,BOOL,TRect&);
void EvVScroll(UINT, UINT, HWND);
DECLARE_RESPONSE_TABLE(TMyWin);
};
DEFINE_RESPONSE_TABLE1(TMyWin,TFrameWindow)
EV_WM_VSCROLL,
END_RESPONSE_TABLE;
void TMyWin::Paint(TDC &dc,BOOL,TRect&)
{
TColor color(TColor::LtBlue);
TPen pen1(color);
dc.SelectObject(pen1);
dc.Rectangle(pn,pk);
TPen pen2(TColor::LtGreen);
dc.SelectObject(pen2);
dc.Ellipse(pn,pk);
}
void TMyWin::EvVScroll(UINT scrollcode, UINT thumbPos, HWND hwnd)
{
TFrameWindow::EvVScroll(scrollcode,thumbPos,hwnd);
InvalidateRect(TRect(pn,pk));
pk.y=pn.y+sb->GetPosition()*2;
UpdateWindow();
}
class TMyApp : public TApplication
{
public:
TMyApp():TApplication()
{}
void InitMainWindow()
{
MainWindow=new TMyWin();
}
};
int OwlMain(int, char *[])
{
TMyApp app;
return app.Run();
}
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\button.h>
#include <owl\dc.h>
#define CM_BUTTON1 100
#define CM_BUTTON2 200
class TMyWin : public TFrameWindow
{
public:
TPoint pn,pk;
int nColor;
TMyWin() : TFrameWindow(0,"The Paint function")
{
new TButton(this,CM_BUTTON1,"Palette 1",350,50,80,30);
new TButton(this,CM_BUTTON2,"Palette 2",350,100,80,30);
pn.x=100;
pn.y=50;
pk.x=300;
pk.y=200;
nColor=1;
}
void Paint(TDC&,BOOL,TRect&);
void CmButton1()
{
nColor=1;
Invalidate();
UpdateWindow();
}
void CmButton2()
{
nColor=2;
Invalidate();
UpdateWindow();
}
DECLARE_RESPONSE_TABLE(TMyWin);
};
DEFINE_RESPONSE_TABLE1(TMyWin,TFrameWindow)
EV_COMMAND(CM_BUTTON1,CmButton1),
EV_COMMAND(CM_BUTTON2,CmButton2),
END_RESPONSE_TABLE;
void TMyWin::Paint(TDC &dc,BOOL,TRect&)
{
TColor color(nColor==1 ? TColor::LtBlue : TColor::LtYellow);
TPen pen1(color);
dc.SelectObject(pen1);
dc.Rectangle(pn,pk);
TPen pen2(nColor==1 ? TColor::Black : TColor::LtRed);
dc.SelectObject(pen2);
dc.Ellipse(pn,pk);
}
class TMyApp : public TApplication
{
public:
TMyApp():TApplication()
{}
void InitMainWindow()
{
MainWindow=new TMyWin();
}
};
int OwlMain(int, char *[])
{
TMyApp app;
return app.Run();
}
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\edit.h>
#include <owl\button.h>
#include <owl\dc.h>
#define ID_MULTILINER 150
#define CM_BUTTON 160
class TMyWin: public TFrameWindow
{
TEdit *multiLiner;
char *txt;
public:
TMyWin(): TFrameWindow(0,"the TEdit object")
{
- multiLiner=new TEdit(this,ID_MULTILINER,"Input lines",10,10,200,100,0,TRUE);
- new TButton(this,CM_BUTTON,"Update",10,130,70,25);
}
protected:
void CmButton();
void Paint(TDC&,BOOL,TRect&);
DECLARE_RESPONSE_TABLE(TMyWin);
};
DEFINE_RESPONSE_TABLE1(TMyWin,TFrameWindow)
EV_COMMAND(CM_BUTTON,CmButton),
END_RESPONSE_TABLE;
void TMyWin::CmButton()
{
Invalidate();
//UpdateWindow();
}
void TMyWin::Paint(TDC& dc,BOOL,TRect&)
{
- for (int i=1;i<=multiLiner->GetNumLines();i++)
- {
- int lineLength= multiLiner->GetLineLength(i-1);
- txt= new char[lineLength];
- multiLiner->GetLine(txt,lineLength,i-1);
- dc.TextOut(250,50+i*20,txt);
- delete txt;
- }
}
class TMyApp:public TApplication
{
public:
TMyApp(): TApplication(){};
void InitMainWindow()
- {
- MainWindow=new TMyWin();
- }
};
int OwlMain(int,char *[])
{
return TMyApp().Run();
}