Mikelgiles Active Member Licensed User Longtime User Oct 15, 2019 #1 In the visual designer/Variants I only have one entry - 1400 x 700, scale = 1(160 dpi) In the B4J file I have added Code: Copy #Region Project Attributes #MainFormWidth: 1400 #MainFormHeight: 700 #End Region But when runs it is always small ( 600 x 600 guessing) But if I add this code in AppStart I can get it to the larger window. Code: Copy Sub AppStart MainForm.WindowWidth = 1400 MainForm.Windowheight = 700 Hoping that someone can tell me what i am missing. I would really like to be able to have the window size control come from thr visual designer rather than code if possible since I have anchors there. I did some searches first and found some posts on the Visual Designer and Variants but I didnt understand all of it LOL. Is there a tutorial available for controlling the window size?
In the visual designer/Variants I only have one entry - 1400 x 700, scale = 1(160 dpi) In the B4J file I have added Code: Copy #Region Project Attributes #MainFormWidth: 1400 #MainFormHeight: 700 #End Region But when runs it is always small ( 600 x 600 guessing) But if I add this code in AppStart I can get it to the larger window. Code: Copy Sub AppStart MainForm.WindowWidth = 1400 MainForm.Windowheight = 700 Hoping that someone can tell me what i am missing. I would really like to be able to have the window size control come from thr visual designer rather than code if possible since I have anchors there. I did some searches first and found some posts on the Visual Designer and Variants but I didnt understand all of it LOL. Is there a tutorial available for controlling the window size?
Jorge M A Well-Known Member Licensed User Longtime User Oct 16, 2019 #2 1.- Be sure to load the layout before you set the window properties: Code: Copy MainForm.RootPane.LoadLayout("Main") 'Load the layout file. MainForm.WindowWidth = 1400 MainForm.WindowHeight = 700 2.- Additionally, You can use SetWindowSizeLimits to set min and max window dimensions. Code: Copy MainForm.SetWindowSizeLimits(600, 600, 1400,700) MainForm.WindowWidth = 1400 MainForm.WindowHeight = 700 3.-The visual designer is fundamental, if you want your program to be able to be seen in different screen sizes and resolutions. Have you had a chance to watch Erel's videos yet? a) https://www.b4x.com/etp.html?vimeography_gallery=1&vimeography_video=254278034 b) https://www.b4x.com/etp.html?vimeography_gallery=1&vimeography_video=254439386 Upvote 0
1.- Be sure to load the layout before you set the window properties: Code: Copy MainForm.RootPane.LoadLayout("Main") 'Load the layout file. MainForm.WindowWidth = 1400 MainForm.WindowHeight = 700 2.- Additionally, You can use SetWindowSizeLimits to set min and max window dimensions. Code: Copy MainForm.SetWindowSizeLimits(600, 600, 1400,700) MainForm.WindowWidth = 1400 MainForm.WindowHeight = 700 3.-The visual designer is fundamental, if you want your program to be able to be seen in different screen sizes and resolutions. Have you had a chance to watch Erel's videos yet? a) https://www.b4x.com/etp.html?vimeography_gallery=1&vimeography_video=254278034 b) https://www.b4x.com/etp.html?vimeography_gallery=1&vimeography_video=254439386
Erel B4X founder Staff member Licensed User Longtime User Oct 16, 2019 #3 Setting the attributes should change the initial size. If it doesn't then there is a different problem. Maybe you are setting it again in your code. #MainFormWidth: 1400 #MainFormHeight: 700 Jorge M A said: Be sure to load the layout before you set the window properties: Click to expand... This is actually not required. Generally speaking it is better to set the container size before loading the layout. Upvote 0
Setting the attributes should change the initial size. If it doesn't then there is a different problem. Maybe you are setting it again in your code. #MainFormWidth: 1400 #MainFormHeight: 700 Jorge M A said: Be sure to load the layout before you set the window properties: Click to expand... This is actually not required. Generally speaking it is better to set the container size before loading the layout.
Mikelgiles Active Member Licensed User Longtime User Oct 16, 2019 #4 Erel said: Setting the attributes should change the initial size. If it doesn't then there is a different problem. Maybe you are setting it again in your code. #MainFormWidth: 1400 #MainFormHeight: 700 This is actually not required. Generally speaking it is better to set the container size before loading the layout. Click to expand... Thanks Erel! I will check the code again to make sure that I am not setting it in some unknown place. I was thinking that if I remove any settings from code that it should stay with what was set in the visual designer. Is setting it in the Variant window the proper place to do that? I was assuming that the initial size was set in the variant window, setting the attributes would override the initial settings and from there anything processed in code would override again. I would like it to happen in just one single place. Upvote 0
Erel said: Setting the attributes should change the initial size. If it doesn't then there is a different problem. Maybe you are setting it again in your code. #MainFormWidth: 1400 #MainFormHeight: 700 This is actually not required. Generally speaking it is better to set the container size before loading the layout. Click to expand... Thanks Erel! I will check the code again to make sure that I am not setting it in some unknown place. I was thinking that if I remove any settings from code that it should stay with what was set in the visual designer. Is setting it in the Variant window the proper place to do that? I was assuming that the initial size was set in the variant window, setting the attributes would override the initial settings and from there anything processed in code would override again. I would like it to happen in just one single place.
Mikelgiles Active Member Licensed User Longtime User Oct 16, 2019 #5 Mikelgiles said: Thanks Erel! I will check the code again to make sure that I am not setting it in some unknown place. I was thinking that if I remove any settings from code that it should stay with what was set in the visual designer. Is setting it in the Variant window the proper place to do that? I was assuming that the initial size was set in the variant window, setting the attributes would override the initial settings and from there anything processed in code would override again. I would like it to happen in just one single place. Click to expand... I am even more confused now. The only settings being done in code were the ones setting the window to 1400 x 700 which I thought was necessary yesterday. For testing I remarked them off and the #MainFormWidth: 1400 & #MainFormHeight: 700 is now working which I thought was not working yesterday. Sometimes I think I am just getting too old for development work LOL. Now I just need to understand what I am doing wrong in the visual designer that requires me to set the size with #MainFormWidth: 1400 & #MainFormHeight: 700. I am using 1400 x 700, scale = 1(160 dpi) in the visual designer/Variants window. I only have the one setting there and I was assuming that I would not need anything else set but if I remove #MainFormWidth: 1400 & #MainFormHeight: 700 from the B4J file it goes back to the small size so I am thinking I am doing something wrong in the designer. What do I need to post to help with my question? Upvote 0
Mikelgiles said: Thanks Erel! I will check the code again to make sure that I am not setting it in some unknown place. I was thinking that if I remove any settings from code that it should stay with what was set in the visual designer. Is setting it in the Variant window the proper place to do that? I was assuming that the initial size was set in the variant window, setting the attributes would override the initial settings and from there anything processed in code would override again. I would like it to happen in just one single place. Click to expand... I am even more confused now. The only settings being done in code were the ones setting the window to 1400 x 700 which I thought was necessary yesterday. For testing I remarked them off and the #MainFormWidth: 1400 & #MainFormHeight: 700 is now working which I thought was not working yesterday. Sometimes I think I am just getting too old for development work LOL. Now I just need to understand what I am doing wrong in the visual designer that requires me to set the size with #MainFormWidth: 1400 & #MainFormHeight: 700. I am using 1400 x 700, scale = 1(160 dpi) in the visual designer/Variants window. I only have the one setting there and I was assuming that I would not need anything else set but if I remove #MainFormWidth: 1400 & #MainFormHeight: 700 from the B4J file it goes back to the small size so I am thinking I am doing something wrong in the designer. What do I need to post to help with my question?
stevel05 Expert Licensed User Longtime User Oct 16, 2019 #6 The variant size in the designer does not set the window size, the best fit is selected when the layout is loaded or the form is resized (if you leave the Handle Resize Event checkbox checked). In this way you can build responsive layouts that change if the window is resized by the user. You can size the window using the Attributes as you have, or directly using the forms WindowHeight and WindowWidth methods. Upvote 0
The variant size in the designer does not set the window size, the best fit is selected when the layout is loaded or the form is resized (if you leave the Handle Resize Event checkbox checked). In this way you can build responsive layouts that change if the window is resized by the user. You can size the window using the Attributes as you have, or directly using the forms WindowHeight and WindowWidth methods.