Silverfrost Forums

Welcome to our forums

Scrollable format window?

20 Apr 2011 7:30 #8100

Is there a way to scroll a format window? I haven't been able to find one.

22 Apr 2011 4:49 #8111

Nobody replied to this?

Only certain controls can be scrolled. They all fit inside a format window (%ca/%ww etc).

The examples I know include graphics windows, some types of text boxes (including %cw), and various drop-down list boxes etc.

If you have so much info that an entire window needs to be scrolled, it looks to me like a case for simplification, or time to buy a much, much, bigger screen!

Taking the example of the Silverfrost Forum display, what you are scrolling is the 'client area' within Internet Explorer (say), which is just a big fancy graphic, even though it does look like it has buttons, text boxes etc. that you might be able to duplicate with Clearwin if you tried.

Eddie

31 Oct 2013 3:35 #13254

Hi, Eddie... This is something that I'm looking for now, too. I take the point on simplification. And the 'we need a bigger screen' argument. However, what I want to do is run the same software that I've developed on a 'normal' screen and run it on a much smaller screen on a Windows tablet.

Example images attached.

http://www.vmine.net/win1.jpg This shows the window as set up for use on a normal screen. Works fine.

http://www.vmine.net/win2.jpg I've made it resizable, so it can fit on the smaller screen of an HP Envy pad. Size is now fine, but I need to scroll it to see all the controls.

Yes, I could re-structure the whole page to use property sheets, but that still doesn't solve the problem, because it's still possible to overflow the size. The number of buttons is variable dependent on the requirements of the particular options chosen.

It would be really good just to be able to attach scroll-bars to the window.

-Steve[/img]

31 Oct 2013 4:31 #13256

Hi Steve,

What about reading in the screen dimensions, and laying out a window to suit? I've done this with some programs to decide that a toolbar across the top should be replaced by one down the side if the smaller screen is widescreen format - which they usually are - or if it is not, then to make the toolbar a popup window of its own.

The calls are:

       IXRES = GetSystemMetrics(SM_CXSCREEN)
       IYRES = GetSystemMetrics(SM_CYSCREEN)

Up to a point, you can simply make the font smaller, in which case you may be better using a very scalable font like Segoe UI rather than the windows default font.

Eddie

31 Oct 2013 4:49 #13257

excellent suggestion, Eddie. Hadn't thought of changing the font but of course that's an obvious thing to do. Changing the window layout is also possible: already thinking I can improve things by using property sheets. I've also cut down the default window border - saves a few more pixels.

4 Nov 2013 1:00 #13269

Tidying up, font sizing and control positioning can make a huge change to the space you need. Here is a 686 x 564 wide data entry screen for one of my programs. It was a huge effort but lots of data was placed on the screen. http://norsoftdev.com/trunnion_screen.jpg

Regarding your display, do you need buttons for each entry description, I use %ap%rs to layout the info, with a vertical increment of about 1.3d0 for the %ap. The %rs (for output) and %bg[white]%rf for input are set to a slightly different height to maintain the alignment. the %ob titles are actually %rs controls overlaying the box boundaries as it seems that for a multiple %ob you cannot have multiple titles.

The controls in the boxes on your display could be moved up using less %ff and %nl codes. I hope this helps. Ian

4 Nov 2013 3:20 #13270

Ian - that is an excellent example. In reply to your question about buttons. No I don't really need them. I was using them to get callbacks to a system dialog (for file names) and a popup window with a dropdown list (for field names) but neither really needs to be done via buttons, and the fieldname selection would be much simpler through %ls. Could save a lot of space!

15 Nov 2013 5:21 #13319

Actually, just returned to this after a break (a paying consultancy project 😄 ), and I think I do need buttons after all - unless you can attach bubble help or tooltips to something other than the %bt and %tt controls. However, I guess I could squash them closer together by using absolute positioning.

15 Nov 2013 7:22 #13321

Actually, I think that with a little bit of work and help from winapi you could scroll the window.

I haven't tried any of this, but steps would be something like:

  1. You need a handle of the window.

  2. Use SetWindowLongPtr() to modify window styles (WS_HSCROLL, WS_VSCROLL).

  3. You need to handle the WM_SIZE message and set new page size for scrollbars.

  4. You need to handle the WM_HSCROLL and WM_VSCROLL messages. Scroll the window client area by requested amount with ScrollWindow() and update current scrolling position.

