PDA

View Full Version : OpenGL & MultiThread & East language input in WinXP



pango
04-29-2006, 09:19 PM
My program create a child thread,and create a OpenGL render in the thread.Firstly,I found when my program is running,a open a chinese input method(I'm a chinese,I use Windows XP Chinese Version),my program is dead(not crashed,is not response for mouse & keyboard action).This is very strange!Then from some query,I know I must create a window in child thread to deal message,then I do,problem is solved.But I only test the program in my machine(it can work with NV 6600GT,6800GT,7600GT,7800GT),some days ago I install my program in a computer that has newer hardware than my machine(newer motherboard,and has SCSI harddisk,but display card is NV 7800GT),the problem is showed again!
The problem make me worry,it is so strange.Anyone can help me?
Below is the code that I create the window in child thread:

//////////////////////////////////////////////////////////////////////////
//Register window class
//////////////////////////////////////////////////////////////////////////
WNDCLASSEX wndClass;
memset(&wndClass,0,sizeof(WNDCLASSEX));
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WindowProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = GetModuleHandle(NULL);//Is it right?
wndClass.hIcon = NULL;
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = _T("MyClass");
wndClass.hIconSm = NULL;
if(!RegisterClassEx(&wndClass))
{
assert(false);
return 0;
}

//////////////////////////////////////////////////////////////////////////
//Create Window
//////////////////////////////////////////////////////////////////////////
m_hMsgRecvWnd=CreateWindowEx(
0,
wndClass.lpszClassName,
_T("OpenGL Window"),
WS_OVERLAPPED,
0,0,1,1,
NULL,//No Parent window,is it right?
NULL,
GetModuleHandle(NULL),
NULL);
assert(m_hMsgRecvWnd);
if(m_hMsgRecvWnd == NULL)
return 0;


//////////////////////////////////////////////////////////////////////////
//Message Loop
//////////////////////////////////////////////////////////////////////////
MSG msg;
while(GetMessage(&msg,m_hMsgRecvWnd,0,0))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}