친구들 기다리는 동안 감사원 근처 '삼청공원' 에서 접사를 연습했다.


솜씨가 제법이지 않나 ? ^____^
//! ~Ctl.h
// ---------------------------------------------------------------
class ~Ctrl : public COleControl
{
public:
...
// ADD [
HWND m_hWnd;
HWND m_hIrrlichtWindow;
HINSTANCE m_hInstance;
bool m_IsFirst; // set flag, at drawing first time via OnDraw(...)
void EngineTest(CWnd* cWnd);
// ]
...
};
// ---------------------------------------------------------------
//! ~Ctl.cpp
// ---------------------------------------------------------------
// Global Variable
#include "stdafx.h"
#include "~.h"
#include "~Ctl.h"
#include "~Ppg.h"
//! Here !
#include
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// 3D Engine Test
// -----------------------------------------------------------------------------
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
video::IVideoDriver* driver = 0;
IGUIEnvironment* env = 0;
scene::ISceneManager* smgr = 0;
s32 cnt = 0;
IGUIListBox* listbox = 0;
HWND g_hWnd;
// -----------------------------------------------------------------------------
...
CTest_engine_activex_vc60Ctrl::CTest_engine_activex_vc60Ctrl()
{
InitializeIIDs(&IID_DTest_engine_activex_vc60, &IID_DTest_engine_activex_vc60Events);
// TODO: Initialize your control's instance data here.
// ADD [
m_IsFirst = true;
// ]
}
void ~Ctrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
// pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
// pdc->Ellipse(rcBounds);
// ADD [
if( m_IsFirst ) {
m_IsFirst = false;
EngineTest( pdc->GetWindow() );
}
// ]
//! EventReceiver
// Yes, you using your own EventReceiver class as before.
// ADD [
class MyEventReceiver : public IEventReceiver
{
private:
bool m_isRender;
IrrlichtDevice* device;
public:
void setDevice(IrrlichtDevice* v) { device = v; }
void setRender(bool v) { m_isRender = v; }
bool getRender(void) { return m_isRender; }
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
IGUIEnvironment* env = device->getGUIEnvironment();
switch(event.GUIEvent.EventType)
{
case EGET_SCROLL_BAR_CHANGED:
if (id == 104)
{
s32 pos = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos();
for (u32 i=0; i{
SColor col = env->getSkin()->getColor((EGUI_DEFAULT_COLOR)i);
col.setAlpha(pos);
env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col);
}
}
break;
case EGET_BUTTON_CLICKED:
if (id == 101)
{
setRender( false );
return true;
}
default:
break;
}
}
return false;
}
...
};
// ]
void ~Ctrl::EngineTest(CWnd* cWnd)
{
// ADD [
//! Set for Child Window as a Button
// -----------------------------------------
video::E_DRIVER_TYPE driverType;
driverType = video::EDT_OPENGL;
MyEventReceiver receiver;
irr::SIrrlichtCreationParameters param;
m_hWnd = cWnd->m_hWnd;
m_hInstance = AfxGetInstanceHandle();
m_hIrrlichtWindow = CreateWindow("BUTTON", "Test Engine On The ActiveX", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 10, 200, 640, 480, m_hWnd, NULL, m_hInstance, NULL);
param.WindowId = reinterpret_cast( m_hIrrlichtWindow );
param.DriverType = driverType;
IrrlichtDevice* device = irr::createDeviceEx( param );
receiver.setDevice( device );
receiver.setRender( true );
device->setEventReceiver(&receiver);
// -----------------------------------------
// Your code
// -----------------------------------------
//! Prepare to Rendering
// -----------------------------------------
g_hWnd = m_hWnd;
::ShowWindow( m_hIrrlichtWindow , SW_SHOW );
::UpdateWindow( m_hIrrlichtWindow );
while( device->run() && driver ) {
if( !receiver.getRender() ) { break; }
//! "isWindowActivate()" isn't work here.
//if( device->isWindowActive() ) {
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
env->drawAll();
driver->endScene();
//! ^___^
::UpdateWindow( m_hIrrlichtWindow );
//}
}
// ]
device->closeDevice();
device->drop();
}
//! Mouse Event
// ClassWizard -> add Message "WM_MOUSEACTIVATE"
int ~Ctrl::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default
// ADD [
OnActivateInPlace( true, NULL );
// ]
return COleControl::OnMouseActivate(pDesktopWnd, nHitTest, message);
}
// ---------------------------------------------------------------
//! ~Ctl.h
// ---------------------------------------------------------------
class ~Ctrl : public COleControl
{
public:
...
// ADD [
HWND m_hWnd;
HWND m_hIrrlichtWindow;
HINSTANCE m_hInstance;
bool m_IsFirst; // set flag, at drawing first time via OnDraw(...)
void EngineTest(CWnd* cWnd);
// ]
...
};
// ---------------------------------------------------------------
//! ~Ctl.cpp
// ---------------------------------------------------------------
// Global Variable
#include "stdafx.h"
#include "~.h"
#include "~Ctl.h"
#include "~Ppg.h"
//! Here !
#include
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// 3D Engine Test
// -----------------------------------------------------------------------------
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
IrrlichtDevice *device = 0;
video::IVideoDriver* driver = 0;
IGUIEnvironment* env = 0;
scene::ISceneManager* smgr = 0;
s32 cnt = 0;
IGUIListBox* listbox = 0;
HWND g_hWnd;
// -----------------------------------------------------------------------------
...
CTest_engine_activex_vc60Ctrl::CTest_engine_activex_vc60Ctrl()
{
InitializeIIDs(&IID_DTest_engine_activex_vc60, &IID_DTest_engine_activex_vc60Events);
// TODO: Initialize your control's instance data here.
// ADD [
m_IsFirst = true;
// ]
}
void ~Ctrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
// pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
// pdc->Ellipse(rcBounds);
// ADD [
if( m_IsFirst ) {
m_IsFirst = false;
EngineTest( pdc->GetWindow() );
}
// ]
//! EventReceiver
// Yes, you using your own EventReceiver class as before.
// ADD [
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
...
}
...
};
// ]
void ~Ctrl::EngineTest(CWnd* cWnd)
{
// ADD [
//! Set for Child Window as a Button
// -----------------------------------------
video::E_DRIVER_TYPE driverType;
driverType = video::EDT_OPENGL;
MyEventReceiver receiver;
irr::SIrrlichtCreationParameters param;
m_hWnd = cWnd->m_hWnd;
m_hInstance = AfxGetInstanceHandle();
m_hIrrlichtWindow = CreateWindow("BUTTON", "Test Engine On The ActiveX", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 10, 200, 640, 480, m_hWnd, NULL, m_hInstance, NULL);
param.WindowId = reinterpret_cast( m_hIrrlichtWindow );
param.DriverType = driverType;
device = createDeviceEx( param );
device->setEventReceiver(&receiver);
// -----------------------------------------
// Your code
// -----------------------------------------
//! Prepare to Rendering
// -----------------------------------------
g_hWnd = m_hWnd;
::ShowWindow( m_hIrrlichtWindow , SW_SHOW );
::UpdateWindow( m_hIrrlichtWindow );
while( device->run() && driver ) {
//! "isWindowActivate()" isn't work here.
//if( device->isWindowActive() ) {
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
env->drawAll();
driver->endScene();
//! ^___^
::UpdateWindow( m_hIrrlichtWindow );
//}
}
// ]
}
//! Mouse Event
// ClassWizard -> add Message "WM_MOUSEACTIVATE"
int ~Ctrl::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default
// ADD [
OnActivateInPlace( true, NULL );
// ]
return COleControl::OnMouseActivate(pDesktopWnd, nHitTest, message);
}
// ---------------------------------------------------------------