摘要:
通过ID2D1HwndRenderTarget,可以轻松地画作各种样式的长方形和椭圆形:View Code #include "Precompiled.h"#include "DesktopWindow.h"D2D1_COLOR_F const COLOR_BLUE = { 0.26f, 0.56f, 0.87f, 1.0f };D2D1_COLOR_F const COLOR_WHITE = { 1.0f, 1.0f, 1.0f, 1.0f };D2D1_COLOR_F const COLOR_BLACK = { 0.0f, 0.0f, 0.0f, 1 阅读全文
摘要:
为方便,将D2D的一个基本类DesktopWindow写成如下所示:View Code #include "Precompiled.h"#include <d2d1.h>#include <wrl.h>#pragma comment(lib, "d2d1")using namespace D2D1;using namespace Microsoft::WRL;template<typename T>struct DesktopWindow : CWindowImpl<T, CWindow, CWinTraits& 阅读全文
摘要:
Direct2D基于Windows窗体,因此必须了解一些基本的Windows窗体编程:首先,最基本的,可以使用Windows API写一个窗体:View Code #include <Windows.h>typedef LRESULT (* message_callback)(HWND, WPARAM, LPARAM);struct message_handler{ UINT message; message_callback handler;};static message_handler s_handlers[] = { { WM_PAINT, [] (HW... 阅读全文