Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

MouseMove over Image - problem

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-03-2008, 11:58 AM
Knows the basics
 
Join Date: Jun 2008
Location: Barneveld, NL
Posts: 78
Default MouseMove over Image - problem

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
File Type: sbp BigImage-v2.sbp (3.2 KB, 16 views)
Reply With Quote
  #2 (permalink)  
Old 11-03-2008, 01:20 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

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

Best regards.
Attached Files
File Type: zip DrawOnBigBitmap.zip (167.1 KB, 38 views)
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #3 (permalink)  
Old 11-03-2008, 01:40 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

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

Code:
Sub img1mve_NewEvent
  <font color=
"Red">img1obj.Value = img1mve.Data</font>
  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/addit...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|*.*"
Reply With Quote
  #4 (permalink)  
Old 11-03-2008, 02:37 PM
Knows the basics
 
Join Date: Jun 2008
Location: Barneveld, NL
Posts: 78
Default

Thanks, that fixed it! I still need to get my head round the "why" part - but that will come with practise I hope
Reply With Quote
  #5 (permalink)  
Old 11-03-2008, 03:09 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by DaveW View Post
I still need to get my head round the "why" part -
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.
Reply With Quote
  #6 (permalink)  
Old 11-03-2008, 03:41 PM
Knows the basics
 
Join Date: Jun 2008
Location: Barneveld, NL
Posts: 78
Default

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

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!
Reply With Quote
  #7 (permalink)  
Old 11-03-2008, 03:53 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

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?
Reply With Quote
  #8 (permalink)  
Old 11-03-2008, 04:23 PM
Knows the basics
 
Join Date: Jun 2008
Location: Barneveld, NL
Posts: 78
Default

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!
Reply With Quote
  #9 (permalink)  
Old 11-03-2008, 04:49 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Your error message is a secondary error as your device doesn't have the error messages intalled to save space. See here http://www.basic4ppc.com/forum/quest....html#post4461

I do have the messages on my device and it is line 20. I should have remembered this as it has come up before on this app. See post #10 here http://www.basic4ppc.com/forum/quest....html#post4461 for the changes to run on a device.
Reply With Quote
  #10 (permalink)  
Old 11-04-2008, 08:08 AM
Knows the basics
 
Join Date: Jun 2008
Location: Barneveld, NL
Posts: 78
Default

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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem: fetch and store image to/from database willisgt Questions (Windows Mobile) 2 05-13-2008 03:10 PM
Image problem with ImageButtons klaus Bug Reports 3 02-15-2008 08:10 AM
Image size problem agraham Bug Reports 4 10-24-2007 05:40 PM
Move an image inside an image control Cableguy Questions (Windows Mobile) 5 05-14-2007 07:40 PM


All times are GMT. The time now is 03:04 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0