當前位置: 首頁>>代碼示例>>C++>>正文


C++ AttachThreadInput函數代碼示例

本文整理匯總了C++中AttachThreadInput函數的典型用法代碼示例。如果您正苦於以下問題:C++ AttachThreadInput函數的具體用法?C++ AttachThreadInput怎麽用?C++ AttachThreadInput使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了AttachThreadInput函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: bring_to_top

void bring_to_top(GtkWidget *win){
#ifdef __WIN32__
	HWND hWnd;
	int nTargetID, nForegroundID;
	BOOL res;

	hWnd = GDK_WINDOW_HWND (win->window);

	/* From  http://techtips.belution.com/ja/vc/0012/ */
	nForegroundID = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
	nTargetID = GetWindowThreadProcessId(hWnd, NULL );

	AttachThreadInput(nTargetID, nForegroundID, TRUE );

	// SPI_GETFOREGROUNDLOCKTIMEOUT will be undefined. Why ?
	/*
	SystemParametersInfo( SPI_GETFOREGROUNDLOCKTIMEOUT,0,&sp_time,0);
	SystemParametersInfo( SPI_SETFOREGROUNDLOCKTIMEOUT,0,(LPVOID)0,0);
	SetForegroundWindow(hWnd);
	SystemParametersInfo( SPI_SETFOREGROUNDLOCKTIMEOUT,0,sp_time,0);
	*/

	res = SetForegroundWindow(hWnd);

	AttachThreadInput(nTargetID, nForegroundID, FALSE);

	if(!res){
		SetFocus(hWnd);
	}
#else
	gdk_window_show(GTK_WIDGET(win)->window);
	gdk_window_focus(GTK_WIDGET(win)->window, gtk_get_current_event_time());

#endif
}
開發者ID:fujii,項目名稱:ebview,代碼行數:35,代碼來源:selection.c

示例2: SetForegroundWindowInternal

