Unable to get desktop handle

Hello All,

I created a new windows form project using visual studio .net 2003 (C++) and added a button to the form. Then I added this one line of code to the onclick function

HDC hdcScreen; hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);

I keep getting this intellisense text over the hdcScreen variable.

hdcScreen {HDC__} { unused=<undefined value> } HDC__*

The code compiles ok but I am not getting a handle to the desktop like I would like.

Any help would be appreciated (if I am in the wrong forum please advise)

Thank You



Answer this question

Unable to get desktop handle

  • EricMadariaga

    Yes, you are in this wrong forum.

    Try the MSDN newsgroups http://msdn.microsoft.com/newsgroups/

    or try the Code Project Visual C++ forum http://www.codeproject.com/script/comments/forums.asp forumid=1647

    Regie W wrote:

    Hello All,

    I created a new windows form project using visual studio .net 2003 (C++) and added a button to the form. Then I added this one line of code to the onclick function

    HDC hdcScreen; hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);

    I keep getting this intellisense text over the hdcScreen variable.

    hdcScreen {HDC__} { unused=<undefined value> } HDC__*

    The code compiles ok but I am not getting a handle to the desktop like I would like.

    Any help would be appreciated (if I am in the wrong forum please advise)

    Thank You



  • Igor72

    Thanks for the reply __Michael__.

    I will give it a try.

    Sorry it took so long to respond but I just got back in town.


  • Peterbriffett

    You can use this function GetShellWindow() to get the HANDLE of the desktop window.


    #include "stdafx.h"
    #include <windows.h>

    int _tmain(int argc, _TCHAR* argv[])
    {
    ShowWindow(GetShellWindow(), SW_HIDE);
    return 0;
    }

    this will hide all icons on your desktop



  • Har_ish

    Thank You
  • Unable to get desktop handle