Board index » cppbuilder » Minimize main form to taskbar?

Minimize main form to taskbar?

Is there a way to minimize the project's main form to the taskbar? I know
how to do secondary forms, but the main?
 

Re:Minimize main form to taskbar?


Hi Alexis,

Quote
> Is there a way to minimize the project's main form to the taskbar? I know
> how to do secondary forms, but the main?

What look are you going for?  I know the taskbar button actually corresponds to
the hidden Application window, however, the end result is nearly the same.  Do
you want a separate taskbar button for the MainForm as well as the Application
window?

--------------------------------------
Damon Chandler

http://bcbcaq.freeservers.com
Answers to <Commonly Asked Questions>

Re:Minimize main form to taskbar?


Is just the effect when you click on the minimize button, that you can view
it minimizing to the taskbar or viceversa. Mr. Howard Howe's has an
excellent example of doing that for secondary forms, but if you use the same
code with your main form, it does nothing.
I just want to know, if it is possible. It's a simple thing, but I want to
know.

Quote
Damon Chandler <dm...@cornell.edu> wrote in message

news:3802C0EE.30290046@cornell.edu...
Quote
> Hi Alexis,
> > Is there a way to minimize the project's main form to the taskbar? I
know
> > how to do secondary forms, but the main?

> What look are you going for?  I know the taskbar button actually
corresponds to
> the hidden Application window, however, the end result is nearly the same.
Do
> you want a separate taskbar button for the MainForm as well as the
Application
> window?

> --------------------------------------
> Damon Chandler

> http://bcbcaq.freeservers.com
> Answers to <Commonly Asked Questions>

Re:Minimize main form to taskbar?


Hi Alexis,

Quote
> Is just the effect when you click on the minimize button, that you can view
> it minimizing to the taskbar or viceversa. Mr. Howard Howe's has an
> excellent example of doing that for secondary forms, but if you use the same
> code with your main form, it does nothing.

Ok, I see what you're saying now.  You mean the animation effects that occur
when you minimize a form.  You'll need to add the WS_EX_APPWINDOW extended style
to the window (SetWindowLong()) so that it will minimize to the taskbar.  Next,
you need to hide the hidden Application window's taskbar button using the
ShowWindow() API function with the SW_HIDE flag.  Finally, you need to handle
the WM_SYSCOMMAND message, calling the ShowWindow() function with the
SW_MINIMIZE flag if the uCmdType is SC_MINIMIZE (i.e., the user has chosen to
minimize the form).  Here's an example...

// in header...
    void __fastcall WMSysCommand(TMessage &Msg);

BEGIN_MESSAGE_MAP
    MESSAGE_HANDLER(WM_SYSCOMMAND, TMessage, WMSysCommand)
END_MESSAGE_MAP(TForm)

// in source...
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
    DWORD dwStyle = GetWindowLong(Handle, GWL_EXSTYLE);
    SetWindowLong(Handle, GWL_EXSTYLE, dwStyle | WS_EX_APPWINDOW);

    ShowWindow(Application->Handle, SW_HIDE);

Quote
}

void __fastcall TForm1::WMSysCommand(TMessage &Msg)
{
    int uCmdType = Msg.WParam & 0xFFF0;
    if (uCmdType == SC_MINIMIZE)
    {
        ShowWindow(Handle, SW_MINIMIZE);
        Msg.Result = 0;
        return;
    }

    TForm::Dispatch(&Msg);

Quote
}

HTH.

--------------------------------------
Damon Chandler

http://bcbcaq.freeservers.com
Answers to <Commonly Asked Questions>
52064929

Re:Minimize main form to taskbar?


Thanks, it worked nicely.
Quote
Damon Chandler <dm...@cornell.edu> wrote in message

news:380618A0.8E02018@cornell.edu...
Quote
> Hi Alexis,
> > Is just the effect when you click on the minimize button, that you can
view
> > it minimizing to the taskbar or viceversa. Mr. Howard Howe's has an
> > excellent example of doing that for secondary forms, but if you use the
same
> > code with your main form, it does nothing.

> Ok, I see what you're saying now.  You mean the animation effects that
occur
> when you minimize a form.  You'll need to add the WS_EX_APPWINDOW extended
style
> to the window (SetWindowLong()) so that it will minimize to the taskbar.
Next,
> you need to hide the hidden Application window's taskbar button using the
> ShowWindow() API function with the SW_HIDE flag.  Finally, you need to
handle
> the WM_SYSCOMMAND message, calling the ShowWindow() function with the
> SW_MINIMIZE flag if the uCmdType is SC_MINIMIZE (i.e., the user has chosen
to
> minimize the form).  Here's an example...

> // in header...
>     void __fastcall WMSysCommand(TMessage &Msg);

> BEGIN_MESSAGE_MAP
>     MESSAGE_HANDLER(WM_SYSCOMMAND, TMessage, WMSysCommand)
> END_MESSAGE_MAP(TForm)

> // in source...
> __fastcall TForm1::TForm1(TComponent* Owner)
>     : TForm(Owner)
> {
>     DWORD dwStyle = GetWindowLong(Handle, GWL_EXSTYLE);
>     SetWindowLong(Handle, GWL_EXSTYLE, dwStyle | WS_EX_APPWINDOW);

>     ShowWindow(Application->Handle, SW_HIDE);
> }

> void __fastcall TForm1::WMSysCommand(TMessage &Msg)
> {
>     int uCmdType = Msg.WParam & 0xFFF0;
>     if (uCmdType == SC_MINIMIZE)
>     {
>         ShowWindow(Handle, SW_MINIMIZE);
>         Msg.Result = 0;
>         return;
>     }

>     TForm::Dispatch(&Msg);
> }

> HTH.

> --------------------------------------
> Damon Chandler

> http://bcbcaq.freeservers.com
> Answers to <Commonly Asked Questions>
> 52064929

Other Threads