Solved

Unable to send Parameters to Draw method in kodak imaging OCX

Posted on 2004-04-14
17
177 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
  • 8
  • 7
17 Comments
 
LVL 8

Expert Comment

by:shamstar
Comment Utility
What annotation type are you using?
0
 

Author Comment

by:MagicianH
Comment Utility
TestOcxImage.AnnotationType = 3 'rectangle stamp
0
 
LVL 8

Expert Comment

by:shamstar
Comment Utility
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
 

Author Comment

by:MagicianH
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Yep.. that would be the next best thing to do :-)
Let me know what they say.
0
 

Author Comment

by:MagicianH
Comment Utility
I found that my ActiveX expects a constant.
is there a way to send it a variable ?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:MagicianH
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed, with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 this Micro Tutorial viewers will learn the basic shortcuts and functions of Illustrator. The viewer will learn about the paintbrush tool, anchor points, font sizing, and more.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now