小祥的blog

游戏开发
随笔 - 11, 文章 - 0, 评论 - 7, 引用 - 0
数据加载中……

SplashScreen

 SplashScreen

     开始学习wxWidgets。准备把学到的都记下来,算是自己的学习笔记。
     今天写了一个SplashScreen的小例子。SplashScreen的意思通俗点来说就是在程序运行前先蹦出来的东东。举个例子,比如游侠网下载的游戏,每次运行前都会蹦出来一个小图片,停留几秒后,等它消失了才会进入游戏。
     大致流程是:1. 加载需要的image handler,下表列出的是wx可用的image handler(可以看出目前只有PNG格式支持alpha通道)
                          
wxBMPHandler For loading and saving, always installed.
wxPNGHandler For loading (including alpha support) and saving.
wxJPEGHandler For loading and saving.
wxGIFHandler Only for loading, due to legal issues.
wxPCXHandler For loading and saving (see below).
wxPNMHandler For loading and saving (see below).
wxTIFFHandler For loading and saving.
wxTGAHandler For loading only.
wxIFFHandler For loading only.
wxXPMHandler For loading and saving.
wxICOHandler For loading and saving.
wxCURHandler For loading and saving.
wxANIHandler For loading only.
    wx默认加载wxBMPHandler,如果要用其他格式,则可以通过调用wxImage::AddHandler()函数进行加载。也可以调用wxImage::wxInitAllImageHandlers()加载所有的,但通常没有这个必要。
                    2. Load图片。
                        通过wxBitmap::LoadFile( const wxString& name, wxBitmapType type )函数。
                        name是将要load进来得图片的名字,type是图片格式的类型,比如bmp格式的图片就是wxBITMAP_TYPE_BMP ,PNG格式的就是wxBITMAP_TYPE_PNG。。。
                    3. 可以创建SplashScreen了。
                        wxSplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSIMPLE_BORDER|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP)
                        具体参数一看就明白意思了。bitmap就是上面第2步创建的,splashStyle是风格,例:wxSPLASH_CENTRE_ON_SCREEN。后面几个参数分别是 持续时间,父窗口指针, id号, 位置, 大小,样式。。

 1wxImage::AddHandler(new wxPNGHandler);
 2
 3    wxBitmap bitmap;
 4
 5    bitmap.LoadFile(_T("splash.png"), wxBITMAP_TYPE_PNG);
 6
 7    wxSplashScreen* const splashScreen = new wxSplashScreen(bitmap,
 8            wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,
 9            -1, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize,
10            wxSIMPLE_BORDER|wxSTAY_ON_TOP);
11
12    Yield(); // 挂起消息
13
14         Sleep( 2000 );
15
16        delete splashScreen;

这样,程序在每次运行前,都会在先屏幕中央弹出splash.png这张图片,2秒终后,出现程序界面。。

版权声明:本篇为原创文章,允许转载,但转载时请务必以超链接形式标明文章的原始出处和作者信息。请尊重本人的劳动成果,谢谢!
小祥的BLOG http://xfxsworld.cnblogs.com

posted on 2008-01-26 21:45 小祥 阅读(333) 评论(0)  编辑 收藏 网摘 所属分类: wxWidgets


标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
Google站内搜索

China-pub 计算机图书网上专卖店!6.5万品种 2-8折!
近千种 9-95 新二手计算图书火热销售中!
开发者征途系统新作:《设计模式——基于C#的工程化实现及扩展》



相关文章:

相关链接:

所属分类的其他文章:
wxWidgets helper classes
SplashScreen