INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How do I set position of OpenDialog object?

How do I set position of OpenDialog object?

(OP)
Hello.  I have posted this question before but I still don't have an answer.  Your help would be MOST appreciated!
   What I want to do is really very simple.  I wish to launch an OpenDialog from my app and I wish to set the position to be in the center of the parent window.  However, there is no Top or Left property for the OpenDialog.  There is not even a Position property.  The Windows OS is deciding where the OpenDialog will be positioned and I don't know how to control this.  How do I set the Left, Top, and/or Position of the OpenDialog?  Thanks so much.

-Rob

RE: How do I set position of OpenDialog object?

Hi, try this :)

CODE


//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    Timer1->Enabled = true;
    OpenDialog1->Execute();
}
//---------------------------------------------------------------------------


void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
    Timer1->Interval = 125;
    UnicodeString TMPApriDialog_Title = L"ApriDialog_Univocal_Title_UDY78d093204du38287429dhqhdqi";
    static UnicodeString ORIGApriDialog_Title = L"";
    if( ORIGApriDialog_Title == L"" )
        ORIGApriDialog_Title = OpenDialog1->Title;
    OpenDialog1->Title = TMPApriDialog_Title;
    HWND hwnd = FindWindow(NULL, TMPApriDialog_Title.c_str() );
    if( hwnd )
    {
        WINDOWINFO info;
        info.cbSize = sizeof(WINDOWINFO);
        ::GetWindowInfo( hwnd, &info );
        int x = this->Left + ( (this->Width  - (info.rcWindow.right  - info.rcWindow.left) ) /2 );
        int y = this->Top  + ( (this->Height - (info.rcWindow.bottom - info.rcWindow.top ) ) /2 );
        ::SetWindowPos( hwnd          // handle of window
                      , HWND_TOP      // placement-order handle
                      , x             // horizontal position
                      , y             // vertical position
                      , 0             // width
                      , 0             // height
                      , SWP_NOSIZE ); // window-positioning flags
        OpenDialog1->Title = ORIGApriDialog_Title;
        ORIGApriDialog_Title = L"";
        Timer1->Enabled = false;
    }
}
//---------------------------------------------------------------------------

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close