首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

MFC 创造透明的窗体

2012-09-10 
MFC 创建透明的窗体有一个程序,界面有时没有InvalidateRect,使画面卡住如果弹出MessageBox,然后点掉,界面

MFC 创建透明的窗体
有一个程序,界面有时没有InvalidateRect,使画面卡住

如果弹出MessageBox,然后点掉,界面就更新出来

已经有调用InvalidateRect函数

可能是机器的问题

现在想做的是,我创建个透明的窗体,然后发CLOSE消息,把透明窗体关掉,这样用户不会感觉到。

这要如何做?

[解决办法]

BOOL CPartTransparentDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE);// Set big icon
SetIcon(m_hIcon, FALSE);// Set small icon

// TODO: Add extra initialization here
//加入WS_EX_LAYERED扩展属性
SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,
GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0xfffff);//可调透明度
//GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);
HINSTANCE hInst = LoadLibrary("User32.DLL"); 
if(hInst) 

typedef BOOL (WINAPI *MYFUNC)(HWND,COLORREF,BYTE,DWORD); 
MYFUNC fun = NULL;
//取得SetLayeredWindowAttributes函数指针 
fun=(MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes");
if(fun)fun(this->GetSafeHwnd(),0,128,2); 
FreeLibrary(hInst); 
}
return TRUE; // return TRUE unless you set the focus to a control
}

[解决办法]
说实在话,我读了两遍也还没太搞明白你到底想表达的意思...

SendMessage(m_hWnd, WM_CLOSE,。。。)
关闭不可以么?

还是类似于慢慢退出的那种感觉...?

热点排行