窗体动画加载和退出AnimateWindow

实现动画显示窗体需要使用AnimateWindow函数,并设值为AW_CENTER|AW_HIND等风格,由于该函数没有被封装,需要手动的从USER32动态库中导出,该函数可以通过窗体的创建和销毁的过程中使用,并且可以达到动态效果。

BOOL CDlgDlg::OnInitDialog()
{
  ....
// 动画显示窗口
	CenterWindow(); 

	DWORD dwstyle = AW_CENTER;
	HINSTANCE hinst = LoadLibrary(L"User32.DLL");
	typedef BOOL(WINAPI MYFUNC(HWND, DWORD, DWORD));
	MYFUNC* AnimateWindow;
	AnimateWindow = (MYFUNC*)::GetProcAddress(hinst, "AnimateWindow");
	AnimateWindow(this->m_hWnd, 1000, dwstyle);
	FreeLibrary(hinst);	

}


void CDlgDlg::OnClose()
{
	// TODO:  在此添加消息处理程序代码和/或调用默认值

	DWORD dwstyle = AW_CENTER;
	HINSTANCE hinst = LoadLibrary(L"User32.DLL");
	typedef BOOL(WINAPI MYFUNC(HWND, DWORD, DWORD));
	MYFUNC* AnimateWindow;
	AnimateWindow = (MYFUNC*)::GetProcAddress(hinst, "AnimateWindow");
	AnimateWindow(this->m_hWnd, 1000, AW_HIDE | dwstyle);
	FreeLibrary(hinst);

	CDialogEx::OnClose();
}

 

 

 

你可能感兴趣的:(VC++/MFC)