Fixed sizing of the progress label

git-svn-id: trunk@7678 -
This commit is contained in:
vincents 2005-09-12 11:29:19 +00:00
parent 924ba29164
commit a641b3fe25
3 changed files with 31 additions and 49 deletions

View File

@ -6,7 +6,7 @@ object SearchForm: TSearchForm
OnCreate = SearchFormCREATE OnCreate = SearchFormCREATE
OnDestroy = SearchFormDESTROY OnDestroy = SearchFormDESTROY
ParentFont = True ParentFont = True
PixelsPerInch = 112 PixelsPerInch = 96
Position = poOwnerFormCenter Position = poOwnerFormCenter
HorzScrollBar.Page = 427 HorzScrollBar.Page = 427
VertScrollBar.Page = 148 VertScrollBar.Page = 148
@ -16,6 +16,7 @@ object SearchForm: TSearchForm
Width = 428 Width = 428
object Panel2: TPanel object Panel2: TPanel
Align = alClient Align = alClient
BorderSpacing.OnChange = nil
BevelInner = bvLowered BevelInner = bvLowered
ClientHeight = 149 ClientHeight = 149
ClientWidth = 428 ClientWidth = 428
@ -23,10 +24,10 @@ object SearchForm: TSearchForm
ParentFont = True ParentFont = True
TabOrder = 0 TabOrder = 0
TabStop = True TabStop = True
OnClick = Panel2Click
Height = 149 Height = 149
Width = 428 Width = 428
object lblMatches: TLabel object lblMatches: TLabel
BorderSpacing.OnChange = nil
Color = clNone Color = clNone
Left = 96 Left = 96
Height = 17 Height = 17
@ -34,6 +35,7 @@ object SearchForm: TSearchForm
Width = 321 Width = 321
end end
object MatchesLabel: TLabel object MatchesLabel: TLabel
BorderSpacing.OnChange = nil
Caption = 'Matches' Caption = 'Matches'
Color = clNone Color = clNone
Left = 16 Left = 16
@ -42,7 +44,7 @@ object SearchForm: TSearchForm
Width = 64 Width = 64
end end
object lblProgress: TLabel object lblProgress: TLabel
AutoSize = False BorderSpacing.OnChange = nil
Color = clNone Color = clNone
Left = 96 Left = 96
Height = 17 Height = 17
@ -50,6 +52,7 @@ object SearchForm: TSearchForm
Width = 320 Width = 320
end end
object SearchingLabel: TLabel object SearchingLabel: TLabel
BorderSpacing.OnChange = nil
Caption = 'Searching:' Caption = 'Searching:'
Color = clNone Color = clNone
Left = 16 Left = 16
@ -58,6 +61,7 @@ object SearchForm: TSearchForm
Width = 64 Width = 64
end end
object SearchTextLabel: TLabel object SearchTextLabel: TLabel
BorderSpacing.OnChange = nil
Caption = 'Search Text:' Caption = 'Search Text:'
Color = clNone Color = clNone
Left = 16 Left = 16
@ -66,6 +70,7 @@ object SearchForm: TSearchForm
Width = 80 Width = 80
end end
object lblSearchText: TLabel object lblSearchText: TLabel
BorderSpacing.OnChange = nil
Color = clNone Color = clNone
Left = 96 Left = 96
Height = 17 Height = 17
@ -74,6 +79,7 @@ object SearchForm: TSearchForm
end end
object btnCancel: TButton object btnCancel: TButton
AutoSize = True AutoSize = True
BorderSpacing.OnChange = nil
Caption = 'Cancel' Caption = 'Cancel'
Default = True Default = True
OnClick = btnAbortCLICK OnClick = btnAbortCLICK

View File

