Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wsMaximized breaks it, NOT caused by Position=poScreenCenter, reproducible dfm

378 views
Skip to first unread message
Message has been deleted

Ian Boyd

unread,
May 30, 2006, 10:17:24 AM5/30/06
to
A lot of people post problems that when they set a form's WindowState to
wsMaximized, the forms position, size, and state will be all wrong. Symptoms
involve
- the form not taking up the entire screen (i.e. not maximized) but
instead stuck in the top-left corner.
- the maximize/restore system icon is set to "Maximized"
- the form may be almost the size of the screen, but shifted down and to
the right a bit, with the bottom edge underlapping the task bar
- if you click the "restore" system icon, the form restores. If you then
click the "Maximize" system icon, the form properly maximizes
- the form, while not taking up the whole screen is not sizable or
movable while it is in it's pseudo-maximized state


The often quoted solution is to not set Position to anything involving
center i.e.
poScreenCenter
poDesktopCenter
poMainFormCenter
poOwnerFormCenter

and instead the Form.Position should be left as "default"
poDefault
poDefaultPosOnly
poDefaultSizeOnly
poDesigned

Problem is, 10% of the time this doesn't fix it. i, and many other people,
continue to have problems after changing the setting of "Position" to
poDefault. Other suggested solutions involve:

1. Setting the WindowState during the OnCreate event
procedure TForm1.OnCreate(Sender: TObject);
begin
Self.WindowState := wsMaximized;
end;

2. Setting the WindowState during the first OnShow event
procedure TForm1Create(Sender: TObject);
begin
FOneShot := True;
end;

procedure TForm1Show(Sender: TObject);
begin
if FOneShot then
begin
Self.WindowState := wsMaximized;
FOneShot := False;
end;
end;

3. Setting the WindowState during the first OnActivate event
procedure TForm1Create(Sender: TObject);
begin
FOneShot := True;
end;

procedure TForm1Activate(Sender: TObject);
begin
if FOneShot then
begin
Self.WindowState := wsMaximized;
FOneShot := False;
end;
end;

3. Setting the WindowState during the first OnResize event
procedure TForm1Create(Sender: TObject);
begin
FOneShot := True;
end;

procedure TForm1Resize(Sender: TObject);
begin
if FOneShot then
begin
Self.WindowState := wsMaximized;
FOneShot := False;
end;
end;

4. Post a message during OnCreate to tell yourself to mazimize

5. Start a timer and maximize the form shortly after creating (see 4 using
WM_TIMER)

Problem is, aside from being unsighly to the user, and total hacks, they
don't always work.


So, i present for you consideration a pared down PAS/DFM that exhibits the
"WindowState equals wsMaximized" failure. There is a single line in the DFM
that you can delete, and the problem goes away. i leave it up to Borland to
not track down this issue, and not post a Delphi 5 fix for it.

FSearchSalesOrders.pas
==============
unit FSearchSalesOrders;

interface

uses
Menus, ComCtrls, Buttons, StdCtrls, ExtCtrls, Forms, ToolWin, Controls,
Classes, ActnList;

