Simple Vector Drawing Application
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: Simple Vector Drawing Application

  1. #1
    Join Date
    Jul 2006
    Posts
    11

    Question Simple Vector Drawing Application

    Hi friends,
    Searched the internet for almost a week, but could not find a single simple example of vector drawing capabilities in Visual Basic 6.0.

    The program flow is simple.

    1. Draw vector shapes (Lines, rectangles, Bezier curves) in run time.
    2. Selecting the shapes.
    3. Modify the shape in real time.

    Can you help me in developing this simple but brain teasing application??

    Thanks in advance.

    Keep smiling

  2. #2
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Simple Vector Drawing Application

    Welcome to CodeGuru!

    I think the stuff you want to do is best done via win32 API. I'd first recommend looking at AllApi.net, and get the free Guide and the Viewer. It can take awhile to become comfortable with the API and how to use them, but once you get going, it quickly gets easier.

    Also, check out PlanetSourceCode.com for example projects. I'm sure there's plenty you will find useful there as well.

    Take your time with this one. It's not a simple one-week application. You may also find a project in progress by Rich2189 to be very helpful. Many of the basic concepts you'll be using are discussed in those threads at length.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  3. #3
    Join Date
    Jul 2006
    Posts
    11

    Re: Simple Vector Drawing Application

    Thanks Wizbang,
    I have been using APIguide since last year. OK, there are lots of functions to display graphics. But designing a vector graphics application requires much more depths of intelligence. I had thought of designing a drawing surface consisting of multiple layers with vector element assigned to each of a different layer, but things were getting more complicated. Right now I am working like this:
    1) Writing first to memoryDC
    2) Storing location points into vector array.
    3) Displaying it to the PictureBox.

    The problem is with dragging/ translating the vector surfaces. I will code more intensively to find the solutions.

    Let me know if you find some useful links for VB6.

    Where can get Rich2189 threads?

  4. #4
    Join Date
    Jul 2006
    Posts
    1

    Re: Simple Vector Drawing Application

    I am in the middle of developing a system like what you want to do. I know what you mean about taking you a week and still no info.

    This is what you need to do:

    1. When you draw you need to save your objects in a CollectionBase so you save the object you drew on the PictureBox (I assume).
    2. Widen the GraphicPath (so you can detect when the mouse is over a line. If it other than line you dont have to winden)
    3. When you click on the object (mouse down event handler) loop the collectionbase and test for mouse-object intersection using Isvisible.
    4. Bingo...now you knew which object was selected and you can do whatever you want, resize it, delete it, change its attributes...etc

    I dont have any code to give you right now. As I said, I just started my program. Hopefully, soon I will post the code.

    I hope that helped. Also, visit this site http://www.bobpowell.net it is a great GDI+ site.

    Finally, Please share with us your code when you have it working

  5. #5
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,091

  6. #6
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: Simple Vector Drawing Application

    Great Links!
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Jul 2006
    Posts
    11

    Re: Simple Vector Drawing Application

    Hi SamerAZ,
    I am using GDI+ with Visual Basic 6.0. I had visited Bob Powell article. It requires VB.Net. I want to do this application in VB 6.0. No doubt, we have to store the graphics object in a collection array. I will post the progress as soon I finish each functional step. Thanks.

    Hi HanneSThEGreaT,
    I studied the links you you posted. Well drawing is not the problem. Storing the drawings in transparent layers, and selecting the layer for manipulating the vector drawing is what required. Vector Graphics ActiveX control is a very good control, but we have to write the code from scratch. Thanks and stay in touch.

  8. #8
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Simple Vector Drawing Application

    Here are some links to the threads I was referring to:
    http://www.codeguru.com/forum/showthread.php?t=376458
    http://www.codeguru.com/forum/showthread.php?t=385576
    http://www.codeguru.com/forum/showthread.php?t=389584

    Those should help with keeping track of where objects are and such.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  9. #9
    Join Date
    Jul 2006
    Posts
    11

    Lightbulb Re: Simple Vector Drawing Application

    Hi WizBang,
    Thanks for the threads. Seems important. Just gone through the image manipulation thread.

    I have surfed another site : Hope it will help others involved in visual basic graphic programming:

    http://edais.mvps.org/Tutorials/index.html

  10. #10
    Join Date
    Oct 2005
    Location
    England
    Posts
    803

    Re: Simple Vector Drawing Application

    You probably already do this but heres a tip, if you have any mathamatical functions always work out some test examples on paper, then code a test function. Test the fucntion till your fingers fall off. Then and only then put it into your main code.

    @Wiz, progress well i'm coding hard just to stay still, I keep finding new ways to code whole sections. So im not actually getting anywhere just making what I have better .
    Rich

    Visual Studio 2010 Professional | Windows 7 (x64)
    Ubuntu

  11. #11
    Join Date
    Jul 2006
    Posts
    11

    Question Simple Vector Drawing Application

    Hi everybody!
    A lot of days have passed while developing this vector drawing application.
    Wizbang, If you are there, you had said right.. This is not a one week application. Studying lot of GDI+ examples, applying various logics, I am near to complete this application. Well, the application can now:
    1) Draw lines, curves, ellipses, rectangles, polygons.
    2) Store all these in Path collection.
    3) Perform hit test.
    4) Drag the object, Rotate the object, modify the nodes in curves by dragging,deleting, adding the nodes. Paths can be deleted and added.

    5) Now comes the difficult task:

    Scaling The Matrix.

    Well, Scale method of the matrix takes horizontal scale factor and vertical scale factor. If we want to double the size of say rectangle in horizontal direction, we send a value of 2 to the scaleX factor. But I want to gradually increase the value from 1 to 2 depending on the dragging of RESIZING HANDLE using MouseMove event. The code is working perfect if I send the value 2 directly in MouseUp event. But when I send the gradual values using the MouseMove event, the scaling gets on doubled at each pixel difference.

    Anybody out there who has worked out a similar problem while scaling objects in individual directions ?????

    Keep smiling.
    mahesh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center