| Global HScroll:TGadget 'Horizontal Scroll Gadget Global sh:Int, sv:Int 'Scroller Horizontal and Vertical Values Global VScroll:TGadget 'Vertical Scroll Gadget |
| '-------------------------------------------------------- 'Create Vertical and Horizontal Scrollers for Main Canvas '-------------------------------------------------------- CreateScrollers() |
| Case EVENT_GADGETACTION Process_GadgetActionEvent |
| '--------------------------------------------- 'Create Vertical and Horizontal Scrollers for Main Canvas '--------------------------------------------- Function CreateScrollers() Local CW:int = GadgetWidth(Canvas1) Local CH:int = GadgetHeight(Canvas1) VScroll:TGadget=CreateSlider(CW,0,20,CH,MyWindow,SLIDER_VERTICAL) HScroll:TGadget=CreateSlider(0,CH,CW,20,MyWindow,SLIDER_HORIZONTAL) End Function |
| '--------------------------------------------- 'Function to Process EVENT_GADGETACTION '--------------------------------------------- Function Process_GadgetActionEvent:Int() Select EventSource() Case HScroll sh=EventData() pix:TPixmap=PixmapWin(PixMap1,sh,sv) RedrawGadget(Canvas1) Case VScroll sv=EventData() pix:TPixMap=PixmapWin(PixMap1,sh,sv) RedrawGadget(Canvas1) End Select End Function |
| '--------------------------------------------- 'Load the image - later on we will put in a File Requester 'Make a copy of the Pixmap for the canvas '--------------------------------------------- Function LoadCanvasImage(file:String="") If file="" file=RequestFile("Load Image File") PixMap1:TPixmap=LoadPixmap(file) If PixMap1=Null Then PixMap1=LoadPixmap("1945.bmp") 'loads default if fails EndIf Pix:TPixmap=PixmapWin(PixMap1,0,0) '-------------------------------------------------------- 'Since we know the size of the image we can set the slider range '-------------------------------------------------------- SetSliderRange VScroll,GadgetHeight(Canvas1),PixmapHeight(PixMap1) SetSliderRange HScroll,GadgetWidth(Canvas1),PixmapWidth(PixMap1) End Function |
![]() |