Page 1 of 1

Posted: Sat May 04, 2002 2:42 pm
by BackupUser
Restored from previous forum. Originally posted by wickedRush.

I know i'm missing something but i sure can't find it. I even opened the "commdlg32.dll" library and called ChooseFont with no luck.????

Code: Select all

Structure LOGFONT2
 lfHeight.l
 lfWidth.l
 lfEscapement.l
 lfOrientation.l
 lfWeight.l
 lfItalic.b
 lfUnderline.b
 lfStrikeOut.b
 lfCharSet.b
 lfOutPrecision.b
 lfClipPrecision.b
 lfQuality.b
 lfPitchAndFamily.b
 lfFaceName.b[50]
EndStructure
Structure CHOOSEFONT
 lStructSize.l
 hwndOwner.l
 hDC.l
 lpLogFont.l
 iPointSize.l
 Flags.l
 rgbColors.l
 lCustData.l
 lpfnHook.l
 lpTemplateName.b
 hInstance.l
 lpszStyle.l
 nFontType.w
 missing_alignment.w 
 nSizeMin.l
 nSizeMax.l
EndStructure

Declare Font()

Quit.l = 0
#TRUE = 1
If OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu, "All Fonts")
    Repeat
        EventID.l = WaitWindowEvent()
        If EventID = #PB_EventCloseWindow
         Quit = 1
        ElseIf EventID = #PB_EVENTREPAINT
         Font()
        EndIf
    Until Quit = 1
  EndIf
End

Procedure Font()
  lf.LOGFONT2
  lf\lfHeight=-24
  lf\lfWeight=700
  lf\lfWidth=0
  lf\lfStrikeOut=1
  PokeS(@lf\lfFaceName[0], "cuckoo")

  cf.CHOOSEFONT
  cf\lStructSize=SizeOf(CHOOSEFONT)
  cf\hwndOwner=WindowID()
  cf\hDC=#NULL
  cf\lpLogFont=@lf
  cf\iPointSize=0
  cf\rgbColors=0
  cf\lCustData=0
  cf\lpfnHook=0
  cf\lpTemplateName=0
  cf\hInstance=0
  cf\lpszStyle=0
  cf\nSizeMax=0
  cf\nSizeMin=0
  cf\nFontType=0
  cf\Flags=#CF_INITTOLOGFONTSTRUCT | #CF_SCREENFONTS | #CF_EFFECTS

 ChooseFont_(@cf) ; Does nothing....

 *DC = GetDC_(WindowID())
 SetBkMode_(*DC, #TRANSPARENT) 
 fontHdl=CreateFontIndirect_(@lf.LOGFONT2)
 SelectObject_(*DC,fontHdl)
 SetTextColor_(*DC,$00000ff)
 TextOut_(*DC,10,10,"My Font",7)
 DeleteObject_(fontHdl)
 ReleaseDC_(WindowID(), *DC)
EndProcedure
 
Any help would be great, Thanks!

Posted: Sat May 04, 2002 3:40 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.
lpTemplateName.b
Incorrect, should be:

Code: Select all

 lpTemplateName.l
The code works now, but this is also incorrect:
lfFaceName.b[50]
Should be:

Code: Select all

 lfFaceName.b[32]
Bye,

El_Choni

Edited by - El_Choni on 04 May 2002 16:40:51

Posted: Sat May 04, 2002 6:32 pm
by BackupUser
Restored from previous forum. Originally posted by wickedRush.

that works great! I new I was missing something, Thanks!