How does one obtain in code the "Y" position of a text box control on a continuous form. The "X" is basically a constant for all records being displayed at any given time, but the "Y" of a given text box varies as the records are scrolled.
How does one obtain in code the "Y" position of a text box control on a continuous form. The "X" is basically a constant for all records being displayed at any given time, but the "Y" of a given text box varies as the records are scrolled.
The position of the control is relative to the detail section. The detail section is repeated.
Not sure what you're trying to achieve, but perhaps it's something this will solve?
http://www.lebans.com/SelectRow.htm
I've used it where I needed to requery a continuous form and the users wanted the form to return where it was. Normally I'd just bookmark the record, but they wanted it so that it would return to the same position on the screen as well.
That is correct. Now you appreciate the question
Paul has chimed in with a suggestion, I'll look at that a bit later this afternoon.
Paul,
I want to position a popup form in close proximity to a text box that has been clicked. I can't even find the "Y" coordinate of the record that contains the detected text box.
Assuming the textbox is in the detail section and not on the header/footer, perhaps it would be easier and close enough if you got the x / y coordinates of the mouse click?
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
PERFECT. Somehow, I had it on the brain that a mouse-down event wouldn't necessarily be associated with the control of interest, but rather the form itself.
The MouseDown event, for example, applies to forms, form sections and controls on a form (not a report) and all mouse events that occur are relative to that object. I suppose you could get the x and y coordinates of the top and left of the control, but don't know what you'd get for the vertical position on a continuous form. Using the API call to get the coordinates is with respect to the application window, I believe. Both methods may not suit your purpose. I also think either answer will be in twips, which you might have to convert if you want to open a popup form at the mouse position.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
Getting the x,y relative to the app window works fine. And, since the x is constant within the detail section for any given control on a continuous form, I can fine tune the positioning of the popup in the horizontal if desired.
And yes, the units are in twips. The only exception that I know of to that is the use of GetXCursorPos() and GetYCursorPos(), two function entry points in api apiGetWindowRect. The values returned there need to be converted to twips, (X 15).
Thanks,
Bill
Good call, the mouse events. That was going to be my second thought. I use that in a db where users can move labels around on a "map" background to keep track of where taxis are. The x/y coordinates tell me what zone they're in, based on a table of grids.
WOW! I thought I was "out of the woods" on this one. How is it that the x,y reported with the Mouse_Down event is 735,135 where I know that the x coordinate should be more like 7980 twips! (controlname.Left = 5.5417")
Your numbers are relative to the top left of the control (or form if the mousedown is on the form), no?
A conversion calculator I used gave me 7980.048 for 5.5147, so your click was probably 735,135 (twips) offset from the control top left.
Last edited by Micron; 12-31-2015 at 03:06 PM. Reason: calculator
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
I've gone "full circle"! Namely, back to my original understanding in that the x,y of a mousedown on a control is the x,y relative to the control's upper left corner. So, on a continuous form, I can always come up with a fairly accurate x value but knowing where the current record is on the screen is somewhat of a "crap-shoot" using the api referenced earlier in this thread.
So I'm not sure how close you need to be. What about using the GetCursorPos API on the control's mousedown event? It will return the vertical position in twips relative to the window (I think, as opposed to the screen - not sure which), but at least it won't be relative to the control. I placed a vertical line over a control on a continuous form and tried to keep the left/right position as close to the line as possible. I see that it returns the vertical position while the left/right is fairly constant.How does one obtain in code the "Y" position of a text box control on a continuous form.
but knowing where the current record is on the screen is somewhat of a "crap-shoot
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
I used the api:
To obtain the "Y" coordinate in the click event. If I have any further problems, I'll pursue the use of the GetCursorPos API.The only exception that I know of to that is the use of GetXCursorPos() and GetYCursorPos(), two function entry points in api apiGetWindowRect. The values returned there need to be converted to twips, (X 15).