0

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.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
user1635224
  • 1,623
  • 2
  • 15
  • 15
  • 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 Oct 17 '12 at 11:07

2 Answers2

2

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.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • MSDN describes this in detail: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183314%28v=vs.85%29.aspx – Roman R. Oct 17 '12 at 10:34
1

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);
General Grievance
  • 4,555
  • 31
  • 31
  • 45
user1635224
  • 1,623
  • 2
  • 15
  • 15
  • "sometimes the focus..." this is what I meant by saying "more like a competition". You cannot do it once, it will be continuously attempting to come back onto top. – Roman R. Oct 19 '12 at 13:06