miile7
miile7

Reputation: 2393

How to get the available screen size in dm script

I have a dialog that contains a lot of fields, so the dialog is getting very big. When I am switching to computers with a lower screen resolution (smaller screen), I end up with not everything being dispalyed. Especially the "OK" button is not reachable which makes my script not usable anymore.

My current solution now would be to check the screen size and estimate how many inputs I can display. The other inputs will go in other tabs. But how do I get the screen size? (Note that the tab solution should only be used if there is no other possibility. I do not always want to display the tabs because of various reasons.)


I tried to use GetMaximalDocumentWindowRect(). When I use 1 for the first parameter, I get the current size of the window. If there is no other solution I will stick with this. But when the window is not taking the full screen, the available space I get is a lot smaller than the one I could use.

When I use 0 for GetMaximalDocumentWindowRect() I get (-16384/-16384) for (left/top) and (16383/16383) for (right/bottom) which are (the max values of a 15bit (???) signed integer and) obviously not my screen dimensions.

There is also the dialog function GetFrameBounds(), but this returns the dimensions of the current dialog only. The WindowGetFrameBounds() function is used for windows, but I didn't find a way to get the application window. In addition this also only gives me the current size of the application which I don't really want.


Another solution would be to use scrollable content. But I didn't find anything about scrollable in the documentation. If there is a possibility I would prefere this way over creating tabs.

Upvotes: 0

Views: 69

Answers (1)

BmyGuest
BmyGuest

Reputation: 2939

The following script outputs the general screen information of the application. The used commands are not in the official documentation and I don't know if they are valid in all GMS versions.

ClearResults()
number nScreens = CountScreens()
Result("System info on screens and application window.\n")
Result("**********************************************\n")
Result("\n Number of Screens: " + nScreens )
for( number i=0; i<nScreens; i++ )
{
    string name = ScreenGetName(i)
    Result("\n\n\t Screen #"+i+": "+name)

    number st,sl,sb,sr
    ScreenGetBounds(i,st,sl,sb,sr)
    Result("\n\t\t Bounds:    ["+st+";"+sl+";"+sb+";"+sr+"]")

    number wt,wl,wb,wr
    ScreenGetWorkArea(i,wt,wl,wb,wr)
    Result("\n\t\t Work area: ["+wt+";"+wl+";"+wb+";"+wr+"]")
}

Result("\n\n GMS Application window:\n")
number ap_global_x,ap_global_y
ApplicationGetOrigin(ap_global_x,ap_global_y)
result("\n\t Origin(global coordinates): "+ap_global_x+"/"+ap_global_y)

number ap_t, ap_l, ap_b, ap_r
ApplicationGetBounds(ap_t, ap_l, ap_b, ap_r)
Result("\n\t Main area (application coordiantes): ["+ap_t+";"+ap_l+";"+ap_b+";"+ap_r+"]")

To find out what area of the workspace can be actually used for images, you would use the GetMaximalDocumentWindowRect() command.

The options parameter is a number that specifies various flags in its binary form.

  • INSIDE_APPLICATION = 0x00000001 // 1
  • EXCLUDE_FRAME = 0x00000002 // 2
  • EXCLUDE_DOCKED_FLOATING_WINDOWS = 0x000000F0 // 240 (Sum 16+32+64+128)

e.g. Get area which is limited on all four sides by the docked windows but ignore frames:
OPTION = 1+16+32+64+128 = 241

As any document can be partly or completely outside the visible workspace area, using this command without the INSIDE_APPLICATION flag gives the full available 'virtual' space for document windows.

You can use the following script:

void Output( number OPTION , number DRAW)
{
    Number T,L,B,R  // coordinates
    GetMaximalDocumentWindowRect(OPTION,t,l,b,r)
    string z = "000000000000"
    Result("\n ("+left( z, 10-len(Binary(OPTION))) + Binary(OPTION)+")")
    Result("\t Coordintates: ["+Format(t,"%6d")+","+Format(l,"%6d")+","+Format(b,"%6d")+","+Format(r,"%6d")+"]")
    if (DRAW) 
        NewScriptWindow("Test area ("+OPTION+")",t,l,b,r)
}

number DRAWIT = !TwoButtonDialog( "Output current maximum size to results.", "OK", "Also draw windows")
Output(1+2,DRAWIT)      ; result("\t Maximum window, exclude frame")
Output(1+2+240,DRAWIT)  ; result("\t Maximum window, limited by docked, exclude frame")

Upvotes: 0

Related Questions