Solved

Choose Font and Choose Color Dialogs - error when left open

Posted on 2011-09-06
3
415 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
Comment Utility
can you use the Application.FileDialog() method instead of the API?
0
 
LVL 2

Accepted Solution

by:
dstorm10 earned 500 total points
Comment Utility
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
Comment Utility
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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

763 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

11 Experts available now in Live!

Get 1:1 Help Now