type
TfrmSearchSalesOrders = class(TForm)
pnlSearch: TPanel;
Panel7: TPanel;
Label21: TLabel;
pnlSearchTopRight: TPanel;
Splitter1: TSplitter;
StatusBar1: TStatusBar;
CoolBar1: TCoolBar;
tbMain: TToolBar;
ToolButton2: TToolButton;
Splitter2: TSplitter;
tbMenu: TToolBar;
ToolButton5: TToolButton;
ScrollBox1: TScrollBox;
pnlCriteriaGeneral: TPanel;
Label7: TLabel;
PaintBox1: TPaintBox;
Label8: TLabel;
Label6: TLabel;
Label3: TLabel;
Label11: TLabel;
Label9: TLabel;
Label10: TLabel;
Label14: TLabel;
edProject: TEdit;
edQuote: TEdit;
chkShipped: TCheckBox;
chkProduction: TCheckBox;
chkCancelled: TCheckBox;
edSalesOrderNumber: TEdit;
chkOnHold: TCheckBox;
chkReadyForShipping: TCheckBox;
edOwner: TEdit;
Button1: TButton;
chkNeedsAttention: TCheckBox;
chkOrderReceived: TCheckBox;
chkCancelRequested: TCheckBox;
pnlCriteriaDates: TPanel;
Label24: TLabel;
Label25: TLabel;
Label17: TLabel;
rbNextDays: TRadioButton;
edWeeks: TEdit;
udWeeks: TUpDown;
rbBetween: TRadioButton;
dtpStartDate: TDateTimePicker;
dtpEndDate: TDateTimePicker;
rbNextWeeks: TRadioButton;
edMonths: TEdit;
udMonths: TUpDown;
chkDateLimiting: TCheckBox;
pnlCriteriaButtons: TPanel;
bbSearch: TBitBtn;
bbStop: TBitBtn;
Label16: TLabel;
edGreatPlainsNumber: TEdit;
chkCompleted: TCheckBox;
private
public
end;

var
frmSearchSalesOrders: TfrmSearchSalesOrders;

implementation

{$R *.DFM}

end.