16 Nov 2013 2:04 #13322

Here is a sample program that could be developed. At the moment it just has two buttons in a scrolling window. I think that %vs is undocumented - it is like %vx. The program only uses ClearWin+ format codes that have been available for a long time.

!FTN95$WINAPP
module vv
integer hwnd,chwnd,oldy,yscroll
end module vv

integer function vcb()
  use vv
  include <windows.ins>
  integer x,y,w,h,diff,child
  diff = 10*(yscroll - oldy)
  oldy = yscroll
  child = GetWindow(GetParent(chwnd), GW_CHILD);
  do while(child /= 0)
    call get_window_location@(child, x, y, w, h);
    call move_window@(child, x, y - diff);
    child = GetWindow(child, GW_HWNDNEXT)
  end do  
  vcb = 2
end function

integer function sc()
  use vv
  include <windows.ins>
  integer x,y,w,h
  call get_window_location@(hwnd, x, y, w, h)
  call resize_window@(hwnd, w, 100) 
  sc = 2
end function

program main
  use vv
  include <windows.ins>
  integer ii, ctrl, step, max
  integer,external::sc,vcb
  step = 1
  max = 10
  yscroll = 0
  oldy = 0
  !child window with controls...
  ii=winio@('%sh&',ctrl)
  ii=winio@('%bb[OK]&')
  ii=winio@('%lc&', chwnd)
  ii=winio@('%3nl%bb[Cancel]')
  !main window to display child with vertical scroll bar...
  ii=winio@('%ww%ca[Scroll demo]&')
  ii=winio@('%ch&',ctrl)
  ii=winio@('%hw&',hwnd)
  ii=winio@('%sc&',sc)
  ii=winio@('%^vs', step, max, yscroll, vcb);
end program

RESOURCES
1 24 default.manifest
16 Nov 2013 5:43 #13323

Same program tidied up a bit...

!FTN95$WINAPP
module vv
integer hWND,childHWND,lastyScroll,yScroll
end module vv

integer function vcb()
  use vv
  include <windows.ins>
  integer x,y,w,h,diff,cntlHWND
  diff = 10*(yScroll - lastyScroll)
  lastyScroll = yScroll
  !Move all the grandchildren...
  cntlHWND = GetWindow(childHWND, GW_CHILD);
  do while(cntlhwnd /= 0)
    call get_window_location@(cntlHWND, x, y, w, h);
    call move_window@(cntlHWND, x, y - diff);
    cntlHWND = GetWindow(cntlHWND, GW_HWNDNEXT)
  end do  
  vcb = 2
end function

integer function sc()
  use vv
  include <windows.ins>
  integer x,y,w,h
  call get_window_location@(hWND, x, y, w, h)
  call resize_window@(hWND, w, 100) 
  sc = 2
end function

program main
  use vv
  include <windows.ins>
  integer ii, ctrl, step, max
  integer,external::sc,vcb
  step = 1
  max = 10
  yScroll = 0
  lastyScroll = 0
  !child window with controls...
  ii=winio@('%sh&',ctrl)
  ii=winio@('%hw&', childHWND)
  ii=winio@('%bb[OK]&')
  ii=winio@('%3nl%bb[Cancel]')
  !main window to display child with vertical scroll bar...
  ii=winio@('%ww%ca[Scroll demo]&')
  ii=winio@('%ch&',ctrl)
  ii=winio@('%hw&',hWND)
  ii=winio@('%sc&',sc)
  !Match the border to the child background...
  ii=winio@('%bg[BTNFACE]&')
  ii=winio@('%^vs', step, max, yScroll, vcb);
end program

RESOURCES
1 24 default.manifest
16 Nov 2013 5:45 #13324

Hi jalih and Paul - interesting ideas, and will try this program, Paul - though not sure I want to dive into native Windows programming - I don't have the skill or courage of jalih!

16 Nov 2013 10:36 #13325

