游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2422|回复: 2

SetTimer的函式是要如何定?呢(DirectShow?例)

[复制链接]

414

主题

611

帖子

621

积分

高级会员

Rank: 4

积分
621
发表于 2006-3-5 03:17:00 | 显示全部楼层 |阅读模式
SetTimer的函式是要如何定?呢

附上source code:\Players.zip
BGMusic 是

原程式from SamplesDX9b\C++\DirectShow\Players\BGMusic
VOID CALLBACK MyTimerProc(
                          HWND hwnd,     // handle to window
                          UINT uMsg,     // WM_TIMER message
                          UINT idEvent,  // timer identifier
                          DWORD dwTime   // current system time
)
{
    SwapSourceFilter();

    // Update the "current file" text message
    RECT rc;
    GetWindowRect(hwnd, &rc);
    InvalidateRect(hwnd, &rc, TRUE);
}

HRESULT GraphInit(void)
{
    if(!SetTimer(g_hwndApp, 0, MEDIA_TIMEOUT, (TIMERPROC) MyTimerProc))
        return E_FAIL;

我?⑺??成依各??e可是?s出????
VOID CALLBACK CSongPlayer::MyTimerProc(
                          HWND hwnd,     // handle to window
                          UINT uMsg,     // WM_TIMER message
                          UINT idEvent,  // timer identifier
                          DWORD dwTime   // current system time
)
{
    SwapSourceFilter();

    // Update the "current file" text message
    RECT rc;
    GetWindowRect(hwnd, &rc);
    InvalidateRect(hwnd, &rc, TRUE);
}

HRESULT CSongPlayer::GraphInit(void)
{
    if(!SetTimer(g_hwndApp, 0, MEDIA_TIMEOUT, (TIMERPROC) CSongPlayer::MyTimerProc))
        return E_FAIL;

??霈F以下??,是否要把MyTinerProc改成statuc function才可以解呢?

--------------------Configuration: BGMusic - Win32 Debug Unicode--------------------
Compiling...
SongPlayer.cpp
E:\Akira Tmp\SamplesDX9b\C++\DirectShow\Players\Ak -BGMusic\SongPlayer.cpp(86) : error C2440: 'type cast' : cannot convert from '' to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,unsigned long)'
        None of the functions with this name in scope match the target type
Error executing cl.exe.

bgmusic.exe - 1 error(s), 0 warning(s)

sf_2006353174.zip

70.6 KB, 下载次数:

55

主题

263

帖子

263

积分

中级会员

Rank: 3Rank: 3

积分
263
发表于 2006-3-5 06:26:00 | 显示全部楼层

Re:SetTimer的函式是要如何定?呢(DirectShow?例)

SetTimer的回调函数如果要指定成类成员函数的话只能是静态类成员函数,因为系统不会给你传递对象指针
如果要用SetTimer计时的话只能通过一个全局函数中转

414

主题

611

帖子

621

积分

高级会员

Rank: 4

积分
621
 楼主| 发表于 2006-3-6 22:09:00 | 显示全部楼层

Re:SetTimer的函式是要如何定?呢(DirectShow?例)

ok已?解?Q了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-23 19:56

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表