Jump to content
Sign in to follow this  
krolikbest

problem, maybe...

Recommended Posts

Hi,

 

system: win 7

SMS : 2.9.9.34

Problem:

new project->visual component project. On the form two buttons. in section uses add smartCL.Layout. in

procedure TForm1.InitializeObject add:

 

FLayout := Layout.Client(Layout.Margins(20).Spacing(5), [

Layout.Top([

Layout.Left(Layout.Spacing(3),[lew]),

Layout.Right(Layout.Spacing(3),[rig])

])

]);

 

Of course earlier i declared FLayout : TLayout in private section.

 

in TForm1.Resize

 

procedure TForm1.Resize;

begin

inherited;

FLayout.Resize(Self);

end;

 

 

until that it works. then i decided to add some dialog. So in uses section add w3Dialogs

In method OnClick of one button i've written:

 

Application.OnDialogSelect:=ProcessDialogResult;

Application.ShowDialog('Hello','Some text...',aoYesNo);

 

 

and then

 

procedure TForm1.ProcessDialogResult(Sender:TObject;aResult:TW3AlertResult);

begin

if aResult=roYes then

begin

ShowMessage('OK');

end;

end;

 

 

I expected after clicking this button to see message but i can't to see anything. What is wrong?

 

Martin

Share this post


Link to post
Share on other sites

it there's seems a minor issue with the CSS when using dialogs

2w56rg5.jpg

 

There's an panel box and two small buttons right to it and one button on the left. A large button lies under all four of them. At the bottom of the screen is a status bar and all the rest is taken by a memo control. Here is the code:

 

procedure TForm1.InitializeForm;
begin
inherited;
// this is a good place to initialize the Layout

FLayout := Layout.Client(Layout.Margins(3).Spacing(3), [
Layout.Top([
Layout.Client(Layout.Margins(0, 0, 3, 0), Panel1),
Layout.Right(Layout.Spacing(3), [B1, B2]),
Layout.Left(Layout.Spacing(3), [B3])
]),
Layout.Top(Button1),
Layout.Client(Memo1),
Layout.Bottom(StatusBar1)
]);
end;

Application.OnDialogSelect := procedure(Sender:TObject;aResult:TW3AlertResult)
begin
if aResult=roYes then
begin
ShowMessage('OK');
end;
end;

end;

procedure TForm1.Resize;
begin
inherited;
if Assigned(FLayout) then
FLayout.Resize(Self);
end;

 

Share this post


Link to post
Share on other sites

 

Could you explain me why it works when "setting" layout is done in InitializeForm instead of initializeObject?

 

 

You should initialize most of the Form objects in InitializeForm. It's called later when the form is actually visible. Actually - when it becomes visible for the first time.

 

And when it comes to Resize, it is called many times during application startup. I actually is called too many times and I'm in the process of minimizing calls. However, we won't get it down to 1. So you should always make sure to check that the layout or any other controls are actually Assigned() like in the example above.

Share this post


Link to post
Share on other sites

 

  

 

You should initialize most of the Form objects in InitializeForm. It's called later when the form is actually visible. Actually - when it becomes visible for the first time.

 

 

 

 

Thank you! (I should have earlier come up with that, sorry for so stupid question :)

Share this post


Link to post
Share on other sites

it there's seems a minor issue with the CSS when using dialogs2w56rg5.jpgThere's an panel box and two small buttons right to it and one button on the left. A large button lies under all four of them. At the bottom of the screen is a status bar and all the rest is taken by a memo control.

Do you mean, that the Hello is clipped in the dialog?

Share this post


Link to post
Share on other sites

Yes, is clipped for me when testing in my very very old chrome browser, the browser preffix is expected!

 

the correct in the SmartCL.Control.Label should

__LabelStyles.Handle.innerHTML :=
#" .lbxenableBreak { white-space: normal; }
.lbxdisableBreak { white-space: nowrap; }
.lbxcontent {
display: block;
position: absolute;
margin: 0px !important;
padding: 0px !important;
font-family: inherit;
color: inherit;
overflow: hidden;
}


@import url('https://fonts.googleapis.com/css?family=Ubuntu');

.lbxcontent_ellipsis { width: 100%; text-overflow: ellipsis; }
.lbxcontent_v_top { top: 0%; "+BrowserAPI.PrefixDef("transform")+": translate(0, 0); }
.lbxcontent_v_center { top: 50%; "+BrowserAPI.PrefixDef("transform")+": translate(0, -50%); }
.lbxcontent_v_bottom { top: 100%; "+BrowserAPI.PrefixDef("transform")+": translate(0, -100%); }
.lbxcontent_h_left { text-align: left; }
.lbxcontent_h_center { width: 100%; text-align: center; }
.lbxcontent_h_right { width: 100%; text-align: right; }";

Share this post


Link to post
Share on other sites

In the current ALPHA, you are also able to define custom "width"/"height" values for TApplication.ShowDialog calls.

This had been requested by the community and was added to the RTL recently.

Share this post


Link to post
Share on other sites

> In the current ALPHA, you are also able to define custom "width"/"height" values for

> TApplication.ShowDialog calls.

 

Also consider adding AutoSized dialog. In most cases one would change default width/height when text that's showing is too big so he'll use GetTextWidth/Height to get true size and adjust dialog size accordingly.

Share this post


Link to post
Share on other sites

Also consider adding AutoSized dialog. In most cases one would change default width/height when text that's showing is too big so he'll use GetTextWidth/Height to get true size and adjust dialog size accordingly.

 

Thank you, this might be a useful addition for the future!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×