@ -4,23 +4,25 @@ LazarusResources.Add('TSearchForm','FORMDATA',[
'TPF0'#11'TSearchForm'#10'SearchForm'#11'BorderStyle'#7#8'bsDialog'#7'Caption' 'TPF0'#11'TSearchForm'#10'SearchForm'#11'BorderStyle'#7#8'bsDialog'#7'Caption'
+#6#13'Searching....'#12'ClientHeight'#3#149#0#11'ClientWidth'#3#172#1#8'OnCr' +#6#13'Searching....'#12'ClientHeight'#3#149#0#11'ClientWidth'#3#172#1#8'OnCr'
+'eate'#7#16'SearchFormCREATE'#9'OnDestroy'#7#17'SearchFormDESTROY'#10'Parent' +'eate'#7#16'SearchFormCREATE'#9'OnDestroy'#7#17'SearchFormDESTROY'#10'Parent'
+'Font'#9#13'PixelsPerInch'#2'p'#8'Position'#7#17'poOwnerFormCenter'#18'HorzS' +'Font'#9#13'PixelsPerInch'#2'`'#8'Position'#7#17'poOwnerFormCenter'#18'HorzS'
+'crollBar.Page'#3#171#1#18'VertScrollBar.Page'#3#148#0#4'Left'#3#205#1#6'Hei' +'crollBar.Page'#3#171#1#18'VertScrollBar.Page'#3#148#0#4'Left'#3#205#1#6'Hei'
+'ght'#3#149#0#3'Top'#3'!'#1#5'Width'#3#172#1#0#6'TPanel'#6'Panel2'#5'Align'#7 +'ght'#3#149#0#3'Top'#3'!'#1#5'Width'#3#172#1#0#6'TPanel'#6'Panel2'#5'Align'#7
+#8'alClient'#10'BevelInner'#7#9'bvLowered'#12'ClientHeight'#3#149#0#11'Clien' +#8'alClient'#22'BorderSpacing.OnChange'#13#10'BevelInner'#7#9'bvLowered'#12
+'tWidth'#3#172#1#11'FullRepaint'#8#10'ParentFont'#9#8'TabOrder'#2#0#7'TabSto' +'ClientHeight'#3#149#0#11'ClientWidth'#3#172#1#11'FullRepaint'#8#10'ParentFo'
+'p'#9#7'OnClick'#7#11'Panel2Click'#6'Height'#3#149#0#5'Width'#3#172#1#0#6'TL' +'nt'#9#8'TabOrder'#2#0#7'TabStop'#9#6'Height'#3#149#0#5'Width'#3#172#1#0#6'T'
+'abel'#10'lblMatches'#5'Color'#7#6'clNone'#4'Left'#2'`'#6'Height'#2#17#3'Top' +'Label'#10'lblMatches'#22'BorderSpacing.OnChange'#13#5'Color'#7#6'clNone'#4
+#2'P'#5'Width'#3'A'#1#0#0#6'TLabel'#12'MatchesLabel'#7'Caption'#6#7'Matches' +'Left'#2'`'#6'Height'#2#17#3'Top'#2'P'#5'Width'#3'A'#1#0#0#6'TLabel'#12'Matc'
+#5'Color'#7#6'clNone'#4'Left'#2#16#6'Height'#2#17#3'Top'#2'P'#5'Width'#2'@'#0 +'hesLabel'#22'BorderSpacing.OnChange'#13#7'Caption'#6#7'Matches'#5'Color'#7#6
+#0#6'TLabel'#11'lblProgress'#8'AutoSize'#8#5'Color'#7#6'clNone'#4'Left'#2'`' +'clNone'#4'Left'#2#16#6'Height'#2#17#3'Top'#2'P'#5'Width'#2'@'#0#0#6'TLabel'
+#6'Height'#2#17#3'Top'#2'0'#5'Width'#3'@'#1#0#0#6'TLabel'#14'SearchingLabel' +#11'lblProgress'#22'BorderSpacing.OnChange'#13#5'Color'#7#6'clNone'#4'Left'#2
+#7'Caption'#6#10'Searching:'#5'Color'#7#6'clNone'#4'Left'#2#16#6'Height'#2#17 +'`'#6'Height'#2#17#3'Top'#2'0'#5'Width'#3'@'#1#0#0#6'TLabel'#14'SearchingLab'
+#3'Top'#2'0'#5'Width'#2'@'#0#0#6'TLabel'#15'SearchTextLabel'#7'Caption'#6#12 +'el'#22'BorderSpacing.OnChange'#13#7'Caption'#6#10'Searching:'#5'Color'#7#6
+'Search Text:'#5'Color'#7#6'clNone'#4'Left'#2#16#6'Height'#2#17#3'Top'#2#16#5 +'clNone'#4'Left'#2#16#6'Height'#2#17#3'Top'#2'0'#5'Width'#2'@'#0#0#6'TLabel'
+'Width'#2'P'#0#0#6'TLabel'#13'lblSearchText'#5'Color'#7#6'clNone'#4'Left'#2 +#15'SearchTextLabel'#22'BorderSpacing.OnChange'#13#7'Caption'#6#12'Search Te'
+'`'#6'Height'#2#17#3'Top'#2#16#5'Width'#3'@'#1#0#0#7'TButton'#9'btnCancel'#8 +'xt:'#5'Color'#7#6'clNone'#4'Left'#2#16#6'Height'#2#17#3'Top'#2#16#5'Width'#2
+'AutoSize'#9#7'Caption'#6#6'Cancel'#7'Default'#9#7'OnClick'#7#13'btnAbortCLI' +'P'#0#0#6'TLabel'#13'lblSearchText'#22'BorderSpacing.OnChange'#13#5'Color'#7
+'CK'#8'TabOrder'#2#0#4'Left'#3#177#0#6'Height'#2#25#3'Top'#2'p'#5'Width'#2'K' +#6'clNone'#4'Left'#2'`'#6'Height'#2#17#3'Top'#2#16#5'Width'#3'@'#1#0#0#7'TBu'
+#0#0#0#0 +'tton'#9'btnCancel'#8'AutoSize'#9#22'BorderSpacing.OnChange'#13#7'Caption'#6
+#6'Cancel'#7'Default'#9#7'OnClick'#7#13'btnAbortCLICK'#8'TabOrder'#2#0#4'Lef'
+'t'#3#177#0#6'Height'#2#25#3'Top'#2'p'#5'Width'#2'K'#0#0#0#0
]); ]);

