コード例 #1
0
void* FrameworkThread::GetCustomTlsData()
{
	FrameworkThreadTlsData *tls = GetTlsData();
	//DCHECK(tls != NULL);
	if (tls == NULL)
		return NULL;
	return tls->custom_data;
}
コード例 #2
0
void FrameworkThread::SetCustomTlsData(void *data)
{
	FrameworkThreadTlsData *tls = GetTlsData();
	//DCHECK(tls != NULL);
	if (tls == NULL)
		return;
	tls->custom_data = data;
}
コード例 #3
0
FrameworkThread* FrameworkThread::current()
{
	FrameworkThreadTlsData *tls = GetTlsData();
	//DCHECK(tls != NULL);
	if (tls == NULL)
		return NULL;
	return tls->self;
}
コード例 #4
0
int FrameworkThread::GetManagedThreadId()
{
	FrameworkThreadTlsData *tls = GetTlsData();
	//DCHECK(tls != NULL);
	if (tls == NULL)
		return -1;
	return tls->managed_thread_id;
}
コード例 #5
0
bool FrameworkThread::GetThreadWasQuitProperly()
{
	FrameworkThreadTlsData *tls = GetTlsData();
	//DCHECK(tls != NULL);
	if (tls == NULL)
		return false;
	return tls->quit_properly;
}
コード例 #6
0
void FrameworkThread::SetThreadWasQuitProperly(bool flag)
{
	FrameworkThreadTlsData *tls = GetTlsData();
	//DCHECK(tls != NULL);
	if (tls == NULL)
		return;
	tls->quit_properly = flag;
}
コード例 #7
0
void FreeClassicCopyThread( void )
{
	TlsData *pTlsData=GetTlsData();
	if (pTlsData->copyHook)
	{
		UnhookWindowsHookEx(pTlsData->copyHook);
		pTlsData->copyHook=NULL;
	}
}
コード例 #8
0
void FrameworkThread::FreeTlsData()
{
	FrameworkThreadTlsData *tls = GetTlsData();
	//DCHECK(tls != NULL);
	if (tls == NULL)
		return;
	lazy_tls_data.Pointer()->Set(NULL);
	delete tls;
}
コード例 #9
0
void FrameworkThread::InitTlsData(FrameworkThread *self)
{
	FrameworkThreadTlsData *tls = GetTlsData();
	//DCHECK(tls == NULL);
	if (tls != NULL)
		return;
	tls = new FrameworkThreadTlsData;
	tls->self = self;
	tls->managed = 0;
	tls->managed_thread_id = -1;
	tls->quit_properly = false;
	tls->custom_data = NULL;
	lazy_tls_data.Pointer()->Set(tls);
}
コード例 #10
0
LRESULT CALLBACK ClassicCopyHook( int nCode, WPARAM wParam, LPARAM lParam )
{
	if (nCode==HCBT_CREATEWND)
	{
		HWND hWnd=(HWND)wParam;
		CBT_CREATEWND *create=(CBT_CREATEWND*)lParam;
		HINSTANCE hInst=(HINSTANCE)GetWindowLongPtr(hWnd,GWLP_HINSTANCE);
		if (create->lpcs->lpszName && (int)create->lpcs->lpszClass==32770 && hInst==g_hShell32)
		{
			static LONG id;
			int i=InterlockedIncrement(&id);
			SetWindowSubclass(hWnd,WindowProc,i,0);
		}
	}
	TlsData *pTlsData=GetTlsData();
	return CallNextHookEx(pTlsData->copyHook,nCode,wParam,lParam);
}
コード例 #11
0
void FrameworkThread::Run()
{
#ifndef NDEBUG
#if defined(OS_WIN) && defined(COMPILER_MSVC)
	SetThreadName(GetCurrentThreadId(), name_.c_str());
#endif
#endif

	InitTlsData(this);
	SetThreadWasQuitProperly(false);
	{
		ThreadId thread_id = Thread::CurrentId();
		set_thread_id(thread_id);

		// The message loop for this thread.
		MessageLoop *message_loop;
		if (loop_type_ == MessageLoop::kCustomMessageLoop)
			message_loop = factory_->CreateMessageLoop();
		else {
			if (loop_type_ == MessageLoop::kIOMessageLoop)
				message_loop = new IOMessageLoop;
#if defined(OS_WIN)
			else if (loop_type_ == MessageLoop::kUIMessageLoop)
				message_loop = new UIMessageLoop;
#endif
			else
				message_loop = new MessageLoop;
		}
		message_loop_ = message_loop;

		// Let the thread do extra initialization.
		// Let's do this before signaling we are started.
		Init();

		event_.Signal();

#if defined(OS_WIN)
		message_loop_->RunWithDispatcher(dispatcher_);
#else
		message_loop_->Run();
#endif // OS_WIN

		// Let the thread do extra cleanup.
		Cleanup();

		//DCHECK(GetThreadWasQuitProperly());

		// We can't receive messages anymore.
		if (loop_type_ != MessageLoop::kCustomMessageLoop)
			delete message_loop_;
		else
		{
			delete message_loop_;
			factory_.reset();
		}
		message_loop_ = NULL;
	}
	set_thread_id(kInvalidThreadId);
	{
		FrameworkThreadTlsData *tls = GetTlsData();
		if (tls != NULL)
		{ }
			//DCHECK(tls->managed == 0); // you must call ThreadManager::UnregisterThread before come there
	}
	FreeTlsData();
}
コード例 #12
0
// Show the dialog box. Returns true to suppress the original task dialog box
bool CClassicCopyFile::Run( HWND hWnd, IAccessible *pAcc, CString *pLog )
{
	// find all interesting controls
	EnumAccChildren(pAcc,pLog);

	if (!m_YesButton.first || m_YesButton.second!=CHILDID_SELF || !m_NoButton.first || m_NoButton.second!=CHILDID_SELF || !m_Cancel.first)
		return false; // something is wrong, do nothing

	if (pLog) pLog->Empty(); // success - no need to log anything

	// get the info for the source and the destination file (file name, icon, properties)
	m_bReadOnly=false;
	m_bSystem=false;
	GetFileInfo(m_YesButton.first,true);
	GetFileInfo(m_NoButton.first,false);

	TlsData *pTlsData=GetTlsData();
	if (m_CheckBox.first)
		pTlsData->bCopyMultiFile=true;
	else if (pTlsData->bCopyMultiFile)
		m_bCopyMultiLast=true;

	// pick the correct dialog template (for single and multiple files, for LTR and RTL)
	int dlg=pTlsData->bCopyMultiFile?(IsLanguageRTL()?IDD_FILEMULTIR:IDD_FILEMULTI):(IsLanguageRTL()?IDD_FILER:IDD_FILE);

	HWND parent=GetWindow(GetAncestor(hWnd,GA_ROOT),GW_OWNER);

	int res=(int)DialogBoxParam(g_Instance,MAKEINTRESOURCE(dlg),parent,DialogProc,(LPARAM)this);

	if (res==IDOK || (res==IDYES && m_bCopyMultiLast))
	{
		// Yes was pressed, proceed with the operation
		m_YesButton.first->accDoDefaultAction(CComVariant(CHILDID_SELF));
	}
	else if (res==IDNO)
	{
		// No
		if (m_CheckBox.first && GetKeyState(VK_SHIFT)<0)
			m_CheckBox.first->accDoDefaultAction(CComVariant(CHILDID_SELF)); // Shift+No = No to All
		PumpMessages(); // messages need to be pumped after every accessibility action. otherwise the next action doesn't work
		m_NoButton.first->accDoDefaultAction(CComVariant(CHILDID_SELF));
	}
	else if (res==IDYES)
	{
		// Yes to All
		m_CheckBox.first->accDoDefaultAction(CComVariant(CHILDID_SELF));
		PumpMessages(); // messages need to be pumped after every accessibility action. otherwise the next action doesn't work
		m_YesButton.first->accDoDefaultAction(CComVariant(CHILDID_SELF));
	}
	if (res==IDCANCEL)
	{
		// Cancel
		if (GetKeyState(VK_SHIFT)<0 || GetKeyState(VK_CONTROL)<0)
			return false; // // Shift+Cancel or Ctrl+Cancel was clicked - show the original dialog box
		m_Cancel.first->accDoDefaultAction(CComVariant(CHILDID_SELF));
	}
	if (res==IDC_LINKMORE)
	{
		// More... was clicked - show the original dialog box
		return false;
	}
	return true;
}
コード例 #13
0
void InitClassicCopyThread( void )
{
	TlsData *pTlsData=GetTlsData();
	if (!pTlsData->copyHook)
		pTlsData->copyHook=SetWindowsHookEx(WH_CBT,ClassicCopyHook,g_Instance,GetCurrentThreadId());
}