AnimateWindow动态建立窗口


1.建立一个单文档SID程序

2:在CMainNFrame的OnCreate()中添加函数调用

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) {

if (CFrameWnd::OnCreate(lpCreateStruct) == -1)  

return -1;

.... .... ..........  

m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);

EnableDocking(CBRS_ALIGN_ANY);

DockControlBar(&m_wndToolBar);

AnimateWindow(GetSafeHwnd(),2000,AW_SLIDE|AW_HOR_POSITIVE); return 0;

}

这样就有了建立窗口的过程

3:在CMainNFrame类中添加OnClose()消息

void CMainFrame::OnClose()

{ // TODO: Add your message handler code here and/or call default

AnimateWindow(GetSafeHwnd(),2000,AW_HIDE|AW_CENTER);

CFrameWnd::OnClose(); }

这样就建立了关闭窗口的动态过程

4:光作上面的工作你还无法完成整个调用过程,因为在编译时你可能会遇到如下情况:
'AnimateWindow' ,AW_HIDE,AW_CENTER:undeclared identifier 通常碰到这种情况我们可能都会以为是少了包含,AnimateWindow()定义在winuser.h中,

在stdafx.h 添加#include<winuser.h>后应该可以了吧,重新编译发现上面的问题是没有了,但是又出来了新的 问题 syntax error : missing ';' before identifier 'HDWP' fatal error C1004: unexpected end of file found
为什么,难道不能调用?后来查了些资料,问题还是没有解决,最后有个网友提醒我,其实不用在 stdafx.h中添加#include<winuser.h>

在stdafx.h添加如下2行就可以了

// stdafx.h : include file for standard system include files, //  or project specific include files that are used frequently, but //      are changed infrequently //

#if !defined(AFX_STDAFX_H__4724EEBC_1F0B_477B_9BB6_2860AA382394__INCLUDED_)

#define AFX_STDAFX_H__4724EEBC_1F0B_477B_9BB6_2860AA382394__INCLUDED_

就是下面这2行 #undef WINVER #define WINVER 0X500

再编译就会发现一切ok.

posted @ 2012-08-15 20:44  Alan Perlis  阅读(325)  评论(0编辑  收藏  举报