设置窗口透明

1.设置窗口透明

  1: //Set WS_EX_LAYERED on this window
  2: ::SetWindowLong(GetSafeHwnd(),
  3:         GWL_EXSTYLE,
  4: 	   ::GetWindowLongPtr(GetSafeHwnd(),GWL_EXSTYLE)|WS_EX_LAYERED);
  5: 
  6: //Make this window 70% alpha transparent
  7: this->SetLayeredWindowAttributes(0,(255*70)/100,LWA_ALPHA);

2.去除窗口透明

  1: //Remove WS_EX_LAYERED from window style
  2: ::SetWindowLong(GetSafeHwnd(),
  3:     GWL_EXSTYLE,
  4: 	::GetWindowLongPtr(GetSafeHwnd(),GWL_EXSTYLE)&~WS_EX_LAYERED);
  5: //Repaint
  6: this->RedrawWindow();

3.实际运行效果

ScreenShot00074

ScreenShot00075

posted on 2010-05-07 16:11  wudong  阅读(2425)  评论(0)    收藏  举报

导航