Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Get Coordinates Of All Controls...


I got alot of items on my form. I need a way to get the coordinates of every item on the form. I need to get the Height, Width, Left and Top coordinates.

Right now, I use this:

Code:
WriteINI object, "MainWindowTop", Form1.Top, coordinate
WriteINI object, "MainWindowLeft", Form1.Left, coordinate
WriteINI object, "MainWindowHeight", Form1.Height, coordinate
WriteINI object, "MainWindowWidth", Form1.Width, coordinate

WriteINI object, "RTBTop", Form1.rtb.Top, coordinate
WriteINI object, "RTBLeft", Form1.rtb.Left, coordinate
WriteINI object, "RTBHeight", Form1.rtb.Height, coordinate
WriteINI object, "RTBWidth", Form1.rtb.Width, coordinate
I need a easier way to save coordinates.

Is there a way to do this?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Controls Coordinates After SetWindowPos ?
Dear All,

I am using API to change the appearance of certain controls (List boxes in this case) as follows


Code:
Public Sub ControlCaption(Controlname As Control, SetTrue As Boolean)

Dim dwStyle As Long
dwStyle = GetWindowLong(Controlname.hwnd, GWL_STYLE)
If SetTrue Then
dwStyle = dwStyle Or WS_CAPTION
Else
dwStyle = dwStyle - WS_CAPTION
End If
dwStyle = SetWindowLong(Controlname.hwnd, GWL_STYLE, dwStyle)
SetWindowPos Controlname.hwnd, Controlname.Parent.hwnd, 0, 0, 0, 0, _
SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME _
Or SWP_FRAMECHANGED Or SWP_SHOWWINDOW

End Sub


This gives the Control a TitleBar.
I can now click on the titlebar and move the control around the form.

However the controls .Left and .Top properties are not updated.
They remain at the value they were when the controls parent form was loaded.

Can anyone tell me how to get the control to update these properties.

Many thanks

GT

User Controls Coordinates On A Form
If I place a user control on the form, how can I get it's x and y?

Need Help To Find The Coordinates Of Controls From Usercontrol
Hey All,

I want to create a (.ocx) control which acts as a container for other controls. but during the run time the activeX (.ocx) must be transparent and only the controls which are placed during the design time must be visible.
For this i create a ocx setting the contained control property =True.
Here i used the CreatePolyPolygon (WINAPI) and SetWindowRgn Api's.
But from within the usercontrol i am not able to exactly get the coordinates of the other control which are placed on my usercontrol.


i used
X = usercontrol.ScaleX(ocontrol.Left,usercontrol.scalem ode,vbpoints)
Y= usercontrol.ScaleY(ocontrol.Top,usercontrol.scalemo de,vbpoints)

the above code returns a point, but is not exact.
Please let me know how could i exactly retrieve the coordinates of the controls which are placed on my usercontrol from within my usercontrol.

Please help me

Prior Thanks for all.
with regards,
K.Senthil babu

Convert Regular Coordinates To 'system' Coordinates
I'm attempting to make a checkers program. A regular checkers board is the same as the chess board (64 squares) where the normal board coordinates are as follows...

** 01 ** 02 ** 03 ** 04
05 ** 06 ** 07 ** 08 **
** 09 ** 10 ** 11 ** 12
13 ** 14 ** 15 ** 16 **
** 17 ** 18 ** 19 ** 20
21 ** 22 ** 23 ** 24 **
** 25 ** 26 ** 27 ** 28
29 ** 30 ** 31 ** 32 **

Now, for programming purposes it's better to set up the coordinates as follows...

** 05 ** 06 ** 07 ** 08
10 ** 11 ** 12 ** 13 **
** 16 ** 17 ** 18 ** 19
21 ** 22 ** 23 ** 24 **
** 27 ** 28 ** 29 ** 30
32 ** 33 ** 34 ** 35 **
** 38 ** 39 ** 40 ** 41
43 ** 44 ** 45 ** 46 **

