rw8
asked on
BC++4.5 --> 5.0 OWL no graphic display?
I was programming using Borland C++ 4.5 before. I write some programs using the OWL. Recently, I upgraded my Borland C++ to 5.0. I re-compile some of my program codes again and surprising, none of my programs display anything on the screen while I run those "new" files. The only thing displayed on the screen is the window frame and the title... can anyone tell me what is the problem? or did I do something wrong with my program codes? Below is the program code of a simple program which displays a game board:
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\gdiobjec.h>
#include <owl\point.h>
#include <owl\dc.h>
#define LIMIT 5
#define EMPTY 0
#define BLACK 1
#define WHITE 2
class MyApp:public TApplication
{
public:
MyApp():TApplication(){}
void InitMainWindow();
};
class MyMainWndw:public TFrameWindow
{
public:
MyMainWndw(TWindow *parent, const char far *title);
protected:
UINT blockX, blockY, Chess[LIMIT][LIMIT];
RECT rect;
void Paint(TDC &paintDC, BOOL, TRect&);
void EvSize(UINT, TSize &size);
void EvLButtonDown(UINT, TPoint &point);
void EvRButtonDown(UINT, TPoint &point);
DECLARE_RESPONSE_TABLE(MyM ainWndw);
};
DEFINE_RESPONSE_TABLE1(MyM ainWndw, TFrameWindow)
EV_WM_SIZE,
EV_WM_LBUTTONDOWN,
EV_WM_RBUTTONDOWN,
END_RESPONSE_TABLE;
MyMainWndw::MyMainWndw(TWi ndow *parent, const char far *title):TFrameWindow(paren t,title)
{
for (int x=0; x<LIMIT;x++)
for (int y=0; y<LIMIT; y++)
Chess[x][y]=EMPTY;
}
void MyMainWndw::EvSize(UINT, TSize &size)
{
blockX=size.cx/LIMIT;
blockY=size.cy/LIMIT;
Invalidate();
}
void MyMainWndw::EvLButtonDown( UINT,TPoin t &point)
{
int x=point.x/blockX;
int y=point.y/blockY;
if((x<LIMIT)&&(y<LIMIT))
{
MessageBeep(0);
Chess[x][y]=BLACK;
rect.left=x*blockX;
rect.right=(x+1)*blockX;
rect.top=y*blockY;
rect.bottom=(y+1)*blockY;
InvalidateRect(TRect(rect) ,FALSE);
}
}
void MyMainWndw::EvRButtonDown( UINT,TPoin t &point)
{
int x=point.x/blockX;
int y=point.y/blockY;
if((x<LIMIT)&&(y<LIMIT))
{
MessageBeep(0);
Chess[x][y]=WHITE;
rect.left=x*blockX;
rect.right=(x+1)*blockX;
rect.top=y*blockY;
rect.bottom=(y+1)*blockY;
InvalidateRect(TRect(rect) ,FALSE);
}
}
void MyMainWndw::Paint(TDC &paintDC, BOOL, TRect&)
{
int x,y;
char szBuffer[]="1233456";
paintDC.TextOut(10,0,szBuf fer);
TBrush *BlackBrush=new TBrush(TColor::Black);
TBrush *WhiteBrush=new TBrush(TColor::White);
TPen *BlackPen=new TPen(TColor::Black);
paintDC.SelectObject(*Whit eBrush);
paintDC.SelectObject(*Blac kPen);
for( x=0; x<LIMIT;x++)
for( y=0;y<LIMIT;y++)
paintDC.Rectangle(x*blockX ,y*blockY, (x+1)*bloc kX,
(y+1)*blockY);
for (x=0; x<LIMIT; x++)
for(y=0;y<LIMIT;y++)
{
if (Chess[x][y]==BLACK)
paintDC.SelectObject(*Blac kBrush);
else if (Chess[x][y]==WHITE)
paintDC.SelectObject(*Whit eBrush);
if(Chess[x][y]!=EMPTY)
paintDC.Ellipse(x*blockX+1 ,y*blockY+ 1,(x+1)*bl ockX-1,(y+ 1)*blockY- 1);
}
delete BlackBrush;
delete WhiteBrush;
delete BlackPen;
}
void MyApp::InitMainWindow()
{
TFrameWindow *wndw=new MyMainWndw(0, "Hit Test by Mouse");
SetMainWindow(wndw);
}
int OwlMain(int, char*[])
{
return MyApp().Run();
}
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\gdiobjec.h>
#include <owl\point.h>
#include <owl\dc.h>
#define LIMIT 5
#define EMPTY 0
#define BLACK 1
#define WHITE 2
class MyApp:public TApplication
{
public:
MyApp():TApplication(){}
void InitMainWindow();
};
class MyMainWndw:public TFrameWindow
{
public:
MyMainWndw(TWindow *parent, const char far *title);
protected:
UINT blockX, blockY, Chess[LIMIT][LIMIT];
RECT rect;
void Paint(TDC &paintDC, BOOL, TRect&);
void EvSize(UINT, TSize &size);
void EvLButtonDown(UINT, TPoint &point);
void EvRButtonDown(UINT, TPoint &point);
DECLARE_RESPONSE_TABLE(MyM
};
DEFINE_RESPONSE_TABLE1(MyM
EV_WM_SIZE,
EV_WM_LBUTTONDOWN,
EV_WM_RBUTTONDOWN,
END_RESPONSE_TABLE;
MyMainWndw::MyMainWndw(TWi
{
for (int x=0; x<LIMIT;x++)
for (int y=0; y<LIMIT; y++)
Chess[x][y]=EMPTY;
}
void MyMainWndw::EvSize(UINT, TSize &size)
{
blockX=size.cx/LIMIT;
blockY=size.cy/LIMIT;
Invalidate();
}
void MyMainWndw::EvLButtonDown(
{
int x=point.x/blockX;
int y=point.y/blockY;
if((x<LIMIT)&&(y<LIMIT))
{
MessageBeep(0);
Chess[x][y]=BLACK;
rect.left=x*blockX;
rect.right=(x+1)*blockX;
rect.top=y*blockY;
rect.bottom=(y+1)*blockY;
InvalidateRect(TRect(rect)
}
}
void MyMainWndw::EvRButtonDown(
{
int x=point.x/blockX;
int y=point.y/blockY;
if((x<LIMIT)&&(y<LIMIT))
{
MessageBeep(0);
Chess[x][y]=WHITE;
rect.left=x*blockX;
rect.right=(x+1)*blockX;
rect.top=y*blockY;
rect.bottom=(y+1)*blockY;
InvalidateRect(TRect(rect)
}
}
void MyMainWndw::Paint(TDC &paintDC, BOOL, TRect&)
{
int x,y;
char szBuffer[]="1233456";
paintDC.TextOut(10,0,szBuf
TBrush *BlackBrush=new TBrush(TColor::Black);
TBrush *WhiteBrush=new TBrush(TColor::White);
TPen *BlackPen=new TPen(TColor::Black);
paintDC.SelectObject(*Whit
paintDC.SelectObject(*Blac
for( x=0; x<LIMIT;x++)
for( y=0;y<LIMIT;y++)
paintDC.Rectangle(x*blockX
(y+1)*blockY);
for (x=0; x<LIMIT; x++)
for(y=0;y<LIMIT;y++)
{
if (Chess[x][y]==BLACK)
paintDC.SelectObject(*Blac
else if (Chess[x][y]==WHITE)
paintDC.SelectObject(*Whit
if(Chess[x][y]!=EMPTY)
paintDC.Ellipse(x*blockX+1
}
delete BlackBrush;
delete WhiteBrush;
delete BlackPen;
}
void MyApp::InitMainWindow()
{
TFrameWindow *wndw=new MyMainWndw(0, "Hit Test by Mouse");
SetMainWindow(wndw);
}
int OwlMain(int, char*[])
{
return MyApp().Run();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Did I forget to add something in my program code?