VS 2008 Duilib 环境配置与第一个工程
2017-04-05 16:29
295 查看
下载一个源代码,本人使用的是duilib391 如若需要 请联系QQ:728297725
DuiLib工程右键->配置属性->c/c++->代码生成->运行库,编译项目中的DuiLib工程,编译成各个运行库。
启动VS2008,创建win32空项目:
(1)创建stdafx.h
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
#pragma once
#define WIN32_LEAN_AND_MEAN
#define _CRT_SECURE_NO_DEPRECATE
#include <windows.h>
#include <objbase.h>
#include "..\..\DuiLib\UIlib.h"
using namespace DuiLib;
#ifdef _DEBUG
# ifdef _UNICODE
# pragma comment(lib, "..\\..\\Lib\\DuiLib_ud.lib")
# else
# pragma comment(lib, "..\\..\\Lib\\DuiLib_d.lib")
# endif
#else
# ifdef _UNICODE
# pragma comment(lib, "..\\..\\Lib\\DuiLib_u.lib")
# else
# pragma comment(lib, "..\\..\\Lib\\DuiLib.lib")
# endif
#endif
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
(2)创建stdafx.cpp
#include "stdafx.h"
#if defined _M_IX86
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
(3)创建main.cpp
#include "stdafx.h"
class CDuiFrameWnd : public CWindowWnd, public INotifyUI
{
public:
virtual LPCTSTR GetWindowClassName() const { return _T("DUIMainFrame"); }
virtual void Notify(TNotifyUI& msg) {}
virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT lRes = 0;
if( uMsg == WM_CREATE )
{
CControlUI *pWnd = new CButtonUI;
pWnd->SetText(_T("Hello World")); // 设置文字
pWnd->SetBkColor(0xFF00FF00); // 设置背景色
m_PaintManager.Init(m_hWnd);
m_PaintManager.AttachDialog(pWnd);
MessageBoxW(NULL,L"Hello world",NULL,NULL);
return lRes;
}
if( m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes) )
{
return lRes;
}
return __super::HandleMessage(uMsg, wParam, lParam);
}
protected:
CPaintManagerUI m_PaintManager;
};
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
{
CPaintManagerUI::SetInstance(hInstance);
CDuiFrameWnd duiFrame;
duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);
duiFrame.ShowModal();
return 0;
}
DuiLib工程右键->配置属性->c/c++->代码生成->运行库,编译项目中的DuiLib工程,编译成各个运行库。
启动VS2008,创建win32空项目:
(1)创建stdafx.h
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
#pragma once
#define WIN32_LEAN_AND_MEAN
#define _CRT_SECURE_NO_DEPRECATE
#include <windows.h>
#include <objbase.h>
#include "..\..\DuiLib\UIlib.h"
using namespace DuiLib;
#ifdef _DEBUG
# ifdef _UNICODE
# pragma comment(lib, "..\\..\\Lib\\DuiLib_ud.lib")
# else
# pragma comment(lib, "..\\..\\Lib\\DuiLib_d.lib")
# endif
#else
# ifdef _UNICODE
# pragma comment(lib, "..\\..\\Lib\\DuiLib_u.lib")
# else
# pragma comment(lib, "..\\..\\Lib\\DuiLib.lib")
# endif
#endif
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
(2)创建stdafx.cpp
#include "stdafx.h"
#if defined _M_IX86
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
(3)创建main.cpp
#include "stdafx.h"
class CDuiFrameWnd : public CWindowWnd, public INotifyUI
{
public:
virtual LPCTSTR GetWindowClassName() const { return _T("DUIMainFrame"); }
virtual void Notify(TNotifyUI& msg) {}
virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT lRes = 0;
if( uMsg == WM_CREATE )
{
CControlUI *pWnd = new CButtonUI;
pWnd->SetText(_T("Hello World")); // 设置文字
pWnd->SetBkColor(0xFF00FF00); // 设置背景色
m_PaintManager.Init(m_hWnd);
m_PaintManager.AttachDialog(pWnd);
MessageBoxW(NULL,L"Hello world",NULL,NULL);
return lRes;
}
if( m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes) )
{
return lRes;
}
return __super::HandleMessage(uMsg, wParam, lParam);
}
protected:
CPaintManagerUI m_PaintManager;
};
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
{
CPaintManagerUI::SetInstance(hInstance);
CDuiFrameWnd duiFrame;
duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);
duiFrame.ShowModal();
return 0;
}
相关文章推荐
- windows下正确配置CUDA 4.0环境并在Visual Studio 2008中新建工程
- duilib入门简明教程 -- VS环境配置(2)
- windows下正确配置CUDA 4.0环境并在Visual Studio 2008中新建工程
- Android的JNI【实战教程】2⃣️--AS下NDK环境配置及第一个工程
- 重新配置 VS 2008 默认环境
- VS2015工程目录结构 + OpenCV环境配置 的最优解决方案
- duilib入门简明教程 -- VS环境配置
- duilib入门简明教程 -- VS环境配置(2) Alberl
- VS 2008配置Winpcap环境
- VS 2008中PDA开发环境的相关配置。
- VS 配置一次环境 新建工程不必新建
- Alberl 2013 duilib入门简明教程 -- VS环境配置(2)
- duilib入门简明教程 -- VS环境配置(2)
- cuda、gdal环境配置及vs工程创建配置
- duilib入门简明教程 -- VS环境配置(2) (转)
- VS2008环境下开发的某些程序在其他机器运行提示“由于应用程序配置不正确,应用程序未能启动”的问题(IIS)
- vs2008+qt开发环境配置
- 2013 duilib入门简明教程 -- VS环境配置(2)
- VS 2008中PDA开发环境的相关配置
- pcl1.8.0+QT5.7.0+vs2013 win7 x64环境配置以及第一个小程序实现