// http://www.codeproject.com/Tips/76427/How-to-bring-window-to-top-with-SetForegroundWindo
void SetForegroundWindowInternal(HWND hWnd)
{
    SetWindowPos(hWnd,HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    SetWindowPos(hWnd,HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    SetWindowPos(hWnd,HWND_NOTOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
    return;
    //relation time of SetForegroundWindow lock
    DWORD lockTimeOut = 0;
    HWND  hCurrWnd = GetForegroundWindow();
    DWORD dwThisTID = GetCurrentThreadId(),
        dwCurrTID = GetWindowThreadProcessId(hCurrWnd, 0);

    //we need to bypass some limitations from Microsoft :)
    if (dwThisTID != dwCurrTID)
    {
        AttachThreadInput(dwThisTID, dwCurrTID, TRUE);

        SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &lockTimeOut, 0);
        SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);

        AllowSetForegroundWindow(ASFW_ANY);
    }

    SetForegroundWindow(hWnd);

    if (dwThisTID != dwCurrTID)
    {
        SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (PVOID)lockTimeOut, SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
        AttachThreadInput(dwThisTID, dwCurrTID, FALSE);
    }
}
開發者ID:Dergash,項目名稱:homm3tools,代碼行數:32,代碼來源:rmg.c

示例3: activateGame

	XBool activateGame(HWND h)
	{
		//方案1://不行
		//return BringWindowToTop(XEG.getHWND());
		//方案2://可以
		//typedef void (WINAPI *PROCSWITCHTOTHISWINDOW) (HWND, BOOL);
		//PROCSWITCHTOTHISWINDOW SwitchToThisWindow;
		//HMODULE hUser32 = GetModuleHandle("user32");
		//SwitchToThisWindow = ( PROCSWITCHTOTHISWINDOW)GetProcAddress(hUser32, "SwitchToThisWindow");  
		//if(SwitchToThisWindow == NULL) return false;
		////接下來隻要用任何現存窗口的句柄調用這個函數即可,第二個參數指定如果窗口極小化,是否恢複其原狀態。
		//SwitchToThisWindow(XEG.getHWND(), TRUE);
		//return true;
		//方案3://可行
		HWND hCurWnd = GetForegroundWindow();
		DWORD dwMyID = GetCurrentThreadId();
		DWORD dwCurID = GetWindowThreadProcessId(hCurWnd, NULL);
		AttachThreadInput(dwCurID, dwMyID, TRUE);
		SetForegroundWindow(h);
		AttachThreadInput(dwCurID, dwMyID, FALSE);
		return  true;
		//方法4://可行
		//ShowWindow(XEG.getHWND(),SW_SHOWNA);//簡單的顯示主窗口完事兒 
		//SetActiveWindow(XEG.getHWND());
		//SetForegroundWindow(XEG.getHWND());    
		////this->SetWindowPos(this,LOWORD(lParam),HIWORD(lParam),c.Width(),c.Height(),SWP_NOACTIVATE);
		//BringWindowToTop(XEG.getHWND());
		//return true;
	}
開發者ID:xiajiaonly,項目名稱:XEffect2D,代碼行數:29,代碼來源:XEngineCommon.cpp

示例4: set_foreground

static DWORD set_foreground(HWND hwnd)
{
    HWND hwnd_fore;
    DWORD set_id, fore_id, ret;
    char win_text[1024];

    hwnd_fore = GetForegroundWindow();
    GetWindowTextA(hwnd_fore, win_text, 1024);
    set_id = GetWindowThreadProcessId(hwnd, NULL);
    fore_id = GetWindowThreadProcessId(hwnd_fore, NULL);
    trace("\"%s\" %p %08x hwnd %p %08x\n", win_text, hwnd_fore, fore_id, hwnd, set_id);
    ret = AttachThreadInput(set_id, fore_id, TRUE);
    trace("AttachThreadInput returned %08x\n", ret);
    ret = ShowWindow(hwnd, SW_SHOWNORMAL);
    trace("ShowWindow returned %08x\n", ret);
    ret = SetWindowPos(hwnd, HWND_TOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
    trace("set topmost returned %08x\n", ret);
    ret = SetWindowPos(hwnd, HWND_NOTOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
    trace("set notopmost returned %08x\n", ret);
    ret = SetForegroundWindow(hwnd);
    trace("SetForegroundWindow returned %08x\n", ret);
    Sleep(250);
    AttachThreadInput(set_id, fore_id, FALSE);
    return ret;
}
開發者ID:hoangduit,項目名稱:reactos,代碼行數:25,代碼來源:winstation.c

示例5: DoFocus

void DoFocus(BOOL bUseCurrent,HWND hwndFocus)
{
	HWND hwndEdit;
	char WinClass[256];
	DWORD OtherAppThreadID;
	DWORD OtherAppProcessID;
	DWORD TrayThreadID;

	if(bUseCurrent)
	{
		TrayThreadID=GetCurrentThreadId();
		hwndEdit=hwndFocus; 
		GetClassName(hwndEdit,WinClass,255);

		OtherAppThreadID = GetWindowThreadProcessId( hwndEdit, 
			&OtherAppProcessID);

		AttachThreadInput( TrayThreadID, OtherAppThreadID, TRUE );

		// We can key off WinClass if something else
		// needs to be done 

		SetFocus(hwndEdit);

		AttachThreadInput( TrayThreadID, OtherAppThreadID, FALSE );
	}
}
開發者ID:ysangkok,項目名稱:pgp-win32-6.5.8,代碼行數:27,代碼來源:Utils.c

示例6: SetForegroundWindowInternal

BOOL SetForegroundWindowInternal(HWND hWnd) {
	BOOL ret = false;
	if (!IsWindow(hWnd)) return ret;

	//relation time of SetForegroundWindow lock
	DWORD lockTimeOut = 0;
	HWND  hCurrWnd = GetForegroundWindow();
	DWORD dwThisTID = GetCurrentThreadId(),
	dwCurrTID = GetWindowThreadProcessId(hCurrWnd, 0);

	//we need to bypass some limitations from Microsoft :)
	if (dwThisTID != dwCurrTID)
	{
		AttachThreadInput(dwThisTID, dwCurrTID, TRUE);

		SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &lockTimeOut, 0);
		SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);

		AllowSetForegroundWindow(ASFW_ANY);
	}

	ret = SetForegroundWindow(hWnd);

	if (dwThisTID != dwCurrTID)
	{
		SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (PVOID)lockTimeOut, SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
		AttachThreadInput(dwThisTID, dwCurrTID, FALSE);
	}

	return ret;
}
開發者ID:morrisslutsky,項目名稱:NowUGo,代碼行數:31,代碼來源:Popup.cpp

示例7: WaitForReleaseVkKeys

void WaitForReleaseVkKeys(DWORD dwThreadCurrent, DWORD dwThreadTarget, DWORD dwTimeout)
{
  DWORD dwStart=GetTickCount();
  BYTE lpKeyState[256];
  int i;

  Loop:
  if (dwTimeout == INFINITE || GetTickCount() - dwStart < dwTimeout)
  {
    AttachThreadInput(dwThreadCurrent, dwThreadTarget, FALSE);

    if (AttachThreadInput(dwThreadCurrent, dwThreadTarget, TRUE))
    {
      Sleep(0);

      if (GetKeyboardState(lpKeyState))
      {
        for (i=0; i < 256; ++i)
        {
          if (lpKeyState[i] & 0x80)
            goto Loop;
        }
      }
    }
  }
}
開發者ID:embassy,項目名稱:AkelPad,代碼行數:26,代碼來源:Clipboard.c

示例8: _SetForegroundWindowEx

//------------------------------------------------------------------------------
// 
//------------------------------------------------------------------------------
COMMONEXPORT BOOL _SetForegroundWindowEx ( HWND hWnd )
{
	if (hWnd == NULL)
		return FALSE;
	
	// determine current foreground window
	HWND hWndForeground = ::GetForegroundWindow ();

	if (hWndForeground == NULL)
		return ::SetForegroundWindow (hWnd);

	// check whether it is able to pump messages to avoid deadlocks
	DWORD dwResult = 0;

    if  ( SendMessageTimeout ( hWndForeground, WM_NULL, 0, 0, SMTO_NORMAL, 1000, &dwResult ) == 0 )
		return FALSE;

	int iTID = ::GetWindowThreadProcessId ( hWnd, 0 );
	int iForegroundTID  = ::GetWindowThreadProcessId ( hWndForeground, 0 );
	
	AttachThreadInput (iTID, iForegroundTID, TRUE);
	
	::SetForegroundWindow (hWnd);
	
	AttachThreadInput (iTID, iForegroundTID, FALSE);

    return TRUE;
}
開發者ID:hackshields,項目名稱:antivirus,代碼行數:31,代碼來源:popup.cpp

示例9: EnsureValid

HRESULT CSysProgressDlg::ShowModeless(HWND hWndParent, BOOL immediately)
{
	EnsureValid();
	m_hWndProgDlg = nullptr;
	if (!IsValid())
		return E_FAIL;
	m_hWndParent = hWndParent;
	auto winId = GetWindowThreadProcessId(m_hWndParent, 0);
	auto threadId = GetCurrentThreadId();
	if (winId != threadId)
		AttachThreadInput(winId, threadId, TRUE);
	m_hWndFocus = GetFocus();
	if (winId != threadId)
		AttachThreadInput(winId, threadId, FALSE);
	HRESULT hr = m_pIDlg->StartProgressDialog(hWndParent, nullptr, m_dwDlgFlags, nullptr);
	if(FAILED(hr))
		return hr;

	ATL::CComPtr<IOleWindow> pOleWindow;
	HRESULT hr2 = m_pIDlg.QueryInterface(&pOleWindow);
	if(SUCCEEDED(hr2))
	{
		hr2 = pOleWindow->GetWindow(&m_hWndProgDlg);
		if(SUCCEEDED(hr2))
		{
			if (immediately)
				ShowWindow(m_hWndProgDlg, SW_SHOW);
		}
	}
	m_isVisible = true;
	return hr;
}
開發者ID:tribis,項目名稱:TortoiseGit,代碼行數:32,代碼來源:SysProgressDlg.cpp

示例10: bringToFront

void
bringToFront()
{
#if defined(Q_WS_X11)
    {
        qDebug() << Q_FUNC_INFO;

        QWidget* widget = tomahawkWindow();
        if ( !widget )
            return;

        widget->show();
        widget->activateWindow();
        widget->raise();

        WId wid = widget->winId();
        NETWM::init();

        XEvent e;
        e.xclient.type = ClientMessage;
        e.xclient.message_type = NETWM::NET_ACTIVE_WINDOW;
        e.xclient.display = QX11Info::display();
        e.xclient.window = wid;
        e.xclient.format = 32;
        e.xclient.data.l[0] = 2;
        e.xclient.data.l[1] = QX11Info::appTime();
        e.xclient.data.l[2] = 0;
        e.xclient.data.l[3] = 0l;
        e.xclient.data.l[4] = 0l;

        XSendEvent( QX11Info::display(), RootWindow( QX11Info::display(), DefaultScreen( QX11Info::display() ) ), False, SubstructureRedirectMask | SubstructureNotifyMask, &e );
    }
#elif defined(Q_WS_WIN)
    {
        qDebug() << Q_FUNC_INFO;

        QWidget* widget = tomahawkWindow();
        if ( !widget )
            return;

        widget->show();
        widget->activateWindow();
        widget->raise();

        WId wid = widget->winId();

        HWND hwndActiveWin = GetForegroundWindow();
        int  idActive      = GetWindowThreadProcessId(hwndActiveWin, NULL);
        if ( AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) )
        {
            SetForegroundWindow( wid );
            SetFocus( wid );
            AttachThreadInput(GetCurrentThreadId(), idActive, FALSE);
        }
    }
#endif
}
開發者ID:demelziraptor,項目名稱:tomahawk,代碼行數:57,代碼來源:TomahawkUtilsGui.cpp

