Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I think this forum rocks it has saved my bacon many many times..."

Geography

Where in the world do Tek-Tips members come from?

How do I set position of OpenDialog object?

HuntsvilleRob (Programmer)
24 Mar 12 17:09
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
Samuele1421 (Programmer)
1 Apr 12 17:36
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;
    }
}
//---------------------------------------------------------------------------

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!

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