The reason for using different coordinates programmatically is simple. This way, all pieces can move to a number that is 5 or 6 higher than it's coordinate if it's a red piece, and 5 or 6 lower than it's coordinate if it's a white piece.

Anyways, I need to be able to conver coordinates from the regular coordinates to the 'programmable' coordinates and back.

I know how to convert from regular coordinates to 'programmable' coordinates like this

VB Code:
Public Function getInterCoord(boardCoord As Integer) As Integer    getInterCoord = 3 + boardCoord + (boardCoord + 3) 4 + Fix((boardCoord - 1) / 8)End Function


This part works, however I've tried everything and I can't make a function like this that will take the 'programmable' coordinates and return the regular board coordinates.

Can anyone help me out?

By the way, I know you could simply have a bunch of if statements in there , but this routine has to be as efficient as possible because it will be used thousands of times within another routine in my program.

X,Y Coordinates?
Hi guys, i have a bunch of labels on the form and every time u right click on any of the labels a popup menu box appears, one of the options on the popup menu is "reschedule" when the mouse is over teh "rescudule" option i need to show a picture box adjusted in such a way that it seems as if its part of teh popup menu. Basicaly make it seems that "reschedule" has a submenu, since i cant place any controls on the actual menu i created a picturebox with the control that i need on it, and i want to display the picture box right next to the little > arrow that appears next to "rescedule" option.

As i understand i have to manipulate the top and left coordinates of the picture box, but i do not know how to figure out the current coordinates of the popup menu, so that i would adjust the picture box's coordinates appropriately.

I tried to explain as good as i could i hope everyone understands me, and help is greatly appreciated. Thanx

Coordinates Help PLEASE!
Hey Everyone
I'm working on making a multiplayer RPG type game. Everything seems to be going pretty well... except I can't figure out a good way of storing where characters/objects are located. I've been using a sort of grid based way of storing object locations (each grid is 1X1 pixel). This works pretty well for storing where an object is and then printing that object on the screen at those coordinates. However, the objects are not 1X1 pixels... Here is my problem:

I place a character that takes up 50X50 pixels at 3,35. This character would take up coordinates X: 3 to 53 and Y: 35 to 85. When I look at coordinates 16,47 I need to "see" that the character is there. Is there a better way of doing this other than doing something like this?:

'when the object moves:
for X = Object.XCoord to Object.XCoord + Object.width
for Y = Object.YCoord to Object.YCoord + Object.width
Map(X,Y) = Object.ID
next Y
Next X


I REALY need to find a more efficient way of storing where objects are. Any help would be greatly appricated.

Thanks,
VBDude

Coordinates
I need some help with finding the coordinates.. Hopefully someone on this form can help me.

