怎么主窗口点一下透明点一下不透明呢

lluct 2006-03-28 02:37:24
两个对话框A,B. 点对话框A的弹出对话框B.用slider控件控制对话框A的透明度.可是出现一个怪现象.第一次点击"参数设置",对话框A透明.关闭B.第二次点击,A不透明.关闭B,第三次点击,A又透明,如此反复.是怎么回事呢?
主要代码:
A.cpp
void CUctProDlg::OnButtonSettings() //参数设置控件函数
{
// TODO: Add your control notification handler code here
CUctProSettingsDlg dlgSetting;
dlgSetting.DoModal();
}
B.cpp

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

// TODO: Add extra initialization here
m_TransparentSlider.SetRange(5, 255);
m_TransparentSlider.SetPos(::GetPrivateProfileInt("Settings","Transparent",3,".\\Settings.ini"));

SetWindowLong(AfxGetMainWnd()->GetSafeHwnd(),GWL_EXSTYLE,
GetWindowLong(AfxGetMainWnd()->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(AfxGetMainWnd()->GetSafeHwnd(),0,m_TransparentSlider.GetPos(),2);
FreeLibrary(hInst);
}

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}


void CUctProSettingsDlg::OnReleasedcaptureSliderTransparent(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here

m_TransparentData = (BYTE)m_TransparentSlider.GetPos();
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(AfxGetMainWnd()->GetSafeHwnd(),0,m_TransparentData,2);
FreeLibrary(hInst);
}

CString tranStr;
tranStr.Format("%d",m_TransparentData);
::WritePrivateProfileString("Settings","Transparent",tranStr,".\\Settings.ini");

*pResult = 0;
}

void CUctProSettingsDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default

m_TransparentData = (BYTE)m_TransparentSlider.GetPos();
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(AfxGetMainWnd()->GetSafeHwnd(),0,m_TransparentData,2);
FreeLibrary(hInst);
}
...全文
131 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

15,976

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