一、
Tools ->Options ->Projects and Solutions ->Include files 加入G:/PopCap_Framework_v1.3/osframework/source/SexyAppFramework
Tools ->Options ->Projects and Solutions ->Library files 加入G:/PopCap_Framework_v1.3/osframework/source/SexyAppFramework
Tools ->Options ->Projects and Solutions ->Source files 加入G:/PopCap_Framework_v1.3/osframework/source/SexyAppFramework(这样VAssist X可以显示智能提示)
Tips:
DDImage* mMapImg; // DDimage 上F12,定位到DDImage.h,在VS2008 中DDImage.h Tab标签上Alt + O 定位到DDImage.cpp
二、VS2008 中C/C++ ->Code Generation ->Runtime Library 设成Multi-threaded Debug (/MTd)(要和Popcap 编译时的选项一样)
//
// main.cpp
// 显示图片
#include <SexyAppBase.h>
#include <WidgetManager.h>
#include <ResourceManager.h>
#include <Widget.h>
#include <DDImage.h>
#define ASSERT(value) if (!(value)) { _asm{int 3};}
using namespace Sexy;
#pragma comment( lib, "winmm.lib" )
#pragma comment( lib, "wsock32.lib" )
#ifdef _DEBUG
#pragma comment( lib, "SexyAppFramework_D.lib" )
#else
#pragma comment( lib, "SexyAppFramework.lib" )
#endif
class CApp;
class CWidget : public Widget
{
public:
CWidget( CApp *app );
~CWidget();
void Draw( Graphics *g );
void Update();
public:
CApp *mApp;
};
class CWidget;
class CApp : public SexyAppBase
{
public:
CApp();
~CApp();
virtual void Init();
virtual void LoadingThreadProc();
virtual void LoadingThreadCompleted();
public:
DDImage* mMapImg;
CWidget* mWidget;
};
CApp::CApp()
{
mWidth = 550;
mHeight = 650;
mTitle = "APP";
mNoSoundNeeded = true;
mAutoEnable3D = true;
mMapImg = NULL;
}
CApp::~CApp()
{
mWidgetManager->RemoveWidget(mWidget);
delete mWidget;
}
void CApp::Init()
{
SexyAppBase::Init();
}
void CApp::LoadingThreadProc()
{
mMapImg = (DDImage*)GetImage("./image/map"); // /Debug/image/map.jpg // Debug 目录是生成的EXE 所在目录
ASSERT(mMapImg != NULL);
}
void CApp::LoadingThreadCompleted()
{
SexyAppBase::LoadingThreadCompleted();
if (mLoadingFailed)
return;
mWidget = new CWidget(this);
mWidget->Resize(0, 0, mWidth, mHeight);
mWidgetManager->AddWidget(mWidget);
}
CWidget::CWidget( CApp *app )
{
mApp = app;
}
CWidget::~CWidget()
{
}
void CWidget::Draw( Graphics *g )
{
// DrawImageF(img, 窗体坐标x, 窗体坐标y, Rect(图片坐标x, 图片坐标y, 宽, 高) )
g->DrawImageF( mApp->mMapImg, 0, 0, Rect( 0, 0,
550, 650 ) );
}
void CWidget::Update()
{
Widget::Update();
MarkDirty();
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
gHInstance = hInstance;
CApp *app = new CApp();
app->Init();
app->Start();
delete app;
return 0;
}
//