using_20a_20pager_20control
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
using_20a_20pager_20control [2018/03/31 13:19] – external edit 127.0.0.1 | using_20a_20pager_20control [2024/01/05 00:21] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 2: | Line 2: | ||
//by Richard Russell, July 2010//\\ \\ A [[http:// | //by Richard Russell, July 2010//\\ \\ A [[http:// | ||
+ | <code bb4w> | ||
INSTALL @lib$+" | INSTALL @lib$+" | ||
INSTALL @lib$+" | INSTALL @lib$+" | ||
Line 28: | Line 29: | ||
iccx.dwICC% = ICC_PAGESCROLLER_CLASS | iccx.dwICC% = ICC_PAGESCROLLER_CLASS | ||
SYS " | SYS " | ||
+ | </ | ||
Note that **WINLIB2** is installed for the purpose of creating the dialogue box; it is not required for the pager control itself. The **ON CLOSE** and **ON ERROR** statements ensure that the dialogue box is closed when the program is terminated. The **PROCcleanup** routine is listed below.\\ \\ The next step is to create the pager control: | Note that **WINLIB2** is installed for the purpose of creating the dialogue box; it is not required for the pager control itself. The **ON CLOSE** and **ON ERROR** statements ensure that the dialogue box is closed when the program is terminated. The **PROCcleanup** routine is listed below.\\ \\ The next step is to create the pager control: | ||
+ | <code bb4w> | ||
x% = 100 | x% = 100 | ||
y% = 100 | y% = 100 | ||
Line 36: | Line 39: | ||
\ 0, PGS_VERT OR WS_BORDER, 0) | \ 0, PGS_VERT OR WS_BORDER, 0) | ||
IF hPager% = 0 ERROR 100, " | IF hPager% = 0 ERROR 100, " | ||
+ | </ | ||
The position and size have been set to arbitrary values for the purpose of the demonstration. The **PGS_VERT** style signifies that the pager control allows vertical scrolling; if you want to enable horizontal scrolling specify the **PGS_HORZ** style (you cannot enable both at the same time).\\ \\ The appearance of the pager control and its scroll buttons can be changed by sending various messages; see this [[http:// | The position and size have been set to arbitrary values for the purpose of the demonstration. The **PGS_VERT** style signifies that the pager control allows vertical scrolling; if you want to enable horizontal scrolling specify the **PGS_HORZ** style (you cannot enable both at the same time).\\ \\ The appearance of the pager control and its scroll buttons can be changed by sending various messages; see this [[http:// | ||
+ | <code bb4w> | ||
Dialog% = FN_newdialog(" | Dialog% = FN_newdialog(" | ||
id% = 100 | id% = 100 | ||
Line 45: | Line 50: | ||
NEXT x% | NEXT x% | ||
NEXT y% | NEXT y% | ||
+ | </ | ||
Before we display the dialogue box we need to perform a little magic on its template: | Before we display the dialogue box we need to perform a little magic on its template: | ||
+ | <code bb4w> | ||
Dialog%!16 = (Dialog%!16 AND NOT (WS_POPUP OR WS_DLGFRAME)) OR \ | Dialog%!16 = (Dialog%!16 AND NOT (WS_POPUP OR WS_DLGFRAME)) OR \ | ||
\ WS_CHILD OR CCS_NORESIZE | \ WS_CHILD OR CCS_NORESIZE | ||
!(Dialog%!4+8) = hPager% : REM Set parent | !(Dialog%!4+8) = hPager% : REM Set parent | ||
PROC_showdialog(Dialog%) | PROC_showdialog(Dialog%) | ||
+ | </ | ||
The first line modifies the dialogue box's style; in particular the title bar is removed and it is made a child window. The second line sets the dialogue box's parent to be the pager control we created earlier.\\ \\ We have to tell the pager control the dimensions of the child window it contains, so it can calculate when to display the scroll buttons. This is done as follows: | The first line modifies the dialogue box's style; in particular the title bar is removed and it is made a child window. The second line sets the dialogue box's parent to be the pager control we created earlier.\\ \\ We have to tell the pager control the dimensions of the child window it contains, so it can calculate when to display the scroll buttons. This is done as follows: | ||
+ | <code bb4w> | ||
DIM rc{l%, | DIM rc{l%, | ||
SYS " | SYS " | ||
PROCsetnotify(rc.r%-rc.l%, | PROCsetnotify(rc.r%-rc.l%, | ||
+ | </ | ||
The **PROCsetnotify** routine is listed below.\\ \\ There is just one more step, which is to ' | The **PROCsetnotify** routine is listed below.\\ \\ There is just one more step, which is to ' | ||
+ | <code bb4w> | ||
SYS " | SYS " | ||
+ | </ | ||
Now the pager control, containing the scrollable dialogue box, should be displayed. The rest of the program is simulated by this simple loop: | Now the pager control, containing the scrollable dialogue box, should be displayed. The rest of the program is simulated by this simple loop: | ||
+ | <code bb4w> | ||
REPEAT | REPEAT | ||
WAIT 0 | WAIT 0 | ||
UNTIL FALSE | UNTIL FALSE | ||
END | END | ||
+ | </ | ||
In practice you will want to do something rather more useful!\\ \\ Here are the listings of the **PROCsetnotify** and **PROCcleanup** routines: | In practice you will want to do something rather more useful!\\ \\ Here are the listings of the **PROCsetnotify** and **PROCcleanup** routines: | ||
+ | <code bb4w> | ||
DEF PROCsetnotify(iWidth%, | DEF PROCsetnotify(iWidth%, | ||
LOCAL L%, P%, oldwndproc, newwndproc, exit, notify | LOCAL L%, P%, oldwndproc, newwndproc, exit, notify | ||
Line 91: | Line 106: | ||
hPager% += 0 : IF hPager% PROC_closewindow(hPager%) | hPager% += 0 : IF hPager% PROC_closewindow(hPager%) | ||
ENDPROC | ENDPROC | ||
+ | </ | ||
Needless to say, you should incorporate in the **PROCcleanup** routine any cleanup operations needed by the rest of your program. | Needless to say, you should incorporate in the **PROCcleanup** routine any cleanup operations needed by the rest of your program. |
using_20a_20pager_20control.1522502388.txt.gz · Last modified: 2024/01/05 00:16 (external edit)