BBC BASIC for Windows
Programming >> User Interface >> Fixing the position of a progress bar
http://bb4w.conforums.com/index.cgi?board=ui&action=display&num=1409245434

Fixing the position of a progress bar
Post by g3nrw on Aug 28th, 2014, 5:03pm

I have an app containing many controls, whose positions are expressed as x%, y% units relative to the top left hand corner of the window. When I run the app on different systems with different resolution monitors, all the controls appear in the same position relative to each other. No problem.

I have now added a progress bar to the app. It works, but it appears in different positions on different resolution monitors. This is evidently because the position of the bar is expressed as xpos%, ypos%, where these parameters are in pixels relative to the top left hand corner, rather than in x%, y% units.

This is a pain, because the bar appears in different places on different systems, depending on the screen resolution.

Is there any way to express the position of the bar as x%, y% units, as with all the other controls, rather than xpos%, ypos% pixels?

--
Ian

Re: Fixing the position of a progress bar
Post by DDRM on Aug 29th, 2014, 08:57am

Hi Ian,

Please can you clarify a little? Does your app put the controls on the main window (e.g. using Winlib5), or are you using a dialogue box (eg. using Winlib2)?

If you are using Winlib5, it looks like control sizes are specified in pixels anyway, as are progress bars in Winlib3.

If you are using Winlib2, have you seen the section in the manual on making a progress bar using

PROC_dlgctrl(dlg%,"",id%,x%,y%, cx%, cy%, &50000000, "msctls_progress32")

That seems to generate a progress bar in dialogue box units, which scales with other controls as you change font size or screen resolution, at least on my machine and a quick test.

If it's a dialogue box and you aren't using Winlib2, would the MapDialogRect function do what you need?

http://msdn.microsoft.com/en-gb/library/windows/desktop/ms645502%28v=vs.85%29.aspx

If you search for "rect" in the help, there's an example (under displaying enhanced metafiles) of how to make and use a rect structure in BB4W to send/receive data from a SYS call, which I guess, but have not tried, should work similarly with this call.

Hope that's helpful,

David

Re: Fixing the position of a progress bar
Post by g3nrw on Aug 30th, 2014, 08:35am

Hi David

on Aug 29th, 2014, 08:57am, DDRM wrote:
Please can you clarify a little?

Yes, I realize I didn't give much information!

Quote:
If you are using Winlib2, have you seen the section in the manual on making a progress bar using

PROC_dlgctrl(dlg%,"",id%,x%,y%, cx%, cy%, &50000000, "msctls_progress32")


Yes, that is what I should have used. I used instead:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pb% = FN_createprogressbar(@hwnd%, 550, 145, 150, 20, 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Problem solved.

Thanks David

--
Ian