启动界面淡入淡出效果

启动界面淡入淡出效果需要加载User32.DLL动态链接库

1.新建对话框资源,Border=none,添加图像控件,导入位图资源

2.动态窗口定义

/*
* AnimateWindow() Commands
*/
#define AW_HOR_POSITIVE             0x00000001
#define AW_HOR_NEGATIVE             0x00000002
#define AW_VER_POSITIVE             0x00000004
#define AW_VER_NEGATIVE             0x00000008
#define AW_CENTER                   0x00000010
#define AW_HIDE                     0x00010000
#define AW_ACTIVATE                 0x00020000
#define AW_SLIDE                    0x00040000
#define AW_BLEND                    0x00080000

3.BOOL CMFCApplication2Dlg::OnInitDialog()



// TODO: Add extra initialization here
	CenterWindow(); //对话框处于中心位置
	DWORD dwStyle = AW_BLEND;
	HINSTANCE hInst = LoadLibrary("User32.DLL");  //导入动态链接库User32.DLL
	typedef BOOL(WINAPI MYFUNC(HWND, DWORD, DWORD));
	MYFUNC* AnimateWindow;  //声明函数
	AnimateWindow = (MYFUNC *)::GetProcAddress(hInst, "AnimateWindow");
	AnimateWindow(this->m_hWnd, 750, dwStyle);
	FreeLibrary(hInst);      //释放动态链接库
	SetTimer(1, 2000, NULL); //设置定时器


	//return TRUE;  // return TRUE unless you set the focus to a control


4.添加定时器消息ON_WM_TIMER()

5.void CMFCApplication2Dlg::OnTimer(UINT nIDEvent)

{
	// TODO: Add your message handler code here and/or call default
	DWORD dwStyle = AW_BLEND;
	HINSTANCE hInst = LoadLibrary("User32.DLL"); //导入动态链接库User32.DLL
	typedef BOOL(WINAPI MYFUNC(HWND, DWORD, DWORD));
	MYFUNC* AnimateWindow; //声明函数
	AnimateWindow = (MYFUNC *)::GetProcAddress(hInst, "AnimateWindow");
	AnimateWindow(this->GetSafeHwnd(), 750, AW_HIDE | dwStyle);
	FreeLibrary(hInst);   //释放动态链接库
	KillTimer(1);
	CDialog::OnOK(); //关闭对话框
	CDialog::OnTimer(nIDEvent);
}

6.代码

http://download.csdn.net/detail/greless/9853931



你可能感兴趣的:(Visual,C++从入门到精通,笔记)