?
Solved

Choose Font and Choose Color Dialogs - error when left open

Posted on 2011-09-06
3
Medium Priority
?
428 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

650 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