FSearchSalesOrders.dfm
===============
object frmSearchSalesOrders: TfrmSearchSalesOrders
Left = 118
Top = 140
AutoScroll = False
Caption = 'Sales Orders'
ClientHeight = 530
ClientWidth = 790
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell Dlg'
Font.Style = []
OldCreateOrder = True
Position = poDefault
ShowHint = True
WindowState = wsMaximized
PixelsPerInch = 96
TextHeight = 13
object Splitter1: TSplitter
Left = 225
Top = 49
Width = 3
Height = 462
Cursor = crHSplit
AutoSnap = False
MinSize = 225
ResizeStyle = rsUpdate
end
object Splitter2: TSplitter
Left = 0
Top = 46
Width = 790
Height = 3
Cursor = crVSplit
Align = alTop
Visible = False
end
object pnlSearch: TPanel
Left = 0
Top = 49
Width = 225
Height = 462
Align = alLeft
BevelOuter = bvNone
Color = clWindow
Constraints.MinWidth = 200
TabOrder = 0
object Panel7: TPanel
Left = 0
Top = 0
Width = 225
Height = 22
Align = alTop
TabOrder = 0
object Label21: TLabel
Left = 5
Top = 5
Width = 84
Height = 13
Caption = 'Search Criteria'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell Dlg 2'
Font.Style = [fsBold]
ParentFont = False
end
object pnlSearchTopRight: TPanel
Left = 201
Top = 1
Width = 23
Height = 20
Align = alRight
BevelOuter = bvNone
TabOrder = 0
end
end
object ScrollBox1: TScrollBox
Left = 0
Top = 22
Width = 225
Height = 440
VertScrollBar.Position = 45
Align = alClient
BorderStyle = bsNone
TabOrder = 1
object pnlCriteriaGeneral: TPanel
Left = 0
Top = -45
Width = 208
Height = 329
Align = alTop
BevelOuter = bvNone
BorderWidth = 10
ParentColor = True
TabOrder = 0
object Label7: TLabel
Left = 15
Top = 7
Width = 132
Height = 13
Caption = 'Search for Sales Orders'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell dlg 2'
Font.Style = [fsBold]
ParentFont = False
end
object PaintBox1: TPaintBox
Left = 13
Top = 22
Width = 185
Height = 1
Anchors = [akLeft, akTop, akRight]
end
object Label8: TLabel
Left = 12
Top = 60
Width = 44
Height = 13
Caption = 'S.O. No.:'
end
object Label6: TLabel
Left = 176
Top = 216
Width = 36
Height = 13
Caption = 'Project:'
Visible = False
end
object Label3: TLabel
Left = 12
Top = 108
Width = 32
Height = 13
Caption = 'Quote:'
end
object Label11: TLabel
Left = 12
Top = 176
Width = 33
Height = 13
Caption = 'Status:'
end
object Label9: TLabel
Left = 12
Top = 132
Width = 34
Height = 13
Caption = 'Dealer:'
end
object Label10: TLabel
Left = 12
Top = 156
Width = 61
Height = 13
Caption = 'Salesperson:'
end
object Label14: TLabel
Left = 12
Top = 36
Width = 34
Height = 13
Caption = 'Owner:'
end
object Label16: TLabel
Left = 12
Top = 84
Width = 44
Height = 13
Caption = 'G.P. No.:'
end
object edProject: TEdit
Left = 176
Top = 232
Width = 125
Height = 21
Hint = 'Search by Product Code (e.g. P12345) or project name'
Anchors = [akLeft, akTop, akRight]
TabOrder = 3
Visible = False
end
object edQuote: TEdit
Left = 76
Top = 104
Width = 125
Height = 21
Hint = 'Search by Quote Number (e.g. Q12345) or quote description'
Anchors = [akLeft, akTop, akRight]
TabOrder = 4
end
object chkShipped: TCheckBox
Left = 76
Top = 224
Width = 97
Height = 17
Hint = 'Include shipped sales orders in the search results'
Caption = 'Shipped'
Checked = True
State = cbChecked
TabOrder = 9
end
object chkProduction: TCheckBox
Left = 76
Top = 192
Width = 97
Height = 17
Hint = 'Include sales orders in production in search results'
Caption = 'Production'
Checked = True
State = cbChecked
TabOrder = 7
end
object chkCancelled: TCheckBox
Left = 76
Top = 304
Width = 97
Height = 17
Hint = 'Include cancelled sales orders in the search results'
Caption = 'Cancelled'
TabOrder = 6
end
object edSalesOrderNumber: TEdit
Left = 76
Top = 56
Width = 125
Height = 21
Hint = 'Search by Sales Order number'
Anchors = [akLeft, akTop, akRight]
CharCase = ecUpperCase
TabOrder = 1
end
object chkOnHold: TCheckBox
Left = 76
Top = 256
Width = 97
Height = 17
Hint = 'Include sales orders on hold in search results'
Caption = 'On Hold'
Checked = True
State = cbChecked
TabOrder = 12
end
object chkReadyForShipping: TCheckBox
Left = 76
Top = 208
Width = 117
Height = 17
Caption = 'Ready for Shipping'
Checked = True
State = cbChecked
TabOrder = 8
end
object edOwner: TEdit
Left = 76
Top = 32
Width = 98
Height = 21
Hint = 'Search By Project'#39's Current Owner'
Anchors = [akLeft, akTop, akRight]
TabOrder = 0
end
object Button1: TButton
Left = 178
Top = 31
Width = 21
Height = 22
Hint = 'Select Owner'
Anchors = [akTop, akRight]
Caption = '...'
TabOrder = 11
end
object chkNeedsAttention: TCheckBox
Left = 76
Top = 272
Width = 97
Height = 17
Hint = 'Include sales orders on hold in search results'
Caption = 'Needs Attention'
Checked = True
State = cbChecked
TabOrder = 13
end
object chkOrderReceived: TCheckBox
Left = 76
Top = 176
Width = 97
Height = 17
Hint = 'Include sales orders in production in search results'
Caption = 'Order Placed'
Checked = True
State = cbChecked
TabOrder = 5
end
object chkCancelRequested: TCheckBox
Left = 76
Top = 288
Width = 113
Height = 17
Hint = 'Include cancelled sales orders in the search results'
Caption = 'Cancel Requested'
Checked = True
State = cbChecked
TabOrder = 14
end
object edGreatPlainsNumber: TEdit
Left = 76
Top = 80
Width = 125
Height = 21
Hint = 'Search by Great Plains number'
Anchors = [akLeft, akTop, akRight]
TabOrder = 2
end
object chkCompleted: TCheckBox
Left = 76
Top = 240
Width = 97
Height = 17
Hint = 'Include shipped sales orders in the search results'
Caption = 'Completed'
Checked = True
State = cbChecked
TabOrder = 10
end
end
object pnlCriteriaDates: TPanel
Tag = 125
Left = 0
Top = 284
Width = 208
Height = 127
Align = alTop
BevelOuter = bvNone
ParentColor = True
TabOrder = 1
object Label24: TLabel
Left = 150
Top = 28
Width = 31
Height = 13
Caption = 'weeks'
end
object Label25: TLabel
Left = 70
Top = 105
Width = 18
Height = 13
Caption = 'and'
end
object Label17: TLabel
Left = 150
Top = 53
Width = 34
Height = 13
Caption = 'months'
end
object rbNextDays: TRadioButton
Left = 25
Top = 27
Width = 69
Height = 17
Caption = 'in the last'
TabOrder = 1
TabStop = True
end
object edWeeks: TEdit
Left = 100
Top = 25
Width = 31
Height = 21
TabOrder = 2
Text = '1'
end
object udWeeks: TUpDown
Left = 131
Top = 25
Width = 16
Height = 21
Associate = edWeeks
Min = 1
Max = 999
Position = 1
TabOrder = 3
Wrap = True
end
object rbBetween: TRadioButton
Left = 25
Top = 75
Width = 69
Height = 17
Caption = 'between'
TabOrder = 7
TabStop = True
end
object dtpStartDate: TDateTimePicker
Left = 100
Top = 75
Width = 83
Height = 21
CalAlignment = dtaLeft
Date = 37214.644831088
Time = 37214.644831088
DateFormat = dfShort
DateMode = dmComboBox
Kind = dtkDate
ParseInput = False
TabOrder = 8
end
object dtpEndDate: TDateTimePicker
Left = 100
Top = 100
Width = 83
Height = 21
CalAlignment = dtaLeft
Date = 37214.644831088
Time = 37214.644831088
DateFormat = dfShort
DateMode = dmComboBox
Kind = dtkDate
ParseInput = False
TabOrder = 9
end
object rbNextWeeks: TRadioButton
Left = 25
Top = 52
Width = 69
Height = 17
Caption = 'in the last'
Checked = True
TabOrder = 4
TabStop = True
end
object edMonths: TEdit
Left = 100
Top = 50
Width = 31
Height = 21
TabOrder = 5
Text = '1'
end
object udMonths: TUpDown
Left = 131
Top = 50
Width = 16
Height = 21
Associate = edMonths
Min = 1
Max = 999
Position = 1
TabOrder = 6
Wrap = True
end
object chkDateLimiting: TCheckBox
Left = 15
Top = 5
Width = 106
Height = 14
Caption = 'Date Limiting'
TabOrder = 0
end
end
object pnlCriteriaButtons: TPanel
Left = 0
Top = 411
Width = 208
Height = 38
Align = alTop
BevelOuter = bvNone
ParentColor = True
TabOrder = 2
object bbSearch: TBitBtn
Left = 15
Top = 5
Width = 75
Height = 22
Caption = 'Search'
Default = True
TabOrder = 0
end
object bbStop: TBitBtn
Left = 100
Top = 5
Width = 75
Height = 22
Caption = 'Stop'
TabOrder = 1
end
end
end
end
object StatusBar1: TStatusBar
Left = 0
Top = 511
Width = 790
Height = 19
Panels = <>
SimplePanel = False
end
object CoolBar1: TCoolBar
Left = 0
Top = 0
Width = 790
Height = 46
AutoSize = True
Bands = <
item
Control = tbMenu
ImageIndex = -1
MinHeight = 19
Width = 790
end
item
Control = tbMain
ImageIndex = -1
MinHeight = 23
Width = 790
end>
EdgeBorders = [ebBottom]
EdgeOuter = esRaised
object tbMain: TToolBar
Left = 9
Top = 21
Width = 777
Height = 23
AutoSize = True
BorderWidth = 1
ButtonHeight = 19
ButtonWidth = 59
Caption = 'tbMain'
EdgeBorders = []
Flat = True
List = True
ShowCaptions = True
TabOrder = 0
Transparent = True
Wrapable = False
object ToolButton2: TToolButton
Left = 0
Top = 0
Hint = 'Edit Selected Quote'
AutoSize = True
Caption = 'Properties'
ImageIndex = 9
end
end
object tbMenu: TToolBar
Left = 9
Top = 0
Width = 777
Height = 19
AutoSize = True
ButtonHeight = 19
ButtonWidth = 34
Caption = 'tbMenu'
EdgeBorders = []
Flat = True
List = True
ShowCaptions = True
TabOrder = 1
Transparent = True
Wrapable = False
object ToolButton5: TToolButton
Left = 0
Top = 0
AllowAllUp = True
AutoSize = True
Caption = '&File'
Grouped = True
end
end
end
end


