ОБНОВЛЕННЫЙ КОД:
m_hwnd = CreateWindowEx(WS_EX_LAYERED, L"DemoApp", L"Demo App", 0, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_DESKTOP, NULL, HINST_THISCOMPONENT, this );
const int totalWidth = GetSystemMetrics(SM_CXSCREEN);
const int totalHeight = GetSystemMetrics(SM_CYSCREEN);
HDC hdcScreen = GetDC(NULL);
HDC hDC = CreateCompatibleDC(hdcScreen);
int cx = totalWidth;
int cy = totalHeight;
RECT rc = { 0, 0, cx, cy };
BITMAPINFO bmi = { 0 };
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
bmi.bmiHeader.biWidth = cx;
bmi.bmiHeader.biHeight = cy;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
RGBQUAD *prgbBits;
//// Create memory bitmap
HBITMAP hBmp = CreateDIBSection(hdcScreen, &bmi, DIB_RGB_COLORS, &reinterpret_cast<void*&>(prgbBits), NULL, 0);
HBITMAP hBmpOld = (HBITMAP)SelectObject(hDC, hBmp);
//// Draw image to memory bitmap (currently selected in memory DC)
//I WANT TO USE THIS TO INCREASE THE THICKNESS OF THE BORDER, BUT IT IS NOT WORKING
HPEN hOldPen = (HPEN)SelectObject(hDC, CreatePen(PS_DOT, 20, RGB(255, 0, 0)));
// Draw a simple picture
RECT rc2 = { 0, 0, totalWidth, totalHeight };
FrameRect(hDC, &rc2, CreateSolidBrush(RGB(255, 0, 0)));
BLENDFUNCTION blend = { 0 };
blend.BlendOp = AC_SRC_OVER;
blend.SourceConstantAlpha = 255;
blend.AlphaFormat = AC_SRC_ALPHA;
POINT ptLocation = { 0, 0 };
SIZE szWnd = { cx, cy };
POINT ptSrc = { 0, 0 };
BOOL status1 = UpdateLayeredWindow(m_hwnd, hdcScreen, &ptLocation, &szWnd, hDC, &ptSrc, 0, &blend, ULW_ALPHA);
BOOL status = SetWindowPos(m_hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
hr = m_hwnd ? S_OK : E_FAIL;
if (SUCCEEDED(hr))
{
ShowWindow(m_hwnd, SW_MAXIMIZE);
UpdateWindow(m_hwnd);
}
SelectObject(hDC, hOldPen);
SelectObject(hDC, hBmpOld);
DeleteObject(hBmp);
DeleteObject(hOldPen);
DeleteDC(hDC);
ReleaseDC(NULL, hdcScreen);