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




Absolute Control Position


ok i want a function 2 find the absolute position of a control on the form.... for example if the control passed in is in 2 pic boxes it will return the twirps to the top left of the form

- i will be doing this kinda thing abit so i need a generic function -

thanks kris




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Absolute Control Position?
How can I know the absolute position of a control on a
form, using the upper left corner of the form as 1,1

These controls may be put inside other controls (nested)!

Would anybody help?

Any hint?

Thanks

Getting The Absolute Position Of A Control Without Knowing Its Parent
Is there anyway to get the screen coords of a control that doesn't have an hWnd and if you don't know its parent control? I am trying to work on a class and I need to know the top and left of a control relative to a screen (not the window) without passing an hWnd.

Absolute Position?
Ok back to my datacontrol thing... now I have the record count total but I want to know what record the user is on when they press forward, back, move first, or last in the data control. I have this

Private Sub Data1_Validate(Action As Integer, Save As Integer)
Dim myStr As String
myStr = "Record " & Data1.Recordset.AbsolutePosition & " of " & Data1.Recordset.RecordCount
info.Caption = myStr
End Sub

but the absoluteposition seems to return random things... such as 3 when the text box really displays record 0 and 2 when its really on record number 4. ... am I using this wrong?

complete code


Code:
Option Explicit
Dim rs As Recordset
Dim tCnt As Integer
Dim myPos As Integer

Private Sub Data1_Validate(Action As Integer, Save As Integer)
Dim myStr As String
myStr = "Record " & Data1.Recordset.AbsolutePosition & " of " & Data1.Recordset.RecordCount
info.Caption = myStr
End Sub

Private Sub Form_Load()
CommonDialog1.ShowOpen
Data1.DatabaseName = CommonDialog1.FileName

'Set rs = .OpenRecordset("AUTHORS")
Data1.RecordSource = "branch"
Set Data1.Recordset = rs
Data1.Refresh ' Open the recordset
Data1.Recordset.MoveLast
Data1.Recordset.MoveFirst
Text1.DataField = "branch_name"
tCnt = 1
End Sub

Absolute Position
Hello...
what the different between selbookmark and absolute position in datagrid...?
i can get the current pointed recordset with that two, can't i ?

how if i do a multiple select ? how absolute position works in multiple select?

thanks,
ganero

.Absolute Position
I have a code errors out telling me I have an invalid key. The code it errors on is as follows:

Do While Not rs.EOF

.Add rs.AbsolutePosition + 1, rs!Site_Number, rs!Site_Number
rs.MoveNext
Loop

(it errors at the .ADD rs line)
I can't find any help on the invalid key error. Anyone have any suggestions?
Thanks
Pat

Absolute Position
I am trying to use rs.absoluteposition to keep incrementing the count on a label, but this always seems to stay at -1. Any ideas?

Thanks!
Erica

Absolute Position In A Query
Hi, using DAO and Access, is there a way to know the exact position of a record in a query ? Like absolute position or something ?
Many Thanks

Absolute Position Of A Record !!!
Friends,

How can I view the number of exact row in a label that is currently showing the data.

Something like this: Record 15 of 75

Help needed please.

Absolute Cell Position
Is there any way of obtaining the absolute pixel position of a CELL so that I can use the AddShape position to draw a shape in that cell of equal size and position of that cell?

ie. AddShape(msoShapeOval, Cell.Top, Cell.Left, Cell.Height, Cell.Width)
'Kind of thing'

Many Thanks in advance.
Riyaz

Absolute Position In Data Reports
How can you print out an ordered sequence to number the records in a VB data report? The function control won't go into the detail section, and calculated fields only work if you have other fields to calculate from. It seems so easy in Access (number grouping), but why not in VB? Any ideas?

Record Count And Absolute Position
On my form I'm trying to display the number of recoreds in my Access DB and also the current position I'm at but I'm having no luck. Currently i'm using the below but I keep getting -1 of -1 displayed. Can anyone see what is wrong?

Thanks


Code:
strCn = ConnectString()

