Results 1 to 10 of 10

Thread: [RESOLVED] how to make common dialog center

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] how to make common dialog center

    I use common dialog. How to make it center?

    Code:
    CommonDialog5.ShowColor

  2. #2
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: how to make common dialog center

    I don't think this is that easy. It might need subclassing.
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: how to make common dialog center

    When I click at green book, the common dialog appear on the top of the form. How to make it appear on the center of the screen?
    Attached Images Attached Images  

  4. #4
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: how to make common dialog center

    Put 'SetHook' in the Form_Load event.

    Put 'ReleaseHook' in the Form_Unload event.
    Attached Files Attached Files

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to make common dialog center

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: how to make common dialog center

    Quote Originally Posted by Chris001
    Put 'SetHook' in the Form_Load event.

    Put 'ReleaseHook' in the Form_Unload event.
    It good but have problem

    I have try this..When I run, the common dialog appear on the center. But When I try end the project, the program hang.. What the cause of this problem?
    Last edited by matrik02; Feb 7th, 2008 at 05:00 AM.

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: how to make common dialog center

    There are 3 possibilities that I can think of..
    1. You didn't "Put 'ReleaseHook' in the Form_Unload event.", as Chris001 specified.
    2. You aren't unloading the form properly (perhaps by using the evil "End" command), so the Form_Unload event is not running.
    3. The code that Chris001 provided has issues (I've had a quick look, and it seems fine).

    Based on how often we see it, I would expect number 2 to be the issue. To check if it is, put a MsgBox at the start of the Form_Unload event - if it doesn't show, you aren't closing your form properly.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: how to make common dialog center

    Quote Originally Posted by si_the_geek
    There are 3 possibilities that I can think of..
    1. You aren't unloading the form properly (perhaps by using the evil "End" command), so the Form_Unload event is not running.
    I used this button to end the program
    Attached Images Attached Images  

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: how to make common dialog center

    That is basically the same thing as the "End" command, and should not really be used (in any situation) unless you have no other alternative - like if your code is stuck in an infinite loop.

    In cases where you are using sub-classing (as you are here), it results in an obvious crash.. but in many cases it will do permanent damage that you don't notice until it is too late (like corrupting databases that you are connected to).

  10. #10
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Smile Re: how to make common dialog center

    Check out this link

    http://www.vbaccelerator.com/codelib/cmdlgd/cmdlgct.htm

    hope this helps

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