예제 #1
0
파일: button.c 프로젝트: RPG-7/reactos
/* retrieve the button text; returned buffer must be freed by caller */
static inline WCHAR *get_button_text( HWND hwnd )
{
    INT len = 512;
    WCHAR *buffer = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
    if (buffer) InternalGetWindowText( hwnd, buffer, len + 1 );
    return buffer;
}
예제 #2
0
static inline WCHAR *get_button_text(HWND hwnd)
{
    INT len = 512;
    WCHAR *text;
    text = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
    if (text) InternalGetWindowText(hwnd, text, len + 1);
    return text;
}
예제 #3
0
void ReloadTsTrayIcons() {
	if (g_dwFlags & TSF_SHOWTRAYICON) {
		if (!ReloadTrayIcon(g_hwndMain, IDI_TASKSWITCHXP))
			ShowTrayIcon(TRUE);
	}
	for (int i = (int)g_cWti - 1; i >= 0; i--) {
		if (!ReloadTrayIcon(g_hwndMain, g_pWti[i].uID)) {
			if (IsWindow(g_pWti[i].hwnd)) {
				WCHAR szCaption[MAX_CAPTION];
				InternalGetWindowText(g_pWti[i].hwnd, szCaption, MAX_CAPTION);
				AddTrayIcon(g_hwndMain, g_pWti[i].uID, g_pWti[i].hIconSm, szCaption);
			}
		}
	}
}
예제 #4
0
ULONG PhGetWindowTextEx(
    _In_ HWND hwnd,
    _In_ ULONG Flags,
    _Out_opt_ PPH_STRING *Text
    )
{
    PPH_STRING string;
    ULONG length;

    if (Flags & PH_GET_WINDOW_TEXT_INTERNAL)
    {
        if (Flags & PH_GET_WINDOW_TEXT_LENGTH_ONLY)
        {
            WCHAR buffer[32];
            length = InternalGetWindowText(hwnd, buffer, sizeof(buffer) / sizeof(WCHAR));
        }
        else
        {
            // TODO: Resize the buffer until we get the entire thing.
            string = PhCreateStringEx(NULL, 256 * sizeof(WCHAR));
            length = InternalGetWindowText(hwnd, string->Buffer, (ULONG)string->Length / sizeof(WCHAR) + 1);
            string->Length = length * sizeof(WCHAR);

            if (Text)
                *Text = string;
            else
                PhDereferenceObject(string);
        }

        return length;
    }
    else
    {
        length = GetWindowTextLength(hwnd);

        if (length == 0 || (Flags & PH_GET_WINDOW_TEXT_LENGTH_ONLY))
        {
            if (Text)
                *Text = PhReferenceEmptyString();

            return length;
        }

        string = PhCreateStringEx(NULL, length * sizeof(WCHAR));

        if (GetWindowText(hwnd, string->Buffer, (ULONG)string->Length / sizeof(WCHAR) + 1))
        {
            if (Text)
                *Text = string;
            else
                PhDereferenceObject(string);

            return length;
        }
        else
        {
            if (Text)
                *Text = PhReferenceEmptyString();

            PhDereferenceObject(string);

            return 0;
        }
    }
}
예제 #5
0
BOOL FlipToTray(HWND hwnd) {

	if (g_cWti >= MAX_WNDTRAY)
		return(FALSE);
	if (!IsWindow(hwnd))
		return(FALSE);

	HWND hwndShell = GetShellWindow(), hwndTmp, hwndOwner;
	hwndTmp = hwndOwner = hwnd;
	do {
		hwndOwner = hwndTmp;
		hwndTmp = GetWindow(hwndTmp, GW_OWNER);
	} while (hwndTmp && hwndTmp != hwndShell);

	DWORD dw = GetWindowLongPtr(hwndOwner, GWL_STYLE);
	if (!(dw & WS_MINIMIZEBOX) || dw & WS_CHILD)
		return(FALSE);

	//SetForegroundWindow(g_hwndMain);
	//MySwitchToThisWindow(GetShellWindow());

	for (UINT i = 0; i < g_cWti; i++) {
		if (g_pWti[i].hwnd == hwndOwner) {
			if (IsWindowVisible(hwndOwner))
				_UnflipFromTray(i, 0);
			else return(FALSE);
		}
	}

	UINT uID = IDC_FIRSTTRAYICON;
	if (g_cWti > 0) {
		while (uID < IDC_FIRSTTRAYICON + MAX_WNDTRAY) {
			BOOL fIs1 = TRUE;
			for (UINT i = 0; i < g_cWti; i++) {
				if (g_pWti[i].uID == uID)
					fIs1 = FALSE;
			}
			if (fIs1) break;
			uID++;
		}
	}

	HICON hIcon, hIconSm;
	GetWindowIcons(hwndOwner, &hIcon, &hIconSm);

	WCHAR szCaption[MAX_CAPTION];
	InternalGetWindowText(hwndOwner, szCaption, MAX_CAPTION);
	if (szCaption[0] == L'\0' && hwnd != hwndOwner) {
		InternalGetWindowText(hwnd, szCaption, MAX_CAPTION);
	}

	if (MyIsHungAppWindow(hwndOwner))
		return(FALSE);

	RECT rcTray = { 0 };

	g_pWti[g_cWti].fAnimate = FALSE;

	if (!(dw & WS_MINIMIZE)) {

		GetWindowRect(hwnd, &g_pWti[g_cWti].rcWnd);
	
		ANIMATIONINFO ai;
		ai.cbSize = sizeof(ANIMATIONINFO);
		ai.iMinAnimate = FALSE;
		SystemParametersInfo(SPI_GETANIMATION, sizeof(ANIMATIONINFO), &ai, FALSE);

		if (ai.iMinAnimate) {
			HWND hwndTray = FindTrayToolbarWindow();
			if (hwndTray) {
				GetWindowRect(hwndTray, &rcTray);
				rcTray.bottom = rcTray.top;
				rcTray.right = rcTray.left;

				KillTimer(g_hwndMain, TIMER_SETANIMATION);
				g_pWti[g_cWti].fAnimate = TRUE;			
				ai.iMinAnimate = 0;
				SystemParametersInfo(SPI_SETANIMATION, sizeof(ANIMATIONINFO), &ai, FALSE);
				SetTimer(g_hwndMain, TIMER_SETANIMATION, 500, NULL);

				DrawAnimatedRects(g_hwndMain, IDANI_CAPTION, 
					&g_pWti[g_cWti].rcWnd, &rcTray);
			}
		}

		//ShowWindow(hwndOwner, SW_MINIMIZE);
		if (!SendMessageTimeout(hwndOwner, WM_SYSCOMMAND, SC_MINIMIZE, 0, 
			SMTO_ABORTIFHUNG, 500, &dw)) return(FALSE);
	}

	//ShowWindow(hwndOwner, SW_HIDE);
	SetWindowPos(hwndOwner, NULL, 0, 0, 0, 0, 
		SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_HIDEWINDOW);

	//if (g_pWti[g_cWti].fAnimate) {
	//}

	g_pWti[g_cWti].hwnd = hwndOwner;
	g_pWti[g_cWti].uID = uID;
	g_pWti[g_cWti].hIconSm = hIconSm;
	g_cWti++;
	AddTrayIcon(g_hwndMain, uID, hIconSm, szCaption);
	return(TRUE);
}
예제 #6
0
파일: zprivate.c 프로젝트: mingpen/OpenNT
int ZInternalGetWindowText( HWND hWnd, LPWSTR lpString, int nMaxCount)
{
    return InternalGetWindowText(hWnd,lpString,nMaxCount);
 ;
        
}
예제 #7
0
파일: Window.cpp 프로젝트: caidongyun/libs
/** 
 * 
 * Extracts details pertaining to a window
 * 
 * @param       WindowObj - Window data
 * @return      void
 * @exception   Nil
 * @see         Nil
 * @since       1.0
 */
