Solved

Choose Font and Choose Color Dialogs - error when left open

Posted on 2011-09-06
3
416 Views
Last Modified: 2012-05-12
I am using API functions to Choose a font and color using the below:-

Private Declare Function ChooseFont Lib "comdlg32.dll" Alias "ChooseFontA" _
(pChoosefont As FONTSTRUC) As Long
Private Declare Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" ( _
pChoosecolor As CHOOSECOLORSTRUCTURE) As Long

All works fine - only issue is that if a user leaves the font selector open they can close the form that opened the dialog and this creates an error. In some cases if they click on something else on the screen the font selector can hide behind other forms.

Is there a way to open the font (and color) selector as a dialog or in some way lock the form until it is closed or alternatively close the font selector when the form is closed?.

Appreciate any ideas

0
Comment
Question by:donhannam
3 Comments
 
LVL 45

Expert Comment

by:aikimark
ID: 36495607
can you use the Application.FileDialog() method instead of the API?
0
 
LVL 2

Accepted Solution

by:
dstorm10 earned 500 total points
ID: 36495757
If you use the code from here: http://support.microsoft.com/kb/153929  then you shouldn't have a problem.

I've attached a sample db that works fine for me.  

The example only uses the color choser common dialog box - I'm sure you'll work out how to do the font choser (though if you're struggling just say)

Ds
Color001.mdb
0
 

Author Closing Comment

by:donhannam
ID: 36507844
Thanks for that - the trick was to set the hwnd property to the active form. It then locked the form till the dialog was responded to.
In the example you have it set it as me.hwnd when in the forms code.
With the font I had the code in a module which declared a Type of FontStrut. in the code I had FS.hwnd = Screen.active.hwnd.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now