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!

windowtop & windowleft to position form

Status
Not open for further replies.

Eupher

MIS
Jul 18, 2002
1,724
US
Not being completely satisfied with the many ActiveX-less date picker solutions out there (though many are quite good), I decided to build my own. I'm setting it up so that when the user clicks a button the calendar pops up immediately beneath the associated date field, sorta like an ActiveX date picker would. I'm using the following calculation to determine where the calendar form should be positioned when it opens, then the Move method to position the form at the desired coordinates:
Code:
p_TopPos = Me.WindowTop + Me!txtMyDate.Top + Me!txtMyDate.Height
p_LeftPos = Me.WindowLeft + Me!txtMyDate.Left
The left positioning works just fine. As you can see, the top positioning simply sums the form's distance from the top of the Access window, the control's distance from the top of the form, and the date field's height to theoretically arrive at the bottom edge of the date field. But it doesn't put the calendar form at the bottom edge of the date field, it's slightly above the top edge of the field. If I add 320 twips to the sum it positions it about right, but I'm curious why this is so. Is there a margin or a scrollbar dimension (no scrollbars on this form) or some such that I'm failing to account for?

Thanks for any insight.

Ken S.
 
Don't you have a Header section ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Upon further investigation, it appears the calling form's title bar is the missing dimension. If I position the calendar at Me.WindowTop, it displays at the very top of the form, not the top of the detail section. But Me!txtMyDate.Top returns the distance to the control from the top of the detail section, not the top of the title bar. I didn't find a property or method to access the height of the title bar (or the title bar itself, for that matter). Wonder if there's another way? Maybe windowheight minus insideheight? I'll give it a try and see what I come up with.

Ken S.
 
If your date picker forms "BorderStyle" property is set to "None" then your problem will be solved - However a word of warning! Put a close form button on the form or you won't be able to close it. (or set a double-click on the form background to close the form)

Just ideas

Tony
 
Hi, Tony, thanks for the input. The dimensions of the datepicker form itself don't seem to be the issue, rather the dimensions of the form that is calling the datepicker form. I'm trying to position the datepicker relative to objects on the calling form. I did play around with the BorderStyle property on the calling form and you're absolutely right. If you remove the border from the equation, all the measurements add up. Oddly, I can't seem to find a property which accounts for the dimensions of the border. FWIW, looks like any BorderStyle property on the datepicker is being over-ridden by the fact that I'm opening it in dialog mode.

Ken S.
 
As far as I am aware this is problem that has no direct solution as the size (height) of the titlebar of any form is tied by the font size, as set in the Windows Advanced Appearance settings. Unfortunately if you add 320 twips to the posioning code it will only be correct at a certain screen resolution and font settings. If I think of a work-around I will let you know!

Regards

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top