MouseMove over Image - problem

Discussion in 'Questions (Windows Mobile)' started by DaveW, Nov 3, 2008.

  1. DaveW

    DaveW Active Member Licensed User

    Hi,

    I am a Newbie to Basic4PPC so sorry if this is a dumb question!!

    I have modified the BigImage program I found elsewhere on the forum to add some more functionality. I hav added zooming to it and wanted to add a readout of mouse position over the image. However I have been unable to make this work. I have followed all the examples I can find on the forum and elsewhere but get an error:

    "Object Reference not set to an instance of an object."

    The relevant code is:

    Sub App_Start
    ......
    img1obj.New1(False)
    img1obj.FromControl("Image1")
    img1mve.New1(img1obj.Value,"MouseMove")
    .......

    Sub img1mve_NewEvent
    x = img1obj.GetProperty("X") '<error here!
    y = img1obj.GetProperty("Y")
    label1.Text = x
    label2.Text = y
    End Sub

    Can anyone help get me on the right track?

    David.
     

    Attached Files:

  2. klaus

    klaus Expert Licensed User

    You can have a look at this sample program.
    It's based on agraham BigImage program

    Best regards.
     

    Attached Files:

  3. agraham

    agraham Expert Licensed User

    You need to assign the eventargs of the event to an object before you try to access them

    Code:
    Sub img1mve_NewEvent
      [COLOR=
    "Red"]img1obj.Value = img1mve.Data[/COLOR]
      x = img1obj.GetProperty(
    "X")
      y = img1obj.GetProperty(
    "Y")
      label1.Text = x
      label2.Text = y
    End Sub
    I also note that you are using dzImage.dll on the desktop, it should be dzImageDesktop.dll. Make sure you have got the latest version from post #30 here http://www.basic4ppc.com/forum/additional-libraries/1403-dzimage-library-3.html.

    You should also assign a filter to the OpenDialog to define the files types you want to open.
    Code:
    OpenDialog1.Filter = "Picture Files|*.bmp;*.jpg|Text Files|*.txt|All Files|*.*"
     
  4. DaveW

    DaveW Active Member Licensed User

    Thanks, that fixed it! I still need to get my head round the "why" part - but that will come with practise I hope :)
     
  5. agraham

    agraham Expert Licensed User

    In your code img1obj contains a reference to your Image1 control. img1mve is an event object, owned by img1obj, that calls NewEvent when the mouse moves over the image.

    Each event has an eventargs object assoicated with it that contains none, one or more details of the event depending upon the event type. In this case X and Y are properties of the eventargs belonging to the img1mve event. You cannot access these properties through img1obj, you must get them from the eventargs of the img1mve event and for this reason these are exposed to you by the Data property of the img1mve event object.

    The Door library is not intended for routine use by "normal" programmers. To use it, other than by example, needs reasonably in-depth knowledge of the underlying .NET Common Language Runtime and its objects, and knowledge of how to access its documentation and understand it once you have found it. The library is provided so that features of objects that are desired to be used when they are not exposed by Basic4ppc or its libraries can be accessed without having to implement them in a library upgrade. The major "users" of this library are probably Erel and myself on behalf of other users.
     
  6. DaveW

    DaveW Active Member Licensed User

    Thanks for the excellent explanation of the 'why' !

    I realise that Door was not really intended for the likes of me - but someone opened Pandora's Box and now we (i.e. you ;) ) have to live with it :D

    Having got the Desktop version of the posted code working, I made the Setup and Install files using the SetupBuilder program, I put the dlls (dzEventsMagic, Door, dzImage, ImageLib) and exe in the installer and installed the app on my PDA. However I get a NullReferenceException when I try to open an image. If I say continue the image appears but the ScrollBars do not. This seems to indicate that the errors is in the 'door' bit still.

    I know that bugfixing idiot's code is not your job, but I would be very impressed if you (or anyone) could offer more help!
     
  7. agraham

    agraham Expert Licensed User

    Its always as well to post the actual code that is failing. Try running the app in the IDE on the device, this should give you the line number that is failing and therefore a better idea of what is wrong.

    EDIT :- You did compile the exe for the device didn't you?
     
  8. DaveW

    DaveW Active Member Licensed User

    I would like to have posted the actual code that is failing but that was all I saw. I have been trying to run the app in the PDA IDE but without success. I just get an error message "An error occured. No error message can be given because an optional source files cannot be found." (or something like that - I have a Dutch language PDA!)

    The app is identical to the one the posted at teh start of this thread with the one fix you suggested: img1obj.Value = img1mve.Data

    And yes, I have compiled the app - though I confess I did miss that the first couple of times! :D
     
  9. agraham

    agraham Expert Licensed User

  10. DaveW

    DaveW Active Member Licensed User

    Thanks for the excellent help!

    It turned out that the problems were a combination of newbie stuff - mainly missing DLLs on the PDA and some overly complex code. Once I got the DLLs copied over and removed all the stuff about getting the Scrollbar position and Maximum, the whole thing works fine :)
     
  11. agraham

    agraham Expert Licensed User

Loading...
  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