Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

A simple way to control a common dialog's position

Total Hit ( 4198)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


The CommonDialog control doesn't provide any direct way to decide where a common dialog appears on the screen. In all cases, in fact, the control tries to display the common dialog centered on its owner form. This behavior suggests a simple way to affect the approximate position of the common dialog.

The trick is simple: instead of using a CommonDialog control on the current form, you place the CommonDialog control on another form. This form will be always invisible, and its only purpose is to affect where the common dialog be be displayed.

Create a form, name it frmCD, and place a CommonDialog control on it. Then, run the following code from another form when you want to display the Color common dialog in the upper-left corner of the screen:

Click here to copy the following block
Dim frmCD As New frmCD
frmCD.Move 0, 0
frmCD.CommonDialog1.ShowColor

Similarly, here's how you display the common dialog approximately at the center of the screen:

Click here to copy the following block
Dim frmCD As New frmCD
frmCD.Move (Screen.Width - frmCD.Width) / 2, (Screen.Height - frmCD.Height) / 2
frmCD.CommonDialog1.ShowColor

Note that this method lets you affect the position of the common dialog only approximately. For a more precise placement you must resort to more advanced techniques, such as subclassing.


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.