The problem is (I'm going to translate it into a form of a game so it fits into this form).
There is a man who is going to jump from a helicopter onto a hill. The odd thing is that he is going to reach the hill by traversing a line(from the helicopter to the point of reaching the hill) which is perpendicular to the surface of the hill (at the point where he touches the hill). Then he walks along the surface of the hill. At any point on the hill he is perpendicular to the surface. Now I know the point where he hits the surface of the hill. So at that point the man has an x,y,z position and a roll,pitch,yaw. Now what I need is ... the user enters how far the helicopter is from the point the man hits surface(x,y,z,roll,pitch,yaw) of the hill.

Then we need to figure out the X,Y,Z coordinates of the helicopter... keeping in mind that the helicopter is at a distance the user specified from x,y,z,roll,pitch,yaw (the point the man hits the surface of the hill) and that the man reaches the surface by traversing a line perpendicular to the surface of the hill.

Can anyone help me with this?

Getting Coordinates
Hi,
I have written a code that grabs the location of shapes in word documents and gives its coordinates. But I do not know what measure it gives the coordinate in. It gives negative numbers too sometimes.
The width of the full page was about 612 (in some units?).
How can I convert the coordinate system to inches or mm?
thanks in advance. MY CODE:

Dim W1 As Word.Application
Dim W2 As Word.Document
Dim shape

Private Sub Form_Load()
Set W1 = New Word.Application

Set W2 = W1.Documents.Open(FileName:="c:drawing.doc")
Dim i
i = 1

For Each shape In W2.Shapes
Text1.Text = shape.Top
i = i + 1
Next

W2.Close

Set W2 = Nothing
Set W1 = Nothing

End Sub

Thanks.
Regards,
M

2D Coordinates -> 3D Coordinates
Private Function TranslateCords()
Dim view As D3DVIEWPORT8
Dim temp As D3DVECTOR
Dim NearTemp As D3DVECTOR
Dim FarTemp As D3DVECTOR

Game.DirectX.D3DHardWare.GetViewport view

temp.x = Game.CursorObj.XPos
temp.y = Game.CursorObj.YPos
temp.z = 0

D3DXVec3Unproject NearTemp, temp, view, ProjectionMatrix, ViewMatrix, WorldMatrix

temp.x = Game.CursorObj.XPos
temp.y = Game.CursorObj.YPos
temp.z = 1

D3DXVec3Unproject FarTemp, temp, view, ProjectionMatrix, ViewMatrix, WorldMatrix
End Function

Im not really sure how I calculate the point where the line and plane intersect

Need Help With Coordinates
I would like to know how to convert coordinates from direct3d to client coordinates because i added buttons wich are square textured and I need to check if the coordinates that i get when I click with the mouse are the coordinates of my figure

Coordinates...
does anyone know a way, or a site that can show me a way to rotate XY coordinates upon another? this thing has been wrackin my brain all day but i just cant figure it out.

thanks for any help

steve

X And Y Coordinates
Is there a way to get X and Y coordinates of a control? Namely a command button in VB6? I know you can get X and Y in MouseUp or Down events for that button but I want to be able to find the location of the button from somewhere else.

Will appreciate an help.

Help With Coordinates
I need help with coordinates...im making a game for my tech class and i want to make a rpg type game.

My first question is how do i make my character(image1) not go through a wall>i mean when i walk into the wall my character cant go anymore into that direction , i make line and i remember the x,y(1440, 2440) but how do i put that into my code and so he cant go past that line...thats my question.

Next question...

Its almost the same thing as the one above...I have a box(image2) in the center on my form. My character(image1) is moving up, when he reaches the box, i want him not to go through it...like the wall BUT if i go from the left or right side i dont want to go through the box either. That is my second question.

I hope people can understand what i am trying to say, and trying to do...Thank you for ur time.

Help With Coordinates...
I posted this in another portion of VBForums... Not sure which section of VB Forums it belongs in...

VBFourms Link

Getting The Right Coordinates
How do I get the right coordinates of POINTAPI when the usercontrol windowless property is set to true?

I don't have problems getting the right coordinates using the GetCursorPos and ScreenToClient API's. I need this for the purpose of having to hover the mouse to the usercontrol and be able to change the graphic when it is over and out.

Thanks!

X And Y Coordinates
hello,

can anybody suggest how to get the X and Y coordinate values of images from a picture box or a form and write it into a text file line by line, first line has x value and second line has y value and so on.

does it return the x,y values of the upper left corner of the image or the center of the image?

cheers.
Dinesh.

Coordinates
how would know if my xy coordinates is in pixels? using mousemove events.

X And Y Coordinates
I have seen a program( i can't remember exactly what the name of it is i think is jks' or jv's something...the program will find the handle of the window that you point to by dragging a small arrow to the window and it also generates the code) I want to code an aplication similar to this, i want to be able to click and drag an arrow anywhere on the screen and when i release the mouse button the x and y coordinates of where the arrow is, get recorded. I have tried several aproches to this but it only works within the form and if i drag it ouside the form id doesn't work.

Thanx

X And Y Coordinates ???
Hi Guys/Gals

I've been looking for an answer for this Please help ?

How can we find the Y Coordinate of the selected/Highlighted item in a ListBox ??

I want this Y value while using the Up/Down Key.

I know i could use MouseDown Event But it works only while using the mouse. However,
i tried invoking it in the list.Click Event with no success.

Also, utilizeing GetCursorPos API wouldn't return the mouse Pos. in the listBox !!


Thanx.

Coordinates X,Y
Hello everybody;
I'm working in a project, that uses Drag and Drop. I have to be able to
transfer the caption of a textbox, into a Picturebox, at the position where
the textbox is dropped.

I know that by specifying the X and Y coordinates of the Picturebox, I can
set the place where the text should appear, but having the coordinates
changing at runtime,
I can't figere that out yet.
TIA
LuisB

Coordinates! Need Help
I am in a serious bind.
See, there is one picture (pic1) has the coordinates of 2280, 240 which corispond to X, Y, respectively. There is another picture (pic2) below it with coordinates 2280, 4530. I have pic1 move up the screen via .Move command. What i need to happen is:

-when pic2 overlaps pic1 a key should be pressed to add a score to a label and a "GOOD" image will appear

- if pic2 does not overlap pic1 and the key is pressed anyway, no score will be added and a "BOO" image will appear

NOTE: All coordinates are in 'twips'

Here's what i have already:

-------------------------------------------------
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim intscore As Integer
Select Case KeyCode

Case vbKeyLeft

If pic2.Top = 200 - 400 Then
score = score + 1000
imggood.Visible = True

ElseIf pic2.Top = 0 - 199 Or 401 - 900 Then
imgbad.Visible = True

End If
-----------------------------------------------
Private Sub tmrpic2_Timer()
'Left arrow 1
pic2.Move pic2.Left + 0, _
pic2.Top - 80

End Sub
-----------------------------------------

is there anything i am doing wrong?

Coordinates
While keyin in text box, if I press any control key(ex. ctrl+spacebar), I should get one list box at cursor position.
Like vb editor, i may enter few characters and press ctrl+spacebar, I should get one list box.
pls give me an idea, how to get the coordinates of cursor position.

Coordinates
Hi , i want to find out the coordinates of the top lefthand corner of this IE window (but below the 'Address' bar of IE) & the rightmost bottom corner ( but above the system clock & to the right of the word "internet" ). Can anyone tell me ?

Coordinates Problem
Hi.

First of all I'm newbie here :P

Can anyone explain me why when i put a label with 4215 on top and 285 of height it goes out of my form, that has the height defined with 4590???

Thanks for any help.

André

Curve Coordinates
I have completed my picture in visual basic and it is of a gum ball machine using circles and lines. The animation part is a gum ball that spirals down. I need a way to come up with the X and Y coordinates that will create a smooth curve down. Any help is appreciated.

How To Get/set Mouse Coordinates.
Hi,

Would like to know how to get/set mouse coordinates.

Thanks.

Coordinates In RichTextBox
Hi,
Does anyone know how can I get x and y screen coordinates in pixels of the SelStart position in RichTextBox

Thanks in advance

Texture Coordinates
Here is my big problem:

I created a 3D program in Visual Basic 6 using the DirectX 7 type library. The problem is situated on a plane that according to the graphics editor exists of 2 triangles.

Now here's the thing: The texture, a bitmap of 128x128 px, was first completly stretched out over the plane; not being infected by the triangles. Then I found that [mesh.SetTextureCoordinates ?, ?, ?] infects the texture, while being influenced by the triangles.

Now the question: What do you do to have the texture repeated over the plane in regular tiles, without interfearance from the triangle-polygons of the mesh ?

If this is unclear in any way, just post a comment here and I'll try to be specific.

Thanks in advance,
egsoc

VB6/DX8: CreateBox/uv-coordinates
Hi @ all.
now, after I created my subsets and looked at the window for the results(Screen.jpg) it seems that the texture (WoodNode) is loaded correctly but looks like it is stretched. So I guess, that this is the output of a mesh with no uv-coordinates.

As the meshes are created via CreateBox which inherits no uv-information, the uv-coordinates have to be set manually, depending on the position of the vertex (lowest and most right will get the 1 others the 0). Well, so far so good (I hope). Now, where are the vertexinfos? In the mesh-obj I presume but my D3DVertexBuffer8GetData returns "Nothing". Hmm, k, perhaps if I take a closer look at the Adjacency, which is filled after the createbox-call I might figure out how to use these Information to get my vertexinfos. But this buffer is also nothing

stuck
How can I get the vertexinfo? Does it matter if the adjacency-buffer is nothing?

I know that CreateBox is usually not prefered due to those limitations, so there isn´t much about it in the inet.

thanks in advance.

CreateTLVERTEX (X, Y) Coordinates
Here's the thing, I'm trying to move a TriangleStrip (A Box) Across the screen so I increase the X Value of each vertex by one. But, this is already quite fast. And I'm hoping to have varying speeds in here. (Currently I have it increasing X once per Render Cycle, and putting it into a timer does not work because then it is way too choppy)
So, is there another way to determine coordinates of vertices other than in pixels? (I.e. something smaller than pixels?) Thanks

Texture Coordinates?
I was wondering..
Is it possible to just specify like a texure offset and width/height insted
of jumbling with this U,V stuff?

Really I am trying to find a solution past the texturing blues of
Index buffers & texturing.

Vertex Coordinates
Friends

Some examples of programs of this site and others define the coordinates of the vertices of a polygon using something like: X=1.0 Y=1.0 Z=0.5
But in my project I would like to define the vertices of a box with a range of more precision, that is to say, to be able to use 0 - 5 - 12.....150... .N coordinates for the axes.
Would somebody help me with this problem? Maybe the problem is with the type of vertices?
Thank you in advance!

ARC

About The Coordinates On The Form
hello everyone!

Here's my idea: The user can draw rectanculars on the form anywhere they want by enter 3 kinds of datas on a table: the x,y coordinates, the width and the height.

Could anyone give me some hints that how can I realize this idea?

Here's my question:
1, If the top-left point of the form's coordinate is (0,0), how can I define the bottom-right point of the form's coordinate? say, like(-200, -200) is what I want for the bottom-right point. Because it's no use for the user to have ability to draw rectangular on every pixel or every twip on the form.

2, By which way can I connect the table to the drawing? So every time I run this program the form will immediately show the rectangulars which the user wants on the table.

I'm new in VB and your help will be very appriciated. Thanks guys!

Circles And Coordinates
Hi all,
I'm trying to create a 2D enviroment on a VB form in which circular "cells" with fixed appendages interact with eachother, but I've come up against a bit of a problem.

I'm interested to know if anyone can provide me with a formula or series of formulae I can use to discover the X and Y coordinates of a point on the circumference of a circle, given that I will know the circle's radius, origin, and the angle in terms of degrees that the point is from "north" on the circle.

I have all the necessary knowledge (circle equation, trigonometry, etc.) I just can't apply it in terms of coordinates. It's the degrees idea that really has me stumped - on paper I can't work out the relationship between the bearing of the point and its X,Y coordinates.

To summarise, the given variables will be circle radius, XY coordinates of circle origin and 0-360 degree bearing for the point on the circumference.

The unknowns are the XY coordinates of the point.

I know this is more a mathematics problem than a programming one, but it is directly related to a current VB project I've decided to undertake.

Any help would be much appreciated, thanks in advance.

Help - Cursor Coordinates
I'm trying to make an image component move towards the location of a mouse click on a form; my problem is that I don't know how to detect the .left and .top properties of where the cursor click took place.

What values store the X and Y of the cursor over the form? I'm using Form_Click() as my sub for this process.

Screen Coordinates
I have an app that i've put a useful feature in, In the status bar it displays the coordinates that the mouse pointer is at on the screen. Unfortunatly, My current resolution is at 1280 X 1024... I have 2 laptops and a second computer that I would like to use the app on (which automates clicks at certain coordinates) but Instead of huge amounts of additional coding for the smaller resolutions is there a way to restrict the coordinates to the actual app window instead of the screen. ex: coordinate 0,0 would be the apps upper left corner no matter where it is placed on the screen.

Mouse Coordinates
A form has 2 textboxes.
Can someone please supply coding that would display the coordinates of the mouse while the mouse is clicked and moved about the form? X coordinates in 1 textbox and y coordibates in the other.
Any help would be appreciated.

Coordinates In Textbox
Hi, here is what I'd like to know:
Is there a way to know the coords (row,column) of the cursor in a textbox? It's possible to modify them from code? Thanks.

Picture Coordinates
The x and y coordinates used in picture box methods like line or pset are related to the form or to the control itself ? I had tryed a few times but couldn't get it...
Thanks for helping...

if you want to hit the stars,shoot to the sky.

Coordinates In PictureBox
I have a picture box with it's Autosize property set to true. The picture loaded into it is a map. Is there any way to give VB X and Y coordinates and store them in a variable?

Jacob Sheehy
http://www.sheehy.ca

Multitasking - screwing up several things at once

Picture Box Coordinates
Hi everybody,

I have two questions.

First : how do I visualize the mouse position (X,Y) while I move it over a picture box ? I need the picture box coordinates (and I would like to have it in text boxes the user can see), not the form coordinates.

Second : I found that I can change the current width and height of the drawing area. Good ! But I need to start the same drawing area at a point other than 0. My data looks like

Longitude (X)Latitude (Y)
11.10573300000045.131667000000
11.10571633333345.131667000000
11.10570244444445.131667000000

So if it begins at 0, it is not enough accurate. I only see a point (wich are in fact all my points shown with a scale that begins at 0 and goes up to 46 for example). I want to see something from 45 to 46 on the Y axis, and from 11 to 12 on the X axis.

If you can help a poor lost frenchie...


PS. I know that I can visualize everything with Excel, and that I could use VBA, I am a bit weird, you're right...

Coordinates And Maps
Does anyone have any ideas on creating a map that associates with Coordinates. It will also alow me to overlay multiple layers of information in given areas that I can integrate into an application (IE. integrading goolemaps, gis information... ect.)? :

Help! {coordinates And TwipsPerPixel}
I have couple of questions to ask:

Situation: I am drawing picture on form creating a box, circle, and line.

1a. how can I determine the X and Y coordinate if the scale width = 400 * Screen.TwipsPerPixelX and the scale height = 400 * Screen.TwipsPerPixelX ?

2a.What exactly does 400 times Screen.TwipsPerPixel.. I mean what is the value of Screen.TwipPerPixel?

3a.I suppose vb6 should have some type of display which show the numbers of X and Y coordinates somewhere, would I find one in menu or else? because as matter of fact I couldn't determine the coordinates.



I must emphasize you that I am not good at math, but I can learn. I just wantetd to understand all math complications today for my benefit

X Y Coordinates/Cursor
Hi all...

I am BRAND new to Visual basic, but already i have a task that i really want to complete.. (and im stuck)

I have a large text box (multi-lined) and i want it that so that the program can change the possession of the text cursor (not mouse cursor) depending on two coordinates that are handed to it, a X coordinate and a Y coordinate.. How would i do this???

Thanks for anybody’s help..

NOTE: it does not matter at all how the program receives the coordinates...

Thanks again,
Dan

Mouse Coordinates
hello,

Im trying to find out how to get the coordinates of the mouse pointer. Basically what i want is....

if mouse coords = x then....

and so on

Any help appreciated

Mouse Coordinates
Hi I'm trying to capture the mouse coordinates when the mouse
is in another Application than my VB-Form (=another App has the focus). It would be fine also to have a transparent form (as a kind of invisible frame around the other app), and I've tried that but then the MouseMove event only fires when the mouse passes over a visible control. Help?

Mouse X, Y Coordinates
how do i get the x and y coordinates of the mouse so i can pass them to the PtInRect api function?

How To Get The Coordinates From The Picturebox?
i have a picture box, i want to get the coordinates of the point which im clicking on, how to do this? tks!

Getting A Windows Coordinates
Is there a way to find the position of a window on the desktop? I want to place the mouse pointer to this position.

Copyright © 2005-08 www.BigResource.com, All rights reserved