BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

WindowState = wsMaximized

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Dan
Guest





PostPosted: Tue Apr 24, 2007 7:08 pm    Post subject: WindowState = wsMaximized Reply with quote



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





PostPosted: Tue Apr 24, 2007 8:51 pm    Post subject: Re: WindowState = wsMaximized Reply with quote



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





PostPosted: Wed Apr 25, 2007 1:20 am    Post subject: Re: WindowState = wsMaximized Reply with quote



Quote:
Do you have some dialogs in OnActivate or similar?
OnActivate definitely did the trick.


Thanks
Back to top
Vladimir Stefanovic
Guest





PostPosted: Wed Apr 25, 2007 1:53 pm    Post subject: Re: WindowState = wsMaximized Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.