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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set initial position of OpenPictureDialog

Status
Not open for further replies.

HuntsvilleRob

Programmer
Nov 3, 2010
26
US
Hello. I've written an app in Borland C++ Builder 6 to work on multiple monitors. When I have the main app window on a given monitor and I click on Open Picture (launching the OpenPictureDialog), the OpenPictureDialog always opens in the middle of the main monitor. I want it to open centered on the main app window, on whichever monitor the main app window happens to be on. I can find no option in the TOpenPictureDialog class to set its position! I always just opens where it wants to! How can I set this? Thanks!
-Rob
 
Look at the form that holds the OpenPictureDialog. There is a property named "Postiion." In this property, you can set where the form "pops" up.

Help said:
VCL Reference
TCustomForm::position

Represents the size and placement of the form.

enum TPosition { poDesigned, poDefault, poDefaultPosOnly, poDefaultSizeOnly, poScreenCenter, poDesktopCenter, poMainFormCenter, poOwnerFormCenter };

__property TPosition Position = {read=FPosition, write=SetPosition, stored=IsForm, default=poDesigned};

Description
Use Position to get or set the size and placement of the form. Position can have one of the following TPosition values:

Value Meaning
poDesigned The form appears positioned on the screen and with the same height and width as it had at design time.

poDefault The form appears in a position on the screen and with a height and width determined by the operating system. Each time you run the application, the form moves slightly down and to the right. The right side of the form is always near the far right side of the screen, and the bottom of the form is always near the bottom of the screen, regardless of the screen's resolution.

poDefaultPosOnly The form displays with the size you created it at design time, but the operating system chooses its position on the screen. Each time you run the application, the form moves slightly down and to the right. When the form can no longer move down and to the right and keep the same size while remaining entirely visible on the screen, the form displays at the top-left corner of the screen.

poDefaultSizeOnly The form appears in the position you left it at design time, but the operating system chooses its size. The right side of the form is always near the far right side of the screen, and the bottom of the form is always near the bottom of the screen, regardless of the screen's resolution.

poScreenCenter The form remains the size you left it at design time, but is positioned in the center of the screen. In multi-monitor applications, the form may be moved from this center position so that it falls entirely on one monitor, as specified by the DefaultMonitor property.

poDesktopCenter The form remains the size you left it at design time, but is positioned in the center of the screen. No adjustments are made for multi-monitor applications.

poMainFormCenter The form remains the size you left it at design time, but is positioned in the center of the application’s main form. No adjustments are made for multi-monitor applications. This position should only be used with secondary forms. If set for a main form, it acts like poScreenCenter.

poOwnerFormCenter The form remains the size you left it at design time, but is positioned in the center of the form specified by the Owner property. If the Owner property does not specify a form, this position acts like poMainFormCenter.

I suspect that you aught to change the form's position to poOwnerFormCenter.


James P. Cottingham
I'm number 1,229!
I'm number 1,229!
 
Hello, James.
Thank you for your reply. If I look at the Object Inspector for OpenDialog or OpenPictureDialog, then click on the Properties tab, I do not see a Position property. If these forms have a Position property, how do I set it? Thanks again.

-Rob
 
It should be on the form where the dialog is. Form1->Position->poMainFormCenter or something like that. Check your help file.


James P. Cottingham
I'm number 1,229!
I'm number 1,229!
 
There is no Position property on the OpenDialog or OpenPictureDialog object. If I change the Position property "on the form where the dialog is", i.e.- the owner form of the OpenDialog, it will change where the *owner* opens, not the OpenDialog. Any other suggestions? Thanks.
 
The property isn't on the dialog, it's on the form that holds the dialog.


James P. Cottingham
I'm number 1,229!
I'm number 1,229!
 
I'm sure you're right but I don't know what you mean by "the form that holds the dialog". As I already mentioned, if you change the Position property of the owner form of the dialog, you only change the position of the owner form, not the position of its children. Could you please be more specific? I really do appreciate your guidance! Thanks.

-Rob
 
Since I don't use multiple monitors, I really can't say how the form works. When I drop a dialog onto a form, the dialog is linked to the form but since this is a multiple monitor app, I'm kinda lost.

James P. Cottingham
I'm number 1,229!
I'm number 1,229!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top