sSQL = "SELECT * FROM tblBuy ORDER BY Completed DESC, Date DESC"
Set rsEditBuy = New ADODB.Recordset
rsEditBuy.Open sSQL, strCn, adOpenDynamic, adLockOptimistic

lblTrades.Caption = rsEditBuy.AbsolutePosition & " of " & rsEditBuy.RecordCount

Absolute Character Position In Richtext Box
I am trying to auto generate some text in a richtext box. Characters will have different sizes and be of different widths.

I need a way to line up the tabs inbetween things. Sometimes I need 2 tabs, but most of the time I only need 1 inbetween things (Sorry if this is vauge, I will attach an example if needed).

The only way I can think of accomplishing this is by testing the absolute position of a character from the line above and if absolute position of the current character matches that then leave the tabs how they are, otherwise add a tab until the tabs line up.

I searched through the object browser for a good hour testing all the different properties of the richtext lib, and nothing worked. SelTabs looked promising but it always returns 0 for some reason.

Any ideas?

ADO Record Count And Absolute Position
I finally figured out how display the record count of a table or query as well as the absolute record being focused on, but I am getting eroneus numbers -1 of 26 and when I click on the right or left arrow the counter wont increment (or decrement) unles I click the arrow twice. I put the statement in the form load:

Adodc1.Caption = " " & Adodc1.Recordset.AbsolutePosition & " of " & Adodc1.Recordset.RecordCount

and then I put it under the click sub for the Adodc1 control:

Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Adodc1.Caption = " " & Adodc1.Recordset.AbsolutePosition & " of " & Adodc1.Recordset.RecordCount
End Sub


Any suggestions on how I can get the proper results? Also when a query is run and produces no results, I would like the "counter" to display 0 of 0 instead of -1 of 0 and the control seems to be shaded like Enabled = False. DAVE

Visio - How To Move Shape To Absolute Position?
Hi,

Thanks for taking the time to look at my post.

I would like to move a shape object to an absolute location of my choice, e.g. I would like to know how to move a shape object to position (100, 100).

The selection object's move method only allows the selection to be moved relative to where it's original position was.

here is the code:


VB Code:
Sub start() Dim aShape As ShapeDim aSelection As Selection Set aShape = Documents(1).Pages(1).Shapes(1) ActiveWindow.Select aShape, visSelect Set aSelection = ActiveWindow.SelectionaSelection.Move 2, 2 'i want to move to an absolute location, not just 2 up and 2 right like this line doesEnd Sub


Thanks for your time
<>GT<>

Absolute Position A Text Box In Word Macro ??
Hi Guys

Wondering if anyone can tell me if its possible (and how to) absolute position a text box in a word macro....

I have a word document that runs a macro that places a text box on the page containing a barcode. The word document contains text that is editable by the user. However, if the user edits the text, the text box moves as if it is set to position relative to the text. I need the text box to remain in the absolute same spot all the time.

Please, any info on this would be much appreciated.

Nick

Finding All Links Absolute Position X,Y Relatively To The Screen In VB6 WebBrowser
Finding all links absolute position X,Y relatively to the screen in VB6 WebBrowser
There is a Visual Basic 6 application with WebBrowser in it.
This application is about statistical information on what html tags were loaded, where they are being located - it's position X,Y

For example I want to find Document.getelementsbytagname("a") link and anchor position on the screen, how do I do it?
There is example in JS, that I could inject into webpage by scriptcontrol but could I do in in VB6 itself?
function getElementPosition(elemId)
{
var elem = document.getElementById(elemId);

var w = elem.offsetWidth;
var h = elem.offsetHeight;

var l = 0;
var t = 0;

while (elem)
{
l += elem.offsetLeft;
t += elem.offsetTop;
elem = elem.offsetParent;
}

return {"left":l, "top":t, "width": w, "height":h};
}

Trying by vb6 in webbrowser

Dim WithEvents doc As HTMLDocument
Dim elem As IHTMLElement
Set doc = ie.document

For x = 0 To doc.getElementsByTagName("a").length - 1

Set elem = doc.getElementsByTagName("a")(x)


