// AsynCallDlg.cpp : CAsynCallDlg 的实现

#include "stdafx.h"
#include "AsynCallDlg.h"

#include "AsynCallDemo.h"

// CAsynCallDlg
LRESULT CAsynCallDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    CAxDialogImpl<CAsynCallDlg>::OnInitDialog(uMsg, wParam, lParam, bHandled);
    CenterWindow();
    return 1;
}

LRESULT CAsynCallDlg::OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
    if(_ctl)
        _ctl->do_call();
    //EndDialog(wID);
    return 0;
}

static DWORD
WINAPI
myDlgThread(LPVOID p)
{
    CoInitialize(NULL);
    CAsynCallDlg *pdlg = (CAsynCallDlg*)p;
    if(pdlg)
        pdlg->DoModal();
    CoUninitialize();
    return 0;
}

void CAsynCallDlg::StartDialog(void)
{
    if(IsWindow()) /* 已经启动了 */
        return;
    CloseHandle(CreateThread(NULL,0,myDlgThread,(LPVOID)this,0,NULL));
}
