Announcement

Collapse
No announcement yet.

DDT SourceCode

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lance Edmonds
    replied
    CONTROL ADD SCROLLBAR syntax does allow you to specify a callback, but the callback is not able to be utilized.

    Instead, you intercept %WM_VSCROLL (for %SBS_VERT controls) or %WM_HSCROLL (for %SBS_HORZ) controls in the dialog callback, just like you would do with normal applications

    Code:
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
     
    %SBSTEPS = 9 ' 9 unique STEP positions in the scrollbar
    %ID_SCROLL = 102
     
    CALLBACK FUNCTION DlgCallback
        STATIC SI AS SCROLLINFO
          
        SELECT CASE CBMSG
            CASE %WM_INITDIALOG
                SI.cbSize = LEN(SI)
                SI.fMask  = %SIF_ALL
                SI.nMin   = 1
                SI.nMax   = 10 * %SBSTEPS ' 10 * 9 = 90 possible positions (1 to 90)
                SI.nPage  = (SI.nMax - SI.nMin) / %SBSTEPS
                SI.nPos   = (SI.nMax - SI.nMin) \ 2
                CONTROL SEND CBHNDL, %ID_SCROLL, %SBM_SETSCROLLINFO, %FALSE, VARPTR(SI)
     
            CASE %WM_COMMAND
                IF CBCTLMSG = %BN_CLICKED THEN
                    MSGBOX "You clicked a button! (Button ID=" & STR$(CBCTL) & ")"
                    DIALOG END CBHNDL, 1
                END IF
      
            CASE %WM_VSCROLL
                SELECT CASE LOWRD(CBWPARAM)
                    CASE %SB_LINEDOWN
                        INCR SI.nPos
                    CASE %SB_PAGEDOWN
                        SI.nPos = SI.nPos + Si.nPage
                    CASE %SB_LINEUP
                        DECR SI.nPos 
                    CASE %SB_PAGEUP
                        SI.nPos = SI.nPos - Si.nPage
                    CASE %SB_THUMBPOSITION, %SB_THUMBTRACK
                        SI.nPos = HIWRD(CBWPARAM)
                    CASE ELSE
                        EXIT FUNCTION
                END SELECT
     
                ' Ensure range is correct
                SI.nPos = MAX&(Si.nMin, MIN&(SI.nPos, Si.nMax - Si.nPage + 1))
     
                ' Update the scroll bar
                Si.fMask = %SIF_POS
                CONTROL SEND CBHNDL, %ID_SCROLL, %SBM_SETSCROLLINFO, %TRUE, VARPTR(Si)
                FUNCTION = 1
        END SELECT
    END FUNCTION
     
    FUNCTION PBMAIN
        DIM hdlg AS LONG
        DIALOG NEW 0, "SCROLLBAR Test By Lance Edmonds",,, 200, 100, %WS_SYSMENU OR %WS_CAPTION TO hDlg
        CONTROL ADD BUTTON, hDlg, 100, "Button 1", 10, 10, 50, 14
        CONTROL ADD BUTTON, hDlg, 101, "Button 2", 10, 31, 50, 14
        CONTROL ADD SCROLLBAR, hDlg, %ID_SCROLL, "", 190, 0, 10, 100, %SBS_VERT OR %SBS_RIGHTALIGN
        DIALOG SHOW MODAL hDlg CALL DlgCallback
    END FUNCTION
    * Posted to the Source Code forum too.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Paul Dwyer
    replied
    Lance,

    Thanks for the info, I looked up the API functions and I get the idea however I can't seem to use it like this"

    Code:
    Control Add ScrollBar, hfrm_ByteMaster&,  %HSCR_BYTEMARKER,  "", 72, 14, 154, 8, %WS_CHILD Or %WS_VISIBLE Or %SBS_HORZ  Call HSCR_BYTEMARKER
    Can't I use it lake the other "ADD CONTROL" functions with the CALL statement? This help file gap is most inconvenient as the scrollbar looks to work differently from the others !!

    There was almost no code doing a search, just a few tantalising tips



    ------------------
    Paul Dwyer
    Network Engineer
    Aussie in Tokyo

    Leave a comment:


  • Lance Edmonds
    replied
    The actual CONTROL ADD SCROLLBAR statement is the same as the other CONTROL ADD statements:
    Code:
    CONTROL ADD SCROLLBAR, hDlg, id, text$, x, y, xx, yy, style, exstyle
    Your callback will receive standard %WM_VSCROLL or %WM_HSCROLL messages. From that point, you need to use the SetScrollInfo() and GetScrollInfo() API's to set and get the scroll bar information as with conventional scrollbars. Just remember to use the %SB_CTL flag, since a DDT SCROLLBAR is a child control, rather than "part of the dialog".

    Search the BBS for "SetScrollInfo" and you should find some example code.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Paul Dwyer
    started a topic DDT SourceCode

    DDT SourceCode

    Does anyone have any source code for a DDT scroll bar? There seems to be a large hole in my PB6 help file.

    Apparently you can use:

    Control Add Scrollbar

    but then what??

    Thanks

    PS, Lance, is it my imagination or is the PB website been slower over the last couple of weeks?


    ------------------
    Paul Dwyer
    Network Engineer
    Aussie in Tokyo
Working...
X