0
votes

I have an MFC application. In my application if I run on Windows XP it's working fine. But if I run in Windows Vista the MFC dialog hides behind the taskbar.

bool bHide=true;
CRect rectWorkArea = CRect(0,0,0,0);
CRect rectTaskBar = CRect(0,0,0,0); 

CWnd* pWnd = CWnd::FindWindow("Shell_TrayWnd", ""); 
pWnd->ShowWindow(SW_SHOW);
if( bHide ) 
{  // Code to Hide the System Task Bar  
    SystemParametersInfo(SPI_GETWORKAREA,0,(LPVOID)&rectWorkArea,0);   
    if( pWnd ) 
    {   
        pWnd->GetWindowRect(rectTaskBar);   
    //    rectWorkArea.bottom -= rectTaskBar.Height();  
        rectWorkArea.bottom += rectTaskBar.Height();//-----to hide taskbar
        SystemParametersInfo(SPI_SETWORKAREA,0,(LPVOID)&rectWorkArea,0);    
    //    pWnd->ShowWindow(SW_SHOW);  
        pWnd->ShowWindow(SW_HIDE); //--to hide taskbar
    }
}

I used this code but it hides the taskbar. But I want to show the application above the task bar.

2
If you want to overlap the taskbar then your window needs to be a borderless maximized window. Which is the only kind of window that ever needs to overlap the taskbar.Hans Passant

2 Answers

2
votes

You don't own the taskbar, so you are not supposed to hide it. You have the option to auto-minimize it by the way. You have another option of using secondary monitor without taskbar there.

On the primary monitor your app is given work area, you are being able to locate (judging from the code snippet provided above). It is the best to position your window within this area without interfering with the taskbar, whether it is above or beyond.

If you still feel like making it more like a competition "who is on top" with the task bar, you might want to take a look at SetWindowPos API and window Z-Order.

1
votes

finally i found the solution , what we want to do is we should add the below code in our oninitdialog,

SetWindowPos(&this->wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

the above line is enough to show the mfc dialog on above the taskbar . but sometimes the focus of the dialog get changed looks hanged(no response in dialog) the application.if it occurs put the below code.

SetWindowPos(&this->wndBottom,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);