Results 1 to 3 of 3

Thread: [RESOLVED] [2005] AboutBox location versus OpenFileDialog Location problem

  1. #1

    Thread Starter
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Resolved [RESOLVED] [2005] AboutBox location versus OpenFileDialog Location problem

    This seems rather strange to me and was wondering what the solution is:

    If i have a Form (Form1) and add a new item, an AboutBox, to my project (AboutBox1). If I open this Aboutbox from a menuStrip item (Help -> About), the AboutBox always appears in the centre of my form and it doesn't matter where the form is located or what size it is. That's great.

    If I have a File -> Open menu item and want to open an OpenFileDialog, it doesn't have the same behaviour. No matter what size or where my form is on the screen the dialog always opens in the same location which I really need to stop it from doing.

    Does anyone have answers to why this happens and more importantly - a solution so the OpenFileDialog does what the AboutBox does naturally.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] AboutBox location versus OpenFileDialog Location problem

    Bad luck I'm afraid. Your AboutBox is itself a form, thus you can set its StartPosition property. The OpenFileDialog is NOT a form itself. It is a component that, when you call its ShowDialog method, creates a form for you with all the required controls and functionality, which it then displays. You have no direct access to that form so you cannot set its StartPosition property before its dispalyed and you cannot set its Loaction property after its displayed. Your only option would be to use the SetWindowPos API to move the window after it's been displayed, but that will not be immediate.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: [2005] AboutBox location versus OpenFileDialog Location problem

    ok, thanks for the info. I'll look into the SetWindowPos API and see how it works out. I'll mark this resolved.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width