Solved

Choose Font and Choose Color Dialogs - error when left open

Posted on 2011-09-06
3
420 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

815 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