home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
POLYEDIT.LZH
/
MESSAGE
/
TEST.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-01
|
4KB
|
190 lines
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
// チュートリアル アプリケーション -- step04.cpp
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dc.h>
#include <stdio.h>
#include <dos.h>
#include "message.h"
static TMessageWindow *MessageOut ;
static TFrameWindow *MainW ;
class TMyWindow : public TWindow {
public:
TMyWindow(TWindow *parent = 0);
int shiftstat ;
int line, col ;
protected:
// TWindow のメンバー関数をオーバーライドする
// BOOL CanClose();
// メッセージ応答関数
void EvLButtonDown(UINT, TPoint&);
void EvRButtonDown(UINT, TPoint&);
void EvMouseMove(UINT, TPoint&);
void EvLButtonUp(UINT, TPoint&);
void EvChar( UINT key, UINT count, UINT flags );
void EvKeyDown( UINT key, UINT count, UINT flags );
void EvKeyUp( UINT key, UINT count, UINT flags );
DECLARE_RESPONSE_TABLE(TMyWindow);
};
DEFINE_RESPONSE_TABLE1(TMyWindow, TWindow)
EV_WM_LBUTTONDOWN,
EV_WM_RBUTTONDOWN,
EV_WM_MOUSEMOVE,
EV_WM_LBUTTONUP,
EV_WM_CHAR,
EV_WM_KEYDOWN,
EV_WM_KEYUP,
EV_WM_DROPFILES,
END_RESPONSE_TABLE;
TMyWindow::TMyWindow(TWindow *parent)
{
Init(parent, 0, 0);
shiftstat = 0;
line = 0;
col = 0;
}
/*
BOOL TMyWindow::CanClose()
{
return MessageBox("保存しますか?", "内容が変更されています",
MB_YESNO | MB_ICONQUESTION) == IDNO;
}
*/
void TMyWindow::EvChar( UINT key, UINT, UINT flags )
{
TClientDC dc(*this);
char str[64] ;
wsprintf( str, "C %X %X %d", key, flags, shiftstat );
dc.TextOut( col * 80, line * 16, str );
line++ ;
if ( line == 32 )
{
line = 0 ;
col ++ ;
if ( col == 8 )
{
col = 0 ;
}
}
if ( key == ' ' )
CanClose();
}
void TMyWindow::EvKeyDown( UINT key, UINT count, UINT flags )
{
// shift
if ( key == 0x10 )
shiftstat |= 1 ;
// ctrl
if ( key == 0x11 )
shiftstat |= 2 ;
// function key
*MessageOut << "key : " << (int)key << "\n" ;
}
void TMyWindow::EvKeyUp( UINT key, UINT, UINT )
{
// shift
if ( key == 0x10 )
shiftstat &= 0xfe ;
// ctrl
if ( key == 0x11 )
shiftstat &= 0xfd ;
}
void TMyWindow::EvLButtonDown(UINT, TPoint&)
{
// TClientDC dc(*this);
// char str[64] ;
// long l = (unsigned long)this ;
// wsprintf( str, "this : %lX : %X %X", l, FP_SEG( this ), FP_OFF( this ) );
// dc.TextOut( col * 80, line * 16, str );
}
void TMyWindow::EvRButtonDown(UINT, TPoint&)
{
*MessageOut << this << " : RButtonDown\n" ;
Invalidate();
}
void TMyWindow::EvMouseMove(UINT, TPoint&)
{
}
void TMyWindow::EvLButtonUp(UINT, TPoint&)
{
}
class TMyApp : public TApplication {
public:
TMyWindow *MainWindow ;
TMyApp() : TApplication() {}
protected:
void InitMainWindow();
void InitInstance();
void EvDropFiles( TDropInfo );
DECLARE_RESPONSE_TABLE(TMyApp);
};
DEFINE_RESPONSE_TABLE1(TMyApp, TApplication)
EV_WM_DROPFILES,
END_RESPONSE_TABLE;
void TMyApp::InitMainWindow()
{
MainWindow = new TMyWindow ;
SetMainWindow( new TFrameWindow(0, "グラフ", MainWindow ));
MainW = GetMainWindow();
}
void TMyApp::InitInstance()
{
TApplication::InitInstance();
GetMainWindow()->DragAcceptFiles(TRUE);
MessageOut = new TMessageWindow( "message window", 100 );
MessageOut->GetWindowPtr()->Create();
}
void TMyApp::EvDropFiles( TDropInfo info )
{
TClientDC dc(*MainWindow);
char str[64] ;
char file[128] ;
dc.GetTextFace( 256, str );
wsprintf( "font : %s\n", str );
dc.TextOut( MainWindow->col * 80, MainWindow->line * 16, str );
MainWindow->line ++ ;
info.DragQueryFile( 0, file, 128 );
wsprintf( str, "drop:%s", file );
dc.TextOut( MainWindow->col * 80, MainWindow->line * 16, str );
MainWindow->line ++ ;
}
int OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TMyApp().Run();
}