Results 1 to 2 of 2

Thread: How to use native windows api in Qt C++?

  1. #1
    Join Date
    Jan 2015
    Posts
    35
    Thanks
    20
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default How to use native windows api in Qt C++?

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


    Thanks in advanced.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use native windows api in Qt C++?

    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,
    _

  3. The following 2 users say thank you to anda_skoa for this useful post:

    binary001 (6th July 2015), Cupidvogel (1st January 2016)

Similar Threads

  1. Getting native windows and resizing
    By jerome in forum Newbie
    Replies: 2
    Last Post: 12th July 2010, 19:39
  2. Looking Native on Windows, saying similar to Microsoft Office
    By henry_shanghai in forum General Discussion
    Replies: 4
    Last Post: 30th May 2010, 15:35
  3. Alien vs Native Windows - Flicker in Screen Transition
    By pinakis in forum Qt-based Software
    Replies: 1
    Last Post: 18th October 2009, 17:47
  4. MS Sql native driver??
    By LordQt in forum Qt Programming
    Replies: 4
    Last Post: 9th October 2007, 14:41
  5. Can Native Api be Used?
    By iGoo in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2006, 12:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.