Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Two Questions

Two Questions

Scheduled Pinned Locked Moved Visual Basic
csharpcssregextutorial
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Quecumber256
    wrote on last edited by
    #1

    Hi Everyone: I have two questions: 1. I saw a trick using the Matrix class that will shift the Y-axis origin (0,0) from the top left hand corner to the bottom left hand corner. Can anyone provide the code for this? I can’t remember where I first saw it. 2. After I reset the Origins I would like to draw a grid pattern on the form. I would like the grid pattern to be adjustable. Does anyone know where I can find an example of this for VB.NET? Thanks in advance, Quecumber256

    D 1 Reply Last reply
    0
    • Q Quecumber256

      Hi Everyone: I have two questions: 1. I saw a trick using the Matrix class that will shift the Y-axis origin (0,0) from the top left hand corner to the bottom left hand corner. Can anyone provide the code for this? I can’t remember where I first saw it. 2. After I reset the Origins I would like to draw a grid pattern on the form. I would like the grid pattern to be adjustable. Does anyone know where I can find an example of this for VB.NET? Thanks in advance, Quecumber256

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      1. The origin is not moved on the form. It's moved (mathematically) when your object is being drawn. The transformation alters the coordinates of the drawn object, not the coordinates of the drawing surface. You can see an example of this here[^]. This particular example just moves the origin down and to the right 50 pixels. Look into the other methods exposed by the Transform class to move and orient the origin how you want. 2. This is a simple loop, For...Step...Next. The Step value is your "adjustibility". For exmaple, drawing line every other pixel would be:

      For I As Integer = 0 to 500 Step 2
         ....
      Next
      

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      Q 1 Reply Last reply
      0
      • D Dave Kreskowiak

        1. The origin is not moved on the form. It's moved (mathematically) when your object is being drawn. The transformation alters the coordinates of the drawn object, not the coordinates of the drawing surface. You can see an example of this here[^]. This particular example just moves the origin down and to the right 50 pixels. Look into the other methods exposed by the Transform class to move and orient the origin how you want. 2. This is a simple loop, For...Step...Next. The Step value is your "adjustibility". For exmaple, drawing line every other pixel would be:

        For I As Integer = 0 to 500 Step 2
           ....
        Next
        

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        Q Offline
        Q Offline
        Quecumber256
        wrote on last edited by
        #3

        Hi Dave, Thanks for the response. While I was waiting on an answer I continued to search the web and found the code using a Matrix to swap the y-axis to the bottom-left corner on the screen. Unfortunately, solving this problem lead directly into another. The new problem is: I'm playing around with a GDI+ application using VB.NET. I have written a small Windows application that will allow me to place a rectangle at the screen's origin (top-left corner of the screen). After the rectangle is placed I can point to it with my mouse and by holding down the left button move the selected rectangle elsewhere on the screen. This only works when the Y-Axis' location is at the top-left hand corner. I used a matrix transformation to reset the Y-Axis' origin to the bottom left hand corner. This time when I draw a rectangle it is placed at the bottom-left hand corner, but when I place my mouse on this rectangle it will not highlight saying this rectangle has been selected. The strange thing is: If I move the mouse back to the top-left corner where the default origin is the rectangle at the botton-left corner will highlight and when I press the left mouse button and move the mouse down the selected rectangle moves up. This is not how I want it to work. I have the project if you need it to see exactly want is happening. I wrote this for another discussion group, but I thought you would be interested in the problem that cropped up when I reset the origin to the bottom-left corner of the screen. Thanks, Quecumber256

        D 1 Reply Last reply
        0
        • Q Quecumber256

          Hi Dave, Thanks for the response. While I was waiting on an answer I continued to search the web and found the code using a Matrix to swap the y-axis to the bottom-left corner on the screen. Unfortunately, solving this problem lead directly into another. The new problem is: I'm playing around with a GDI+ application using VB.NET. I have written a small Windows application that will allow me to place a rectangle at the screen's origin (top-left corner of the screen). After the rectangle is placed I can point to it with my mouse and by holding down the left button move the selected rectangle elsewhere on the screen. This only works when the Y-Axis' location is at the top-left hand corner. I used a matrix transformation to reset the Y-Axis' origin to the bottom left hand corner. This time when I draw a rectangle it is placed at the bottom-left hand corner, but when I place my mouse on this rectangle it will not highlight saying this rectangle has been selected. The strange thing is: If I move the mouse back to the top-left corner where the default origin is the rectangle at the botton-left corner will highlight and when I press the left mouse button and move the mouse down the selected rectangle moves up. This is not how I want it to work. I have the project if you need it to see exactly want is happening. I wrote this for another discussion group, but I thought you would be interested in the problem that cropped up when I reset the origin to the bottom-left corner of the screen. Thanks, Quecumber256

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Like I said before, the transformation applies ONLY to the DRAWING of that particular object. It does NOT apply to mouse coordinates, nor does it apply to "hit testing" mouse coordinates in objects, nor does it apply to locating controls on the screen. As far as Windows is concerned, the object is right where it's supposed to be, in the top-left corner of the screen.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          Q 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Like I said before, the transformation applies ONLY to the DRAWING of that particular object. It does NOT apply to mouse coordinates, nor does it apply to "hit testing" mouse coordinates in objects, nor does it apply to locating controls on the screen. As far as Windows is concerned, the object is right where it's supposed to be, in the top-left corner of the screen.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008

            Q Offline
            Q Offline
            Quecumber256
            wrote on last edited by
            #5

            I was afraid of that.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups