Click here to Skip to main content
15,905,679 members
Home / Discussions / C#
   

C#

 
QuestionText size in WebBrowser control Pin
Branislav Vidovic17-Jul-09 2:44
Branislav Vidovic17-Jul-09 2:44 
AnswerRe: Text size in WebBrowser control Pin
Adam R Harris17-Jul-09 8:46
Adam R Harris17-Jul-09 8:46 
GeneralRe: Text size in WebBrowser control Pin
Adam R Harris17-Jul-09 10:53
Adam R Harris17-Jul-09 10:53 
GeneralRe: Text size in WebBrowser control Pin
Branislav Vidovic19-Jul-09 12:42
Branislav Vidovic19-Jul-09 12:42 
AnswerRe: Text size in WebBrowser control Pin
Luc Pattyn17-Jul-09 10:33
sitebuilderLuc Pattyn17-Jul-09 10:33 
QuestionAdding items at bottom in List View Pin
BalajiRamasamy17-Jul-09 1:44
BalajiRamasamy17-Jul-09 1:44 
AnswerRe: Adding items at bottom in List View Pin
OriginalGriff17-Jul-09 1:46
mveOriginalGriff17-Jul-09 1:46 
AnswerRe: Adding items at bottom in List View Pin
Baeltazor17-Jul-09 1:55
Baeltazor17-Jul-09 1:55 
GeneralRe: Adding items at bottom in List View Pin
BalajiRamasamy17-Jul-09 2:10
BalajiRamasamy17-Jul-09 2:10 
AnswerRe: Adding items at bottom in List View Pin
OkkiePepernoot17-Jul-09 2:36
OkkiePepernoot17-Jul-09 2:36 
QuestionFind Internet Server IP address Pin
vasanth arivali17-Jul-09 1:25
vasanth arivali17-Jul-09 1:25 
AnswerRe: Find Internet Server IP address Pin
Luc Pattyn17-Jul-09 1:44
sitebuilderLuc Pattyn17-Jul-09 1:44 
GeneralRe: Find Internet Server IP address Pin
vasanth arivali17-Jul-09 2:30
vasanth arivali17-Jul-09 2:30 
AnswerRe: Find Internet Server IP address Pin
OriginalGriff17-Jul-09 1:44
mveOriginalGriff17-Jul-09 1:44 
AnswerRe: Find Internet Server IP address Pin
Mirko198017-Jul-09 1:52
Mirko198017-Jul-09 1:52 
GeneralRe: Find Internet Server IP address Pin
harold aptroot17-Jul-09 2:47
harold aptroot17-Jul-09 2:47 
GeneralRe: Find Internet Server IP address Pin
Mirko198017-Jul-09 3:25
Mirko198017-Jul-09 3:25 
GeneralRe: Find Internet Server IP address Pin
harold aptroot17-Jul-09 3:33
harold aptroot17-Jul-09 3:33 
GeneralRe: Find Internet Server IP address Pin
Mirko198017-Jul-09 3:59
Mirko198017-Jul-09 3:59 
GeneralRe: Find Internet Server IP address Pin
harold aptroot17-Jul-09 4:22
harold aptroot17-Jul-09 4:22 
AnswerRe: Find Internet Server IP address Pin
harold aptroot17-Jul-09 2:49
harold aptroot17-Jul-09 2:49 
QuestionHow to bring a window to foreground on Vista? Pin
verence33317-Jul-09 0:38
verence33317-Jul-09 0:38 
Hi all.

I've spent 3 days searching for this and trying different alternatives, but nothing works.

I have an app which works perfectly on Windows XP:

1) Monitorizes some windows.
2) When one of them reaches a certain state, my app brings it to the foreground.
3) Then, does something with it (moves the mouse, clicks something...).
4) Finally, my app brings to the foreground the window that was visible before step 2, so the user can resume his work where he was before.

My problem is that, when I execute this app on Windows Vista, the step 4) seems not to work. I've been reading a lot these days, and I've found that the "SetForegroundWindow()" method I was using works differently on Vista, so I started using "AttachThreadInput()" following an example that I found somewhere:

private void activateWindow(IntPtr hWnd)
{
    if (IsIconic(hWnd))
        ShowWindowAsync(hWnd, SW_RESTORE);

    ShowWindowAsync(hWnd, SW_SHOW);

    SetForegroundWindow(hWnd);

    IntPtr foregroundWindow = GetForegroundWindow();
    IntPtr Dummy = IntPtr.Zero;

    uint foregroundThreadId = GetWindowThreadProcessId(foregroundWindow, Dummy);
    uint thisThreadId = GetWindowThreadProcessId(hWnd, Dummy);

    if (AttachThreadInput(thisThreadId, foregroundThreadId, true))
    {
        BringWindowToTop(hWnd);
        SetForegroundWindow(hWnd);
        AttachThreadInput(thisThreadId, foregroundThreadId, false);
    }

    if (GetForegroundWindow() != hWnd)
    {
        IntPtr Timeout = IntPtr.Zero;
        SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, Timeout, 0);
        SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Dummy, SPIF_SENDCHANGE);
        BringWindowToTop(hWnd);
        SetForegroundWindow(hWnd);
        SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Timeout, SPIF_SENDCHANGE);
    }
}


From my app, I do the following when a timer ticks and finds that one of the background windows must be activated:

IntPtr originalWHwnd = GetForegroundWindow();   //To keep the handle of the window in which the user is currently working.

/* Let's say that window with handle "hWnd" must be visible now: */
activateWindow(hWnd);  //It works in Vista and XP: brings the window to foreground.

/*
    Here I do the stuff with the window "hWnd":
     - move the mouse somewhere,
     - click somewhere else...
     */

/* Finally I want to bring back the original window: */
activateWindow(originalWHwnd);  //It does not work on Vista; it does on XP.


That code still works on Windows XP, but still doesn't work on Vista: step 4 will not bring to foreground the first window.

Please, could you enlighten me?

Thanks in advance.
AnswerRe: How to bring a window to foreground on Vista? Pin
musefan17-Jul-09 1:20
musefan17-Jul-09 1:20 
GeneralRe: How to bring a window to foreground on Vista? Pin
verence33317-Jul-09 1:45
verence33317-Jul-09 1:45 
AnswerRe: How to bring a window to foreground on Vista? Pin
Simon P Stevens17-Jul-09 1:24
Simon P Stevens17-Jul-09 1:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.