 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Dan Guest
|
Posted: Tue Apr 24, 2007 7:08 pm Post subject: WindowState = wsMaximized |
|
|
Hi, in design mode, I like my form to be a specific size, typically the
size of the most common user's screen (mine is much larger in
resolution). However, when the program runs, I want the form to show up
maximized and unmoveable (unless the user presses the restore window
button in the upper left).
I have added WindowState = wsMaximized to the OnShow() event, which does
look like the form is maximized (the maximize button is disabled and the
other is not) however, the form is movable. I can restore the size of
the app and then click the maximize button and then the form is
maximized and unmovable.
How do I mimic that operation in some startup code, line OnShow? |
|
| Back to top |
|
 |
Vladimir Stefanovic Guest
|
Posted: Tue Apr 24, 2007 8:51 pm Post subject: Re: WindowState = wsMaximized |
|
|
| Quote: | I have added WindowState = wsMaximized to the OnShow()
event,
|
OnShow() is not the best place for that. Move that code in the
Constructor insted.
| Quote: | which does look like the form is maximized (the maximize
button is disabled and the other is not) however, the form is
movable. I can restore the size of the app and then click the
maximize button and then the form is maximized and unmovable.
How do I mimic that operation in some startup code, line
OnShow?
|
Do you have some dialogs in OnActivate or similar?
Also, note that OnShow and OnActivate can be exectuted more
that once, so you need some additional code like this, to avoid
multiple execution ofsome parts of code:
void __fastcall TForm1::FormShow(TObject *Sender)
{
static bool HasPassedOnceOnShow = false;
if ( ! HasPassedOnceOnShow )
{
HasPassedOnceOnShow = true;
WindowState = wsMaximized
}
}
--
Best Regards,
Vladimir Stefanovic |
|
| Back to top |
|
 |
Dan Guest
|
Posted: Wed Apr 25, 2007 1:20 am Post subject: Re: WindowState = wsMaximized |
|
|
| Quote: | Do you have some dialogs in OnActivate or similar?
OnActivate definitely did the trick. |
Thanks |
|
| Back to top |
|
 |
Vladimir Stefanovic Guest
|
Posted: Wed Apr 25, 2007 1:53 pm Post subject: Re: WindowState = wsMaximized |
|
|
Dan <Dan (AT) do (DOT) not.spam> wrote:
| Quote: |
Do you have some dialogs in OnActivate or similar?
OnActivate definitely did the trick.
Thanks
|
Deciding whether or not to set wsMaximized WindowState at
run-time can make some weird problems when you extend your
app with some new features, like showing startup dialogs
(licensing systems, tips of the day, etc...). This is what
I have faced with few years ago:
--- Problem 1 ---
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
// Eg: I read Config and decided to open app maximized
WindowState = wsMaximized;
}
void __fastcall TForm1::FormActivate(TObject *Sender)
{
ShowMessage( "This message box mimics any dialog, eg. Licensing System" );
}
If you try the simple code (below), you'll see very weird
visual effect.
The even more weird effect you'll see if you have a Panel
on the main form, which is aligned alClinet, and has to be
invisible during startup:
--- Problem 2 ---
__fastcall TForm1::TForm1(TComponent* Owner) // same as in Problem 1
: TForm(Owner)
{
WindowState = wsMaximized;
}
void __fastcall TForm1::FormActivate(TObject *Sender)
{
Panel1->Visible = false; // aligned alClient
ShowMessage( "This message box mimics any dialog, eg. Licensing System" );
Panel1->Visible = true;
}
And that's the main reason I moved all dialogs to the most
unusual place, when I want to initiate the startup dialogs.
That't OnPaint() event:
void __fastcall TForm1::FormPaint(TObject *Sender)
{
static bool HasPassedOnceOnPaint = false;
if ( ! HasPassedOnceOnPaint )
{
HasPassedOnceOnPaint = true;
ShowMessage( "This message box mimics any dialog, eg. Licensing System" );
}
}
Then WindowState = wsMaximized assigned at run-time works well
without any issues known to me.
Best Regards,
Vladimir Stefanovic |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|