Jump to content


Photo

problem, maybe...


  • Please log in to reply
14 replies to this topic

#1 krolikbest

krolikbest
  • Members
  • 13 posts

Posted 26 September 2017 - 06:41 PM

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

#2 krolikbest

krolikbest
  • Members
  • 13 posts

Posted 26 September 2017 - 06:54 PM

If i commented in TForm1.Resize this "//FLayout.Resize(self)" then i see dialog but not commented does a problem..

#3 jarto

jarto
  • Administrators
  • 72 posts
  • LocationVaasa, Finland
  • Enterprise Edition

Posted 26 September 2017 - 08:50 PM

The problem is, that the first Resize is called when FLayout is nil.
Change the resize to:

if FLayout<>nil then FLayout.Resize(Self);
  • ielite likes this

#4 krolikbest

krolikbest
  • Members
  • 13 posts

Posted 26 September 2017 - 09:20 PM

Thanks for an answer, but still it must be something else.

#5 Laksekjønn

Laksekjønn
  • Members
  • 455 posts

Posted 27 September 2017 - 05:39 AM

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;


#6 krolikbest

krolikbest
  • Members
  • 13 posts

Posted 27 September 2017 - 05:49 PM

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

#7 krolikbest

krolikbest
  • Members
  • 13 posts

Posted 27 September 2017 - 05:50 PM

Anyway thanks for help

#8 jarto

jarto
  • Administrators
  • 72 posts
  • LocationVaasa, Finland
  • Enterprise Edition

Posted 27 September 2017 - 09:19 PM

&nbsp;

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

&nbsp;

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.

#9 krolikbest

krolikbest
  • Members
  • 13 posts

Posted 27 September 2017 - 10:47 PM

&nbsp;

&amp;nbsp;&amp;nbsp;

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.

&nbsp;

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

#10 jarto

jarto
  • Administrators
  • 72 posts
  • LocationVaasa, Finland
  • Enterprise Edition

Posted 28 September 2017 - 12:51 PM

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?

#11 Laksekjønn

Laksekjønn
  • Members
  • 455 posts

Posted 28 September 2017 - 02:10 PM

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; }";


#12 Laksekjønn

Laksekjønn
  • Members
  • 455 posts

Posted 28 September 2017 - 02:23 PM

OFFTOPIC: Don't forget to fix the minor issue uncomment
LHandle.style.backgroundSize:="auto auto";
from http://forums.smartm...gets-distorted/
  • Nico Wouterse likes this

#13 Dennis07

Dennis07
  • Administrators
  • 40 posts
  • LocationBerlin, Germany
  • Enterprise Edition

Posted 12 October 2017 - 01:39 PM

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.
  • Igor Savkic likes this

#14 Igor Savkic

Igor Savkic
  • Members
  • 188 posts

Posted 12 October 2017 - 06:32 PM

> 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.

#15 Dennis07

Dennis07
  • Administrators
  • 40 posts
  • LocationBerlin, Germany
  • Enterprise Edition

Posted Yesterday, 01:08 PM

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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users