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 

Want to Make a form unmovable

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Michael Brazee
Guest





PostPosted: Thu Dec 18, 2003 5:36 pm    Post subject: Want to Make a form unmovable Reply with quote



Hi,
I have a need to make a form that cannot have its position changed.
I have tried using a MessageMap for the WM_WINDOWPOSCHANGING message and was
successful using SWP_NOMOVE flag.
The problem I am experiencing is that I have MinWidth and MinHeight
constraints set for the form.
The constraints are honored if I don't process the WINDOWPOSCHANGING
message, but are not if I do handle it.
I have had limited success in constraining the size with the SWM_NOSIZE flag
in the same message map procedure, but the operation is not as smooth as I
would like. I have tried using OnCanResize event but this doesn't get fired
off when using the message map.
I also tried to include a WM_SIZE message map procedure, but then any other
resizing controls don't receive their message.

Any suggestions.

Thanks,
Mike


Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Dec 18, 2003 6:58 pm    Post subject: Re: Want to Make a form unmovable Reply with quote




"Michael Brazee" <mbrazee (AT) gleason (DOT) com> wrote


Quote:
The problem I am experiencing is that I have MinWidth and
MinHeight constraints set for the form. The constraints are
honored if I don't process the WINDOWPOSCHANGING
message, but are not if I do handle it.

What does your exact code look like? Did you pass the message to the
default handler after you modified it?


Gambit



Back to top
Michael Brazee
Guest





PostPosted: Thu Dec 18, 2003 7:43 pm    Post subject: Re: Want to Make a form unmovable Reply with quote



Remy,

here are code snippets.

void __fastcall
TformSummaryEditor::WMWindowPosChanging(TWMWindowPosChanging& Message)
{
tagWINDOWPOS *WindowPos = Message.WindowPos;
/*
if ((WindowPos->cx > 0 && WindowPos->cx < 640) || (WindowPos->cy > 0 &&
WindowPos->cy < 480))
{
if (Width < 640)
{
WindowPos->cx = 640;
WindowPos->flags = WindowPos->flags | SWP_NOSIZE;
}
if (Height < 480)
{
WindowPos->cy = 480;
WindowPos->flags = WindowPos->flags | SWP_NOSIZE;
}
//WindowPos->flags = WindowPos->flags | SWP_NOSIZE;
}
*/
if (!AllowWindowMove)
{
WindowPos->flags = WindowPos->flags | SWP_NOMOVE;
}
DefWindowProc(Handle, Message.Msg, NULL, (long)WindowPos);
}
//--------------------------------------------------------------------------
-
(from .h file)
void __fastcall WMEndSession(TWMEndSession& Message);
void __fastcall WMWindowPosChanging(TWMWindowPosChanging& Message);
void __fastcall WMSize(TWMSize& Message);
BEGIN_MESSAGE_MAP
//VCL_MESSAGE_HANDLER(WM_ENDSESSION, TWMEndSession, WMEndSession)
VCL_MESSAGE_HANDLER(WM_WINDOWPOSCHANGING, TWMWindowPosChanging,
WMWindowPosChanging);
//VCL_MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize);
END_MESSAGE_MAP(TForm)

The commented out code was just various attempts at getting positive
results. I was actually using Constraints->MinWidth and MinHeight.
These values were actually being changed during runtime (but not by my
code).

Mike
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote

Quote:


<snip>
Quote:
What does your exact code look like? Did you pass the message to the
default handler after you modified it?


Gambit





Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Dec 18, 2003 8:22 pm    Post subject: Re: Want to Make a form unmovable Reply with quote


"Michael Brazee" <mbrazee (AT) gleason (DOT) com> wrote


Quote:
DefWindowProc(Handle, Message.Msg, NULL, (long)WindowPos);

Change that line to this instead:

TForm::Dispatch(&Message);


Gambit



Back to top
Michael Brazee
Guest





PostPosted: Thu Dec 18, 2003 8:28 pm    Post subject: Re: Want to Make a form unmovable Reply with quote

Remy,
As always you're brilliant.
Thanks for the help and enjoy the Holiday season.
Mike
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote

Quote:

"Michael Brazee" <mbrazee (AT) gleason (DOT) com> wrote in message
news:3fe20299$1 (AT) newsgroups (DOT) borland.com...

DefWindowProc(Handle, Message.Msg, NULL, (long)WindowPos);

Change that line to this instead:

TForm::Dispatch(&Message);


Gambit





Back to top
bcb
Guest





PostPosted: Thu Dec 18, 2003 10:44 pm    Post subject: Re: Want to Make a form unmovable Reply with quote

Hi Mike

This should also prevent the user from moving the Form


....
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//--------------------------------------------------------------------------
-
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
DeleteMenu(GetSystemMenu(Handle, false), SC_MOVE, MF_BYCOMMAND);
}
//--------------------------------------------------------------------------
-
....


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) 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.