第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

運(yùn)行之后出現(xiàn)以下錯(cuò)誤后:請(qǐng)問該怎么修改?

運(yùn)行之后出現(xiàn)以下錯(cuò)誤后:請(qǐng)問該怎么修改?

C++ C
泛舟湖上清波郎朗 2022-04-22 14:15:41
#include<iostream>#include<String.h>#include<afx.h>using namespace std;VOID CALLBACK my_timer();void main(){SetTimer(NULL,0,1000,my_timer);}VOID CALLBACK my_timer(){cout<<"timer"<<endl;}運(yùn)行之后出現(xiàn)以下錯(cuò)誤:error C2664: 'SetTimer' : cannot convert parameter 4 from 'void (void)' to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,unsigned long)'應(yīng)該怎么改?
查看完整描述

2 回答

?
繁花不似錦

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超4個(gè)贊

就是定時(shí)器
創(chuàng)建定時(shí)器:SetTimer(1,1000,NULL);
1表示定時(shí)器的ID,1000表示沒1000ms也就是1s調(diào)用一次處理函數(shù),最后一個(gè)參數(shù)是處理的函數(shù),如果填NULL表示,
添加響應(yīng)函數(shù)
對(duì)話框右擊建立響應(yīng)事件
WM_Timer在這里面寫你要執(zhí)行的操作就可以了,如果你有多個(gè)定時(shí)器要在這里寫if(nIDEvent
==
1)類似的東西去區(qū)分不同的定時(shí)器
其實(shí)比較常用switch(nIDEvent)
關(guān)閉定時(shí)器:KillTimer(1)



查看完整回答
反對(duì) 回復(fù) 2022-04-24
?
絕地?zé)o雙

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超4個(gè)贊

你的概念有問題吧,settimer用的是mfc的還是window的api?
看一下下面的資料吧
MFC中的SetTimer

CWnd::SetTimer
UINT SetTimer( UINT nIDEvent, UINT nElapse, void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD) );

Return Value

The timer identifier of the new timer if the function is successful. An application passes this value to the KillTimer member function to kill the timer. Nonzero if successful; otherwise 0.

Parameters

nIDEvent

Specifies a nonzero timer identifier.

nElapse

Specifies the time-out value, in milliseconds.

lpfnTimer

Specifies the address of the application-supplied TimerProc callback function that processes the WM_TIMER messages. If this parameter is NULL, the WM_TIMER messages are placed in the application’s message queue and handled by the CWnd object.

Remarks

Installs a system timer. A time-out value is specified, and every time a time-out occurs, the system posts aWM_TIMER message to the installing application’s message queue or passes the message to an application-defined TimerProc callback function.

The lpfnTimer callback function need not be named TimerProc, but it must be defined as follows:

void CALLBACK EXPORT TimerProc(
HWND hWnd, // handle of CWnd that called SetTimer
UINT nMsg, // WM_TIMER
UINT nIDEvent // timer identification
DWORD dwTime // system time
);

Timers are a limited global resource; therefore it is important that an application check the value returned by the SetTimer member function to verify that a timer is actually available.

Example

// This example shows how to use CWnd::SetTimer, CWnd::KillTimer, and how to handle WM_TIMER messages. A timer is set up to send a WM_TIMER message to the main frame window every 2 seconds in OnStartTimer(). OnStopTimer will stop the timer by calling CWnd::KillTimer. OnTimer was set up through class wizard to handle WM_TIMER messages for the main frame window. In this example the PC speaker will beep every 2 seconds.

void CMainFrame::OnStartTimer()
{
m_nTimer = SetTimer(1, 2000, 0);
}

void CMainFrame::OnStopTimer()
{
KillTimer(m_nTimer);
}

void CMainFrame::OnTimer(UINT nIDEvent)
{
MessageBeep(0xFFFFFFFF); // Beep

// Call base class handler.
CMDIFrameWnd::OnTimer(nIDEvent);
}

Windows API中的SetTimer

SetTimer
The SetTimer function creates a timer with the specified time-out value.

UINT_PTR SetTimer(
HWND hWnd, // handle to window
UINT_PTR nIDEvent, // timer identifier
UINT uElapse, // time-out value
TIMERPROC lpTimerFunc // timer procedure
);
Parameters
hWnd
[in] Handle to the window to be associated with the timer. This window must be owned by the calling thread. If this parameter is NULL, no window is associated with the timer and the nIDEvent parameter is ignored.
nIDEvent
[in] Specifies a nonzero timer identifier. If the hWnd parameter is NULL, this parameter is ignored.
If the hWnd parameter is not NULL and the window specified by hWnd already has a timer with the value nIDEvent, then the existing timer is replaced by the new timer. When SetTimer replaces a timer, the timer is reset. Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored.

uElapse
[in] Specifies the time-out value, in milliseconds.
lpTimerFunc
[in] Pointer to the function to be notified when the time-out value elapses. For more information about the function, see TimerProc.
If lpTimerFunc is NULL, the system posts a WM_TIMER message to the application queue. The hwnd member of the message's MSG structure contains the value of the hWnd parameter.

Return Values
If the function succeeds and the hWnd parameter is NULL, the return value is an integer identifying the new timer. An application can pass this value to the KillTimer function to destroy the timer.

If the function succeeds and the hWnd parameter is not NULL, then the return value is a nonzero integer. An application can pass the value of the nIDTimer parameter to the KillTimer function to destroy the timer.

If the function fails to create a timer, the return value is zero. To get extended error information, call GetLastError.

Remarks
An application can process WM_TIMER messages by including a WM_TIMER case statement in the window procedure or by specifying a TimerProc callback function when creating the timer. When you specify a TimerProc callback function, the default window procedure calls the callback function when it processes WM_TIMER. Therefore, you need to dispatch messages in the calling thread, even when you use TimerProc instead of processing WM_TIMER.

The wParam parameter of the WM_TIMER message contains the value of the nIDEvent parameter.

The timer identifier, nIDEvent, is specific to the associated window. Another window can have its own timer which has the same identifier as a timer owned by another window. The timers are distinct.



查看完整回答
反對(duì) 回復(fù) 2022-04-24
  • 2 回答
  • 0 關(guān)注
  • 193 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)