Je suis sous Access 2000 et je souhaiterais cr=E9er un bout=20
de code me permettant de mettre la liste des polices=20
install=E9es sur mon ordi dans une table Access
Sous vb6, j'arrive =E0 utiliser l'objet Printer, mais sous=20
Access il semble que ce soit autre chose, qu'en est il ?
Mon code sous vb6 (avec comme table, la table POLICE=20
poss=E9dant le champ NOM :
For i =3D 0 To Printer.FontCount - 1
Rs.AddNew
Rs("NOM") =3D Printer.Fonts(i)
Rs.Update
Next i
Public Type LOGFONT lfHeight As Long lfWidth As Long lfEscapement As Long lfOrientation As Long lfWeight As Long lfItalic As Byte lfUnderline As Byte lfStrikeOut As Byte lfCharSet As Byte lfOutPrecision As Byte lfClipPrecision As Byte lfQuality As Byte lfPitchAndFamily As Byte lfFaceName(LF_FACESIZE) As Byte End Type
Public Type NEWTEXTMETRIC tmHeight As Long tmAscent As Long tmDescent As Long tmInternalLeading As Long tmExternalLeading As Long tmAveCharWidth As Long tmMaxCharWidth As Long tmWeight As Long tmOverhang As Long tmDigitizedAspectX As Long tmDigitizedAspectY As Long tmFirstChar As Byte tmLastChar As Byte tmDefaultChar As Byte tmBreakChar As Byte tmItalic As Byte tmUnderlined As Byte tmStruckOut As Byte tmPitchAndFamily As Byte tmCharSet As Byte ntmFlags As Long ntmSizeEM As Long ntmCellHeight As Long ntmAveWidth As Long End Type
'ntmFlags field flags Public Const NTM_REGULAR = &H40& Public Const NTM_BOLD = &H20& Public Const NTM_ITALIC = &H1&
'tmPitchAndFamily flags Public Const TMPF_FIXED_PITCH = &H1 Public Const TMPF_VECTOR = &H2 Public Const TMPF_DEVICE = &H8 Public Const TMPF_TRUETYPE = &H4
Public Const ELF_VERSION = 0 Public Const ELF_CULTURE_LATIN = 0
'EnumFonts Masks Public Const RASTER_FONTTYPE = &H1 Public Const DEVICE_FONTTYPE = &H2 Public Const TRUETYPE_FONTTYPE = &H4
Public Declare Function EnumFontFamilies Lib "gdi32" _ Alias "EnumFontFamiliesA" _ (ByVal hDC As Long, _ ByVal lpszFamily As String, _ ByVal lpEnumFontFamProc As Long, _ lParam As Any) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Function EnumFontFamProc(lpNLF As LOGFONT, _ lpNTM As NEWTEXTMETRIC, _ ByVal FontType As Long, _ lParam As String) As Long
Dim FaceName As String Dim rst As Recordset
'convert the returned string from Unicode to ANSI FaceName = StrConv(lpNLF.lfFaceName, vbUnicode)
Set rst = CurrentDb.OpenRecordset("tblPolice", dbOpenDynaset) With rst .AddNew .Fields("fldPolice") = left$(FaceName, InStr(FaceName, vbNullChar) - 1) .Update End With
rst.Close: Set rst = Nothing EnumFontFamProc = 1
End Function
Private Sub Command2_Click() Dim hDC As Long hDC = GetDC(Application.hWndAccessApp) EnumFontFamilies hDC, vbNullString, AddrOf("EnumFontFamProc"), "tblPolice"
End Sub *****************************************************
-- @+ Jessy Sempere - Access MVP
------------------------------------ Site @ccess : http://access.jessy.free.fr/ Pour l'efficacité de tous : http://users.skynet.be/mpfa/ ------------------------------------ "Nicolas" a écrit dans le message news: def401c43be8$73ed9ce0$ Bonjour,
Je suis sous Access 2000 et je souhaiterais créer un bout de code me permettant de mettre la liste des polices installées sur mon ordi dans une table Access
Sous vb6, j'arrive à utiliser l'objet Printer, mais sous Access il semble que ce soit autre chose, qu'en est il ?
Mon code sous vb6 (avec comme table, la table POLICE possédant le champ NOM :
For i = 0 To Printer.FontCount - 1 Rs.AddNew Rs("NOM") = Printer.Fonts(i) Rs.Update Next i
Merci d'avance
Nicolas
Bonjour
Le code qui suit devrait te convenir, il utilises une table qui s'appele
"tblPolice" avec un champ qui se nomme "fldPolice"...
Public Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(LF_FACESIZE) As Byte
End Type
Public Type NEWTEXTMETRIC
tmHeight As Long
tmAscent As Long
tmDescent As Long
tmInternalLeading As Long
tmExternalLeading As Long
tmAveCharWidth As Long
tmMaxCharWidth As Long
tmWeight As Long
tmOverhang As Long
tmDigitizedAspectX As Long
tmDigitizedAspectY As Long
tmFirstChar As Byte
tmLastChar As Byte
tmDefaultChar As Byte
tmBreakChar As Byte
tmItalic As Byte
tmUnderlined As Byte
tmStruckOut As Byte
tmPitchAndFamily As Byte
tmCharSet As Byte
ntmFlags As Long
ntmSizeEM As Long
ntmCellHeight As Long
ntmAveWidth As Long
End Type
'ntmFlags field flags
Public Const NTM_REGULAR = &H40&
Public Const NTM_BOLD = &H20&
Public Const NTM_ITALIC = &H1&
'tmPitchAndFamily flags
Public Const TMPF_FIXED_PITCH = &H1
Public Const TMPF_VECTOR = &H2
Public Const TMPF_DEVICE = &H8
Public Const TMPF_TRUETYPE = &H4
Public Const ELF_VERSION = 0
Public Const ELF_CULTURE_LATIN = 0
'EnumFonts Masks
Public Const RASTER_FONTTYPE = &H1
Public Const DEVICE_FONTTYPE = &H2
Public Const TRUETYPE_FONTTYPE = &H4
Public Declare Function EnumFontFamilies Lib "gdi32" _
Alias "EnumFontFamiliesA" _
(ByVal hDC As Long, _
ByVal lpszFamily As String, _
ByVal lpEnumFontFamProc As Long, _
lParam As Any) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Function EnumFontFamProc(lpNLF As LOGFONT, _
lpNTM As NEWTEXTMETRIC, _
ByVal FontType As Long, _
lParam As String) As Long
Dim FaceName As String
Dim rst As Recordset
'convert the returned string from Unicode to ANSI
FaceName = StrConv(lpNLF.lfFaceName, vbUnicode)
Set rst = CurrentDb.OpenRecordset("tblPolice", dbOpenDynaset)
With rst
.AddNew
.Fields("fldPolice") = left$(FaceName, InStr(FaceName, vbNullChar) -
1)
.Update
End With
rst.Close: Set rst = Nothing
EnumFontFamProc = 1
End Function
Private Sub Command2_Click()
Dim hDC As Long
hDC = GetDC(Application.hWndAccessApp)
EnumFontFamilies hDC, vbNullString, AddrOf("EnumFontFamProc"),
"tblPolice"
End Sub
*****************************************************
--
@+
Jessy Sempere - Access MVP
news@access.fr.vu
------------------------------------
Site @ccess : http://access.jessy.free.fr/
Pour l'efficacité de tous :
http://users.skynet.be/mpfa/
------------------------------------
"Nicolas" <nicolasheurtevin@wanadoo.fr> a écrit dans le message news:
def401c43be8$73ed9ce0$a601280a@phx.gbl...
Bonjour,
Je suis sous Access 2000 et je souhaiterais créer un bout
de code me permettant de mettre la liste des polices
installées sur mon ordi dans une table Access
Sous vb6, j'arrive à utiliser l'objet Printer, mais sous
Access il semble que ce soit autre chose, qu'en est il ?
Mon code sous vb6 (avec comme table, la table POLICE
possédant le champ NOM :
For i = 0 To Printer.FontCount - 1
Rs.AddNew
Rs("NOM") = Printer.Fonts(i)
Rs.Update
Next i
Public Type LOGFONT lfHeight As Long lfWidth As Long lfEscapement As Long lfOrientation As Long lfWeight As Long lfItalic As Byte lfUnderline As Byte lfStrikeOut As Byte lfCharSet As Byte lfOutPrecision As Byte lfClipPrecision As Byte lfQuality As Byte lfPitchAndFamily As Byte lfFaceName(LF_FACESIZE) As Byte End Type
Public Type NEWTEXTMETRIC tmHeight As Long tmAscent As Long tmDescent As Long tmInternalLeading As Long tmExternalLeading As Long tmAveCharWidth As Long tmMaxCharWidth As Long tmWeight As Long tmOverhang As Long tmDigitizedAspectX As Long tmDigitizedAspectY As Long tmFirstChar As Byte tmLastChar As Byte tmDefaultChar As Byte tmBreakChar As Byte tmItalic As Byte tmUnderlined As Byte tmStruckOut As Byte tmPitchAndFamily As Byte tmCharSet As Byte ntmFlags As Long ntmSizeEM As Long ntmCellHeight As Long ntmAveWidth As Long End Type
'ntmFlags field flags Public Const NTM_REGULAR = &H40& Public Const NTM_BOLD = &H20& Public Const NTM_ITALIC = &H1&
'tmPitchAndFamily flags Public Const TMPF_FIXED_PITCH = &H1 Public Const TMPF_VECTOR = &H2 Public Const TMPF_DEVICE = &H8 Public Const TMPF_TRUETYPE = &H4
Public Const ELF_VERSION = 0 Public Const ELF_CULTURE_LATIN = 0
'EnumFonts Masks Public Const RASTER_FONTTYPE = &H1 Public Const DEVICE_FONTTYPE = &H2 Public Const TRUETYPE_FONTTYPE = &H4
Public Declare Function EnumFontFamilies Lib "gdi32" _ Alias "EnumFontFamiliesA" _ (ByVal hDC As Long, _ ByVal lpszFamily As String, _ ByVal lpEnumFontFamProc As Long, _ lParam As Any) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Function EnumFontFamProc(lpNLF As LOGFONT, _ lpNTM As NEWTEXTMETRIC, _ ByVal FontType As Long, _ lParam As String) As Long
Dim FaceName As String Dim rst As Recordset
'convert the returned string from Unicode to ANSI FaceName = StrConv(lpNLF.lfFaceName, vbUnicode)
Set rst = CurrentDb.OpenRecordset("tblPolice", dbOpenDynaset) With rst .AddNew .Fields("fldPolice") = left$(FaceName, InStr(FaceName, vbNullChar) - 1) .Update End With
rst.Close: Set rst = Nothing EnumFontFamProc = 1
End Function
Private Sub Command2_Click() Dim hDC As Long hDC = GetDC(Application.hWndAccessApp) EnumFontFamilies hDC, vbNullString, AddrOf("EnumFontFamProc"), "tblPolice"
End Sub *****************************************************
-- @+ Jessy Sempere - Access MVP
------------------------------------ Site @ccess : http://access.jessy.free.fr/ Pour l'efficacité de tous : http://users.skynet.be/mpfa/ ------------------------------------ "Nicolas" a écrit dans le message news: def401c43be8$73ed9ce0$ Bonjour,
Je suis sous Access 2000 et je souhaiterais créer un bout de code me permettant de mettre la liste des polices installées sur mon ordi dans une table Access
Sous vb6, j'arrive à utiliser l'objet Printer, mais sous Access il semble que ce soit autre chose, qu'en est il ?
Mon code sous vb6 (avec comme table, la table POLICE possédant le champ NOM :
For i = 0 To Printer.FontCount - 1 Rs.AddNew Rs("NOM") = Printer.Fonts(i) Rs.Update Next i
C'est normal, c'est une fonction perso pour access 97...
Si tu es sur 2000 ou +, remplace :
AddrOf("EnumFontFamProc")
par :
AddressOf (EnumFontFamProc)
Sinon dis le moi, je te donnerais le code pour la fonction AddrOf...
@+ Jessy Sempere - Access MVP
------------------------------------ Site @ccess : http://access.jessy.free.fr/ Pour l'efficacité de tous : http://users.skynet.be/mpfa/ ------------------------------------ "Nicolas" a écrit dans le message news: dfdc01c43bfe$fdf94400$
Access ne comprend pas AddrOf, que faire ?
Nicolas
C'est normal, c'est une fonction perso pour access 97...
Si tu es sur 2000 ou +, remplace :
AddrOf("EnumFontFamProc")
par :
AddressOf (EnumFontFamProc)
Sinon dis le moi, je te donnerais le code pour la fonction AddrOf...
@+
Jessy Sempere - Access MVP
news@access.fr.vu
------------------------------------
Site @ccess : http://access.jessy.free.fr/
Pour l'efficacité de tous :
http://users.skynet.be/mpfa/
------------------------------------
"Nicolas" <nicolasheurtevin@wanadoo.fr> a écrit dans le message news:
dfdc01c43bfe$fdf94400$a601280a@phx.gbl...
C'est normal, c'est une fonction perso pour access 97...
Si tu es sur 2000 ou +, remplace :
AddrOf("EnumFontFamProc")
par :
AddressOf (EnumFontFamProc)
Sinon dis le moi, je te donnerais le code pour la fonction AddrOf...
@+ Jessy Sempere - Access MVP
------------------------------------ Site @ccess : http://access.jessy.free.fr/ Pour l'efficacité de tous : http://users.skynet.be/mpfa/ ------------------------------------ "Nicolas" a écrit dans le message news: dfdc01c43bfe$fdf94400$