I want convert this nonsense
'"-PParent=" & elem.offsetParent.offsetParent.tagName & "=" & elem.offsetParent.offsetParent.id & _
'"-3Parent=" & elem.offsetParent.offsetParent.offsetParent.tagName & _
'"-4Parent=" & elem.offsetParent.offsetParent.offsetParent.offsetParent.tagName & _
'"-4Parent=" & elem.offsetParent.offsetParent.offsetParent.offsetParent.id

To while loop, but I can't figure it out how

While (TypeOf elem Is IHTMLElement)
parentall = "-Parent Tag=" & elem.offsetParent.tagName & _
elem.id & ",l=" & elem.offsetLeft & ";t=" & elem.offsetTop & _
Set elem = elem.offsetParent
Wend

Next x

Finding All Links Absolute Position X,Y Relatively To The Screen In VB6 WebBrowser
Finding all links absolute position X,Y relatively to the screen in VB6 WebBrowser
There is a Visual Basic 6 application with WebBrowser in it.
This application is about statistical information on what html tags were loaded, where they are being located - it's position X,Y

For example I want to find Document.getelementsbytagname("a") link and anchor position on the screen, how do I do it?
There is example in JS, that I could inject into webpage by scriptcontrol but could I do in in VB6 itself?
function getElementPosition(elemId)
{
var elem = document.getElementById(elemId);

var w = elem.offsetWidth;
var h = elem.offsetHeight;

var l = 0;
var t = 0;

while (elem)
{
l += elem.offsetLeft;
t += elem.offsetTop;
elem = elem.offsetParent;
}

return {"left":l, "top":t, "width": w, "height":h};
}

Trying by vb6 in webbrowser

Dim WithEvents doc As HTMLDocument
Dim elem As IHTMLElement
Set doc = ie.document

For x = 0 To doc.getElementsByTagName("a").length - 1

Set elem = doc.getElementsByTagName("a")(x)


I want convert this nonsense
'"-PParent=" & elem.offsetParent.offsetParent.tagName & "=" & elem.offsetParent.offsetParent.id & _
'"-3Parent=" & elem.offsetParent.offsetParent.offsetParent.tagName & _
'"-4Parent=" & elem.offsetParent.offsetParent.offsetParent.offsetParent.tagName & _
'"-4Parent=" & elem.offsetParent.offsetParent.offsetParent.offsetParent.id

To while loop, but I can't figure it out how

While (TypeOf elem Is IHTMLElement)
parentall = "-Parent Tag=" & elem.offsetParent.tagName & _
elem.id & ",l=" & elem.offsetLeft & ";t=" & elem.offsetTop & _
Set elem = elem.offsetParent
Wend

Next x

Server Side Cursor Recordset Absolute Position
I apologize in advance for this one since I have seen a solution for this some time ago, but cannot seem to turn it up in a search.

 I am using a server side cursor (This will be an advantage for several reasons, so I will not want to change this).

 I only need to determine the recordset absolute position and the recordset count so I can display "Record 1 of 25" or whatever.

 I do a move last then a move first, but still receive the values of -1 for both absolute position and count.

I am using VB6 with SQL Server 7 ADO connection

Terry (cyberbiker)

Finding All Links Absolute Position X,Y Relatively To The Screen In VB6 WebBrowser
Finding all links absolute position X,Y relatively to the screen in VB6 WebBrowser
There is a Visual Basic 6 application with WebBrowser in it.
This application is about statistical information on what html tags were loaded, where they are being located - it's position X,Y

For example I want to find Document.getelementsbytagname("a") link and anchor position on the screen, how do I do it?
There is example in JS, that I could inject into webpage by scriptcontrol but could I do in in VB6 itself?
function getElementPosition(elemId)
{
    var elem = document.getElementById(elemId);
    
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
    
    var l = 0;
    var t = 0;
    
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}

Trying by vb6 in webbrowser

Dim WithEvents doc As HTMLDocument
Dim elem As IHTMLElement
Set doc = ie.document

For x = 0 To doc.getElementsByTagName("a").length - 1

Set elem = doc.getElementsByTagName("a")(x)


