本文整理汇总了C++中PeekMessage函数的典型用法代码示例。如果您正苦于以下问题:C++ PeekMessage函数的具体用法?C++ PeekMessage怎么用?C++ PeekMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PeekMessage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dumpstuff
void dumpstuff(WiimoteHandler* wiimote) {
VRBackendBasics graphics_objects = BeginDirectx(false, "");
MSG msg;
int prev_time = timeGetTime();
int frame_index = 0;
unsigned int rhod_entity_id = graphics_objects.entity_handler->AddEntity(makerhod(graphics_objects));
unsigned int wiimote_entity_id = graphics_objects.entity_handler->AddEntity(makewiimote(graphics_objects));
graphics_objects.entity_handler->FinishUpdate();
Quaternion obj_orient;
while (TRUE)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
if (msg.message == WM_QUIT) {
break;
}
else if (msg.message == WM_KEYDOWN) {
graphics_objects.input_handler->HandleKeydown(msg.wParam);
switch (msg.wParam) {
case 'F':
wiimote->RequestCalibrateMotionPlus();
break;
case 'C':
wiimote->SendOutputReport(OutputReportTemplates::request_calibration);
}
}
}
obj_orient = wiimote->GetCurrentState().orientation;
// Convert orientation from wiimote coord system to screen coord system
std::swap(obj_orient.y, obj_orient.z);
//float tmp = obj_orient.y;
//obj_orient.y = obj_orient.z;
//obj_orient.z = tmp;
obj_orient.x = -obj_orient.x;
ConstantBufferTyped<TransformationMatrixAndInvTransData>* wiimote_settings = graphics_objects.entity_handler->GetEntityObjectSettings<TransformationMatrixAndInvTransData>(wiimote_entity_id);
wiimote_settings->SetBothTransformations(
DirectX::XMMatrixMultiply(
DirectX::XMMatrixRotationQuaternion(
DirectX::XMVectorSet(
obj_orient.x,
obj_orient.y,
obj_orient.z,
obj_orient.w)),
DirectX::XMMatrixTranslation(0, 0, -4)));
graphics_objects.entity_handler->FinishUpdate();
int new_time = timeGetTime();
int time_delta = new_time - prev_time;
prev_time = new_time;
graphics_objects.input_handler->UpdateStates(frame_index);
graphics_objects.world->UpdateLogic(time_delta);
graphics_objects.render_pipeline->Render();
++frame_index;
}
// clean up DirectX and COM
graphics_objects.view_state->Cleanup();
if (graphics_objects.input_handler->IsOculusActive()) {
graphics_objects.oculus->Cleanup();
}
}
开发者ID:mhoff12358,项目名称:WiimoteTests,代码行数:73,代码来源:WiimoteTest.cpp
示例2: WinMain
// windows stuff..
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
WNDCLASS wc;
HWND hWnd;
// set up and register wndclass wc... windows stuff
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) WinProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(DWORD);
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "D3D8PROG";
if (! RegisterClass(&wc))
{
// error
return false;
}
// create window
hWnd = CreateWindow("D3D8PROG", "Direct3D 8 Program", // class and caption
WS_VISIBLE | WS_POPUP, // style
0, // horizontal start..
0, // vertical start..
800, // horz end
600, // vertical end..
GetDesktopWindow(), // parent..
NULL, // menu..
hInstance, // instance
NULL); // params..
if (! hWnd)
return false;
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
if (init3D(hWnd) != true) // error checking...
{
cleanup();
return false;
}
if (initData() != true)
{
cleanup();
return false;
}
do // control loop... life of the program
{
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) // gets messages when they appear
{
TranslateMessage(&msg); // standard win message stuff..
DispatchMessage(&msg);
}
else // if no message.. render
{
// this is where you do stuff when there aren't messages.. mainly render..
// might rearrange and doMath and/or other stuff here...
// depends what would be best in the future..
// for now just render
render();
}
} while (WM_QUIT != msg.message);
cleanup(); // clean it up!
return msg.wParam; // more win stuff..
}
开发者ID:pnchang,项目名称:advgraphics,代码行数:74,代码来源:example04.cpp
示例3: WinMain
int APIENTRY
WinMain(
HINSTANCE hCurrentInst,
HINSTANCE hPreviousInst,
LPSTR lpszCmdLine,
int nCmdShow)
{
WNDCLASS wndClass;
HWND hWnd;
MSG msg;
/* Define and register a window class */
wndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hCurrentInst;
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = className;
RegisterClass(&wndClass);
/* Figure out a default size for the window */
winWidth = GetSystemMetrics(SM_CYSCREEN) / 3;
winHeight = GetSystemMetrics(SM_CYSCREEN) / 3;
/* Create a window of the previously defined class */
hWnd = CreateWindow(
className, /* Window class's name */
windowName, /* Title bar text */
WS_OVERLAPPEDWINDOW | /* The window's style */
WS_CLIPCHILDREN |
WS_CLIPSIBLINGS,
winX, winY, /* Position */
winWidth, winHeight, /* Size */
NULL, /* Parent window's handle */
NULL, /* Menu handle */
hCurrentInst, /* Instance handle */
NULL); /* No additional data */
/* Map the window to the screen */
ShowWindow(hWnd, nCmdShow);
/* Force the window to repaint itself */
UpdateWindow(hWnd);
/* Process Messages */
while (1) {
/* execute the idle function while there are no messages to process */
while (idleFunc &&
PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) == FALSE)
{
(*idleFunc)();
}
if (GetMessage(&msg, NULL, 0, 0) != TRUE) {
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
开发者ID:yangguang-ecnu,项目名称:smisdk,代码行数:65,代码来源:indexfnc.c
示例4: winIsFakeCtrl_L
Bool
winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam)
{
MSG msgNext;
LONG lTime;
Bool fReturn;
/*
* Fake Ctrl_L presses will be followed by an Alt_R keypress
* with the same timestamp as the Ctrl_L press.
*/
if (message == WM_KEYDOWN
&& wParam == VK_CONTROL
&& (HIWORD (lParam) & KF_EXTENDED) == 0)
{
/* Got a Ctrl_L press */
/* Get time of current message */
lTime = GetMessageTime ();
/* Look for fake Ctrl_L preceeding an Alt_R press. */
fReturn = PeekMessage (&msgNext, NULL,
WM_KEYDOWN, WM_KEYDOWN,
PM_NOREMOVE);
/*
* Try again if the first call fails.
* NOTE: This usually happens when TweakUI is enabled.
*/
if (!fReturn)
{
/* Voodoo to make sure that the Alt_R message has posted */
Sleep (0);
/* Look for fake Ctrl_L preceeding an Alt_R press. */
fReturn = PeekMessage (&msgNext, NULL,
WM_KEYDOWN, WM_KEYDOWN,
PM_NOREMOVE);
}
/* Is next press an Alt_R with the same timestamp? */
if (fReturn && msgNext.wParam == VK_MENU
&& msgNext.time == lTime
&& (HIWORD (msgNext.lParam) & KF_EXTENDED))
{
/*
* Next key press is Alt_R with same timestamp as current
* Ctrl_L message. Therefore, this Ctrl_L press is a fake
* event, so discard it.
*/
return TRUE;
}
}
/*
* Fake Ctrl_L releases will be followed by an Alt_R release
* with the same timestamp as the Ctrl_L release.
*/
if ((message == WM_KEYUP || message == WM_SYSKEYUP)
&& wParam == VK_CONTROL
&& (HIWORD (lParam) & KF_EXTENDED) == 0)
{
/* Got a Ctrl_L release */
/* Get time of current message */
lTime = GetMessageTime ();
/* Look for fake Ctrl_L release preceeding an Alt_R release. */
fReturn = PeekMessage (&msgNext, NULL,
WM_KEYUP, WM_SYSKEYUP,
PM_NOREMOVE);
/*
* Try again if the first call fails.
* NOTE: This usually happens when TweakUI is enabled.
*/
if (!fReturn)
{
/* Voodoo to make sure that the Alt_R message has posted */
Sleep (0);
/* Look for fake Ctrl_L release preceeding an Alt_R release. */
fReturn = PeekMessage (&msgNext, NULL,
WM_KEYUP, WM_SYSKEYUP,
PM_NOREMOVE);
}
/* Is next press an Alt_R with the same timestamp? */
if (fReturn
&& (msgNext.message == WM_KEYUP
|| msgNext.message == WM_SYSKEYUP)
&& msgNext.wParam == VK_MENU
&& msgNext.time == lTime
&& (HIWORD (msgNext.lParam) & KF_EXTENDED))
{
/*
* Next key release is Alt_R with same timestamp as current
* Ctrl_L message. Therefore, this Ctrl_L release is a fake
* event, so discard it.
*/
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:dri-ex-svn,代码行数:101,代码来源:winkeybd.c
示例5: WinMain
int WINAPI WinMain(HINSTANCE hInstance, // Instance
HINSTANCE hPrevInstance, // Previous Instance
LPSTR lpCmdLine, // Command Line Parameters
int nCmdShow) // Window Show State
{
MSG msg; // Windows Message Structure
BOOL done = FALSE; // Bool Variable To Exit Loop
eng = Engine();
// Ask The User Which Screen Mode They Prefer
if (MessageBox(NULL, "Would You Like To Run In Fullscreen Mode?", "Start FullScreen?", MB_YESNO | MB_ICONQUESTION) == IDNO)
{
eng.SetScreenMode(FALSE); // Windowed Mode
}
// Create Our OpenGL Window
if (!CreateGLWindow("NeHe's Textures, Lighting & Keyboard Tutorial", 640, 480, 16, eng.GetScreenMode()))
{
return 0; // Quit If Window Was Not Created
}
while (!done) // Loop That Runs While done=FALSE
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) // Is There A Message Waiting?
{
if (msg.message == WM_QUIT) // Have We Received A Quit Message?
{
done = TRUE; // If So done=TRUE
}
else // If Not, Deal With Window Messages
{
TranslateMessage(&msg); // Translate The Message
DispatchMessage(&msg); // Dispatch The Message
}
}
else // If There Are No Messages
{
// Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene()
//bool *keys = eng.GetKeys();
if ((eng.GetActive() && !eng.DrawGLScene()) || keys[VK_ESCAPE]) // Active? Was There A Quit Received?
{
done = TRUE; // ESC or DrawGLScene Signalled A Quit
}
else // Not Time To Quit, Update Screen
{
SwapBuffers(eng.hDC); // Swap Buffers (Double Buffering)
if (keys['L'] && !lp)
{
lp = TRUE;
light = !light;
if (!light)
{
glDisable(GL_LIGHTING);
}
else
{
glEnable(GL_LIGHTING);
}
}
if (!keys['L'])
{
lp = FALSE;
}
if (keys[VK_PRIOR])
{
GLfloat z = eng.GetDepth();
z -= 0.02f;
eng.SetDepth(z);
}
if (keys[VK_NEXT])
{
GLfloat z = eng.GetDepth();
z += 0.02f;
eng.SetDepth(z);
}
if (keys[VK_UP])
{
GLfloat xspeed = eng.GetXSpeed();
xspeed -= 0.001f;
eng.SetXSpeed(xspeed);
}
if (keys[VK_DOWN])
{
GLfloat xspeed = eng.GetXSpeed();
xspeed += 0.001f;
eng.SetXSpeed(xspeed);
}
if (keys[VK_RIGHT])
{
GLfloat yspeed = eng.GetYSpeed();
yspeed += 0.001f;
eng.SetYSpeed(yspeed);
}
if (keys[VK_LEFT])
{
GLfloat yspeed = eng.GetYSpeed();
yspeed -= 0.001f;
eng.SetYSpeed(yspeed);
}
//.........这里部分代码省略.........
开发者ID:John-Janzen,项目名称:Comp4995-OpenGL-assignment,代码行数:101,代码来源:Main.cpp
示例6: wWinMain
INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR szCmdLine, int iCmdShow)
{
WNDCLASSEX winClass ;
winClass.lpszClassName = "ScreenQuad";
winClass.cbSize = sizeof(WNDCLASSEX);
winClass.style = CS_HREDRAW | CS_VREDRAW;
winClass.lpfnWndProc = MsgProc;
winClass.hInstance = hInstance;
winClass.hIcon = NULL ;
winClass.hIconSm = NULL ;
winClass.hCursor = LoadCursor(NULL, IDC_ARROW) ; // to avoid busy cursor
winClass.hbrBackground = NULL ;
winClass.lpszMenuName = NULL ;
winClass.cbClsExtra = 0;
winClass.cbWndExtra = 0;
RegisterClassEx (&winClass) ;
HWND hWnd = CreateWindowEx(NULL,
winClass.lpszClassName, // window class name
"ScreenQuad", // window caption
WS_OVERLAPPEDWINDOW, // window style
32, // initial x position
32, // initial y position
600, // initial window width
600, // initial window height
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
// Create window failed
if(hWnd == NULL)
{
MessageBoxA(hWnd, "Create Window failed!", "Error", 0) ;
return -1 ;
}
// Initialize Direct3D
if( SUCCEEDED(InitD3D(hWnd)))
{
InitVB() ;
// Show the window
ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );
// Enter the message loop
MSG msg ;
ZeroMemory( &msg, sizeof(msg) );
PeekMessage( &msg, NULL, 0U, 0U, PM_NOREMOVE );
while (msg.message != WM_QUIT)
{
if( PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) != 0)
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
else // Render the game if there is no message to process
{
Render() ;
}
}
}
UnregisterClass(winClass.lpszClassName, hInstance) ;
return 0;
}
开发者ID:BillyKim,项目名称:directxcode,代码行数:70,代码来源:Quad.cpp
示例7: while
/// <summary>
/// Handle a completed frame from the Kinect Fusion processor.
/// </summary>
/// <returns>S_OK on success, otherwise failure code</returns>
void CKinectFusionExplorer::HandleCompletedFrame()
{
KinectFusionProcessorFrame const* pFrame = nullptr;
// Flush any extra WM_FRAMEREADY messages from the queue
MSG msg;
while (PeekMessage(&msg, m_hWnd, WM_FRAMEREADY, WM_FRAMEREADY, PM_REMOVE)) {}
m_processor.LockFrame(&pFrame);
if (!m_bSavingMesh) // don't render while a mesh is being saved
{
if (m_processor.IsVolumeInitialized())
{
m_pDrawDepth->Draw(pFrame->m_pDepthRGBX, pFrame->m_cbImageSize);
m_pDrawReconstruction->Draw(pFrame->m_pReconstructionRGBX, pFrame->m_cbImageSize);
m_pDrawTrackingResiduals->Draw(pFrame->m_pTrackingDataRGBX, pFrame->m_cbImageSize);
}
SetStatusMessage(pFrame->m_statusMessage);
SetFramesPerSecond(pFrame->m_fFramesPerSecond);
}
if (pFrame->m_bIntegrationResumed)
{
m_params.m_bPauseIntegration = false;
CheckDlgButton(m_hWnd, IDC_CHECK_PAUSE_INTEGRATION, BST_UNCHECKED);
m_processor.SetParams(m_params);
}
else if (m_processor.IsCameraPoseFinderAvailable() && !m_params.m_bPauseIntegration)
{
m_params.m_bPauseIntegration = true;
CheckDlgButton(m_hWnd, IDC_CHECK_PAUSE_INTEGRATION, BST_CHECKED);
m_processor.SetParams(m_params);
}
if (!m_bUIUpdated && m_processor.IsVolumeInitialized())
{
const int Mebi = 1024 * 1024;
// We now create both a color and depth volume, doubling the required memory, so we restrict
// which resolution settings the user can choose when the graphics card is limited in memory.
if (pFrame->m_deviceMemory <= 1 * Mebi) // 1GB
{
// Disable 640 voxel resolution in all axes - cards with only 1GB cannot handle this
HWND hButton = GetDlgItem(m_hWnd, IDC_VOXELS_X_640);
EnableWindow(hButton, FALSE);
hButton = GetDlgItem(m_hWnd, IDC_VOXELS_Y_640);
EnableWindow(hButton, FALSE);
hButton = GetDlgItem(m_hWnd, IDC_VOXELS_Z_640);
EnableWindow(hButton, FALSE);
if (Is64BitApp() == FALSE)
{
// Also disable 512 voxel resolution in one arbitrary axis on 32bit machines
hButton = GetDlgItem(m_hWnd, IDC_VOXELS_Y_512);
EnableWindow(hButton, FALSE);
}
}
else if (pFrame->m_deviceMemory <= 2 * Mebi) // 2GB
{
if (Is64BitApp() == FALSE)
{
// Disable 640 voxel resolution in one arbitrary axis on 32bit machines
HWND hButton = GetDlgItem(m_hWnd, IDC_VOXELS_Y_640);
EnableWindow(hButton, FALSE);
}
// True 64 bit apps seem to be more able to cope with large volume sizes.
}
m_bUIUpdated = true;
}
m_bColorCaptured = pFrame->m_bColorCaptured;
m_processor.UnlockFrame();
}
开发者ID:qenops,项目名称:RGBDAugmentedReality,代码行数:81,代码来源:KinectFusionExplorer.cpp
示例8: PVRFrameEnableControlWindow
//程序运行
int CCApplication::run()
{
//设置注册表PVRFrame隐藏
PVRFrameEnableControlWindow(false);
//主消息循环
MSG msg;
LARGE_INTEGER nFreq;
LARGE_INTEGER nLast;
LARGE_INTEGER nNow;
//WINDOWS高精度定时器的用法,先获取频率
QueryPerformanceFrequency(&nFreq);
//获取当前的计数值,即频率x当前时间
QueryPerformanceCounter(&nLast);
//initInstance函数为虚函数,由派生类AppDelegate进行了重载。此段代码在调用AppDelegate重载的initInstance函数之后调用applicationDidFinishLaunching函数完成一些初始化处理。
//注:AppDelegate重载initInstance函数做了什么我们暂且只先认为它如平时我们WINDOWS基本框架程序一样创建了一个Windows窗口。【伏笔1后面会有讲解】。
if (! initInstance() || ! applicationDidFinishLaunching())
{
return 0;
}
//取得当前使用的OPENGL窗口管理实例对象
CCEGLView& mainWnd = CCEGLView::sharedOpenGLView();
//将窗口居中显示
mainWnd.centerWindow();
ShowWindow(mainWnd.getHWnd(), SW_SHOW);
//非常熟悉!进入WINDOWS消息循环
while (1)
{
//如果没有获取到WINDOWS消息
if (! PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
// 取得当前的计数值,即频率x当前时间
QueryPerformanceCounter(&nNow);
//m_nAnimationInterval.QuadPart的值 为setAnimationInterval函数进行设置的固定值。此处是为了判断时间流逝了多久,是否应该更新显示设备
if (nNow.QuadPart - nLast.QuadPart > m_nAnimationInterval.QuadPart)
{
//如果时间流逝达到了设定的FPS时间差,则更新计数值。
nLast.QuadPart = nNow.QuadPart;
//这里是设备渲染场景的函数,【伏笔2后面会有讲解】
CCDirector::sharedDirector()->mainLoop();
}
else
{
//sleep0秒的意义是让CPU做下时间片切换,防止死循环而使系统其它程序得不到响应。
Sleep(0);
}
continue;
}
//有消息获取到
if (WM_QUIT == msg.message)
{
// 如果获取的消息是退出则退出循环。
break;
}
// 如果没有定义加速键或者处理完加速键信息
if (! m_hAccelTable || ! TranslateAccelerator(msg.hwnd, m_hAccelTable, &msg))
{
//处理Windows消息
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
开发者ID:DionysosLai,项目名称:Coco2d-xRes,代码行数:64,代码来源:CCApplication.c
示例9: ContentPartnerThreadProc
DWORD WINAPI ContentPartnerThreadProc(LPVOID lpParameter)
{
CONTENT_PARTNER_THREAD_CONTEXT* pThreadCtx = NULL;
CComPtr<IWMPContentPartnerCallback> spCallback;
MSG msg = {0};
HRESULT hr = S_OK;
BOOL comInitialized = FALSE;
if(NULL == lpParameter)
{
hr = E_INVALIDARG;
goto cleanup;
}
pThreadCtx = static_cast<CONTENT_PARTNER_THREAD_CONTEXT*>(lpParameter);
if(NULL == pThreadCtx->pIStream)
{
hr = E_INVALIDARG;
goto cleanup;
}
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if(FAILED(hr))
{
ATLTRACE2("%x: ContentPartnerThreadProc(type %d): CoInitializeEx failed. %x\n", GetCurrentThreadId(), pThreadCtx->threadType, hr);
goto cleanup;
}
comInitialized = TRUE;
// Get a pointer to an IWMPContentPartnerCallback interface.
hr = CoGetInterfaceAndReleaseStream(
pThreadCtx->pIStream,
__uuidof(IWMPContentPartnerCallback),
reinterpret_cast<LPVOID*>(&spCallback) );
// The stream was released (even if CoGetInterfaceAndReleaseStream failed).
// Set the stream pointer to NULL.
pThreadCtx->pIStream = NULL;
if(FAILED(hr))
{
ATLTRACE2("%x: ContentPartnerThreadProc(type %d): Failed to get IWMPContentPartnerCallback interface. %x\n", GetCurrentThreadId(), pThreadCtx->threadType, hr);
goto cleanup;
}
if(NULL == spCallback)
{
hr = E_UNEXPECTED;
goto cleanup;
}
ATLTRACE2("%x: ContentPartnerThreadProc(type %d): Succeeded in getting IWMPContentPartnerCallback interface.\n", GetCurrentThreadId(), pThreadCtx->threadType);
// Make sure we have a message queue.
PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
// Tell the main thread that we are ready to receive messages.
SetEvent(pThreadCtx->hInitialized);
hr = ContentPartnerMessageLoop(pThreadCtx, spCallback);
cleanup:
if(NULL != pThreadCtx)
{
// Set this event here, just in case there was a "goto cleanup"
// before the event was set.
SetEvent(pThreadCtx->hInitialized);
// The thread that started this thread allocated a
// CONTENT_PARTNER_THREAD_CONTEXT structure.
// We must free that memory here.
if(NULL != pThreadCtx->pIStream)
{
// For some reason, CoGetInterfaceAndReleaseStream never got called.
// So release the stream here.
pThreadCtx->pIStream->Release();
pThreadCtx->pIStream = NULL;
}
ATLTRACE2("%x: ContentPartnerThreadProc(type %d): Returning %x\n", GetCurrentThreadId(), pThreadCtx->threadType, hr);
delete pThreadCtx;
pThreadCtx = NULL;
}
if(comInitialized)
{
CoUninitialize();
}
return hr;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:99,代码来源:Threads.cpp
示例10: ContentPartnerMessageLoop
HRESULT ContentPartnerMessageLoop(
CONTENT_PARTNER_THREAD_CONTEXT* pThreadCtx,
CComPtr<IWMPContentPartnerCallback> spCallback)
{
MSG msg = {0};
HRESULT hr = S_OK;
if(NULL == pThreadCtx || NULL == spCallback)
{
hr = E_UNEXPECTED;
goto cleanup;
}
// Windows message loop
while(TRUE)
{
BOOL ret = 0;
// Suppose we have several messages (for example,
// buy or download messages) in the queue, and then
// the user closes Windows Media Player. We would like
// to let Windows Media Player close without waiting for all
// those queued messages to be processed.
//
// So we use the following strategy.
//
// Peek into the message queue to see if there is an exit message.
// If there is an exit message anywhere in the queue, break out of
// the message loop even though there might be several
// messages remaining in the queue.
if( PeekMessage(
&msg,
NULL,
pThreadCtx->msgExitMessageLoop,
pThreadCtx->msgExitMessageLoop,
PM_REMOVE) )
{
ATLTRACE2("%x: ContentPartnerMessageLoop(type &d): PeekMessage retrieved an exit message.\n", GetCurrentThreadId(), pThreadCtx->threadType);
goto cleanup;
}
ret = GetMessage(&msg, 0, 0, 0);
if(-1 == ret)
{
ATLTRACE2("%x: ContentPartnerMessageLoop(type %d): GetMessage failed (returned -1).\n", GetCurrentThreadId(), pThreadCtx->threadType);
hr = HRESULT_FROM_WIN32(GetLastError());
goto cleanup;
}
if(pThreadCtx->msgExitMessageLoop == msg.message)
{
ATLTRACE2("%x: ContentPartnerMessageLoop(type %d): GetMessage retrieved an exit message.\n", GetCurrentThreadId(), pThreadCtx->threadType);
break; // Break out of the message loop.
}
switch(pThreadCtx->threadType)
{
case ThreadTypeDownload:
hr = HandleMessageForDownloadThread(&msg, pThreadCtx, spCallback);
break;
case ThreadTypeBuy:
hr = HandleMessageForBuyThread(&msg, pThreadCtx, spCallback);
break;
case ThreadTypeRefreshLicense:
hr = HandleMessageForRefreshLicenseThread(&msg, pThreadCtx, spCallback);
break;
case ThreadTypeLogin:
hr = HandleMessageForLoginThread(&msg, pThreadCtx, spCallback);
break;
case ThreadTypeSendMessage:
hr = HandleMessageForSendMessageThread(&msg, pThreadCtx, spCallback);
break;
case ThreadTypeUpdateDevice:
hr = HandleMessageForUpdateDeviceThread(&msg, pThreadCtx, spCallback);
break;
case ThreadTypeList:
hr = HandleMessageForListThread(&msg, pThreadCtx, spCallback);
break;
default:
hr = E_UNEXPECTED;
} // switch(threadType)
if(FAILED(hr))
{
goto cleanup;
}
} // while(TRUE)
cleanup:
if(NULL != pThreadCtx)
{
switch(pThreadCtx->threadType)
{
case ThreadTypeDownload:
RemoveMessagesFromDownloadThreadQueue(pThreadCtx);
break;
//.........这里部分代码省略.........
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:101,代码来源:Threads.cpp
示例11: WinMain
//entry point for any windows program
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
//start timer
TIM->Start();
D3DApp dapp;
//gTextureMan = new TextureManager();
//the handle for the window, filled by a function
HWND hWnd;
//this struct holds info for the window class
WNDCLASSEX wc;
//clear out the window class for use
ZeroMemory(&wc, sizeof(WNDCLASSEX) );
//fill in the struct with the needed information
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) COLOR_WINDOW;
wc.lpszClassName = "WindowClass1";
//register the window class
RegisterClassEx(&wc);
// create the window and use the result as the handle
hWnd = CreateWindowEx(NULL,
"WindowClass1", // name of the window class
"DirectXGraphics by Jimmy Roland", // title of the window
WS_OVERLAPPEDWINDOW, // window style
300, // x-position of the window
300, // y-position of the window
SCREEN_WIDTH, // width of the window
SCREEN_HEIGHT, // height of the window
NULL, // we have no parent window, NULL
NULL, // we aren't using menus, NULL
hInstance, // application handle
NULL); // used with multiple windows, NULL
// display the window on the screen
ShowWindow(hWnd, nCmdShow);
//start Visual Leak Detector
VLDEnable();
//create global for DirectInput pointer
gDInput = new DirectInput(hInstance, hWnd,
DISCL_NONEXCLUSIVE |
DISCL_FOREGROUND,
DISCL_NONEXCLUSIVE |
DISCL_FOREGROUND);
//set up and initialize Direct3D
dapp.InitD3D(hWnd,hInstance, true);
// enter the main loop:
//gD3DDev = *dapp.GetDevice();
// this struct holds Windows event messages
MSG msg;
// Enter the infinite message loop
while(TRUE)
{
// Check to see if any messages are waiting in the queue
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
// translate keystroke messages into the right format
TranslateMessage(&msg);
// send the message to the WindowProc function
DispatchMessage(&msg);
}
// If the message is WM_QUIT, exit the while loop
if(msg.message == WM_QUIT)
break;
//DirectInput polling
gDInput->poll();
//dapp.SetMousePos(hWnd);
// Run game code here
dapp.Update( (float)TIM->GetTimeElapsed() );
}
VLDReportLeaks();
//clean up DirectX and COM
dapp.CleanDirect3D();
//delete global
delete gDInput;
//.........这里部分代码省略.........
开发者ID:rukamir,项目名称:DirectXGraphics,代码行数:101,代码来源:WinMain.cpp
示例12: WinMain
int WINAPI WinMain( HINSTANCE hInstance, // Дескриптор приложения
HINSTANCE hPrevInstance, // Дескриптор родительского приложения
LPSTR lpCmdLine, // Параметры командной строки
int nCmdShow ) // Состояние отображения окна
{
MSG msg; // Структура для хранения сообщения Windows
BOOL done = FALSE; // Логическая переменная для выхода из цикла
// Спрашивает пользователя, какой режим экрана он предпочитает
if( MessageBox( NULL, "Хотите ли Вы запустить приложение в полноэкранном режиме?", "Запустить в полноэкранном режиме?", MB_YESNO | MB_ICONQUESTION) == IDNO )
{
fullscreen = FALSE; // Оконный режим
}
// Создать наше OpenGL окно
if( !CreateGLWindow( "NeHe OpenGL окно", 800, 600, 32, fullscreen ) )
{
return 0; // Выйти, если окно не может быть создано
}
while( !done ) // Цикл продолжается, пока done не равно true
{
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) // Есть ли в очереди какое-нибудь сообщение?
{
if( msg.message == WM_QUIT ) // Мы поучили сообщение о выходе?
{
done = TRUE; // Если так, done=true
}
else // Если нет, обрабатывает сообщения
{
TranslateMessage( &msg ); // Переводим сообщение
DispatchMessage( &msg ); // Отсылаем сообщение
}
}
else // Если нет сообщений
{
// Прорисовываем сцену.
if( active ) // Активна ли программа?
{
if(keys[VK_ESCAPE]) // Было ли нажата клавиша ESC?
{
done = TRUE; // ESC говорит об останове выполнения программы
}
else // Не время для выхода, обновим экран.
{
DrawGLScene(); // Рисуем сцену
SwapBuffers( hDC ); // Меняем буфер (двойная буферизация)
}
}
if( keys[VK_F1] ) // Была ли нажата F1?
{
//.........这里部分代码省略.........
开发者ID:stden,项目名称:comp_graph,代码行数:101,代码来源:lesson1.cpp
示例13: WinMain
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE legacy,
LPSTR lpCmdLine,
int nCmdShow)
{
__EXPN__ = new ExceptionData_t (20, "ExceptionErrors.txt");
srand (static_cast<UINT>(time (nullptr)));
try
{
WindowClass window (int (SCREEN_WIDTH * 0.98f), int (SCREEN_HEIGHT * 0.9f));
AllocConsole ();
FILE* file = nullptr;
freopen_s (&file, "CONOUT$", "w", stdout);
Direct3DProcessor d3dProc (&window);
d3dProc.ApplyBlendState (d3dProc.AddBlendState (true));
//d3dProc.ApplyRasterizerState (d3dProc.AddRasterizerState (false, false, true));
//XMMATRIX world = XMMatrixTranslation (0.0f, 0.0f, 0.0f);
CamInfo_t camInfo = { { BASE_X, BASE_Y, BASE_Z, 1.0f }, {}, 0.01f , 0.0f};
Direct3DCamera cam (&window,
camInfo.pos.x, camInfo.pos.y, camInfo.pos.z,
0.0f, -1.0f, 1.0f,
0.0, 1.0f, 0.0f,
FOV, 0.5f);
XMStoreFloat4(&camInfo.dir, cam.GetDir());
ConstantBufferIndex_t camBuf = d3dProc.RegisterConstantBuffer (&camInfo,
sizeof (camInfo),
1);
d3dProc.UpdateConstantBuffer (camBuf);
MeteoObject meteo ("Data/COSMOMESH", "Data/Fronts", "Data/H", &camInfo.step, 0.01f, &d3dProc, &cam);
cam.Update ();
meteo.RunPolygonalBuilding();
//SetForegroundWindow (window.hwnd ());
printf("Processing\n");
d3dProc.ProcessObjects ();
MSG msg = {};
bool rotate = true;
bool wasPressedSpace = false;
uint64_t ticksOld = 0;
uint64_t ticksNew = GetTickCount64 ();
char ticksN = 0;
printf("Drawing\n");
int hour = 0;
while (true)
{
if (PeekMessage (&msg, nullptr, 0, 0, PM_REMOVE))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
if (msg.message == WM_QUIT) break;
}
// SCENE PROCESSING
/*if (rotate) meteo.Rotate (0.01f);
if (GetAsyncKeyState (VK_SPACE) & 0x8000)
{
if (!wasPressedSpace)
{
rotate = !rotate;
wasPressedSpace = true;
}
}
else wasPressedSpace = false;*/
if (GetAsyncKeyState('J') & 0x8000)
{
while (GetAsyncKeyState('J'));
camInfo.noise = 2.0f - camInfo.noise;
}
ProcessCam (&cam, &camInfo);
meteo.PreDraw ();
cam.Update ();
cam.StorePos (camInfo.pos);
d3dProc.UpdateConstantBuffer (camBuf);
d3dProc.SendCBToGS (camBuf);
d3dProc.SendCBToPS (camBuf);
d3dProc.ProcessDrawing (&cam, true);
d3dProc.Present ();
if (ticksN >= 10)
{
ticksN = 0;
//.........这里部分代码省略.........
开发者ID:rafdp,项目名称:MeteoProject,代码行数:101,代码来源:Main.cpp
示例14: ZeroMemory
/// <summary>
/// Creates the main window and begins processing
/// </summary>
/// <param name="hInstance">handle to the application instance</param>
/// <param name="nCmdShow">whether to display minimized, maximized, or normally</param>
int CDataCollection::Run(HINSTANCE hInstance, int nCmdShow)
{
MSG msg = {0};
WNDCLASS wc;
// Dialog custom window class
ZeroMemory(&wc, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.cbWndExtra = DLGWINDOWEXTRA;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APP));
wc.lpfnWndProc = DefDlgProc;
wc.lpszClassName = L"DataCollectionAppDlgWndClass";
if (!RegisterClass(&wc))
{
return 0;
}
// Create main application window
HWND hWndApp = CreateDialogParam(
hInstance,
MAKEINTRESOURCE(IDD_APP),
NULL,
(DLGPROC)CDataCollection::MessageRouter,
reinterpret_cast<LPARAM>(this));
// Show window
ShowWindow(hWndApp, nCmdShow);
const int eventCount = 2;
HANDLE hEvents[eventCount]={m_hNextColorFrameEvent, m_hNextSkeletonEvent};
// Main message loop
while (WM_QUIT != msg.message)
{
// Check to see if we have either a message (by passing in QS_ALLINPUT)
// Or a Kinect event (hEvents)
// Update() will check for Kinect events individually, in case more than one are signalled
DWORD dwEvent = MsgWaitForMultipleObjects(eventCount, hEvents, FALSE, INFINITE, QS_ALLINPUT);
// Check if this is an event we're waiting on and not a timeout or message
if ((WAIT_OBJECT_0 == dwEvent)||(WAIT_OBJECT_0+1)==dwEvent)
{
Update();
}
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
// If a dialog message will be taken care of by the dialog proc
if ((hWndApp != NULL) && IsDialogMessage(hWndApp, &msg))
{
continue;
}
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
}
return static_cast<int>(msg.wParam);
}
开发者ID:eaglesky,项目名称:ARLK,代码行数:72,代码来源:DataCollection.cpp
示例15: WinMain
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpszCmdLine, int nCmdShow) {
wchar_t progname[] = L"CerealBox";
windata.gameoutput.graphic.width = 1920/2;
windata.gameoutput.graphic.height = 1080/2;
windata.running = ootrue;
windata.gameMemory = (void *) calloc((size_t)gameMemorySize(), 1L);
oouint audioBufferSize = win32AudioBufferSize();
windata.gameoutput.audio.buffer = (ooshort *) calloc((size_t)audioBufferSize, 1L);
oouint audioFramesPerSecond = win32AudioFramesPerSecond();
WNDCLASSEXW winclass;
ZeroMemory(&winclass, sizeof(WNDCLASSEXW));
MSG msg;
winclass.cbSize = sizeof(WNDCLASSEXW);
winclass.style = CS_DBLCLKS;
winclass.lpfnWndProc = &winproc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hInst;
winclass.hIcon = LoadIcon(NULL,IDI_WINLOGO);
winclass.hCursor = LoadCursor(NULL,IDC_ARROW);
winclass.lpszClassName = progname;
if(!RegisterClassExW(&winclass)) {
return 0;
}
oouint startX = 100;
oouint startY = 100;
DWORD windowStyle = WS_SYSMENU|WS_CAPTION|WS_BORDER|WS_OVERLAPPED|WS_VISIBLE|WS_MINIMIZEBOX;
#ifdef OO_FULLSCREEN
windowStyle = WS_EX_TOPMOST | WS_POPUP;
win32GetScreenResolution(&windata.gameoutput.graphic.width, &windata.gameoutput.graphic.height);
startX = 0;
startY = 0;
#endif
RECT wr = {0, 0, windata.gameoutput.graphic.width, windata.gameoutput.graphic.height};
AdjustWindowRect(&wr, windowStyle, FALSE);
windata.window = CreateWindowW(
progname,
progname,
windowStyle,
startX,
startY,
wr.right - wr.left,
wr.bottom - wr.top,
NULL,
NULL,
hInst,
NULL);
initGraphics(&windata);
win32AudioInit(windata.window);
ShowWindow(windata.window,nCmdShow);
UpdateWindow(windata.window);
LARGE_INTEGER timeFrequency;
QueryPerformanceFrequency(&timeFrequency);
LARGE_INTEGER lastTime;
ZeroMemory(&lastTime, sizeof(LARGE_INTEGER) );
LARGE_INTEGER time;
windata.gameinput.dt = 1.f/60.f;
windata.windowDC = GetDC(windata.window);
ooint monitorRefreshHz = 60;
oofloat frameMs = 1.f / (oofloat)monitorRefreshHz;
ooint win32RefreshRate = GetDeviceCaps(windata.windowDC, VREFRESH);
if( win32RefreshRate>1 ) {
monitorRefreshHz = win32RefreshRate;
frameMs = 1.f / (oofloat)monitorRefreshHz;
}
while( windata.running ) {
PeekMessage(&msg,NULL,0,0,PM_REMOVE);
if(msg.message == WM_QUIT) {
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
win32ProcessMouseEvents(windata.window, &windata);
QueryPerformanceCounter(&time);
if( lastTime.QuadPart>0 ) {
//.........这里部分代码省略.........
开发者ID:ali-motisi,项目名称:CerealBox,代码行数:101,代码来源:win32main.c
示例16: usingCOM
int SSOThread::Run()
{
ComInit usingCOM(COINIT_APARTMENTTHREADED|COINIT_DISABLE_OLE1DDE|COINIT_SPEED_OVER_MEMORY);
HKEY hkey;
CLSID clsid;
WCHAR name[MAX_PATH], value[MAX_PATH];
typedef vector<SIfacePtr<IOleCommandTarget>*> SSOVector;
SSOVector sso_ptrs;
if (!RegOpenKey(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ShellServiceObjectDelayLoad"), &hkey)) {
for(int idx=0; ; ++idx) {
DWORD name_len = MAX_PATH;
DWORD value_len = sizeof(value);
if (RegEnumValueW(hkey, idx, name, &name_len, 0, NULL, (LPBYTE)&value, &value_len))
break;
if (!_alive)
break;
SIfacePtr<IOleCommandTarget>* sso_ptr = new SIfacePtr<IOleCommandTarget>;
if (CLSIDFromString(value, &clsid) == NOERROR) {
if (SUCCEEDED(sso_ptr->CreateInstance(clsid, IID_IOleCommandTarget))) {
if (SUCCEEDED((*sso_ptr)->Exec(&CGID_ShellServiceObject, OLECMDID_NEW, OLECMDEXECOPT_DODEFAULT, NULL, NULL)))
sso_ptrs.push_back(sso_ptr);
}
}
}
RegCloseKey(hkey);
}
if (!sso_ptrs.empty()) {
MSG msg;
while(_alive) {
if (MsgWaitForMultipleObjects(1, &_evtFinish, FALSE, INFINITE, QS_ALLINPUT) == WAIT_OBJECT_0+0)
break; // _evtFinish has been set.
while(_alive) {
if (!PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
break;
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
// shutdown all running Shell Service Objects
for(SSOVector::iterator it=sso_ptrs.begin(); it!=sso_ptrs.end(); ++it) {
SIfacePtr<IOleCommandTarget>* sso_ptr = *it;
(*sso_ptr)->Exec(&CGID_ShellServiceObject, OLECMDID_SAVE, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
delete sso_ptr;
}
}
return 0;
}
开发者ID:svn2github,项目名称:ros-explorer,代码行数:64,代码来源:shellservices.cpp
|
请发表评论