基本信息
源码名称:c++不规则界面
源码大小:8.74M
文件格式:.rar
开发语言:C/C++
更新时间:2025-07-11
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

是一个不规则形状界面 


void CIrregularWindow::SetAttachWndTransColor(DWORD dwColor)
{
m_dwAttachWndTransColor = dwColor;

HMODULE hInst = LoadLibrary(_T("User32.DLL")); 

typedef BOOL (WINAPI *MYFUNC)(HWND, COLORREF, BYTE, DWORD); 

MYFUNC SetLayeredWindowAttributes = NULL; 

SetLayeredWindowAttributes = (MYFUNC)::GetProcAddress(hInst, "SetLayeredWindowAttributes"); 

if(SetLayeredWindowAttributes)
{
if(!SetLayeredWindowAttributes(m_hAttachWnd, m_dwAttachWndTransColor, 0, LWA_COLORKEY))
{
assert(false && _T("SetLayeredWindowAttributes 失败了!"));
}
}

::FreeLibrary(hInst);
}

void CIrregularWindow::InitGDIplus()
{
Gdiplus::GdiplusStartupInput gdiplusStartupInput;

Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
}

void CIrregularWindow::UnInitGDIplus()
{
Gdiplus::GdiplusShutdown(gdiplusToken);
}

void CIrregularWindow::CenterWindow()
{
RECT rcDlg = {0};
    ::GetWindowRect(m_hWnd, &rcDlg);
    RECT rcArea = { 0 };
    RECT rcCenter = { 0 };
    HWND hWndParent = ::GetParent(m_hWnd);
    HWND hWndCenter = ::GetWindowOwner(m_hWnd);
    ::SystemParametersInfo(SPI_GETWORKAREA, NULL, &rcArea, NULL);
    if( hWndCenter == NULL ) rcCenter = rcArea; else ::GetWindowRect(hWndCenter, &rcCenter);

    int DlgWidth = rcDlg.right - rcDlg.left;
    int DlgHeight = rcDlg.bottom - rcDlg.top;

    // Find dialog's upper left based on rcCenter
    int xLeft = (rcCenter.left rcCenter.right) / 2 - DlgWidth / 2;
    int yTop = (rcCenter.top rcCenter.bottom) / 2 - DlgHeight / 2;

    // The dialog is outside the screen, move it inside
    if( xLeft < rcArea.left ) xLeft = rcArea.left;
    else if( xLeft DlgWidth > rcArea.right ) xLeft = rcArea.right - DlgWidth;
    if( yTop < rcArea.top ) yTop = rcArea.top;
    else if( yTop DlgHeight > rcArea.bottom ) yTop = rcArea.bottom - DlgHeight;
    ::SetWindowPos(m_hWnd, NULL, xLeft, yTop, -1, -1, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}