• PopupMenu弹出菜单


    CMenu MoviePopupMenu;//声明

    MoviePopupMenu.CreatePopupMenu();//创建弹出菜单

    根据对象类型增加弹出项

     1         if(nTemp == WB_OBJ_FLASH && nSelectedObj == 1)     //    FLASH对象
     2         {
     3             CString strPlay;
     4             strPlay = ReadConfigText(_T("WhiteBoardMenuListText"), _T("movie_play"));
     5             if (strPlay.IsEmpty())
     6             {
     7                 strPlay = _T("播放");
     8             }
     9             CString strStop;
    10             strStop = ReadConfigText(_T("WhiteBoardMenuListText"), _T("movie_Stop"));
    11             if (strStop.IsEmpty())
    12             {
    13                 strStop = _T("停止");
    14             }
    15             CString strPause;
    16             strPause = ReadConfigText(_T("WhiteBoardMenuListText"), _T("movie_pause"));
    17             if (strPause.IsEmpty())
    18             {
    19                 strPause = _T("暂停");
    20             }
    21             CString strLoop;
    22             strLoop = ReadConfigText(_T("WhiteBoardMenuListText"), _T("movie_loop"));
    23             if (strLoop.IsEmpty())
    24             {
    25                 strLoop = _T("循环播放");
    26             }
    27             if (((CWBFlash *)pObj)->m_bIsRunning)
    28             {
    29                 if (((CWBFlash *)pObj)->m_bIsPause)
    30                 {
    31                     MoviePopupMenu.AppendMenu(MF_STRING, ID_OBMENU_MOVIE_PALY, strPlay);
    32                     MoviePopupMenu.AppendMenu(MF_GRAYED|MF_STRING, ID_OBMENU_MOVIE_PAUSE, strPause);
    33                 } 
    34                 else
    35                 {
    36                     MoviePopupMenu.AppendMenu(MF_GRAYED|MF_STRING, ID_OBMENU_MOVIE_PALY, strPlay);
    37                     MoviePopupMenu.AppendMenu(MF_STRING, ID_OBMENU_MOVIE_PAUSE, strPause);
    38                 }            
    39                 MoviePopupMenu.AppendMenu(MF_STRING, ID_OBMENU_MOVIE_STOP,strStop);
    40             } 
    41             else
    42             {
    43                 MoviePopupMenu.AppendMenu(MF_STRING, ID_OBMENU_MOVIE_PALY, strPlay);
    44                 MoviePopupMenu.AppendMenu(MF_GRAYED|MF_STRING, ID_OBMENU_MOVIE_PAUSE, strPause);
    45                 MoviePopupMenu.AppendMenu(MF_GRAYED|MF_STRING, ID_OBMENU_MOVIE_STOP, strStop);
    46             }
    View Code

    MoviePopupMenu.AppendMenu(MF_SEPARATOR);//增加一条分割线

    声明位图对象

    CBitmap m_MoviePlayBmp; //播放
    CBitmap m_MoviePauseBmp; //暂停
    CBitmap m_MovieStopBmp; //停止
    CBitmap m_MovieCircleBmp; //循环播放
    CBitmap m_MediaCatchFrameBmp; //截图
    CBitmap m_MediaSetmuteBmp; //有音
    CBitmap m_MediaNoSetmuteBmp; //静音

    1         //菜单中加载图片
    2         //视频        MoviePopupMenu.SetMenuItemBitmaps(ID_OBMENU_MOVIE_PALY, MF_BYCOMMAND, &m_MoviePlayBmp,NULL); // 播放
    3         MoviePopupMenu.SetMenuItemBitmaps(ID_OBMENU_MOVIE_PAUSE, MF_BYCOMMAND, &m_MoviePauseBmp,NULL); // 暂停
    4         MoviePopupMenu.SetMenuItemBitmaps(ID_OBMENU_MOVIE_STOP, MF_BYCOMMAND, &m_MovieStopBmp,NULL); // 停止
    5         MoviePopupMenu.SetMenuItemBitmaps(ID_OBMENU_MOVIE_CIRCLE, MF_BYCOMMAND, &m_MovieCircleBmp,NULL); // 循环播放
    6         PopupMenu.SetMenuItemBitmaps(ID_OBMENU_MEDIA_CATCHFRAME, MF_BYCOMMAND, &m_MediaCatchFrameBmp,NULL);//截图
    7         PopupMenu.SetMenuItemBitmaps(ID_OBMENU_MEDIA_SETMUTE, MF_BYCOMMAND, &m_MediaSetmuteBmp,&m_MediaNoSetmuteBmp);  //静音
    View Code
     1 void  CWhiteBoardView::LoadPopupMenuBitmap()
     2 {
     3     //视频
     4     m_MoviePlayBmp.LoadBitmap(IDB_OBMENU_MOVIE_PALY); // 视频播放
     5     TranslateBitmapSizeToFitXP(&m_MoviePlayBmp);
     6     m_MoviePauseBmp.LoadBitmap(IDB_OBMENU_MOVIE_PAUSE); //视频暂停
     7     TranslateBitmapSizeToFitXP(&m_MoviePauseBmp);
     8     m_MovieStopBmp.LoadBitmap(IDB_OBMENU_MOVIE_STOP); //视频停止
     9     TranslateBitmapSizeToFitXP(&m_MovieStopBmp);
    10     m_MovieCircleBmp.LoadBitmap(IDB_OBMENU_MOVIE_CIRCLE); //视频循环播放
    11     TranslateBitmapSizeToFitXP(&m_MovieCircleBmp);
    12 
    13     m_MediaCatchFrameBmp.LoadBitmap(IDB_OBMENU_MEDIA_CATCHFRAME); //截图
    14     TranslateBitmapSizeToFitXP(&m_MediaCatchFrameBmp);
    15     m_MediaSetmuteBmp.LoadBitmap(IDB_OBMENU_MEDIA_SETMUTE); //有音
    16     TranslateBitmapSizeToFitXP(&m_MediaSetmuteBmp);
    17     m_MediaNoSetmuteBmp.LoadBitmap(IDB_OBMENU_MEDIA_NOSETMUTE); //静音
    18     TranslateBitmapSizeToFitXP(&m_MediaNoSetmuteBmp);
    19 }
    View Code

    上面是载入菜单项对应的自定义位图资源声明

    #define IDB_OBMENU_MOVIE_PALY 3407
    #define IDB_OBMENU_MOVIE_PAUSE 3408
    #define IDB_OBMENU_MOVIE_STOP 3409
    #define IDB_OBMENU_MOVIE_CIRCLE 3410

    //下面是菜单项的资源声明

    #define ID_OBMENU_MOVIE_PALY 8822
    #define ID_OBMENU_MOVIE_STOP 8823
    #define ID_OBMENU_MOVIE_PAUSE 8824
    #define ID_OBMENU_MOVIE_CIRCLE 8825

    BOOL CWhiteBoardView::OnCommand(WPARAM wParam, LPARAM lParam)
    {
    UINT nItemID = LOWORD(wParam);

    switch (nItemID)
    {

        case ID_OBMENU_MOVIE_PALY: //视频播放
            {
                CWBObject *pObj = g_pWBPage->FindByLayerIndex(m_dwMenuLayerIndex);
                if (pObj == NULL)
                {
                    break;
                }
                WB_OBJ_TYPE ntemptype = (WB_OBJ_TYPE)pObj->GetType();
                if ( ntemptype== WB_OBJ_FLASH) //如果对象是flash
                {
                    ((CWBFlash *)pObj)->Start();
                }
                if (ntemptype == WB_OBJ_MEDIA)
                {
                    if (((CWBMedia*)pObj)->IsActiveCreated())
                    {
                        ((CWBMedia*)pObj)->MediaPlay();
                    }
                    else
                    {
                        ((CWBMedia*)pObj)->SetMediaPlayState(Media_playing);
                    }
                }
                Invalidate();
                //发送同步信息
                XMemIni xmlObj;            
                pObj->SetXmlValue(xmlObj);
                if (ntemptype == WB_OBJ_MEDIA || ntemptype == WB_OBJ_FLASH)
                {
                    xmlObj.Set(KEY_MEDIA_OPERATION, WB_MOVIE_START);
                }
                g_pWhiteBoardView->ChangeObj(xmlObj);
            }
            break;
        case ID_OBMENU_MOVIE_STOP: //视频停止
            {
                CWBObject *pObj = g_pWBPage->FindByLayerIndex(m_dwMenuLayerIndex);
                if (pObj == NULL)
                {
                    break;
                }
                WB_OBJ_TYPE ntemptype = (WB_OBJ_TYPE)pObj->GetType();
                if (ntemptype == WB_OBJ_FLASH) //如果对象是flash
                {
                    ((CWBFlash *)pObj)->Stop();
                }
                if (ntemptype == WB_OBJ_MEDIA)
                {
                    if (((CWBMedia*)pObj)->IsActiveCreated())
                    {
                        ((CWBMedia*)pObj)->MediaStop();
                    }
                    else
                    {
                        ((CWBMedia*)pObj)->SetMediaPlayState(Media_stop);
                    }
                }
                Invalidate();
                //发送同步信息
                XMemIni xmlObj;            
                pObj->SetXmlValue(xmlObj);
                if (ntemptype == WB_OBJ_MEDIA || ntemptype == WB_OBJ_FLASH)
                {
                    xmlObj.Set(KEY_MEDIA_OPERATION, WB_MOVIE_STOP);
                }
                g_pWhiteBoardView->ChangeObj(xmlObj);
            }
            break;
        case ID_OBMENU_MOVIE_PAUSE: //视频暂停
                            .
                            .
                            .
    View Code

    }

    }

    .rc文件

    IDB_BITMAP_EMPTY_MENU_ITEM BITMAP                  "res\image\EmptyMenuItem.bmp"

    IDB_OBMENU_MOVIE_PALY BITMAP "res\image\Menu\IDB_OBMENU_MOVIE_PALY.bmp"
    IDB_OBMENU_MOVIE_PAUSE BITMAP "res\image\Menu\IDB_OBMENU_MOVIE_PAUSE.bmp"
    IDB_OBMENU_MOVIE_STOP BITMAP "res\image\Menu\IDB_OBMENU_MOVIE_STOP.bmp"
    IDB_OBMENU_MOVIE_CIRCLE BITMAP "res\image\Menu\IDB_OBMENU_MOVIE_CIRCLE.bmp"

  • 相关阅读:
    27-Perl 进程管理
    26-Perl 包和模块
    25-Perl CGI编程
    YUM极速安装mariadb
    yum极速安装mysql5.7
    切换阿里yum镜像源
    mysql生成随机字符串函数
    Unable to locate value meta plugin of type (id)
    centos 挂载NTFS移动硬盘
    总有你要的编程书单(GitHub )
  • 原文地址:https://www.cnblogs.com/lisuyun/p/3479754.html
Copyright © 2020-2023  润新知