Search code examples
formsiconsc++buildertaskbar

C++ Builder bizarre issue (taskbar icon not appearing)?


I have an application with a login form (which is the main form) and a main form, which is opened after the log-in one is filled in with the correct info.

However, the program icon does not appear on the taskbar. I would like to ask, why does this happen?

screenshot-1

screenshot-2


Solution

  • I don't think there is anything bizarre in this behaviour. I assume You hide login form after user provides login information?

    By default Main form owns taskbar:

    Application->MainFormOnTaskBar = true;
    

    So either make frmMain "main" instead of LoginForm and create login form dynamically before main Form (this will make login form invisible on taskbar) or add following code to frmMain - in header:

    void __fastcall CreateParams(Controls::TCreateParams &Params);
    

    and in the .cpp file:

    void __fastcall frmMain::CreateParams(Controls::TCreateParams &Params)
    {
      TForm::CreateParams(Params);
      Params.ExStyle   = Params.ExStyle | WS_EX_APPWINDOW;
      Params.WndParent = ParentWindow;
    }
    

    WS_EX_APPWINDOW "Forces a top-level window onto the taskbar when the window is visible."

    As described in this MSDN article

    and Embarcadero DocWiki.