OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   double click to add point.. (http://forum.oberonplace.com/showthread.php?t=4440)

flyer 13-12-2007 00:08

double click to add point..
 
Been programming in VB, but new to VBA with corel x3.

to start what I want to do, I have to insert a node in a existing path, at a point where I double click, (like double clicking in shape tool mode). I will be doing a few things with that point once created, so I need to reference this new point in my code. I need to do this in the VBA code, since I will be creating quite a few new nodes to do what I want.

Once I get to this point, I should be OK.. Just hitting a road block getting started.:confused:

Thanks.

wOxxOm 13-12-2007 06:25

something like this, a non-tested rip from my working macros. All the function dealing with x,y have optional parameter specifying hotArea, play with it to determine the one you need.

I'm not sure about double-clicking event interception...Depends on your workflow with the macro, personally for a single-op. macros I prefer such procedure: hover a mouse over a shape, press a hotkey invoking the macro. And of course in my case the macro uses GetCursorPos winapi instead of GetUserClick.
Code:

sub AddNode()
dim x#, y#, shift&, sh as Shape, seg as Segment, offs&, N as Node

If ActiveDocument.GetUserClick(x, y, shift, 10, True, cdrCursorWinCross) <> 0 Then Exit Sub

with ActivePage.SelectShapesAtPoint(x, y, 0).Shapes
  if .Count=0 then exit sub
  set sh=.Item(.Count)
end with

if sh.IsOnShape(x,y)<>cdrOnMarginOfShape then exit sub

set seg=FoundShape.Curve.FindSegmentAtPoint(x,y,Offs)

set N=seg.AddNodeAt(Offs)


flyer 13-12-2007 16:16

Quote:

Originally Posted by wOxxOm (Post 11376)
something like this, a non-tested rip from my working macros. All the function dealing with x,y have optional parameter specifying hotArea, play with it to determine the one you need.

I'm not sure about double-clicking event interception...Depends on your workflow with the macro, personally for a single-op. macros I prefer such procedure: hover a mouse over a shape, press a hotkey invoking the macro. And of course in my case the macro uses GetCursorPos winapi instead of GetUserClick.
Code:

sub AddNode()
dim x#, y#, shift&, sh as Shape, seg as Segment, offs&, N as Node

If ActiveDocument.GetUserClick(x, y, shift, 10, True, cdrCursorWinCross) <> 0 Then Exit Sub

with ActivePage.SelectShapesAtPoint(x, y, 0).Shapes
  if .Count=0 then exit sub
  set sh=.Item(.Count)
end with

if sh.IsOnShape(x,y)<>cdrOnMarginOfShape then exit sub

set seg=FoundShape.Curve.FindSegmentAtPoint(x,y,Offs)

set N=seg.AddNodeAt(Offs)



ok, double click is not needed in macro to do what I want to do, sorry.

Where are you finding "FoundShape.Curve.FindSegmentAtPoint"??? I have looked through the Docs I have and find nothing like any of the 3 objects. As written "Offs" gives an error as argument, BTW.

This is pretty much what I was looking for and coudn't find it. That appears to be my road block.

Thanks for helping out. I appreciate it.

wOxxOm 13-12-2007 16:28

1. set seg=sh.Curve.FindSegmentAtPoint(x,y,Offs)
2. Offs must be declared as Double (Offs#)
3. I use F2 class browser and search within it

Good luck :-)

flyer 13-12-2007 16:48

much better....
 
Thanks. much better. I gather that FoundShape was defined elsewhere in your macro??? I still cant find it, in object browser, or anywhere...

I was looking everywhere (segment, subpath, node, etc) but not "curve" sheesh...

Thanks

Maybe I can leave you alone for a while..

Don

wOxxOm 13-12-2007 16:54

:-) FoundShape is a dummy name, I've changed it to sh which is my fave for such an object, yet missed that line when changing


All times are GMT -5. The time now is 07:45.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com