I want convert this nonsense
'"-PParent=" & elem.offsetParent.offsetParent.tagName & "=" & elem.offsetParent.offsetParent.id & _
'"-3Parent=" & elem.offsetParent.offsetParent.offsetParent.tagName & _
'"-4Parent=" & elem.offsetParent.offsetParent.offsetParent.offsetParent.tagName & _
'"-4Parent=" & elem.offsetParent.offsetParent.offsetParent.offsetParent.id

To while loop, but I can't figure it out how

While (TypeOf elem Is IHTMLElement)
parentall = "-Parent Tag=" & elem.offsetParent.tagName & _
elem.id & ",l=" & elem.offsetLeft & ";t=" & elem.offsetTop & _
Set elem = elem.offsetParent
Wend

Next x

Absolute Control Of The Screen
Hi Guys,

Please I writing a program that puts a shield on computers runinng in a public place. I need this program to bar access to the screen until users enter valid codes to unshield the systems and let them use these computers. The program is running well except that when people start playing certain games that invoke certain screen modes, the shield becomes ineffective, and can't bar them from using the computers.

Please using VB, how can I make my shield have priority of all screen modes.

Thank you

Absolute Co-ordinate Of Control
How can I know the xy (left, top) of a particular control on the form,

The problem is the control may be inside another control,
and the container itself may be inside another container..
and I don't know how many levels of container it has.

Can anybody help?

What Is The Correct Way To Implement Absolute Positioning In The Webbrowser Control?
I use a toolbarbutton to do this:

htmdoc.execute "AbsolutePosition", false
htmdoc.execute "2D-Position", false

