Sendo
asked on
Very easy question...
Prevent user from resizing Form!
In D3 you selected Resizable bsNone but
in D5 ...where did it go?
Hate clicking so please a quick hint...
So in D5,how do you prevent user from resizing form?Ha...
In D3 you selected Resizable bsNone but
in D5 ...where did it go?
Hate clicking so please a quick hint...
So in D5,how do you prevent user from resizing form?Ha...
I'm convinced: D5 sux! :-) (kidding)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In Delphi 4 it's "Borderstyle=bsSingle" instead of "bsResizable". I dunno if that is also the case in D5?
Hey Victor, you answered it when I was still typing!! :-)
{
IMHO, I believe the way I am doing it is much better although it takes a bit of work.
However, this way, I can have the form maximized properly whether there is or without
windows task bar. Besides, no problem will arise if users were to choose a different
screen resolution.
Hope this helps.
SA/\/\
}
type
TfrmMain = class(TForm)
{ .....}
procedure FormActivate(Sender: TObject);
procedure FormShow(Sender: TObject);
Private
done: Boolean;
procedure WMWindowPosChanging(var Msg: TWMWindowPosChanging); Message WM_WindowPosChanging;
Public
{ Public declarations }
end;
{...}
implementation
procedure TfrmMain.FormActivate(Send er: TObject);
begin
inherited;
done := True;
end;
{ Window can be maximized the first time }
procedure TfrmMain.FormShow(Sender: TObject);
begin
inherited;
{...}
WindowState := wsMaximized;
end;
{ This will prevent users from moving or resizing the desktop }
procedure TfrmMain.WMWindowPosChangi ng;
begin
if done then
Msg.WindowPos^.Flags := Msg.WindowPos^.Flags or SWP_NOMOVE or SWP_NOSIZE;
end;
IMHO, I believe the way I am doing it is much better although it takes a bit of work.
However, this way, I can have the form maximized properly whether there is or without
windows task bar. Besides, no problem will arise if users were to choose a different
screen resolution.
Hope this helps.
SA/\/\
}
type
TfrmMain = class(TForm)
{ .....}
procedure FormActivate(Sender: TObject);
procedure FormShow(Sender: TObject);
Private
done: Boolean;
procedure WMWindowPosChanging(var Msg: TWMWindowPosChanging); Message WM_WindowPosChanging;
Public
{ Public declarations }
end;
{...}
implementation
procedure TfrmMain.FormActivate(Send
begin
inherited;
done := True;
end;
{ Window can be maximized the first time }
procedure TfrmMain.FormShow(Sender: TObject);
begin
inherited;
{...}
WindowState := wsMaximized;
end;
{ This will prevent users from moving or resizing the desktop }
procedure TfrmMain.WMWindowPosChangi
begin
if done then
Msg.WindowPos^.Flags := Msg.WindowPos^.Flags or SWP_NOMOVE or SWP_NOSIZE;
end;
Try bsSingle (as Victor Says) and bsDialog
ASKER
Too much typing for a trivial thing.
I would rather have the user suffer!
Ha,ha,ha....
I will try Meikls and Vics sugg...
Tell ya later...
I would rather have the user suffer!
Ha,ha,ha....
I will try Meikls and Vics sugg...
Tell ya later...
Even more complete, but I should't get points for this, errrrh?
Use the help!
Oh help,
Floris
Specifies the appearance and behavior of the form border.
property BorderStyle: TFormBorderStyle;
Description
Use BorderStyle to get or set the appearance and behavior of the form border. BorderStyle can be any of the following TFormBorderStyle values:
Value Meaning
bsDialog Not resizeable; standard dialog box border
bsSingle Not resizeable; single-line border
bsNone Not resizeable; no visible border line
bsSizeable Standard resizeable border
bsToolWindow like bsSingle but with a smaller caption
bsSizeToolWin like bsSizeable with a smaller caption
Note: Changing the border style of an MDI child form to bsDialog or bsNone has no effect.
Use the help!
Oh help,
Floris
Specifies the appearance and behavior of the form border.
property BorderStyle: TFormBorderStyle;
Description
Use BorderStyle to get or set the appearance and behavior of the form border. BorderStyle can be any of the following TFormBorderStyle values:
Value Meaning
bsDialog Not resizeable; standard dialog box border
bsSingle Not resizeable; single-line border
bsNone Not resizeable; no visible border line
bsSizeable Standard resizeable border
bsToolWindow like bsSingle but with a smaller caption
bsSizeToolWin like bsSizeable with a smaller caption
Note: Changing the border style of an MDI child form to bsDialog or bsNone has no effect.
Okay, Sendo
You're right, easy question, so this one requires an easy answer: Two solutions.
#1
In Delhpi 5 (Enterprise):
In the Object Inspector, choose by the property BorderStyle for the option bsDialog. Now the user can not change the formsize anymore
#2
Install the LMD components, which came as a special edition for Delphi 5 and can be found on the same CD-Rom. Choose for the tab LMD SYS in the component table. Choose for the fourth element of this tab, being the element LMD-FORM. In the object inspector you can define more detailed properties for the form, also the max an min size of this form. Make those two value's the same, and you're there. TIP. When using non-visual compnents, you can make the form large while editing, once started, the form wil be reduced to the value's given bij the max and min items.
If you did not install these components yet, do so. They are exceptional good. You can also download a (unlimited) trial version at www.lmd.de
Success
You're right, easy question, so this one requires an easy answer: Two solutions.
#1
In Delhpi 5 (Enterprise):
In the Object Inspector, choose by the property BorderStyle for the option bsDialog. Now the user can not change the formsize anymore
#2
Install the LMD components, which came as a special edition for Delphi 5 and can be found on the same CD-Rom. Choose for the tab LMD SYS in the component table. Choose for the fourth element of this tab, being the element LMD-FORM. In the object inspector you can define more detailed properties for the form, also the max an min size of this form. Make those two value's the same, and you're there. TIP. When using non-visual compnents, you can make the form large while editing, once started, the form wil be reduced to the value's given bij the max and min items.
If you did not install these components yet, do so. They are exceptional good. You can also download a (unlimited) trial version at www.lmd.de
Success
By the way, forgot to add to the question (to fast to answer, sorry):
If you ad the line:
ShowWindow(Application.Han dle,SW_HID E);
then you also remove the button in the taskbar, and thereby another way to use Minimize and Maximize.
If you ad the line:
ShowWindow(Application.Han
then you also remove the button in the taskbar, and thereby another way to use Minimize and Maximize.
ShowWindow(application.han dle, SW_HIDE);
ShowWindow(FindWindow(nil, @Application.Title[1]), SW_HIDE);
In the application.activate event. Hides it a bit more...
ShowWindow(FindWindow(nil,
In the application.activate event. Hides it a bit more...
ASKER
Sorry ...
"In the Object Inspector, choose by the property BorderStyle for the option bsDialog. Now the user can not change the formsize anymore "
This option prevents user from Max/Min the form and that is not what I want...
Using bsSingle does the trick...
so the points to Victor !
Meikl also had a good point....
Well I guess Vic answered it first (or no?)
Ok,Vic
"In the Object Inspector, choose by the property BorderStyle for the option bsDialog. Now the user can not change the formsize anymore "
This option prevents user from Max/Min the form and that is not what I want...
Using bsSingle does the trick...
so the points to Victor !
Meikl also had a good point....
Well I guess Vic answered it first (or no?)
Ok,Vic
ASKER
Sorry ...
"In the Object Inspector, choose by the property BorderStyle for the option bsDialog. Now the user can not change the formsize anymore "
This option prevents user from Max/Min the form and that is not what I want...
Using bsSingle does the trick...
so the points to Victor !
Meikl also had a good point....
Well I guess Vic answered it first (or no?)
Ok,Vic
"In the Object Inspector, choose by the property BorderStyle for the option bsDialog. Now the user can not change the formsize anymore "
This option prevents user from Max/Min the form and that is not what I want...
Using bsSingle does the trick...
so the points to Victor !
Meikl also had a good point....
Well I guess Vic answered it first (or no?)
Ok,Vic
adjust the constraints-property min and max of width and height to the same value
meikl