1

I am doing some analysis before coding and I was having some trouble finding information or implementations where there is an application where there are these characteristics:

  1. Window #1 (shown on taskbar)
  2. Window #2 (doesn't show on taskbar and you can put this one behind Window #1, so we are not talking about popups/dialogs rooted from Window #1)
  3. Both Window #1 and Window #2 are in the same Project (or application, so to speak)

Again, this is just speaking conceptually, so if you can point me to some information proving that this is possible, it would be great. Note, this is in C++ not C#.

Mathew Kurian
  • 5,949
  • 5
  • 46
  • 73
  • There are very searchable requirements for which windows go on the taskbar. – chris Sep 12 '13 at 17:59
  • @chris: Some links to what you are talking about would be obliged. – Mathew Kurian Sep 12 '13 at 18:02
  • 1
    After the window is created you can remove the [`WS_EX_APPWINDOW`](http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543.aspx) extended window style using [`SetWindowLongPtr`](http://msdn.microsoft.com/en-us/library/windows/desktop/ms644898.aspx) (`GWL_EXSTYLE`). – IInspectable Sep 12 '13 at 18:06
  • @llnspectable: That wouldn't make the window invisible right? – Mathew Kurian Sep 12 '13 at 18:12
  • @mk1 Nope. Visibility is controlled through the `WS_VISIBLE` window style and both of these styles are unrelated. – IInspectable Sep 12 '13 at 18:13
  • @mk1, How about [documentation](http://msdn.microsoft.com/en-us/library/bb776822%28v=vs.85%29.aspx)? – chris Sep 12 '13 at 18:19
  • @IInspectable I am trying to do something like this [Borderless Window + Shadow](http://stackoverflow.com/questions/16765561/borderless-window-using-areo-snap-shadow-minimize-animation-and-shake/17713810#17713810), would it be possible with the concepts mentioned in this thread? – Mathew Kurian Sep 13 '13 at 03:52

1 Answers1

1

The closest I came up with is this:

  1. Added a class derived from CWnd
  2. Added the following function to the class

    void Create2ndWindow(CWnd* pParent){

    LPCTSTR pszClassName = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, ::LoadCursor(NULL, IDC_ARROW), (HBRUSH) ::GetStockObject(WHITE_BRUSH), ::LoadIcon(NULL, IDI_APPLICATION));

    BOOL bCreated = CreateEx(WS_EX_CLIENTEDGE, 
        pszClassName, 
        _T("My Second Window"), 
        WS_BORDER|WS_CAPTION|WS_ACTIVECAPTION|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_POPUPWINDOW|WS_SIZEBOX, 
        CRect(20, 20, 100, 100), 
        pParent, 
        NULL);
    if(bCreated)
        ShowWindow(SW_SHOW);
    

    }

  3. In the InitInstance i added the following lines: CSecondWindow* pWnd = new CSecondWindow(); pWnd->Create2ndWindow(pFrame);

  4. Execute the application, 2 Windows appear on your desktop but you should see only one taskbar button for the pFrame window and no button for the CSecondWindow

if the pParent is NULL then you would see the taskbar button. There is another style you can add WS_EX_TOOLWINDOW but that reduces the height of caption bar.

Simple Fellow
  • 4,315
  • 2
  • 31
  • 44
  • This does not implement the second requirement of the question. Your second window will always be in front of your first window. – IInspectable Sep 12 '13 at 21:01
  • The 2nd requirement says you can not you must. “Some people find fault like there is a reward for it” – Simple Fellow Sep 17 '13 at 01:18
  • The requirement states that it must be possible for the first window to be in front of the second window. With your solution it isn't. This sounds like nitpicking, but it isn't. You missed the core requirement that asks for multiple top level windows with a single taskbar button, by **not** making them top level windows. Your proposed solution illustrates how to create an owned window, you could have simply called `MessageBox` with the same result: 2 windows, 1 taskbar button. I have no idea why it was accepted as an answer. – IInspectable Sep 17 '13 at 07:13
  • At least i wrote the code, experimented with it and see if I could come up with a real solution coz I care about how I can be of any help to people on this site from who I learn so much. A word of advice: Next time try to give a solution rather than commenting on other answers to belittle and denigrate their efforts! – Simple Fellow Sep 17 '13 at 12:39
  • I am not discrediting your efforts. I'm just saying that this answer does not address the question. This site is supposed to be valuable to future visitors just as well. I don't know about you, but when I come here to look for a solution I honestly do not care about the effort someone put into something that doesn't solve my problem at hand. I do care about a solution, and I value comments that do warn me ahead of time that something that looks like a solution isn't. – IInspectable Sep 19 '13 at 20:30