示例11: SetFocusTClockMain

/*------------------------------------------------
  set keyboard focus to the main window forcedly
--------------------------------------------------*/
void SetFocusTClockMain(HWND hwnd)
{
	DWORD pid, curthread, mythread;
	
	curthread = GetWindowThreadProcessId(GetForegroundWindow(), &pid);
	mythread = GetCurrentThreadId();
	AttachThreadInput(mythread, curthread, TRUE);
	SetForegroundWindow(hwnd);
	SetFocus(hwnd);
	AttachThreadInput(mythread, curthread, FALSE);
}
開發者ID:k-takata,項目名稱:TClockLight,代碼行數:14,代碼來源:menu.c

示例12: GetForegroundWindow

HRESULT VegasFSRender::writeData(ISfProgress* progress) {
  BOOL useAudio = (m_pIAudioStream &&
                   m_pTemplate->pAudioTemplate &&
                   m_pTemplate->pAudioTemplate->cNumAStreams);
  BOOL useVideo = (m_pIVideoStream &&
                   m_pTemplate->pVideoTemplate &&
                   m_pTemplate->pVideoTemplate->cNumVStreams);

  if (!useVideo)
    return SF_E_NOVIDEO;

  HWND activewnd = GetForegroundWindow();
  DWORD threadid = GetWindowThreadProcessId(activewnd, NULL);
  AttachThreadInput(GetCurrentThreadId(), threadid, TRUE);

  ZeroMemory(&FfpHeader, NUMBYTES(FfpHeader));

  LPTSTR pszFileName;
#ifdef UNICODE
  pszFileName = m_szFileName;
#else
  TCHAR szFileName[MAX_PATH];
  SfMBFromWC(szFileName, m_szFileName, MAX_PATH);
  pszFileName = szFileName;
#endif
  HRESULT hr = S_OK;

  hr = m_pIVideoStream->GetFrameCount(&FfpHeader.Video.cfTotal);
  hr = m_pIVideoStream->GetFrameRate(&FfpHeader.Video.dFPS);
  FfpHeader.Video.ntLength = SfVideo_FramesToTime(
      FfpHeader.Video.cfTotal, FfpHeader.Video.dFPS);
  FfpHeader.Video.bih = *m_pTemplate->pVideoTemplate->pbihCodec;
  FfpHeader.Video.cbFrameSize = FSDibImageBytes(&FfpHeader.Video.bih);
  if (useAudio) {
    hr = m_pIAudioStream->GetSampleCount(&FfpHeader.Audio.ccTotal);
    FfpHeader.Audio.wfx = m_pTemplate->pAudioTemplate->wfx;
    hr = m_pIAudioStream->GetStreamLength(&FfpHeader.Audio.ntLength);
    FfpHeader.Audio.ntLength = SfAudio_CellsToTime(FfpHeader.Audio.ccTotal,
        FfpHeader.Audio.wfx.nSamplesPerSec);
  }

  Init(!!useAudio, FfpHeader.Audio.wfx.nSamplesPerSec,
      FfpHeader.Audio.wfx.wBitsPerSample, FfpHeader.Audio.wfx.nChannels,
      (DWORD)FfpHeader.Video.cfTotal, FfpHeader.Video.dFPS,
      FfpHeader.Video.bih.biWidth, FfpHeader.Video.bih.biHeight, activewnd, pszFileName);
  hr = S_OK;
  if (!Run())
    hr = SF_E_CANCEL;

  EnableWindow(activewnd, TRUE);
  SetForegroundWindow(activewnd);
  AttachThreadInput(GetCurrentThreadId(), threadid, FALSE);
  return hr;
}
開發者ID:spylfy,項目名稱:frame-server,代碼行數:54,代碼來源:VegasFSRender.cpp

