473,651 Members | 2,518 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HOWTO: Get Web Control Screen Coordinates

How do you get the x,y pixel location of a textbox so that you can position
the Web Date Control popup nearby the associated textbox that will contain
the date selected by the Web Date Control?

--
Thank you kindly,
Dan Sikorsky BAB, BScE, MSC
Nov 18 '05 #1
2 4567
the following client functions work in most browsers:
findPosY = function(obj){
var curtop = 0;
if (document.getEl ementById || document.all) {
while (obj.offsetPare nt) {
curtop += obj.offsetTop;
if (typeof(obj.scr ollTop) == 'number')
curtop -= obj.scrollTop;
obj = obj.offsetParen t;
}
}
else if (document.layer s)
curtop += obj.y;
return curtop;
}

findPosX = function(obj) {
var curleft = 0;
if (document.getEl ementById || document.all) {
while (obj.offsetPare nt) {
curleft += obj.offsetLeft
obj = obj.offsetParen t;
}
}
else if (document.layer s)
curleft += obj.x;
return curleft;
}
-- bruse (sqlwork.com)
"Dan Sikorsky" <ds****@gte.net > wrote in message
news:e$******** ******@TK2MSFTN GP15.phx.gbl...
| How do you get the x,y pixel location of a textbox so that you can
position
| the Web Date Control popup nearby the associated textbox that will contain
| the date selected by the Web Date Control?
|
| --
| Thank you kindly,
| Dan Sikorsky BAB, BScE, MSC
|
|
Nov 18 '05 #2
JavaScript just won't do.

The .NET way should be to handle the button click event on the PostBack and
get the screen coordinates of the button. Then add reasonable offsets to the
x,y point and use that as the position to set the popup position.

Having the calendar on a panel, we need to:

pnlCalendar.Sty le.Item("top") = iTop

pnlCalendar.Sty le.Item("left") = iLeft

where iTop and iLeft are the aforementioned screen coordinates (needing to
be appropriately computed ... which is the purpose of this posting).

"bruce barker" <no***********@ safeco.com> wrote in message
news:OR******** ******@tk2msftn gp13.phx.gbl...
the following client functions work in most browsers:
findPosY = function(obj){
var curtop = 0;
if (document.getEl ementById || document.all) {
while (obj.offsetPare nt) {
curtop += obj.offsetTop;
if (typeof(obj.scr ollTop) == 'number')
curtop -= obj.scrollTop;
obj = obj.offsetParen t;
}
}
else if (document.layer s)
curtop += obj.y;
return curtop;
}

findPosX = function(obj) {
var curleft = 0;
if (document.getEl ementById || document.all) {
while (obj.offsetPare nt) {
curleft += obj.offsetLeft
obj = obj.offsetParen t;
}
}
else if (document.layer s)
curleft += obj.x;
return curleft;
}
-- bruse (sqlwork.com)
"Dan Sikorsky" <ds****@gte.net > wrote in message
news:e$******** ******@TK2MSFTN GP15.phx.gbl...
| How do you get the x,y pixel location of a textbox so that you can
position
| the Web Date Control popup nearby the associated textbox that will contain | the date selected by the Web Date Control?
|
| --
| Thank you kindly,
| Dan Sikorsky BAB, BScE, MSC
|
|

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
21441
by: Robin Senior | last post by:
Hi, I'm trying to drag and drop onto a Panel on my form. The panel is inside a groupBox, which of course is inside my form. When dropping the item onto my Panel, I want it to appear at that point on the Panel, and therefore need the mouse coordinates relative to the Panel and not the form itself. Something like: private void myPanel_DragDrop(object sender, DragEventArgs e) {
1
5080
by: Tantra Veda | last post by:
Hello C# gurus, I have a question about finding cursor position in NumericUpDown control. On my form I have a numericUpDown control with 2 decimal places. I want to increment value in the numeric box by 1 if my cursor is in front of the decimal point. If the cursor is after the decimal point, I want to increment the value by 0.1. How do I accomplish this? Is there a way to find out the cusror position in the control relative to decimal...
1
1736
by: Dan | last post by:
Hi. I want to be able to use the ListView::GetItemAt function from within the ListView's DragDrop event callback. My problem is that GetItemAt requires screen-space coordinates, and the DragEventArgs gives me the drop coordinates in control relative space. Is there an easier way than iterating up the parent hierarchy? Cheers for any help, Dan.
3
5749
by: ZorpiedoMan | last post by:
Help... I need the screen coordinates of a control so I can place a pop up form underneath it. --Zorpy *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
1
1681
by: zoneal | last post by:
OS: Win XP Language: VB.net or C# I have a program where I need to launch 2 separate instances of an App called "Main.exe". Each instance will need to be piped to there own video display. Both displays need to be running at a screen resolution of 640x480. I am able to force to screen resolution of the display that the app is
6
8658
by: Andrea V.F. | last post by:
How can I determine the control under the mouse cursor when a user muves the mouse?? For example if the user moves the cursor over a textbox i would receive the name of that textbox without using the "MouseMove" event for that textbox. Thanks
3
5389
by: steve | last post by:
Hi All I have textboxes within a TableLayoutpanel and I want to be able to position an independant control adjacent to a selected textbox This independent control allows selection of text to insert into the textbox I am having trouble achieving this, see code below, the x position is too far to the right and the y position is close to the bottom of the textbox and I want it to be side by side.
1
27048
by: Simon Verona | last post by:
I have a usercontrol which when entered pops up a form. I want the form to be aligned with the bottom edge of the user control. I was doing this by passing the usercontrol into the form as a parameter and using the left and top properties to find the location on the screen to position the form. However, these are relative to the container (panel/form/tabcontrol etc). How can I best locate or pass the actual screen coordinates of my...
5
27604
by: Jon Slaughter | last post by:
Is there a way to get a controls location in screen coordinates? (not relative to the container it is in)? Thanks, Jon
0
8349
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8795
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8695
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8576
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7296
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4143
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4281
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2696
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.