?
Solved

Commondialog Positioning

Posted on 1999-12-29
12
Medium Priority
?
330 Views
Last Modified: 2013-12-25
How can I position the Commondialog Control on the screen?Becuase there are no properties by which i can move it at some particular position..
Also if we use MoveWindow API call then it requires hwnd as one of its parameter...

So please help me out
0
Comment
Question by:vipin072998
  • 6
  • 5
12 Comments
 
LVL 7

Accepted Solution

by:
kamall earned 200 total points
ID: 2313704
Here is a code snippest that will do the job for you. It is from planet-source-code.
     '***************************************************************
     ' Name: Control position of common dialogs!
     ' Description:A way to control where any of the common dialogs (p
     '     rint setup) windows are displayed from visual basic. (Randy Birch
     '     ,randy_birch@msn.com)
     ' By: Newsgroup Posting
     '
     '
     ' Inputs:None
     '
     ' Returns:None
     '
     'Assumes:A dialog aligns itself to the form on
     which the control is drawn. If you add to your project a new form and
     place the common dialog control on it, and in the Form_Load for that form
     add code to resize the form to 1x1, the dialog will appear wherever you
     ultimately move (reposition in code) the form to.
     This will centre a file open dialog on the screen.....
     '
     'Side Effects:None
     '
     'Code provided by Planet Source Code(tm) (http://www.PlanetSource
     '     Code.com) 'as is', without warranties as to performance, fitness,
     '     merchantability,and any other warranty (whether expressed or impl
     '     ied).
     '***************************************************************

     'Form1 is the main app with a command button to call the dialog w
     '     ith
     'Form2 is the form containing only the common dialog control.


Form1 code:


     Private Sub Command1_Click()
         
         Load Form2

         Form2.CommonDialog1.Flags = cdlOFNHideReadOnly

             Form2.CommonDialog1.Filter = "All Files (*.*)|*.*|"

                 Form2.CommonDialog1.FilterIndex = 2

                     Form2.CommonDialog1.ShowOpen
                         
                         Print Form2.CommonDialog1.filename
                         'do this last
                         Unload Form2
      End Sub


Form2 code:


     Private Sub Form_Load()

         Me.Move Screen.Width / 4, Screen.Height / 4, 1, 1

     End Sub
0
 
LVL 7

Expert Comment

by:kamall
ID: 2321750
Did it work fine?
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2328424
Good idea, kamall, but a slightly cheaper option is to place the common dialog on a container, for example a picture box. Set the picture box's border style to None, and its height and width to 0. Also make sure it has no tab stop, otherwise the user could tab into it, and their cursor will "dissappear". No major deal but annoying.

Apart from that the idea is the same. Position the picture box to the desired location before showing the common dialog.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 7

Expert Comment

by:kamall
ID: 2330820
Although I didn't test your solution, it seems pretty though.
Happy new year.
Regards.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2331434
HNY (&M)!
0
 
LVL 1

Expert Comment

by:prem_kumar_25
ID: 2355263
please drag and keep the dialog box to the position where u want it , on its first execution .then it will be placed there...
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2356201
That's a great suggestion if you want to display the common dialog in the same position all of the time, but totally useless if you want to implement a more dynamic positioning. Which is, quite obviously, what vipin intended to do all along.

Which reminds me..

vipin, what's up buddy? Kamall put in some effort to answer your question. He deserves at least the courtesy of a response. Don't be an arsehole. Thank you.
0
 
LVL 7

Expert Comment

by:kamall
ID: 2369447
caraf_g,
thanks for your kind comment.
Best regards.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2370040
:-(

It didn't help though.

I have some further bad news for you. Just check vipin's record:

Last 10 Grade(s) Given:
D C C C C C C C C C  
You can draw your own conclusions from this. I'm sure everyone gets a less than satisfactory answer sometimes, but it can't be as bad as this all the time..

Question Grading Record:
13 / 17
This speaks volumes. At least four of vipin's questions were answered and vipin never bothered to acknowledge the answers, let alone grade them.

Lesson of the day: before you answer any questions, check the asker's profile and make a point of never helping someone like this.

It's not easy though. As you can see, I commented too. I forget to check.

And that's how people like vipin can keep getting away with it.

What can *we* do?

Keep a link to this URL. Whenever you spot another question by vipin, post a comment to warn other experts and to ask them NOT to answer the question. And post this URL so they can read why.

I will.
0
 
LVL 7

Expert Comment

by:kamall
ID: 2376437
Thanks caraf_g.
You are absolutely right.

vipin,
Please, go ahead and and answer the q.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2379116
kamall, some people have no decency and no shame. vipin obviously is one of these people. I think you'll be waiting in vain for vipin to grade this question.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2690049
"I told you so"....

:-(
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question