R3中微软的Silverlight的例子XAMLPERF中的FRM_START,FRM_STOP,FRM_GET_FRAMES_PER_SECOND什么意思?
这三个东西在main.cpp中定义的:
class FrameRateManager
{
enum FrameRateMonitorMessage
{
FRM_START = 0,
FRM_STOP,
FRM_GET_FRAMES_PER_SECOND
};
使用如下:
//Register the message with the host
HRESULT RegisterMessage()
{
HRESULT hr = S_OK;
m_TestMessage = RegisterWindowMessage(c_FrameRateMessageName);
CBR(0 != m_TestMessage);
CHR(static_cast<HRESULT>(SendMessage(m_Hwnd, m_TestMessage, FRM_START, 0)));
Error:
return hr;
}
还有就是:
// get the current frame rate
HRESULT
GetFrameRate(UINT * pFPS)
{
HRESULT hr = S_OK;
DWORD ProcessId = NULL;
HANDLE hRemoteProcess = NULL;
VOID* pResultBuffer = NULL;
float Result = 0.0;
// Get a handle to the EXR process containing the target HWND
GetWindowThreadProcessId(m_Hwnd, &ProcessId);
hRemoteProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcessId);
// Allocate memory in the EXR process to marshal the fps counter over to this process
pResultBuffer = VirtualAllocEx(hRemoteProcess, NULL, sizeof(FLOAT), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
CPR(pResultBuffer);
hr = static_cast<HRESULT>(SendMessage(m_Hwnd, m_TestMessage, FRM_GET_FRAMES_PER_SECOND, (LPARAM)pResultBuffer));
CHR(hr);
// Read back EXR's response
CBREx(ReadProcessMemory(hRemoteProcess, pResultBuffer, (LPVOID)(&Result), sizeof(FLOAT), NULL), GetLastErrorHR());
if (pFPS)
{
*pFPS = (UINT)Result;
}
Error:
if (pResultBuffer)
{
VirtualFreeEx(hRemoteProcess, pResultBuffer, 0, MEM_RELEASE);
}
return hr;
}
=======================================================
CHR(static_cast<HRESULT>(SendMessage(m_Hwnd, m_TestMessage, FRM_START, 0)));
hr = static_cast<HRESULT>(SendMessage(m_Hwnd, m_TestMessage, FRM_GET_FRAMES_PER_SECOND, (LPARAM)pResultBuffer));
把这两个消息发出去,我看的比较迷茫一个.
我猜测这应该是Silverlight的内部实现的.但是MSDN中没有,不知道如何整.
资料太少了...水平不行啊...
[解决办法]
http://www.cnblogs.com/wangkewei/archive/2009/12/24/1631644.html
楼主问问博主吧,他好像对Silverlight非常熟悉。