Fonts

schumarg

Registered User.
Local time
Today, 05:23
Joined
May 13, 2003
Messages
94
Hi,

I've an app that I would like to use a particular font for the forms. A font I'm sure is not on other computers that will be using the app.

Is there a way to install a particular font in the person's computer when they open the application.

Thanks,
 
Hi,


Thought that was it, but get errors.

Ambiguous name detected:AddFontResourse

Declare Function AddFontResource& Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String)

Declare Function AddFontResource& Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String)

I put the following in the form open event:

Dim retvalue as long
retvalue = AddFontResource("bgothl.ttf")

and the following in the form close event:

Dim retvalue As Long
retvalue = RemoveFontResource("bgothl.ttf")

Any ideas??

Thanks,
 
Bob,

You have the AddFont declared twice, you will get duplicate
definitions.

If that is not the case, then post your db and we'll look.

wayne
 
Hi,

Thanks, one was suppose to be the "Remove", pasted the "Add" twice.

I had declared them within the switchboard, but it doesn't like it.

"Constants, fixed-length strings, arrays, and Declare statements not allowed as Public members of object modules."

Modules and classes are a very weak point.
I would probably need good directions of where and how to put these.

I'll post the app tomorrow, it's late and I would have to remove some code before posting.

Thanks,
 
Bob,

It should be in a Public module.

Go ahead and post it tomorrow. It is late for you today.

See ya,
Wayne
 
Wayne,

Tried this morning with the module and your previous post link. Still not getting there.

One other question came up. The app will be on a server, the font I would like to use is on my desktop. Thinking that what I would like to accomplish is not possible. Would the font not also have to be on the server. How would the app know to go to my desktop for the font. Would or could the font file be attached and then installed. Really don't care to remove if installing on someones desktop is possible. One more font won't kill them. This is getting very confusing.

I tried to attach the file, zipped, but getting an error of file too big. Not sure why, it's on 405k.

Would it be acceptable to email the file directly.

Thanks in advance for you time.
 
Bob,

The function that they call will live in a Public module. Even
though it resides on the server, they will be running the API
routine that is on their machine and installing the font on
their machine.

Now, this is new turf for me, because I haven't had to deal
with fonts ...

Go to the database window. Go to the Modules tab.
Select New, paste your two function defs in, and save the
new module as "SomeName". "SomeName" is whatever you want.


From your main form, you can make the calls (remember to
use the Alias names).

If all else fails, Use the Compact/Repair, then ZIP, then
attach. If you are still over the limit, delete some unneeded
tables and/or data and repeat the above.

Wayne
 
Wayne,

Good morning, removed all forms and reports excep main Order form. Also removed all the code from the main form. Still too big. 290k.

The main form has alot of controls, assume this may be the reason I can't get it down any more.

Suggestions??

Thanks
 
Bob,

290K compacted and zipped?

Are you sure that you compacted?

Code won't reduce it by the required amount. You'd need
to drop about 50 pages. Delete any embedded graphipc if
you can.

Otherwise, let's try working this out.

1) Did you past the two API calls into a new module?

2) Did you remove the current definitions on your local
forms?

3) Make a call to them from your main form or wherever.

4) Run it and we'll address the error(s) as they come up.

We're closer to the end then you think.

Wayne
 
Wayne

Theres about 80 controls in the main form, maybe thats why it won't compact anymore than it has.

Let's try this, the module code is:

Option Compare Database
Option Explicit

Public Declare Function AddFontResource& Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String)
Public Declare Function RemoveFontResource& Lib "gdi32" Alias "RemoveFontResourceA" (ByVal lpFileName As String)

Function AddFontResource()
Dim retvalue As Long
retvalue = AddFontResource("C:\WINNT\Fonts\bgothl.ttf")
End Function

Function RemoveFontResource()
Dim retvalue As Long
retvalue = RemoveFontResource("C:\WINNT\Fonts\bgothl.ttf")
End Function

The code in the switchboard:

Private Sub Form_Open(Cancel As Integer)
retvalue

' Minimize the database window and initialize the form.
Dim retvalue As Long

' Move to the switchboard page that is marked as the default.
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.FilterOn = True
DoCmd.Maximize
End Sub

Private Sub Form_Close()
retvalue
End Sub

thanks,
 
Wayne,

I changed the Switchboard function call from:

retvalue to "RemoveFontResource" and "AddFontResource" for the Close and Open events.

Was a late night and wasn't thinking.

But still getting error of:

Ambiguous name detected: AddFontResource

"Function AddFontResource" is highlighted in the module window.
 
Wayne,

I added an "A" to the functions in the module and Switchboard code to match the 'Alias' in the declaration within the module and am not getting any more errors.

Function AddFontResourceA
Function RemoveFontResourceA

But not sure it's working either. Won't be able to try untill I get to work tomorrow.
 
Bob,

The following belongs in a New Public module ...

Code:
Option Compare Database 
Option Explicit 

