Results 1 to 2 of 2

Thread: Win32 App TaskBar

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    198

    Win32 App TaskBar

    Im trying to make it so when my window show up in the taskbar but its ToolWindow.

    MSDN said "ToolWindow never has a taskbar icon, and it will not appear in the Alt+Tab window. It should be a child window of the main window, like Visual Studio--Solution Explorer. You can create a main window and then create the ToolWindow as its child(set hWndParent parameter in CreateWindowEx), that's what exactly its name "ToolWindow" means."

    How would i add it in?


    Heres my ToolWindow
    Code:
    #include <windows.h>
    
    const wchar_t g_szClassName[] = L"MyWindowName";
    
    // Step 4: the Window Procedure
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        switch(msg)
        {
            case WM_CLOSE:
                DestroyWindow(hwnd);
            break;
    		case WM_DESTROY:
                PostQuitMessage(0);
            break;
            default:
                return DefWindowProc(hwnd, msg, wParam, lParam);
        }
        return 0;
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
    {
        MSG Msg;
    
    	// Register window class
    WNDCLASSEX toolwindow;
    
    toolwindow.cbSize = sizeof(WNDCLASSEX);
    toolwindow.style               = CS_HREDRAW | CS_VREDRAW;
    toolwindow.lpfnWndProc         = WndProc;
    toolwindow.cbClsExtra          = 0;
    toolwindow.cbWndExtra          = 0;
    toolwindow.hInstance           = hInstance;
    toolwindow.hIcon               = 0;
    toolwindow.hCursor             = LoadCursor(NULL, IDC_CROSS);
    toolwindow.hbrBackground       = (HBRUSH)COLOR_WINDOW;
    toolwindow.lpszMenuName        = 0;
    toolwindow.lpszClassName       = TEXT("ToolWindow");
    toolwindow.hIconSm             = 0;
    RegisterClassEx(&toolwindow);
    
    // Set the Window Style
    DWORD flags = WS_CAPTION | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPED | WS_SYSMENU;
    
    // Create the window with WS_EX_TOOLWINDOW
    HWND hWndToolWindow = CreateWindowEx(WS_EX_TOOLWINDOW, TEXT("ToolWindow"), TEXT("My Window Name"), flags, 250, 250, 371, 192, NULL, NULL, hInstance, NULL);
    
    // Show the window
    ShowWindow(hWndToolWindow, 1);
    UpdateWindow(hWndToolWindow);
    
    
        // Step 3: The Message Loop
        while(GetMessage(&Msg, NULL, 0, 0) > 0)
        {
            TranslateMessage(&Msg);
            DispatchMessage(&Msg);
        }
        return Msg.wParam;
    }

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: Win32 App TaskBar

    MSDN is self explanatory. A ToolWindow should not be the main window but should be shown (popup) from the main window.

    So just make the window a different window style if you want it to show in the taskbar!

Posting Permissions

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



Click Here to Expand Forum to Full Width