Add a grave accent to %vs (%^`vs), then vcb is also called whilst the 'thumb' is dragged.

17 Nov 2013 9:11 #13327

Here is the final offering...

!FTN95$WINAPP
module vv
use mswin
integer y0,lastyScroll,yScroll
integer hwnd

contains
  integer function cb()
    integer d,y
    if(y0 == 0) call get_window_location@(hwnd, d, y0, d, d)
    call get_window_location@(hwnd, d, y, d, d)
    !The scaling factor (10 here) could be adjusted to personal preference and screen resolution.
    call move_window@(hwnd, 0, y-y0+10*(lastyScroll-yScroll))
    lastyScroll = yScroll
    cb = 2
  end function
end module vv

program main
  use vv
  integer ii, ctrl, wd, ht
  yScroll = 0; lastyScroll = 0; y0 = 0
  !Set ht to the desired height of the main window...
  wd = 0;  ht = 150
  !child window with controls...
  ii=winio@('%sh&',ctrl)
  ii=winio@('%hw&', hwnd)
  !Add your controls here...
  ii=winio@('Sample containing scrolling child window..&')
  ii=winio@('%3nl%cn%6bb[OK]&')
  ii=winio@('%3nl%cn%6bb[Cancel]')
  !Main window to display child with vertical scroll bar...
  ii=winio@('%ww[no_border,no_maxbox]%ca[Scroll demo]&')
  ii=winio@('%ch&',ctrl)
  ii=winio@('%sz&',wd,ht)
  !Match background to the child background...
  ii=winio@('%bg[BTNFACE]&')
  !The maximum (10 here) is chosen to reflect the number of steps to complete the scrolling process.
  ii=winio@('%^`vs', 1, 10, yScroll, cb);
end program

RESOURCES
1 24 default.manifest
17 Nov 2013 11:29 #13328

Paul,

What version of FTN95/Clearwin+ is required for this example ?

John

18 Nov 2013 7:42 #13329

These are all old features (say 15 years old).

18 Nov 2013 12:07 #13330

Paul,

My version does not recognise '!FTN95$WINAPP' Is this a new compiler control syntax ?

I then get a run-time error '%bb requires button_icon/button_string' at line 30 Is this a consequence of recent changes to %bb ?

[FTN95/Win32 Ver. 6.10.0 Copyright (c) Silverfrost Ltd 1993-2011]

0001) !FTN95$WINAPP 
*** Missing expression
    PROCESSING MODULE  [<VV> FTN95/Win32 v6.10.0]
        1 ERROR  [<CB> FTN95/Win32 v6.10.0]
    NO ERRORS  [<VV> FTN95/Win32 v6.10.0]
    NO ERRORS  [<MAIN> FTN95/Win32 v6.10.0]
[Silverfrost SRC/WIN32 Ver 3.65 Copyright (c) Silverfrost Ltd 2011]
    NO ERRORS  [<SRCTEMP@SRC/WIN32 Ver 3.65]
*** Compilation failed

[FTN95/Win32 Ver. 6.10.0 Copyright (c) Silverfrost Ltd 1993-2011]

    PROCESSING MODULE  [<VV> FTN95/Win32 v6.10.0]
        NO ERRORS  [<CB> FTN95/Win32 v6.10.0]
    NO ERRORS  [<VV> FTN95/Win32 v6.10.0]
    NO ERRORS  [<MAIN> FTN95/Win32 v6.10.0]
[Silverfrost SRC/WIN32 Ver 3.65 Copyright (c) Silverfrost Ltd 2011]
    NO ERRORS  [<SRCTEMP@SRC/WIN32 Ver 3.65]
Creating executable: vv.EXE

I need to get more up to date with the changes to Clearwin+

John

18 Nov 2013 2:48 #13331

%vs is documented in CWPLUS.ENH as number 35, as far back as ver 4.2, and we are over 330 now!

CWPLUS.ENH enhancements are sometimes in FTN95.CHM, sometimes not.

Eddie

18 Nov 2013 7:08 #13333

Yes %bb is new. Replace it with %bt. Use WINAPP in place of the comment embedded directive.

19 Nov 2013 10:28 #13337

A large part of my sample program could be built into the ClearWin+ library via a new option %ch[vscrollbar]. There is also the potential for a similar horizontal scroll bar.

Please login to reply.