Public Declare Function AddFontResource& Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) 
Public Declare Function RemoveFontResource& Lib "gdi32" Alias "RemoveFontResourceA" (ByVal lpFileName As String)


These are your duplicate defs. What we need it to figure out
to call them:


'Function AddFontResource()
'Dim retvalue As Long
'retvalue = AddFontResource("C:\WINNT\Fonts\bgothl.ttf")
'End Function

'Function RemoveFontResource()
'Dim retvalue As Long
'retvalue = RemoveFontResource("C:\WINNT\Fonts\bgothl.ttf")
'End Function


Let's assume that with a command button we remove/install
the fonts. (just for now ...)

Code:
Private Sub MyCommand_Click(Cancel As Integer)
Dim retvalue As Long
   retvalue = RemoveFontResourceA("C:\WINNT\Fonts\bgothl.ttf") 
   retvalue = AddFontResourceA("C:\WINNT\Fonts\bgothl.ttf") 
End Sub


Wayne
 
Wayne,

I'm assuming that the duplicate def's go in the Switchboard code.

I tried, although no errors, fonts did not change. I tried different fonts from the Fonts folder and the code ran, but the fonts in the forms did not change.
 
Bob,

The "duplicate" defs don't go anywhere ... that's why I
commented them out.

The public module code stays where it is.

I used a command button in my example. In the OnClick event
I removed and then installed that one font.

What code do you have on your switchboard and how is
it initiated. You can put a:

MsgBox("Hi I'm running code.")

to see if your code is running. Better yet would be to
put a Stop command in and use the debugger.

Wayne
 
Wayne,

I appreciate your patience.

My code that is in the module:

Option Compare Database
Option Explicit

Public Declare Function AddFontResource& Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String)
Public Declare Function RemoveFontResource& Lib "gdi32" Alias "RemoveFontResourceA" (ByVal lpFileName As String)
Function AddFontResourceA()
Dim retvalue As Long
retvalue = AddFontResourceA("c:\winnt\fonts\bgothm.ttf")
MsgBox "running add"
End Function
Function RemoveFontResourceA()
Dim retvalue As Long
retvalue = RemoveFontResourceA("c:\winnt\fonts\bgothl.ttf")
MsgBox "running remove"
End Function

In the switchboard:

Option Compare Database
Option Explicit
Private Sub Command28_Click()
AddFontResourceA
End Sub
Private Sub Form_Close()
AddFontResourceA
End Sub

Private Sub Form_Open(Cancel As Integer)
AddFontResourceA
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.FilterOn = True
DoCmd.Maximize
End Sub

Now I'm getting "Run time error 28' "Out of Stack Space"

Following code in the module is highlighted
retvalue = AddFontResourceA("c:\winnt\fonts\bgothm.ttf")
 
Bob,

Code:
'
' If these really live in a public module, great ...
'
Option Compare Database 
Option Explicit 

Public Declare Function AddFontResource& Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) 
Public Declare Function RemoveFontResource& Lib "gdi32" Alias "RemoveFontResourceA" (ByVal lpFileName As String)

Code:
'
' If these live anywhere, I'll ...
' These functions belong nowhere ...
' They recursively call themselves and will "stack overflow"
' Please get rid of them
'
Function AddFontResourceA() 
Dim retvalue As Long 
retvalue = AddFontResourceA("c:\winnt\fonts\bgothm.ttf") 
MsgBox "running add" 
End Function 
Function RemoveFontResourceA() 
Dim retvalue As Long 
retvalue = RemoveFontResourceA("c:\winnt\fonts\bgothl.ttf") 
MsgBox "running remove" 
End Function


In the switchboard:

'
' On form open, or when you hit the command button
' you should call the add a font routine ...
'
Option Compare Database
Option Explicit

Private Sub Command28_Click()
Msgbox("Adding font ...")
AddFontResourceA
End Sub

Private Sub Form_Close()
Msgbox("Adding font ...")
AddFontResourceA
End Sub

Private Sub Form_Open(Cancel As Integer)
Msgbox("Adding font ...")
AddFontResourceA
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.FilterOn = True
DoCmd.Maximize
End Sub

Let me know,
Wayne
 
Wayne,

Not sure I understand that the following should live nowhere. Presently they're in the module.
'
' If these live anywhere, I'll ...
' These functions belong nowhere ...
' They recursively call themselves and will "stack overflow"
' Please get rid of them
'
Function AddFontResourceA()
Dim retvalue As Long
retvalue = AddFontResourceA("c:\winnt\fonts\bgothm.ttf")
MsgBox "running add"
End Function
Function RemoveFontResourceA()
Dim retvalue As Long
retvalue = RemoveFontResourceA("c:\winnt\fonts\bgothl.ttf")
MsgBox "running remove"
End Function

Do you mean that they should not be in the module either. If not, there is no code to say what font is to be added or removed.

I remvoed them and get 'Sub or Function Not Defined', and the 'AddFontResourceA' is highlighted in the Switchboard code.

Really confused now.
And your patience must be coming to an end.
 

Users who are viewing this thread

Back
Top Bottom