// 新建一个窗口,其消息循环负责处理BYHX消息,有状态改变时直接Post到界面
HWND parent_hWnd =(HWND)pPrinter->m_byhxHandle;//GetForegroundWindow();
HINSTANCE parent_hInst =GetModuleHandle(NULL);
WNDCLASSEX wcex0 ={ sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW,
BYHXMessageProc, 0, 0, parent_hInst,
LoadIcon(NULL,IDI_INFORMATION), LoadCursor(NULL, IDC_ARROW),
(HBRUSH)GetStockObject(BLACK_BRUSH), NULL, _T("Window0"), NULL
};
RegisterClassEx( &wcex0 );
pPrinter->m_hwndBYHXProc = CreateWindow( _T("Window0"), _T("Window0"), WS_OVERLAPPEDWINDOW|WS_CHILD, 0, 0, 0, 0,parent_hWnd, NULL,wcex0.hInstance, NULL );
if (!pPrinter->m_hwndBYHXProc )
{
ErrorTrace(DEBUG_FUNC,pPrinter->m_iDebug_Level,_T("消息循环创建失败!\n"));
return 1;
}
ShowWindow(pPrinter->m_hwndBYHXProc, SW_HIDE );
WorkTrace(DEBUG_FUNC,pPrinter->m_iDebug_Level,_T("Message Window: %d\n"),pPrinter->m_hwndBYHXProc);
UpdateWindow( pPrinter->m_hwndBYHXProc );
UnregisterClass( _T("Window0"), wcex0.hInstance );
if( !SetMessageWindow((IntPtr)pPrinter->m_hwndBYHXProc,pPrinter->m_byhxwParam))
{
#ifdef _DEBUG
iResult = GetBoardError();
#endif
iResult = GetBoardStatus();
ErrorTrace(DEBUG_FUNC,pPrinter->m_iDebug_Level,_T("Global_BYHXMessageThread SetMessageWindow Error!\n"));
return 1;
}
// 在线程中创建一个消息循环DEBUG_FUNC,theApp.m_iDebug_Level,
WorkTrace(DEBUG_FUNC,pPrinter->m_iDebug_Level,_T("Global_BYHXMessageThread create message loop\n"));
MSG msg;
PeekMessage(&msg,pPrinter->m_hwndBYHXProc,NULL,NULL,PM_NOREMOVE);
while (1)
{
GetMessage(&msg,pPrinter->m_hwndBYHXProc,0,0);
if ((msg.message == WM_QUIT) || (msg.message == WM_CLOSE))
{
break;
}
pPrinter->Status_Refresh(msg.wParam,msg.lParam);
}