How to regain right-click context menu after creating a window-based desktop?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: How to regain right-click context menu after creating a window-based desktop?

  1. #1
    Join Date
    Dec 2010
    Posts
    72

    How to regain right-click context menu after creating a window-based desktop?

    Code:
    winClass.lpszClassName = "Alt_Desktop";
    winClass.cbSize        = sizeof(WNDCLASSEX);
    winClass.style         = CS_HREDRAW | CS_VREDRAW;
    winClass.lpfnWndProc   = WindowProc;
    winClass.hInstance     = hInstance;
    winClass.hIcon	       = LoadIcon(hInstance, NULL);
    winClass.hIconSm	   = LoadIcon(hInstance, NULL);
    winClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
    winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    winClass.lpszMenuName  = NULL;
    winClass.cbClsExtra    = 0;
    winClass.cbWndExtra    = 0;
    
    if( !RegisterClassEx(&winClass) )
    	return E_FAIL;
    
    g_hWnd = CreateWindowEx( NULL, "Alt_Desktop", 
                                 "Alt_Desktop",
    		    WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
    			   0, 0, 640, 480, NULL, NULL, hInstance, NULL );
    
    if( g_hWnd == NULL )
    	return E_FAIL;
    
    SetWindowPos(g_hWnd, HWND_BOTTOM, 0, 0, 1920, 1079, 0);
    I can't use the context menu anymore after creating the desktop like this.
    How to regain the context menu from this code?
    Thanks
    Jack

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    18,907

    Re: How to regain right-click context menu after creating a window-based desktop?

    Quote Originally Posted by luckiejacky View Post

    I can't use the context menu anymore after creating the desktop like this.
    How to regain the context menu from this code?
    What do you mean by "can't use the context menu"?
    Isn't WM_CONTEXTMENU message sent? Or TrackPopupMenu doesn't work? Or something else?
    Victor Nijegorodov

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,517

    Re: How to regain right-click context menu after creating a window-based desktop?

    Are you handling the WM_CONTEXTMENU message?

  4. #4
    Join Date
    Dec 2010
    Posts
    72

    Re: How to regain right-click context menu after creating a window-based desktop?

    I just receive the message WM_CONTEXTMENU, how do I display the system context menu from the desktop?
    BTW, all the sidebar and icons are hidden by this window, how can I put them back to the foreground?
    Thanks
    Jack

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    18,907

    Re: How to regain right-click context menu after creating a window-based desktop?

    Quote Originally Posted by luckiejacky View Post
    I just receive the message WM_CONTEXTMENU, how do I display the system context menu from the desktop?
    What "desktop" do you mean: the standard Windows desktop or your own just created "desktop"?
    Victor Nijegorodov

  6. #6
    Join Date
    Dec 2010
    Posts
    72

    Re: How to regain right-click context menu after creating a window-based desktop?

    I am talking about my own one here..
    Thanks Victor.
    Jack

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    18,907

    Re: How to regain right-click context menu after creating a window-based desktop?

    Quote Originally Posted by luckiejacky View Post
    I am talking about my own one here..
    Well, in such a case (and looking at your code snippet) I'd say that you don't see/have any icon(s) on your "own desktop" just because you didn't set it/them there.

    The standard Windows desktop window contains a child window of type SysListView32 (what is the ListView control) and all the icons (shortcuts) are placed on it.
    Read also this discussion: https://stackoverflow.com/questions/...of-the-desktop
    Victor Nijegorodov

  8. #8
    Join Date
    Dec 2010
    Posts
    72

    Re: How to regain right-click context menu after creating a window-based desktop?

    Do I just get all those funky handles and paint them on top of my desktop?
    Thanks
    Jack

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    18,907

    Re: How to regain right-click context menu after creating a window-based desktop?

    Quote Originally Posted by luckiejacky View Post
    Do I just get all those funky handles and paint them on top of my desktop?
    Thanks
    Jack
    I do NOT know!

    However, you'd probably like to explain what you are trying to achieve...
    So, why do you create your "own desktop" window? What is wrong for you in using the "standard" desktop? Or what is it, the standard one cannot do for some of your special needs?
    Victor Nijegorodov

  10. #10
    Join Date
    Dec 2010
    Posts
    72

    Re: How to regain right-click context menu after creating a window-based desktop?

    Right though, I just create virtual desktops that got different wallpapers...
    simple enough

  11. #11
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    18,907

    Re: How to regain right-click context menu after creating a window-based desktop?

    Quote Originally Posted by luckiejacky View Post
    Right though, I just create virtual desktops that got different wallpapers...
    simple enough
    But why not use the SystemParametersInfo API with SPI_SETDESKWALLPAPER parameter?
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)