PDA

View Full Version : How to use native windows api in Qt C++?



binary001
6th July 2015, 05:15
Hi,

I want to do Hiding/Showing the Windows TaskBar with Qt C++. But there is no code for that function. I found that windows 32 native Code only. How can I use native windows api into my Qt C++ project?

The code I found for hiding/showing the windows taskbar is as follow:
Hiding/Showing the Windows TaskBar

void gShowHideTaskBar(BOOL bHide /*=FALSE*/)
{
CRect rectWorkArea = CRect(0,0,0,0);
CRect rectTaskBar = CRect(0,0,0,0);

CWnd* pWnd = CWnd::FindWindow("Shell_TrayWnd", "");

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();
SystemParametersInfo(SPI_SETWORKAREA,0,LPVOID)&rectWorkArea,0);
pWnd->ShowWindow(SW_HIDE);
}
}
else
{
// Code to Show the System Task Bar
SystemParametersInfo(SPI_GETWORKAREA,0,(LPVOID)&rectWorkArea,0);
if( pWnd )
{
pWnd->GetWindowRect(rectTaskBar);
rectWorkArea.bottom -= rectTaskBar.Height();
SystemParametersInfo(SPI_SETWORKAREA,0,(LPVOID)&rectWorkArea,0);
pWnd->ShowWindow(SW_SHOW);
}
}
}


Thanks in advanced.

anda_skoa
6th July 2015, 08:10
Native API is usually just some C API, which you can call directly in C++ (and thus in a Qt application).

Your code above looks like a mixture of system API and MFC, so if you can get rid of the MFC parts there should be no problem of using the remaining code.

Cheers,
_