?
Solved

Choose Font and Choose Color Dialogs - error when left open

Posted on 2011-09-06
3
Medium Priority
?
429 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 46

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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

862 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