Drawing a Image bigger then the screen

Discussion in 'Questions (Windows Mobile)' started by Georg, May 2, 2008.

  1. Georg

    Georg Member Licensed User


    I want to draw an Image bigger then the screen and have then scrollbars. I didn't found anything in the Treads. Someone can Help?

  2. Erel

    Erel Administrator Staff Member Licensed User

    This code moves a large image by dragging the mouse (the file is also attached):
    Sub Globals
    Dim x1,y1
    Dim maxX,maxY
    End Sub

    Sub App_Start
    "pic.jpg"'Loads the image to a Bitmap object
        rectDest.New1(5,5,form1.Width-10,form1.Height-10'The form's rectangle
        rectSrc.New1(0,0,rectDest.Width,rectDest.Height) 'The bitmap's rectangle
        maxX = bmpMap.Width - rectDest.Width
        maxY = bmpMap.Height - rectDest.Height
    End Sub

    Sub Form1_MouseDown (x,y)
        x1 = x
        y1 = y
    End Sub

    Sub Form1_MouseUp (x,y)
        RectSrc.X = 
    Min(maxX,Max(RectSrc.X - x + x1,0)) 'Checks the bounds and updates the coordinates
        RectSrc.Y = Min(maxY,Max(RectSrc.Y - y + y1,0))
    End Sub

    Sub DrawMap
    End Sub

    Attached Files:

    • Map.zip
      File size:
      51 KB
  3. agraham

    agraham Expert Licensed User

    This puts a big image on a smaller panel and uses the Door library to activate the Panel scroll bars.

    Attached Files:

  4. klaus

    klaus Expert Licensed User

  5. klaus

    klaus Expert Licensed User

    Hi Andrew,

    I had a look at your example. In this case are the LargeChange, SmallChange and Value parameters also accessible and be changed ?

    The landing of the F111 is somewhat risky, isn't it ?

    Thanks in advance
  6. agraham

    agraham Expert Licensed User

    Yes, they should be accessible through the HorizontalScroll and VerticalScroll properties of the Panel which are HScrollProperties and VScrollProperties types respectively. If you walk the Docs for Panel you should see them and their members.

    hscrollobj.value = pnl1obj.GetProperty(
    "HorizontalScroll"' returns an HScrollProperties type

    It's an Autralian one that sustained undercarriage damage on takeoff. They nearly dumped it in the sea but opted to belly it in after lightening it as much as possible. Surprisingly little damage was caused apparently!
  7. klaus

    klaus Expert Licensed User

    Thanks Andrew,
    I will use this in my Map display program

    Best regards.
  8. klaus

    klaus Expert Licensed User

    Hi Andrew,

    Following my previous question, is it possible to add the ValueChanged event to the panel's scrollbars and of course how?
    I did not succeed yet.

    Thank you in advance and Best regards.
  9. agraham

    agraham Expert Licensed User

    Unfortunately it looks like no :(.

    The Door library can see two scroll bar property objects but not the scroll bars themselves. This is because the Panel is a native control, and so are its' scroll bars and the scroll bars are not exposed as .NET controls - only the Panel itself is. There is a Scroll event for the panel for the desktop but not on the device. However even on the desktop this event can't be used as the Door library doesn't know about the ScrollEventHandler object which this event returns.
  10. agraham

    agraham Expert Licensed User

    Actually :)

    Using the dzEventsMagic library :D

    EDIT : Note that if you want to try this on the device that Line 14 should be changed to "MouseDown", as a Panel does not have a MouseClick event on the device, and lines 19,20 and 21 removed as on the device a Panel does not have HorizontalScroll and VerticalScroll properties. The scroll events will work.
    Last edited: May 26, 2008
  11. klaus

    klaus Expert Licensed User

    Thank you Andrew for your always valuable help.

    Best regards.
  12. mjcoon

    mjcoon Well-Known Member Licensed User

    I found that map.zip jolly useful starter-for-ten. I added a mouse_move method so I could watch the scrolling while the stylus was moving. But I found that when running on the desktop the method was triggered by the mouse "flying" over the panel without a mose-down event. Easily cured by making the movement conditional on having had a mouse-down, but a bit of a surprise since I presume that no device can have a flying stylus?

    Cheers, Mike.
  13. klaus

    klaus Expert Licensed User

    Yes on the desktop, if you don't want having the MouseMove event triggered always you should initiate a flag in the MouseDown event to enable it. In most cases you will need it anyway to show a reaction directly at MouseDown and not need to wait for a MouseMove.

    There is a small extension to this with some graphics samples on the french forum, post #3.

    Best regards.
  14. alea46

    alea46 Member Licensed User

    Becarefull for large size image

    When I start the program for my farm, I think there is no problem. But, when I try it on PPC (Asus 730), I got too big probems :
    :( Size of image : the PPC need 29Mo memory for a 3000x3000 (*) bitmap, no solution to decrease the memory size (I would make it smaller with only 4 colors, but it's impossible).
    :(Scrolling bar failed in error pnl1HScrollobj.value=pnl1obj.getproperty("horizontalscroll") error description : NullReferenceExeption.

    Is someone encounter same problem?
    Is someone have solution to this problem?

    The program is design to assist farmer on tractor to guide them with more or less precision (GPS error).

    (*) Note that 3000*3000 is the size I take to avoid problem to charge and discharge data for my Biggest Field within the scale I choose.
  15. agraham

    agraham Expert Licensed User

    That property does not exist on the device. See my post #10 in this thread
  16. alea46

    alea46 Member Licensed User

    How automatically focus on a pixel

    Thank's agraham for the precision.

    If it's impossible to fix scroolbars values, is there an issue to center map on the part that is drawing, whitout any manipulation, like it could be possible with scroolbar property?

    Thank's to Klaus who helps me in french forum to start.
  17. agraham

    agraham Expert Licensed User

    I am afraid that I can't find a way to do that on the device using the scroll bars. However a workaround is to forget about AutoScroll and position the image control on the Panel by setting the Top and Left properties to negative values. If you also want scrollbars then use the ones in ControlsEx and write the code to move the image around.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice