|
-
Nov 12th, 2001, 10:27 PM
#1
Thread Starter
Addicted Member
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
-
Nov 12th, 2001, 10:52 PM
#2
PowerPoster
um....that's kinda confusing.
What do you mean by
I have an image control that is 6000 x 4000...
-
Nov 12th, 2001, 11:23 PM
#3
Thread Starter
Addicted Member
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
-
Nov 12th, 2001, 11:25 PM
#4
PowerPoster
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.
-
Nov 12th, 2001, 11:43 PM
#5
PowerPoster
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]
-----------------------------------------
-
Nov 13th, 2001, 06:02 PM
#6
PowerPoster
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.
-
Nov 13th, 2001, 06:13 PM
#7
PowerPoster
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]
-----------------------------------------
-
Nov 13th, 2001, 06:32 PM
#8
PowerPoster
Sorry, but many people are on 1024x720. If you specify everything in pixels, you may have compatability problems.
-
Nov 13th, 2001, 06:36 PM
#9
PowerPoster
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
-
Nov 13th, 2001, 10:34 PM
#10
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|