Home > Back-end >  Direct2D for help: drawing content beyond the window
Direct2D for help: drawing content beyond the window

Time:11-12

Create a window resolution of 1280 x720,
Create ID2D1RenderTarget range also use GetClientRect (),
Draw the content of the coordinate range is within the 1279 and 719,
Can actually draw out there is always a small part of the content of the right hand and lower edge) (beyond the window, how to break?

P.S. query seems to dpi might be the problem, but don't know how to solve

CodePudding user response:

"Create window resolution of 1280 x720"
If it is the window size is 1280 * 720, that is possible, because the size of the entire window, also including the title bar, the borders, the rest is the client area
In fact you need window, it should be the client area size of 1280 * 720, plus the title bar and border, is certainly more than the area of

When creating a window, so you should make the size of the client area, rather than the total size of the window

You can try it, put your window is set to no title bar, no borders, make its size is 1280 * 720, if the drawing is no problem, that is, you set the wrong form size

This is when I used to do D3D9, generate the code window, you can consult,
M_iWndClientRectWidth=800;
M_iWndClientRectHeight=600;

M_hWnd=CreateWindow (L "D3D9 Window", m_strWindowTitle,
WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX,
100, 100,
//set the window's client area into 800 * 600, therefore to consider form border width and the height of the title bar
//the two values can be through the function: GetSystemMetrics and corresponding parameter
//I'm a genius ah ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
M_iWndClientRectWidth + GetSystemMetrics (SM_CXDLGFRAME) * 2,
M_iWndClientRectHeight + GetSystemMetrics (SM_CXDLGFRAME) * 2 + GetSystemMetrics (SM_CYCAPTION),
GetDesktopWindow (), NULL, hInstance, NULL);

This code is generated a "client area" is the window of the 800 * 600

CodePudding user response:

Wow, thank you very much for the original x plus the size of the title bar and border ah, is the first time I create QWQ window procedure

CodePudding user response:

Directly set
ClientWidth=1280;
ClientHeight=720;
  • Related