You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
I designed an application for screen 1024x1024 using PB Forms. Now my client wants to use it on a screen 1024x768. Long story short, some of the screens don't fit.
Anybody have any ideas on a solution?
Thanks,
Stan
Do not go quiet into that good night,
... Rage, rage against the dark.
Oh, you didn't? Well, then I think you have to do that now.
(If it's a DIALOG coded in DIALOG UNITS (eg DDT/PBFORMS) you could try a smaller font on the screen as a first step. That will shrink everything in both directions, but hell, it might just fit and still be readable.)
When building the Dialog(s), include the %WS_VSCROLL style. That will add a scroll bar so the controls below 768 can be scrolled into view.
=====================================
"If stupidity got us into this mess,
then why can't it get us out?" "
Will Rogers (1879-1935)
=====================================
The real answer is don't design your screens to fit a specific display size. It will only lead to problems later on as you found out
You can resize the controls in response to the WM_SIZE message in the window's callback function. If there is too much room, center the controls in the window.
JFYI, the screen size can be determined using the following calls:
If it is a simple text only screen, setting the screen size along the lines Michael suggested is part of the equation, but you will also need to reset the text control size and/or location, et.al. for it and any other controls if any.
It may mean that you are going to need to do several things. If you want to have a special size for just this client, then you will be adjusting only one copy of the program. However if you want it as an adjustable feature, then you should look into several of the resize topic posts in the forum %WM_SIZE.
Come of the task can be automatic. For example, get the desktop or desktop client size (See the DESKTOP functions) and adjust accordingly. If you allow the client to resize downward from that initial size then you may need a minimum on-screen size, e.g. 800 x 600, 640 x 480.
In resizing I typically look at what is being displayed. For example if I have a fair amount of buttons and some text/list/listview etc. typical controls then I will figure out relative positions based on their general location on the screen. Then the algo executed in the %WM_SIZE message will resize and relocate the controls accordingly.
Controls such as buttons, radio buttons and checks. might get resized in a pinch with CONTROL SET SIZE, but mostly in my apps like this I've found I can usually squeeze the textually oriented controls height and width to get the shrink room. Resizing buttons and similar controls may require assigning a smaller font as MCM pointed out. Some buttons may end up getting spaced closer to each other in some cases, and often you can set their position relative to the side of a display ... anchor point in x and/or y for a new CONTROL SET LOC command or proportionately from such a side.
If you could post the existing code that establishes your window or a screen shot and then folks could point you more clearly along the pathe they might take.
Thanks Michael.
I will put those equates into my library of good things to know.
Gosta:
Yeah, I tried the VSCROLL. It really messed up the logo I have displayed on 2 of the screens though. This is another entry in my good things to know lib.
Kev:
Thanks for that code. I think I will stick that code (along with the equates) into my personal #INCLUDE file with all the stuff that HAS to be done every time from now on.
Richard:
Thank you. I started resizing and moving things around right after I posted my cry for help. This app has a lot of those non-text controls in it so I am squeezing ht x wd as you suggested. Thanks especially for the lead on the WM_SIZE forum.
I've tried some new things (for me) graphically on this app so the text-only solutions won't work, but I think I'll find what I need in the WM_SIZE forum.
As always this is the best place to get help whenever I need it. (Hopefully not being a pain.) Thank you to everybody who responded.
Stan
Do not go quiet into that good night,
... Rage, rage against the dark.
One consideration to keep in mind, if you have not already learned it: DIALOG NEW sets the client size of the dialog window, so you might want to DIALOG SET SIZE based on DESKTOP SIZE/CLIENT function returns during %WM_INITDIALOG. I've found working with PIXELS tends to be a lot easier for me than dialog units. When you go that route, then PBFORMS will size the controls in PIXELS as well, and you are redy to use any of the API's that also return pixels ... many do.
If you can post the code, we can see your screen and give more educated hints and help though.
Not all windows may lend themselves to the same identical resize scheme. Here's a snip of one that does handle a bunch of controls where in this case there are buttons at the top, right side, and a couple of rows between a left aligned listbox and a textbox. It maintains a minimum overall dialog size of ~800 x ~600. Let's face it there can be limits where allowing the user to size below the such a desired minimum would place controls out of the view.
Code:
CALLBACK FUNCTION MainDlgProc()
STATIC dw,dh,cw,ch AS LONG
SELECT CASE AS LONG CBMSG
CASE %WM_SIZE
'need to check re-size action minimize, normal, maximize and adjust the screen.
'we'll leave the buttons the same size, extend the file drop zone and thus have
'a protected column of controls and drop zone on the right side of the main screen.
'all that is left then is to size the listbox, it's label and move it's print button
'Also just extend the direct text box to the right. minimum resolution 800x600
IF IsIconic(CBHNDL) THEN
EXIT FUNCTION 'it is minimized
ELSEIF IsZoomed(CBHNDL) THEN
DIALOG SEND CBHNDL, %WM_SETREDRAW, 0, 0 ' Turn off redraw
DESKTOP GET CLIENT TO dw,dh
DIALOG SET SIZE CBHNDL,dw,dh
DIALOG GET CLIENT CBHNDL TO dw,dh
ELSE
DIALOG SEND CBHNDL, %WM_SETREDRAW, 0, 0 ' Turn off redraw
DIALOG GET CLIENT CBHNDL TO dw,dh
IF dw < 794 OR dh< 575 THEN ' maintain min dlg size limits
dw = 794
dh = 575
DIALOG SET CLIENT CBHNDL,dw,dh
END IF
END IF
CONTROL SET LOC CBHNDL, %ID_BTN_HELP ,dw - 154 ,10
CONTROL SET LOC CBHNDL, %ID_FRM_DROP ,dw - 154 ,50
CONTROL SET LOC CBHNDL, %ID_LB_FILES ,dw - 159 ,66
CONTROL SET LOC CBHNDL, %ID_BTN_RESET ,dw - 154 ,dh - 290
CONTROL SET LOC CBHNDL, %ID_BTN_PRACTICE ,dw - 154 ,dh - 220
CONTROL SET LOC CBHNDL, %ID_BTN_LINK2BROWSER ,dw - 154 ,dh - 185
CONTROL SET LOC CBHNDL, %ID_BTN_MAKELIST ,dw - 154 ,dh - 130
CONTROL SET LOC CBHNDL, %ID_BTN_QUIT ,dw - 154 ,dh - 55
CONTROL SET LOC CBHNDL, %ID_LINE3 ,dw - 154 ,dh - 240
CONTROL SET LOC CBHNDL, %ID_LINE4 ,dw - 154 ,dh - 145
CONTROL SET LOC CBHNDL, %ID_LINE5 ,dw - 154 ,dh - 70
CONTROL SET SIZE CBHNDL, %ID_LBL_WORDLIST ,dw - 184 ,20 'sizing
CONTROL SET SIZE CBHNDL, %ID_LB_WORDS ,dw - 184 ,dh - 225 'sizing
CONTROL GET SIZE CBHNDL, %ID_LB_WORDS TO cw,ch
CONTROL SET LOC CBHNDL, %ID_BTN_PRINT ,dw - 274 ,30 + ch 'locating
CONTROL SET LOC CBHNDL,%ID_BTN_WAV_BACK ,10 , dh -193
CONTROL SET LOC CBHNDL,%ID_BTN_WAV_RECORD ,80 , dh -193
CONTROL SET LOC CBHNDL,%ID_BTN_WAV_STOP ,150 , dh -193
CONTROL SET LOC CBHNDL,%ID_BTN_WAV_PLAY ,220 , dh -193
CONTROL SET LOC CBHNDL,%ID_BTN_WAV_NEXT ,300 , dh -193
CONTROL SET LOC CBHNDL,%ID_BTN_WAV_MULTIUSE ,380 , dh -193
CONTROL SET SIZE CBHNDL, %ID_TEB_WORDS ,dw - 184 ,95 'sizing
CONTROL SET LOC CBHNDL, %ID_TEB_WORDS ,10 ,dh - 120
CONTROL SET LOC CBHNDL, %ID_LBL_TEXTENTRY ,10 ,dh - 143
CONTROL SET LOC CBHNDL, %ID_BTN_SPEAK ,160 ,dh - 143
CONTROL SET LOC CBHNDL, %ID_BTN_TEXTSAVE ,295 ,dh - 143
CONTROL SEND CBHNDL,%ID_SBAR_1, CBMSG,CBWPARAM,CBLPARAM
DIALOG SEND CBHNDL, %WM_SETREDRAW, 1, 0 ' Turn on redraw
DIALOG REDRAW CBHNDL ' and redraw
I suppose you could put all the controls into a pager control. But then when operating at "full vertical size available (1024)" it might look dopey because there is no reason to use a pager control.
Then again, you could detect the resolution available at run time, and use/not use a pager control at that time.
What does the screen look like? Maybe someone would get an idea for an alternate screen if they saw what you are trying to do.
A link to BMP or JPEG or PNG would be good, or post enough code that we could create the screen ourselves.
The solution would be to enum all the child controls and anchor them using the MoveWndow API on the current screen size, like when you resize a window by draging its border.
I always design my window to work in the minimum 800x600 screen size then i use an anchor property to move the control while resizing the form.
Last edited by Patrice Terrier; 29 Feb 2008, 02:53 AM.
Reason: removed anchor source code
Eric: 1024x1024 ? Oh My! I should have said 1280x1024.
Wow! So many solutions to this problem! You guys are all really cool!
I would post a screen shot, but this particular screen has over 300 controls on it and I've squeezed it as much as I can and still make sense of the thing for an end user. I will post a screen shot if you really want to see it. (Don't think it will impress anybody though. )
Everybody seems to want to see the code. I won't trouble you with the code that DIDN'T work, but based on the suggestions I received, I began looking into the DESKTOP functions native to PB. I prefer working in Dialog Units so the pixels were giving me a headache. I discovered that PB will use Dialog Units to resize controls if you don't specify PIXELS in the DIALOG NEW statement. And I wanted a Cut-and-Paste solution for the control IDs because there are waaaay too many controls in this thing.
I think I ended up with a pretty good solution. And maybe with this snippet I'll start giving back to the community for a change.
Here's how I'm controlling the minimum resolution:
Code:
FUNCTION PBMAIN()
LOCAL pxWidth AS LONG
LOCAL pxHeight AS LONG
LOCAL lRslt AS LONG
DESKTOP GET SIZE TO pxWidth, pxHeight ' Get the resolution of the current screen in PIXELS
IF pxWidth < 1024 OR pxHeight < 768 THEN
'lRslt is a dummy arg in this case
lRslt = MSGBOX("You must set your screen resolution to 1024x768 or higher to use this program.", %MB_OK)
ELSE
'program code starts here
END IF
END FUNCTION
And here's my solution for resizing the controls in the window:
Code:
CASE %WM_INITDIALOG
' Initialization handler for the Problem Window
' Fill the ShowScreenControls() array with VALID ProjectScreen id&s (works for me with 344 controls)
ARRAY ASSIGN ShowScreenControls() = %IDC_ShowTitle, _
%IDC_txtR1CS_SequenceNumber, _
%IDC_txtR1CS_SequenceNote, _
...
...
...
%IDC_LABEL87
' Original Design w&h DUs: 846, 574
DESKTOP GET LOC TO x&, y& 'get client area top left corner
DIALOG SET LOC ShowScreen, x&, y& 'reposition the dialog to top left corner
DESKTOP GET CLIENT TO pxWidth, pxHeight 'get client size & convert to DUs
DIALOG PIXELS ShowScreen, pxWidth, pxHeight TO UNITS duWidth, duHeight 'convert pixels to dialog units
DIALOG SET SIZE ShowScreen, duWidth, duHeight 'resize the dialog to fit available space
'get ratio of size conversion
wRatio = duWidth / 846
hRatio = duHeight / 574
'resize and reposition all the controls in the dialog
FOR ControlPosSizeCheck = 0 TO ArrayUBOUND
CONTROL GET LOC ShowScreen, ShowScreenControls(ControlPosSizeCheck) TO x&, y&
x& = x& * wRatio
y& = y& * hRatio
CONTROL SET LOC ShowScreen, ShowScreenControls(ControlPosSizeCheck), x&, y&
CONTROL GET SIZE ShowScreen, ShowScreenControls(ControlPosSizeCheck) TO wide&, high&
wide& = wide& * wRatio
high& = high& * hRatio
CONTROL SET SIZE ShowScreen, ShowScreenControls(ControlPosSizeCheck), wide&, high&
NEXT ControlPosSizeCheck
Feel free to use it if it helps solve anybody else's problem with this sort of thing. I just noticed that I used "magic numbers" in the ratio formula. I'm going to try the DIALOG USER area to send these numbers. Don't have the code for that yet.
Again: THANK YOU EVERYBODY! Your suggestions led me to a solution that works for me and is reusable.
Sincerely,
Stan
Do not go quiet into that good night,
... Rage, rage against the dark.
I think that is at least two or three screens worth.
Normally I would agree with you completely, but ...
It's a real-time monitor and control tool with a live operator. It is imperative that everything stays in proper proportions or it becomes a complete mess.
They say the customer is always right... especially when he's paying cash.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment