Results 1 to 10 of 10

Thread: How do I?

  1. #1

    Thread Starter
    Addicted Member killer_cobra's Avatar
    Join Date
    Jun 2001
    Location
    Lost in space
    Posts
    131

    How do I?

    Hi all,

    I am wondering how I can make a virtual invisible grid on an image control.

    Example:

    I have an image control that is 6000 x 4000, and I want the grid to be say 640x480 but span the whole image control. So if I were to click on the very top left corner of the image in the control, I could get the grid co-ordonates and they would be something like : 632x478.

    I hope this is enough to go on, it's a hard question to explain, but that is my attemp. I imagine there would be some sort of API or math function that would let me do this, but I know not of them.

    Thanx a million in advance,

    Scott
    Error... What Error?!?! I've only typed a single character!
    ______________________________
    VB 6.0 EE, Win 2k Pro on AMD Duron 1Ghz/ 384 MB SDRAM

  2. #2
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    um....that's kinda confusing.


    What do you mean by
    I have an image control that is 6000 x 4000...

  3. #3

    Thread Starter
    Addicted Member killer_cobra's Avatar
    Join Date
    Jun 2001
    Location
    Lost in space
    Posts
    131

    I mean this...

    I mean the property values for width and height of the image control.

    I set them for 6000 x 4000.
    Error... What Error?!?! I've only typed a single character!
    ______________________________
    VB 6.0 EE, Win 2k Pro on AMD Duron 1Ghz/ 384 MB SDRAM

  4. #4
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    Well...you have to convert those to twips, and then set the form to full-screen or something.

    Then, you have to determind the coordinates of the mouse (mouse x, mouse y, in the mouse_move event, I think.) and add 6000 or 4000 to it.

  5. #5
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Don't do that!

    Convert your scale mode for both the form and picture box to 3-Pixels. Twips are bloody gay. There is no visible change except for every 15 twips, which = 1 pixel. Why have a gay scale that doesn't do anything?

    Anyway. Do that ^ and then add the following code to your MouseDown/DragDrop event or whatever (not Mouse_Click - it doesn't pass the X/Y parameters):

    X = X - (X Mod 32)
    Y = Y - (Y Mod 32)

    This will snap the mouse position (X,Y) to the top-left corner of the grid square you click in. (I think this is what you want... am I right?)
    Note : This is for a grid of 32x32 pixel squares. Change the 32 as you wish.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  6. #6
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    Notice that twips adjusts automatically to a computer's screen resolution. 15 pixels will look different on different computers, but i don't think twips do.

  7. #7
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    WEll that's on a 15"/17" monitor, with 800x600 screen settings.
    That's pretty standard. And anyway, Twips still suck arse.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  8. #8
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    Sorry, but many people are on 1024x720. If you specify everything in pixels, you may have compatability problems.

  9. #9
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    That is easily solved by the Screen.TwipsPerPixelX and Screen.TwipsPerPixelY properties.

    It is not always 15, those properties will give the exact values depending on the res in question

  10. #10

    Thread Starter
    Addicted Member killer_cobra's Avatar
    Join Date
    Jun 2001
    Location
    Lost in space
    Posts
    131

    Thumbs up Hey thanks,

    Many thanks to all who input on my thread, but I have found a simple way of doing what I needed to do.

    Code:
    Private Sub Form_Load()
    
    Dim ResWidth, ResHeight
    
    ResWidth = Screen.Width \ Screen.TwipsPerPixelX
    ResHeight = Screen.Height \ Screen.TwipsPerPixelY
    
    End Sub
    
    Private Sub Image1_MouseMove (Button As Integer, Shift _
    As Integer, X As Integer, Y As Integer)
    
    Dim strDataX, strDataY, outDataX, outDataY
    
    strDataX = X \ ResWidth
    strDataY = Y \ ResHeight
    
    outDataX = X \ strDataX
    outDataY = Y \ strDataY
    
    PosX.Text = outDataX
    PosY.Text = outDataY
    
    End Sub
    Now from this, it doesn't matter what the initial resolution is, as it will automatically be taken into account during the form_load sub.

    Thanx a million anyways for trying to help, it's much appreciated!!!!

    Scott
    Error... What Error?!?! I've only typed a single character!
    ______________________________
    VB 6.0 EE, Win 2k Pro on AMD Duron 1Ghz/ 384 MB SDRAM

Posting Permissions

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



Click Here to Expand Forum to Full Width