Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the exact screen position of a subform control 1

Status
Not open for further replies.

comaboy

Programmer
Nov 6, 2001
261
GB
OK, here's the background...

I've been asked to create an 'Outlook-Style' combobox so that users can click the down-button to open the list and then sort on various fields by clicking on a heading label -
So I've built a little Pop-Up form, thrown some code into the Heading labels to sort when clicked on, and all is fine. Upon closing, the Pop-Up then sets the required info in the calling form. Now this 'calling' form (NOT parent, mind!) is actually a subform to a larger form (confused, yet /-)? with a textbox and button sitting beside it to fake the look of a combobox...

The problem I'm banging my head against is to position the form so it opens in the 'right' place to give the impression of a combo. There seems to be no way of getting the exact co-ordinates of the button on the subform with relation to the screen itself - there just isn't a
Code:
TOP
or
Code:
LEFT
property available to work it out... not even for the containing forms! I've looked at using the API, but hey, guess what, all the Access controls are Lightweight, so no HWND to fire a GetWindowRect call to.

This MUST have happened to someone before - I've tried searching the forums, MSDN and technet without success...

Anyone got any idea's?
 
Not sure if I follow but just keep moving it slightly until it's in the right place.

A bit fiddly but should get there with perseverance.
 
Thanks for the tip, StarPassing, but it doesn't help me. I know how to move and resize forms, what I can't get the position to move the form to.

Because of the nature of the mainform/subform, the button that opens the PopUp may appear at any position on the screen. To give the impression of a combo, the PopUp should appear below the button and aligned right.

The problem is that that Top and Left properties are only relative to the top of the subform, not the screen itself. It's this actual screen location that I'm trying to get at.

If anyone else has a suggestion, I'm all ears. This is one of things that should be simplicity itself, but turns into a nightmare when you try to actually do it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top