对话框学习1

以下三个代码都是在OnInitDialog函数的return之前添加的

第一个设置程序窗口启动位置

SetWindowPos(0, 1, 1, -1, -1, SWP_NOSIZE | SWP_NOZORDER);

给个函数链接 http://baike.baidu.com/view/1080349.htm

第二个设置半透明对话框

SetWindowLong(this->GetSafeHwnd(), GWL_EXSTYLE, GetWindowLong(this->GetSafeHwnd(),
        GWL_EXSTYLE) ^ 0x80000);
    HINSTANCE hInst = LoadLibrary("User32.DLL");
    if(hInst){
        typedef BOOL (WINAPI *MYFUNC)(HWND, COLORREF, BYTE, DWORD);
        MYFUNC func = NULL;
        func = (MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes");
        if(func)
            func(this->GetSafeHwnd(), RGB(255, 100, 0), 230, 3);
        FreeLibrary(hInst);
    }
SetLayeredWindowAttributes 函数介绍 http://baike.baidu.com/view/1329156.htm

第三个创建不规则对话框

CRect rect;
    CRgn newRgn;
    GetClientRect(&rect);
    newRgn.CreateEllipticRgn(rect.left, rect.top, rect.Width(), rect.Height());
    ::SetWindowRgn(this->m_hWnd, (HRGN)newRgn, 1);
SetWindowRgn http://baike.baidu.com/view/1559429.htm
原文地址:https://www.cnblogs.com/louzhang/p/2703566.html