void Window::ExtractWindowDetails( const HWND hWnd_i )
{
    // Set window handle
    SetHandle( hWnd_i );

    // Set thread id of window
    SetThreadId( ::GetWindowThreadProcessId( GetHandle(), 0 ));

    // Get class name of window
    TCHAR szBuffer[MAX_PATH] = { 0 };
    ::GetClassName( GetHandle(), szBuffer, MAX_PATH );
    GetClassName() = szBuffer;

    GetClass().cbSize = sizeof( GetClass() );
    GetClassInfoEx( AfxGetInstanceHandle(), szBuffer, &GetClass() );

    // Get window text if any
    InternalGetWindowText( GetHandle(), GetTitle().GetBufferSetLength( MAX_PATH ), MAX_PATH );
    GetTitle().ReleaseBuffer();

    // Get normal style
    SetStyle( GetWindowLong( GetHandle(), GWL_STYLE ));

    // Get extended style
    SetStyleEx( GetWindowLong( GetHandle(), GWL_EXSTYLE ));

    // Get window id
    SetId( GetWindowLong( GetHandle(), GWL_ID ));

    // Get parent window
    SetParentHandle( RCAST( HWND, GetWindowLong( GetHandle(), GWL_HWNDPARENT )));

    // Window state i.e. window is maximized, minimized or restored
    GetStateAsString( GetState() );

    // For style parsing
    RetrieveWndStyles();

    // Window bounds
    CRect crBounds;
    GetWindowRect( GetHandle(), &crBounds );
    if( crBounds.Width() || crBounds.Height() )
    {
        GetBounds().Format( _T( "L:%d T:%d R:%d B:%d" ), crBounds.left, 
                                                         crBounds.top, 
                                                         crBounds.right, 
                                                         crBounds.bottom );
    }// End if

    // Retrieves unicode support status for windows
    SetUnicode( IsWindowUnicode( GetHandle() ));

    // Get window icon
    DWORD dwResult = 0;
    Utils::SndMsgTimeOutHelper( GetHandle(), 
                                WM_GETICON, 
                                ICON_SMALL, 
                                0,
                                dwResult );
    // Get window icon
    SetIcon( RCAST( HICON, dwResult ));

    // Get enabled status of window
    SetEnabled( IsWindowEnabled( GetHandle() ));
}// End ExtractWindowDetails