(i have first set htmdoc = web.document etc. web is my webbrowser control's name.)

It works when inserting a new element - but when i insert subsequent elements or objects the button seems only to affect the first thing i inserted - or to behave oddly by switching the first object inserted between its final position and the relative position it started with. Other components inserted afterwards usually ignore the command - but sometimes by clicking about the window - i get them to work - whats going on?

Thanks in advance!

 

Edited by - scott_p on 9/22/2002 3:49:15 AM

Control Position
Hi

I want to move controls on form with API.
I get the position on the control with GetWindowRect hwnd, cRect. (it received the control position related to the screen).
I add to the Top/Left some pixels, And then I set the new position with SetWindowPos.
This is my code:

public Function ChangeControlsTop(byval cHwnd as Long, byval TopStep as Long) as Long
Dim ControlRect as RECT

GetWindowRect cHwnd, ControlRect
ControlRect.Top = ControlRect.Top + TopStep

SetWindowPos cHwnd, 0, ControlRect.Left, ControlRect.Top, 100, 100, SWP_NOSIZE

End Function




The problem is that the SetWindowPos change the control position related to his parent, and it possible that this control is in other control(like picturebox) etc.

Is any body know how can I fit between the two position ???

Thanks for help

Paste With Position Control
Ok, this is likely stupid but I can't find an answer and I figured a guru here would know if from the top of his or her head

I am pasting text to a dropdown box as the user types characters into it, updating the dropdown as he goes along (that is the easy part)

To do this, I .clear the list with every character change, which means I have to clear the text, which means I have to replace it.

The pointer, then, is as the front of the text string instead of the end. What I need to do is to paste with the pointer at the end of the text string, so that the user can just keep typing

Anyone know how?

Thanks!

SelText Position In A Web Control
how i can find the SelText Start Postion and End Position in a Microsoft Web Control.i.e when i am in desgin mode whatever text i selected i want to display its Start x,y position and End x.y position in a contol.

Control The Position Of A Form
How would I go about forcing a form to go to a specific position if moved via the title bar?

Control Position On Screen
Any fast way to find a controls screen position other then getting the Left value of each parent all the way down to the form?

I want to replace the pixels in my picture box with the pixels of the DesktopDC but i gotta figure out the pixel position.

Control Message Box Position
Is it possible to pop up a message box,
always in the bottom right corner of my app.!!

txt in adv.

How Can I Get The X,Y Position Of A Control In A Form?
How can i get the X,Y position of a control in a form?

Control Startup Position
Hello all. I was wondering if anyone could tell me if it is possible to control the startup position of a seperate app? I am using VLC's media player to stream a terrestrial digital TV signal. The preferences with that app allow me to set the size etc but not the startup position. The code i use to launch the app from within my VB6 app is:

Code: Shell Chr(34) & "C:Program FilesVideoLANVLCvlc.exe" & Chr(34) & " -vvv udp://@239.192.68.111:5000 -- width 776 -- height -100", vbNormalNoFocus

If it is not posssible to directly control the startup position can anyone suggest some sort of work around. Thanks people

----------------------------------------------------
Shrek and Donkey and on another whirlwind adventure!

Force A Control To Take Top Most Position On A Form.
I'm using a 3rd party control to view documents( VSPrinter).
I want to draw a line and have it sit on top of the VSPrinter control but the VSPrinter control always puts the line underneath it.

Any solutions to this problem?

Thanks.

Cursor Position In A TextBox Control
Hey Guys,
I was wondering if anyone knows how to determine the cursor position within a textbox control, or if not,suggest a work around for the following scenario:

I have an MSFlexGrid that I want to allow users to edit. Obviously, a bit of programming allows one to place a text box over the active cell in the grid. This is easy, and works without incident, but I want to add a bit more functionality by allowing the user to use the up/down left/right keys from within the textbox control to move around the grid. THe catch is that I only want the left/right keys to change the grid cell if the cursor is in the first column of the text, or the last column of the text respectively. Since there is no guarantee that any text will be HighLighted, I cannot use .SelStart.

Any thoughts would be helpful,

Thanks,

Hunter

Move Control To Mouse Position
Hello,

Can anyone show me how to move a control to the exact mouse position. I've been using the pointapi when I click on my form but the mouse won't move to the loaction of the cursor,

Cheers
Ross

How To Set The Position Of DataPointLabel In MSChart Control
I have a problem try to move the position of DataPointLabel in Pie chart.
I am not sure but I try to use offset property to change its position, but it doesn't work. The label still the same position.

With grphObj.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel
.LocationType = VtChLabelLocationTypeOutside
.LineStyle = VtChLabelLineStyleStraight
.Component = VtChLabelComponentPercent
.VtFont.Size = 10
.Offset.Set 10, 2
.PercentFormat = "0.00%"
End With

The offset.set is not work because when I debug I check (X,Y) value it still (0,0) rather than (10,2)

How To Control Line Position In A TextBox
I am using a textbox with MultiLine set to true. When the number of lines exceeds the height of the textbox the vertical scrollbar becomes active. How can I tell the topindex or the line position of a textbox?

Thanks,
sneakers

btw: I havent been using this forum for very long and was wondering how to mark a thread as resolved.

Position Form Based On Another Control
Hello, I am working on this game and need help with some form positioning. Since I have used the game so far on a Windows 2000 and XP I am seeing an issue. I have the main form and then another form opening up ontop of this form. The form that opens is positioned to cover a specific part of the main form. If I do the math on one computer, it looks different on the other because of the change of the borders and everything, the top/left get messed up.

I thought I would use a control on the form. Like setting a border around the area and then usign its top/left position but I can get that to work correctly. Can someone help me position 1 form based on a location of a control on another, so on any Operating System, they will line up correctly.

Please help.

Window Size/position Control
i have shelled explorer like this


Code:
Dim One
One = Shell("explorer.exe a:", vbNormalFocus)


Now i want to control its size and position, I will alse be shelling another window,


Code:
dim Two
Two = Shell("explorer.exe C:Documents and SettingsJonMy DocumentsJon", vbNormalFocus)


and i want One to be on the left half of the screen and Two to be on the right half of the screen.

Any suggestions?
Thanks

Position A Textbox On A Richtextbox Control
Hi

I have to design an interactive form where there are lots of explanatory texts and then some textbox controls that should naturally merge into the flow of text. For example a form would have the following:

Your name is <textbox> and address <textbox>.

I have tried using a RichTextbox control where the text contains a specific tag where I expect the textbox to be. I then get the character position of the tag using Find method. Once I get the position I use getLineFromChar to determine the line on which the tag appears. I then use the average height of a character to determine the pixel position of the tag and add this to the top property of the richtextbox. However, I can't find a way to determine the positon of the tag from the left of the richtextbox. This would enable me position my textbox at a particular position within the RTB during runtime.

Does anybody have any idea on how I can achieve this ? Or else, is there an altenative to using RTB ?

I cannot replace the textbox controls since the user should be able to edit the name and address.

Thanks

Cursor Position In Webbrowser Control
Hi,
Does anyone have an idea on how to get the cursor position from the WebBrowser control.

Thanks

Volume And Position Max For Mediaplayer Control
How do i set a slider's value to a max that corresponds to the end of a movie file? Also how do i set the volume on a slider?

Capturing Mouse X Position In A Control
I need a way to capture the X position of the mouse in a control.

I tried using the MouseMove Event but it doesn't seem to get the info i need.

I need to find out the X position as the user moves the mouse within the control.

Position Of Nodes In A Treeview Control
Is there any way to determine the position of a node in a group of child
nodes in a Treeview control? For example:



Days of Week

.... Monday

.... Tuesday

.... Wednesday



I would like to be able to programmatically determine that Monday is the
first child node, Tuesday the second and so on. Also, if I drag and drop
the child nodes, I need to be able to determine the node's new position.
For example (as the result of a drag and drop):



Days of Week

.... Wednesday

.... Tuesday

.... Monday



I now need to know that Wednesday is the first node, and so on.



Thanks for your help

Control The Position Of Components Depending On Others
Hello all,


I was wondering if it's possible to place components on a form
depending on the size of another component.
Let's say I have a datagrid that gets populated from a database.
Depending on the choices of the user, that qill create a query, and
depending on that query, the datagrid might have 10 rows or it might
only have 1. I want to place a radiobuttonlist as well as a label just
beneath the datagrid, but in the design view, I place it right under
the datagrid. And when the datagrid has many rows, my label gets mixed
in the datagrid. Or if it has only one row, the label is way underneath
it....at the bottom.
How can I control the position of components depending on others that
get populated at runtime ?????


I know one of u guys knows this......has to!!
thanks in advance!!
JMT

Text Position In Richtextbox Control
Hi Guys. I have spent the last few hours searching the internet trying to find out how to enter a string into the richtextbox control and have it display the string in the bottom left corner and stay in that position even if the form is maximised. Any subsiquent strings will scroll the control up.

Any ideas how to do this would be much appreciated.



Edited by - Gomjibar on 8/21/2004 7:05:43 AM

How To Get The Position Of Cursor In A Codemax Control
How to you get the cursor pos of the cursor in a codemax control.

I need it so I can use the command CodeMax.InsertText "Text", Pos as RECT

I know the position is a RECT, but Codemax does not have a command to retreave the curdor position, or I can't seem to finf it.

Any help would be great.

Window Position To Bottom Of Control
hi, i posted this question earlier, but maybe i didnt provide enough information. i have a window with a button on it. when the button in pressed another window opens up. how can i set the position of the new window to the bottom of the button control? any help would be appreciated. thanks!

User Control -- Way To Retrieve Position In Container?
I want my user control to be able to determine what its .Left and .Top position are in its container. Is there a way to do this?

-Amrazek

Determinig The Position Of A Control On Its Parent Form...
Im making a graphical button control and I quite like the idea of a floating image when the mouse is over the control, but I cant quite seem to locate the control on the parent, I'm using the GetCursorPos API function to locate the mouse position wherever it is, but I need to compare that to the controls x,y co-ords in its parent... I tried this:

ObjectXCoOrd = UserControl.CurrentX
ObjectYCoOrd = UserControl.CurrentY

But it returns a 0 value all the time... Any help please? Just a pointer in the right direction would be great.

Matt

Access: Fixed Position Under Can Grow Control?
On my Access Report, I have two columns of data (to make it fit on one page). on the right side at the top is a Can Grow text box. It works well and pushes the information on the right side down properly, but it ALSO pushes the information down on the left side, even though no part of it extends over these controls. Is there a way to fix a position of a control so that the Can Grow textbox does not change its position?

This question has been asked before with no answer, but hopefully I can get one this time:
http://www.xtremevbtalk.com/showthread.php?t=132668

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