B4J Question Preferences Dialog Size by code

Guenter Becker

Active Member
Licensed User
Longtime User
Hello,
I am using Preferences Dialog and I set it's size (Main WIndow) by code to 600x600. Works well.
B4X:
PrefDlg.Initialize(Root,"App.-Info",600dip,600dip)
1789200893568.png

Clicking on an Option a second window opens (Sub window) like:
1789200972858.png

This window does not meet the size of the dialog of the main window (600x600) it seems it stays on the smaller standard size.

The question is: How can I set the window size by code for all windows to the same size?
 

Swissmade

Well-Known Member
Licensed User
Longtime User
Hello,
I am using Preferences Dialog and I set it's size (Main WIndow) by code to 600x600. Works well.
B4X:
PrefDlg.Initialize(Root,"App.-Info",600dip,600dip)
View attachment 173565
Clicking on an Option a second window opens (Sub window) like:
View attachment 173566
This window does not meet the size of the dialog of the main window (600x600) it seems it stays on the smaller standard size.

The question is: How can I set the window size by code for all windows to the same size?
Maybe small project can help to see what is happening.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
The question is: How can I set the window size by code for all windows to the same size?
You can set all windows to the same size by code.
However, you may need to adjust the layouts of some windows if you are not satisfied with how they look. such as date type, color type.

B4X:
PrefDlg.Initialize(Root,"App.-Info",600dip,600dip)
...
TemplateDialogWH(PrefDlg, 600dip, 600dip))

private Sub TemplateDialogWH(pfd As PreferencesDialog, w As Int, h As Int)
    If Initialized(pfd.LongTextTemplate) Then
        pfd.LongTextTemplate.mBase.Width=w
        pfd.LongTextTemplate.mBase.Height=h
    End If
    If Initialized(pfd.SearchTemplate) Then
        pfd.SearchTemplate.mBase.Width=w
        pfd.SearchTemplate.mBase.Height=h
    End If
    If Initialized(pfd.DateTemplate) Then
        pfd.DateTemplate.GetPanel(Null).Width=w
        pfd.DateTemplate.GetPanel(Null).Height=h
    End If
    If Initialized( pfd.ColorTemplate) Then
        pfd.ColorTemplate.mBase.Width=w
        pfd.ColorTemplate.mBase.Height=h
    End If
End Sub
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Longtime User
You can set all windows to the same size by code.
However, you may need to adjust the layouts of some windows if you are not satisfied with how they look. such as date type, color type.

B4X:
PrefDlg.Initialize(Root,"App.-Info",600dip,600dip)
...
TemplateDialogWH(PrefDlg, 600dip, 600dip))

private Sub TemplateDialogWH(pfd As PreferencesDialog, w As Int, h As Int)
    If Initialized(pfd.LongTextTemplate) Then
        pfd.LongTextTemplate.mBase.Width=w
        pfd.LongTextTemplate.mBase.Height=h
    End If
    If Initialized(pfd.SearchTemplate) Then
        pfd.SearchTemplate.mBase.Width=w
        pfd.SearchTemplate.mBase.Height=h
    End If
    If Initialized(pfd.DateTemplate) Then
        pfd.DateTemplate.GetPanel(Null).Width=w
        pfd.DateTemplate.GetPanel(Null).Height=h
    End If
    If Initialized( pfd.ColorTemplate) Then
        pfd.ColorTemplate.mBase.Width=w
        pfd.ColorTemplate.mBase.Height=h
    End If
End Sub
Thank you, this is the solution I need now all windows are at same size.
 
Upvote 0
Top