Solved

Unable to send Parameters to Draw method in kodak imaging OCX

Posted on 2004-04-14
17
183 Views
Last Modified: 2010-04-06
I'm using the Kodak Imaging OCX
& trying to draw an image in it in VB.
When I write:
TestOcxImage.Draw leftPos, TopPos, 100, 100
it's working.

But when I write
TestOcxImage.Draw leftPos, TopPos, rightPos, bottomPos
The debugger writes: "Invalid values with width or height parameters".

I tried to define the parameters as integer, variant, long. but to no avail.

anyone has a solution to this strange behavior ?
0
Comment
Question by:MagicianH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
17 Comments
 
LVL 8

Expert Comment

by:shamstar
ID: 10822188
What annotation type are you using?
0
 

Author Comment

by:MagicianH
ID: 10823874
TestOcxImage.AnnotationType = 3 'rectangle stamp
0
 
LVL 8

Expert Comment

by:shamstar
ID: 10827053
how have you assigned values to rightPos and bottomPos, ideally, could you give the line of code you set the value for them on?
From the error message, I would just assume that you are using the wrong data type, maybe you have some speach marks somewhere where they shouldnt be?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:MagicianH
ID: 10830707
I'm copying to you the part of code that doesn't work
(with me trying to define the variables & without...)

    leftPos = 50
    TopPos = 50
'    Dim rightPos As Long
'    Dim bottomPos As Long
    rightPos = 100
    bottomPos = 100
    'if you will comment this line, the next line will work, amazing - no ?
    TestOcxImage.Draw leftPos, TopPos, rightPos, bottomPos
'    TestOcxImage.Draw leftPos, TopPos, 100, 100
0
 
LVL 8

Expert Comment

by:shamstar
ID: 10837925
Huummm... cant see anything obviously wrong there.  You said you have already tried declaring the variables as long (which is what they are supposed to be) but this didnt work.

The comment above the TestOcx line is interesting, do you actually mean that with that comment line there the code works fine but once you remove it you get the error (or another error) ?? Very strange.

Have you treid to see if there is an updated version of the control on the Kodak site, or even information bout this specific problem in their forums or FAQ's ??
0
 

Author Comment

by:MagicianH
ID: 10852203
I didn't see any information in the KODAK site or any way to download their updated version...

I'll try to send their support an email.
0
 
LVL 8

Expert Comment

by:shamstar
ID: 10854405
Yep.. that would be the next best thing to do :-)
Let me know what they say.
0
 

Author Comment

by:MagicianH
ID: 10868735
I found that my ActiveX expects a constant.
is there a way to send it a variable ?
0
 

Author Comment

by:MagicianH
ID: 10868923
I found out what I should do:

    Const rightPos As Variant = 100
    Const bottomPos As Variant = 100

that problem is that I want to send the ActiveX *variables*, not constants - is there a way to do it ?
0
 
LVL 8

Expert Comment

by:shamstar
ID: 10873856
The only way around the const problem that I can think of is by using pointers.  Since VB is anaged fairly tightly, you might not have come across pointers unless you've used it in another language.  But dont worry, its not really that difficult to do, and there isnt too much either.

I wont go into too much detail with explaining pointers since there are many places on the web that do that already.  If you do want more info on them then just ask.

Heres what you need to do:

1) Declare this function (copy and paste):
-------------------------------------------------
Public Declare Sub CopyMemoryWrite Lib "kernel32" Alias _
    "RtlMoveMemory" (Byval Destination As long, Source As Any, _
    ByVal Length As Long)
-------------------------------------------------

2) Declare a variable that will be used to point to your constant called rightPos for example.  Do this using the next line:
------------------------------------------------
Dim lngRightPointer As Long
------------------------------------------------

3) Set the pointer variable above to point to the rightPos constant:
------------------------------------------------
lngRightPointer = VarPtr(rightPos)
------------------------------------------------


4) Now to change the value of the rightPos constant:
------------------------------------------------
dim lngTemp as long
lngTemp = 10
CopyMemoryWrite lngRightPointer,lngTemp,2
------------------------------------------------

Thats all there is to it.  The rest of your code will still be the same, and you will still pass the rightPos and leftPos constants into the Draw function.  The only difference is that you can now change the value of the constant any number of times you like within your code by using the code shown in step 4.

Hopefully I've explained and given you enough code to get this working withing a few minutes.  I got a few of those lines of code from an article I read ages ago, but dont think its on the web anymore otherwise I would have given you that to read as well (its not much good on its own though).

Goodluck! :-)

0
 

Author Comment

by:MagicianH
ID: 10875577
Your solution is great, BUT...

it works only if I declare the rightPos with Dim, but when I declare it as constant,
I suppose windows blocks the operation of this method & it doesn't work.

other suggestions ?
0
 

Author Comment

by:MagicianH
ID: 10875620
Shauli from the VB forum gave me this amazing solution:

Const rightPos As Variant = 100
Const bottomPos As Variant = 100
Dim MyrightPos As Variant
Dim MybottomPos As Variant

' set to any number I want

MyrightPos = 321
MybottomPos = 432
TestImage.draw leftPos, topPos, rightPos + (MyrightPos - rightPos), bottomPos  + MybottomPos - bottomPos)
0
 
LVL 8

Expert Comment

by:shamstar
ID: 10878311
Well, I've tried a few things and Ive got no idea why the pointer thing doesnt work even with a constant.  Let me know if you still want me to have try a bit more to get that to work, otherwise you can use the above method, with a minor modificatoin... i.e. set the constants to be zero, that way it might make things easier for you in the code since you wont have to look at the numbers and do the subtractions.
0
 

Author Comment

by:MagicianH
ID: 10878623
I think that the windows "knows" that a variable is a contant & doesn't let the procedure to work.

Anyway, Since I have solution to my problem, you don't have to worry about it anymore :)
0
 
LVL 8

Expert Comment

by:shamstar
ID: 10878706
The problem in my suggestion was that the VarPtr does not return the correct address of constants, only of variables - so without the correct address the change isnt possible.
But since you're sorted now, you need to get this question closed, you can do this by making a post to the Community Support section of the site, provide a link to this question and ask them to refund your points and PAQ this question.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11958177
PAQed, with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
edit mp4 file 10 107
mpeg files joining and playing in order 7 191
video on my landing page in Wix 1 89
Need to compress an icon to a smaller file size 36 96
Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
In addition to being a great web-based presentation tool, Prezi also makes it easy to save your presentation as a PDF to share with others as well. Learn how in this tutorial. Select the share icon from the top menu in your Prezi editor: Select "D…
It’s easy to embed any of your public Prezi presentations on your website or social network to share with others. Learn how simple it is in this tutorial.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question