vc++中調用AnimateWindow動態建立視窗)

來源:互聯網
上載者:User

1:首先建立一個單文檔工程
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.

原文出處:http://www.cnblogs.com/Richinger/archive/2005/07/22/197871.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.