LRESULT CALLBACK MyWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
int WINAPI DecodeMain()
{
static char szAppName[]="Decode";
MSG    msg;
WNDCLASSEX wndclass;
HINSTANCE  hinstance; hinstance = AfxGetApp()->m_hInstance;
wndclass.cbSize    = sizeof(wndclass);
wndclass.style     = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = XvidWndProc;
wndclass.cbClsExtra  = 0;
wndclass.cbWndExtra  = 0;
wndclass.hInstance   = hinstance;
wndclass.hIcon       = NULL;
wndclass.hIconSm     = NULL;
wndclass.hCursor     = NULL;
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName  = NULL;
wndclass.lpszClassName = szAppName; RegisterClassEx(&wndclass); g_hwnd = CreateWindow(szAppName,NULL,WS_OVERLAPPEDWINDOW,0,0,0,0,NULL,NULL,hinstance,NULL);
ShowWindow(g_hwnd, SW_HIDE);
UpdateWindow(g_hwnd); while(GetMessage(&msg, NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}LRESULT CALLBACK MyWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
switch (iMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
} return DefWindowProc(hwnd, iMsg, wParam, lParam);
}// 启动线程
int start()
{
DecodeMain();
...........
...........
}

解决方案 »

  1.   

    哦,写错了,汗……应该是:
    int start()
    {
          DWORD dwThreadId;      CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DecodeMain,
                          NULL, 0, &dwThreadId)
          .......
          .......
    }
    谢谢,不好意思。
      

  2.   

    我代码里写的是正确的,就是说,decodemain这个线程是启动正常的
      

  3.   

    可以直接使用线程消息,没有必要创建隐藏窗口,在线程中创建消息队列
    PeekMessagewhile(GetMessage(...))
    {
    switch(msg)
    {
    case
    可以使用PostThreadMessage给该线程发送消息
      

  4.   

    谢谢不用了,我弄明白了,我创建窗口主要是为了使用timer,程序死是因为消息发送的方式不对,我用了sendmessage,呵呵,该死谢谢