gpt4 book ai didi

c++ - DWM 缩略图,更改预览窗口的大小

转载 作者:可可西里 更新时间:2023-11-01 10:04:35 24 4
gpt4 key购买 nike

我有一个窗口,它反射(reflect)了另一个带有 DWM 缩略图的窗口。现在我想要当用户调整预览窗口大小时,预览区域会调整到。我怎样才能做到这一点?如何发送有关新预览尺寸的更新(将尺寸 300x300 更改为预览窗口的尺寸)?

switch (message) {
case WM_CREATE:
{
HRESULT hr = S_OK;
HTHUMBNAIL thumbnail = NULL;
hr = DwmRegisterThumbnail(hWnd, ieWindowHwnd, &thumbnail);
if (SUCCEEDED(hr)) {
// The destination rectangle size
RECT dest = {0,0,300,300};

// Set the thumbnail properties for use
DWM_THUMBNAIL_PROPERTIES dskThumbProps;
dskThumbProps.dwFlags = DWM_TNP_RECTDESTINATION | DWM_TNP_VISIBLE | DWM_TNP_SOURCECLIENTAREAONLY;

// Use the window frame and client area
dskThumbProps.fSourceClientAreaOnly = FALSE;
dskThumbProps.fVisible = TRUE;
dskThumbProps.rcDestination = dest;

// Display the thumbnail
hr = DwmUpdateThumbnailProperties(thumbnail, &dskThumbProps);
}
}
break;
case WM_SIZE:
{
// What to do here.
}
break;

最佳答案

WM_CREATE 中移除thumbnail 声明,在Window 过程中将其声明为静态值。然后更新 WM_SIZE 中的 thumbnail

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wp, LPARAM lp)
{
static HTHUMBNAIL thumbnail = NULL;

switch (message)
{
...
case WM_SIZE:
{
if (thumbnail)
{
RECT rc;
GetClientRect(hWnd, &rc);
DWM_THUMBNAIL_PROPERTIES dskThumbProps;
...
dskThumbProps.rcDestination = rc;
DwmUpdateThumbnailProperties(thumbnail, &dskThumbProps);
}
break;
}
}

完成后调用 DwmUnregisterThumbnail

关于c++ - DWM 缩略图,更改预览窗口的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36543939/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com