View File

@ -53,7 +53,6 @@ type
lblProgress: TLABEL; lblProgress: TLABEL;
lblSearchText: TLABEL; lblSearchText: TLABEL;
Panel2: TPANEL; Panel2: TPANEL;
procedure Panel2Click(Sender: TObject);
procedure SearchFormCREATE(Sender: TObject); procedure SearchFormCREATE(Sender: TObject);
procedure SearchFormDESTROY(Sender: TObject); procedure SearchFormDESTROY(Sender: TObject);
procedure btnAbortCLICK(Sender: TObject); procedure btnAbortCLICK(Sender: TObject);
@ -71,7 +70,6 @@ type
fAbort: boolean; fAbort: boolean;
fAbortString: string; fAbortString: string;
fAborting: boolean; fAborting: boolean;
fCharWidth: longint;
fSearchProject: boolean; fSearchProject: boolean;
fSearchOpen: boolean; fSearchOpen: boolean;
fSearchFileList: TStringList; fSearchFileList: TStringList;
@ -115,10 +113,6 @@ begin
end; end;
procedure TSearchForm.SearchFormCREATE(Sender: TObject); procedure TSearchForm.SearchFormCREATE(Sender: TObject);
var
FormFont: THandle;
tm : TTextmetric;
DC: HDC;
begin begin
//Set Defaults //Set Defaults
MatchesLabel.Caption:=lissMatches; MatchesLabel.Caption:=lissMatches;
@ -139,22 +133,8 @@ begin
fSearchOpen:= false; fSearchOpen:= false;
fSearchFiles:= false; fSearchFiles:= false;
self.Caption:= dlgSearchCaption; self.Caption:= dlgSearchCaption;
try
DC:= GetDC(0);
FormFont:= SelectObject(DC, Font.Handle);
GetTextMetrics(DC, tm);
fCharWidth:= tm.tmAveCharWidth;
finally
SelectObject(DC, FormFont);
ReleaseDC(0, DC);
end;//finally
end;//SearchFormCreate end;//SearchFormCreate
procedure TSearchForm.Panel2Click(Sender: TObject);
begin
end;
procedure TSearchForm.SearchFormDESTROY(Sender: TObject); procedure TSearchForm.SearchFormDESTROY(Sender: TObject);
begin begin
FreeAndNil(fParsedMasks); FreeAndNil(fParsedMasks);
@ -508,20 +488,14 @@ end;//UpdateMatches
procedure TSearchForm.UpdateProgress(FileName: string); procedure TSearchForm.UpdateProgress(FileName: string);
var var
DisplayFileName: string; DisplayFileName: string;
OldDisplayFileNameLength:Integer;
begin begin
DisplayFileName := FileName; DisplayFileName := FileName;
OldDisplayFileNameLength := Length(DisplayFileName) + Length(fPad); lblProgress.Caption:= DisplayFileName;
While ((Length(DisplayFileName) * fCharWidth) >= lblProgress.Width) do while (lblProgress.Left + lblProgress.Width)> lblProgress.Parent.ClientWidth-12 do
begin begin
DisplayFileName:= PadAndShorten(DisplayFileName); DisplayFileName:= PadAndShorten(DisplayFileName);
if Length(DisplayFileName) < OldDisplayFileNameLength lblProgress.Caption := DisplayFileName;
then
OldDisplayFileNameLength := Length(DisplayFileName)
else
Break;
end;//while end;//while
lblProgress.Caption:= DisplayFileName;
end;//UpdateProgress end;//UpdateProgress
function TSearchForm.PadAndShorten(FileName: string): string; function TSearchForm.PadAndShorten(FileName: string): string;