示例13: fsSetForegroundWindow

void fsSetForegroundWindow (HWND hWnd)
{
	HWND hFor = GetForegroundWindow ();
	int iMyTID = GetCurrentThreadId ();
	int iCurrTID = GetWindowThreadProcessId (hFor, NULL);

	AttachThreadInput (iMyTID, iCurrTID, TRUE);

	SetForegroundWindow (hWnd);

	AttachThreadInput (iMyTID, iCurrTID, FALSE);
}
開發者ID:HackLinux,項目名稱:Free-Download-Manager-vs2010,代碼行數:12,代碼來源:system.cpp

示例14: handle_task_timer

   void handle_task_timer(void) {
	   KillTimer(m_hwnd, TASK_RISE_TIMER);
	   if (NULL == task_over) return;

	   DWORD ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
	   DWORD ThreadID2 = GetCurrentThreadId();
	   if (ThreadID1 != ThreadID2) {
		   AttachThreadInput(ThreadID1, ThreadID2, TRUE);
		   SetForegroundWindow(m_hwnd);
		   AttachThreadInput(ThreadID1, ThreadID2, FALSE);
	   }
	   PostMessage(GetBBWnd(), BB_BRINGTOFRONT, 0, (LPARAM)task_over);
   }
開發者ID:Jmos,項目名稱:bbclean-xzero450,代碼行數:13,代碼來源:TinyDropTarg.cpp

示例15: GetWindowThreadProcessId

void UIScreenCaptureMgr::forceForgroundWindow(__in HWND hWnd)
{
    HWND hForegroundWnd = ::GetForegroundWindow();
    DWORD dwPid = GetWindowThreadProcessId(hForegroundWnd, NULL);
    if (!AttachThreadInput(dwPid, GetCurrentThreadId(), TRUE)
        || !::SetForegroundWindow(hWnd) 
        || !::BringWindowToTop(hWnd))
    {
        return;
    }

    SwitchToThisWindow(hWnd, TRUE);
    AttachThreadInput(dwPid, GetCurrentThreadId(), FALSE);
}
開發者ID:heavenopener,項目名稱:TeamTalk,代碼行數:14,代碼來源:UIMgr.cpp


注:本文中的AttachThreadInput函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。