If you erase the line 84
VertScrollBar.Position = 45

the form starts in the proper maximized state. In fact, you can even then
set the Postion to poScreenCenter, and it STILL maximizes properly.

Many times, people in the newsgroups say that when they try to reproduce the
steps to cause a failure, they can't make it fail. Well, here's the code
that fails, repeatedly, reproducably. Not only that, but i have a change
that can make it work. It should be a simple matter for whatever company
that wrote Delphi to find the problem and fix it.

So if someone could go ahead and investigate the DFM streaming code, find
the bug, fix it and post the fixed VCL source that would be great.


Ian Boyd

unread,
May 31, 2006, 2:11:47 PM5/31/06
to
> Good reproducible cases like this should be added to QC.

i grow weary of having to create logins every time i visit the site; i stop
visiting.


Craig Stuntz [TeamB]

unread,
May 31, 2006, 3:24:21 PM5/31/06
to
Ian Boyd wrote:

If that's less painful to you than the bug itself, I guess that's your
choice. If, OTOH, the bug is more painful than having to type your
username and password, you need to report it, or it's unlikely to be
fixed.

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
Everything You Need to Know About InterBase Character Sets:
http://blogs.teamb.com/craigstuntz/articles/403.aspx

Ian Boyd

unread,
Jun 1, 2006, 11:29:58 AM6/1/06
to
> If that's less painful to you than the bug itself, I guess that's your
> choice. If, OTOH, the bug is more painful than having to type your
> username and password, you need to report it, or it's unlikely to be
> fixed.

