You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.4 KiB
73 lines
1.4 KiB
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (c) Microsoft Corporation
|
|
//
|
|
// SYNOPSIS
|
|
//
|
|
// Declares the class HiddenDialogWithWorker.
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include <proxypch.h>
|
|
#include <hiddenworker.h>
|
|
|
|
HiddenDialogWithWorker::HiddenDialogWithWorker()
|
|
: worker(0)
|
|
{
|
|
}
|
|
|
|
|
|
HiddenDialogWithWorker::~HiddenDialogWithWorker() throw ()
|
|
{
|
|
if (worker != 0)
|
|
{
|
|
WaitForSingleObject(worker, INFINITE);
|
|
CloseHandle(worker);
|
|
}
|
|
}
|
|
|
|
|
|
void HiddenDialogWithWorker::Start()
|
|
{
|
|
if (!Create(IDD_HIDDEN_WORKER))
|
|
{
|
|
AfxThrowLastError();
|
|
}
|
|
}
|
|
|
|
|
|
BOOL HiddenDialogWithWorker::OnInitDialog()
|
|
{
|
|
worker = CreateThread(0, 0, StartRoutine, this, 0, 0);
|
|
if (worker == 0)
|
|
{
|
|
AfxThrowLastError();
|
|
}
|
|
|
|
return CDialog::OnInitDialog();
|
|
}
|
|
|
|
|
|
LRESULT HiddenDialogWithWorker::OnThreadMessage(WPARAM wParam, LPARAM lParam)
|
|
{
|
|
DestroyWindow();
|
|
OnComplete(lParam);
|
|
return 0;
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(HiddenDialogWithWorker, CDialog)
|
|
ON_MESSAGE(threadMessage, OnThreadMessage)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
DWORD WINAPI HiddenDialogWithWorker::StartRoutine(void* arg) throw ()
|
|
{
|
|
HiddenDialogWithWorker* obj = static_cast<HiddenDialogWithWorker*>(arg);
|
|
|
|
LPARAM result = obj->DoWork();
|
|
|
|
obj->PostMessage(threadMessage, 0, result);
|
|
|
|
return NO_ERROR;
|
|
}
|