Announcement

Collapse
No announcement yet.

Scrollbar and Bitmap

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

  • Scrollbar and Bitmap

    hi folks
    I'am a new in the forum an I would like to say hello to You.
    I live in Switzerland and work in a ordinary office an do some easy "programming". To be honest, i mainly use PB Forms and put some code afterwards in.

    I'have been using Powerbasic 8.01 and PowerbasicForms 1.51 for about 2 years.
    There is a big problem, that i cannot solve. Never found a proper sample somewhere, that exactly solved my big problem. Maybe there is someone of you, who can help me.
    1)
    I would like to show a Bitmap in a resizable window, that has the horizontal and vertical scrollbars.
    2)
    The Bitmap comes "out of a ressource file". (I know how to put that BMP in that ressource file.
    How can I show that bitmap?
    How can I use the scrollbars, hiding when the are not used and the Bitmap fits in to that window or showing them when the Bitmap is bigger than the surrounding window itself.

    I am not able to solve that problem, it bothers me for such a long time.
    I would lik to make a simple Infoprogram, containing a map of certain regions from the first world war.
    But I cannot start with that project when im not able to solve the main problem.
    I hope someone of you can help me, please.

  • #2
    Hi Urs,

    Here are a couple of links that might get you started...
    http://www.powerbasic.com/support/fo...ML/000831.html -Second post.
    http://www.powerbasic.com/support/fo...ML/013831.html
    http://www.powerbasic.com/support/fo...ML/002629.html
    Plus one more for good measure
    http://www.powerbasic.com/support/fo...ML/000743.html
    Last edited by Dave Biggs; 8 Jan 2008, 09:20 AM.
    Rgds, Dave

    Comment


    • #3
      Scrollbar and Bitmap

      Originally posted by Dave Biggs View Post

      Hi Dave
      I've tested the Sample-Programs profided with your links. They are great, Most I like the one with the rotating Bitmap. For the things i'd like to do is the last one, that can be resized to fullscreen and has the red boxes. One can even zoom in and out. There is still ohne question. Can I append a Bitmap FROM A RESSOURCE-FILE to that grafic-window? Is that possible?

      Have a nice day an thanks again.

      Comment


      • #4
        Here's a modified version of one of Seme's posts which uses a Bitmap from a resource file..
        Code:
         'TT Jules and Semen: [URL]http://www.powerbasic.com/support/forums/Forum7/HTML/000743.html[/URL]
        #Compile Exe
        #Dim All
        #Register None
        #Include "WIN32API.INC"
        #Resource "ScrollBmpTest.pbr"         ' See .rc file below
         
        %IDR_IMGFILE1 = 102
        %BTN_BUTTON1  = 103
        '------------------/
         
        CallBack Function DlgProc1
          Select Case CbMsg
            Case %WM_INITDIALOG
              Static hDlg2 As Long, siSz As POINTAPI, siPg As POINTAPI, siLn As POINTAPI
         
              Dialog New CbHndl, "", 0, 0, 700, 600, %WS_CHILD Or %WS_CLIPCHILDREN To hDlg2  ' Image window
              Control Add ImageX, hDlg2, %IDR_IMGFILE1, "#" + Format$(%IDR_IMGFILE1), 0, 0, 710, 630
         
              Dialog Show Modeless hDlg2
         
              Dim rc1 As RECT, rc2 As RECT
              GetClientRect CbHndl, rc1
              siPg.X = rc1.nRight - rc1.nLeft
              siPg.Y = rc1.nBottom - rc1.nTop
         
              GetWindowRect hDlg2, rc2
              siSz.X = rc2.nRight - rc2.nLeft
              siSz.Y = rc2.nBottom - rc2.nTop
         
              siLn.X = 0.1 * siPg.X ' 10% of page
              siLn.Y = 0.1 * siPg.Y ' 10% of page
         
              Static siX As SCROLLINFO, siY As SCROLLINFO
              siX.cbsize = SizeOf(siX)
              siX.nMin = 0
              siX.nPage = siPg.X
              siX.fMask =  %SIF_RANGE Or %SIF_PAGE
              siX.nMax = siSz.X
              SetScrollInfo CbHndl, %SB_HORZ, siX, %False
         
              siY = siX
              siY.nPage = siPg.Y
              siY.nMax = siSz.Y
              SetScrollInfo CbHndl, %SB_VERT, siY, %False
         
            Case %WM_HSCROLL
              Local siRefresh As Long
              Select Case LoWrd(CbWparam)
                Case %SB_LINELEFT   : siX.nPos = siX.nPos - siLn.X: siRefresh = 1
                Case %SB_LINERIGHT  : siX.nPos = siX.nPos + siLn.X: siRefresh = 1
                Case %SB_PAGELEFT   : siX.nPos = siX.nPos - siPg.X: siRefresh = 1
                Case %SB_PAGERIGHT  : siX.nPos = siX.nPos + siPg.X: siRefresh = 1
                Case %SB_THUMBTRACK : siX.nPos = HiWrd(CbWparam)
                Case Else           :  Exit Function
              End Select
              siX.nPos = Max(siX.nPos, 0): siX.nPos = Min(siX.nPos, siSz.X - siPg.X)
              siX.fMask = %SIF_POS
              SetScrollInfo CbHndl, %SB_HORZ, siX, siRefresh
              SetWindowPos hDlg2, 0, -siX.nPos, -siY.nPos, 0, 0, %SWP_NOSIZE Or %SWP_NOZORDER Or %SWP_NOACTIVATE
              'SetWindowText GetParent(CbHndl), "PosX =" + Str$(siX.nPos) + " PosY =" + Str$(siY.nPos) + " (pixels)"
         
            Case %WM_VSCROLL
              Select Case LoWrd(CbWparam)
                Case %SB_LINEUP     : siY.nPos = siY.nPos - siLn.Y: siRefresh = 1
                Case %SB_LINEDOWN   : siY.nPos = siY.nPos + siLn.Y: siRefresh = 1
                Case %SB_PAGEUP     : siY.nPos = siY.nPos - siPg.Y: siRefresh = 1
                Case %SB_PAGEDOWN   : siY.nPos = siY.nPos + siPg.Y: siRefresh = 1
                Case %SB_THUMBTRACK : siY.nPos = HiWrd(CbWparam)
                Case Else           : Exit Function
              End Select
              siY.nPos = Max(siY.nPos, 0): siY.nPos = Min(siY.nPos, siSz.Y - siPg.Y)
              siY.fMask = %SIF_POS
              SetScrollInfo CbHndl, %SB_VERT, siY, siRefresh
              SetWindowPos hDlg2, 0, -siX.nPos, -siY.nPos, 0, 0, %SWP_NOSIZE Or %SWP_NOZORDER Or %SWP_NOACTIVATE
              'SetWindowText GetParent(CbHndl), "PosX =" + Str$(siX.nPos) + " PosY =" + Str$(siY.nPos) + " (pixels)"
         
            CASE %WM_MOUSEWHEEL
             LOCAL zDelta AS INTEGER
              zDelta = HIWRD(CbWparam)
         
              IF (LOWRD(CbwParam) AND %MK_CONTROL) = %MK_CONTROL THEN   'horizontal scroll
                IF zDelta > 0 THEN                                      'scroll to the left
                  SendMessage CbHndl, %WM_HSCROLL, MAKLNG(%SB_LINELEFT, 0), 0
                ELSE                                                    'scroll to the right
                  SendMessage CbHndl, %WM_HSCROLL, MAKLNG(%SB_LINERIGHT, 0), 0
                END IF
              ELSE                                                      'vertical scroll
                IF zDelta > 0 THEN                                      'scroll upwards
                  SendMessage CbHndl, %WM_VSCROLL, MAKLNG(%SB_LINEUP, 0), 0
                ELSE                                                    'scroll downwards
                  SendMessage CbHndl, %WM_VSCROLL, MAKLNG(%SB_LINEDOWN, 0), 0
                END IF
              END IF
         
           End Select
        End Function 
        '------------------/
         
        CallBack Function DlgProc
          Select Case CbMsg
            Case %WM_INITDIALOG
              Local hDlg1 As Long
              Dialog New CbHndl, "", 10, 10, 280, 280, %WS_CHILD Or %WS_VISIBLE Or %WS_CLIPCHILDREN Or _
                %WS_HSCROLL Or %WS_VSCROLL, %WS_EX_CLIENTEDGE Or %WS_VSCROLL To hDlg1   ' Scroll Container
              Dialog Show Modeless hDlg1  Call DlgProc1
          End Select
        End Function 
        '------------------/
         
        Function PbMain
         Local hDlg As Long
          Dialog New 0,"Scroll Bmp Test",,, 300, 300, %WS_CAPTION Or %WS_SYSMENU Or %WS_CLIPSIBLINGS To hdlg
          Dialog Show Modal hdlg Call DlgProc
        End Function 
        '------------------/
         
        #If 0
        //Bitmap Resource File - ScrollBmpTest.rc
        #define IDR_IMGFILE1  102
        IDR_IMGFILE1  BITMAP DISCARDABLE "C:\Windows\Gone Fishing.bmp"
        #ENDIF
        Rgds, Dave

        Comment

        Working...
        X