Also consider that we're using Delphi 5.

When was the last Delphi 5 service pack released?


Craig Stuntz [TeamB]

unread,
Jun 1, 2006, 11:50:09 AM6/1/06
to
Ian Boyd wrote:

> Also consider that we're using Delphi 5.
>
> When was the last Delphi 5 service pack released?

There will probably never be another D5 SP, but if you want to
document a problem or share a workaround with other D5 users in a
searchable archive with comments enabled forever, QC is still the best
place to do it.

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz

Want to help make Delphi and InterBase better? Use QC!
http://qc.borland.com -- Vote for important issues

Liz

unread,
Jun 1, 2006, 12:19:41 PM6/1/06
to
Ian Boyd wrote:

> A lot of people post problems that when they set a form's WindowState
> to wsMaximized, the forms position, size, and state will be all
> wrong. Symptoms involve - the form not taking up the entire screen
> (i.e. not maximized) but instead stuck in the top-left corner. -
> the maximize/restore system icon is set to "Maximized" - the form
> may be almost the size of the screen, but shifted down and to the
> right a bit, with the bottom edge underlapping the task bar - if
> you click the "restore" system icon, the form restores. If you then
> click the "Maximize" system icon, the form properly maximizes - the
> form, while not taking up the whole screen is not sizable or movable
> while it is in it's pseudo-maximized state

I never had that issue with delphi 5. although I did at one point post
messages as I think doing it in the create was confusing it.

So, at one point I had

windowstate := wsmaximized;
postMessage(Handle, WM_SIZE, SIZE_MAXIMIZED, ClientWidth +
(Longint(ClientHeight) shl 16));
postMessage(Handle, WM_SIZE, SIZE_MAXIMIZED, screen.Width +
(Longint(screen.Height) shl 16));

This always worked.

--
Liz the Brit
Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings

0 new messages