Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Converting Unicode data from the Clipboard to a character string using a given code page
Changing file attributes
Copying picture of the active form to the Clipboard using Enhanced Metafile API functions
Enumerating data formats currently available on the clipboard
How to print FoxPro form
Obtaining current Internet Explorer browser version and UserAgent
Custom GDI+ class
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
Creating a clipping region from the path selected into the device context of a form
Storing content of the Clipboard to a bitmap file
FindText -- the hopeless and useless Common Dialog
How to create transparent areas inside a form -- punching holes in the form
Using EnumPrinters function to enumerate locally installed printers
Enumerating Processes -- WinNT
A procedure for setting file times
Retrieving the name of the primary domain controller (PDC) and join status information
Using FrameRgn for displaying system colors
Placing a button on the VFP form as a new child window
Using the DeleteFile
Using the Semaphore object to allow only one instance of VFP application running
Storing screen shot of a form to bitmap file
Enhanced GetFont dialog

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
Comparing to the dialog invoked by the GETFONT(), this one offers few more adjustable parameters: strikeout and underline effects and font color.


See also:
  • GDI+: enumerating fonts installed on the system
  • How to change font name and size in the MessageBox dialog
  • How to position the GETPRINTER() dialog
  • Vertical Label control
  • DO decl 
    
    #DEFINE GMEM_FIXED                 0
    #DEFINE LF_FACESIZE               32
    #DEFINE FW_NORMAL                400
    #DEFINE DEFAULT_CHARSET            1
    #DEFINE OUT_DEFAULT_PRECIS         0
    #DEFINE CLIP_DEFAULT_PRECIS        0
    #DEFINE DEFAULT_QUALITY            0
    #DEFINE DEFAULT_PITCH              0
    #DEFINE CF_SCREENFONTS             1
    #DEFINE CF_INITTOLOGFONTSTRUCT    64
    #DEFINE CF_EFFECTS               256
    #DEFINE CF_FORCEFONTEXIST      65536
    
    *| typedef struct { 
    *|   DWORD        lStructSize;     4
    *|   HWND         hwndOwner;       4
    *|   HDC          hDC;             4
    *|   LPLOGFONT    lpLogFont;       4
    *|   INT          iPointSize;      4
    *|   DWORD        Flags;           4
    *|   COLORREF     rgbColors;       4
    *|   LPARAM       lCustData;       4
    *|   LPCFHOOKPROC lpfnHook;        4
    *|   LPCTSTR      lpTemplateName;  4
    *|   HINSTANCE    hInstance;       4
    *|   LPTSTR       lpszStyle;       4
    *|   WORD         nFontType;       2
    *|   WORD         ___MISSING_ALIGNMENT__; 2
    *|   INT          nSizeMin;        4
    *|   INT          nSizeMax;        4
    *| } CHOOSEFONT, *LPCHOOSEFONT; total: 60 bytes
    
    *| typedef struct tagLOGFONT { 
    *|   LONG lfHeight;                   4
    *|   LONG lfWidth;                    4
    *|   LONG lfEscapement;               4
    *|   LONG lfOrientation;              4
    *|   LONG lfWeight;                   4
    *|   BYTE lfItalic;                   1
    *|   BYTE lfUnderline;                1
    *|   BYTE lfStrikeOut;                1
    *|   BYTE lfCharSet;                  1
    *|   BYTE lfOutPrecision;             1
    *|   BYTE lfClipPrecision;            1
    *|   BYTE lfQuality;                  1
    *|   BYTE lfPitchAndFamily;           1 
    *|   TCHAR lfFaceName[LF_FACESIZE];  32
    *| } LOGFONT, *PLOGFONT; total: 60 bytes
    
        LOCAL lcChooseFont, lcLogFont, hLogFont, lcFontFace
    
        * initializing LOGFONT structure:
        * Times New Roman, Italic
        lcLogFont = num2dword(16) +;
            num2dword(0)  +;
            num2dword(0)  +;
            num2dword(0)  +;
            num2dword(FW_NORMAL) +;
            Chr(1) +;
            Chr(0) +;
            Chr(0) +;
            Chr(DEFAULT_CHARSET)     +;
            Chr(OUT_DEFAULT_PRECIS)  +;
            Chr(CLIP_DEFAULT_PRECIS) +;
            Chr(DEFAULT_QUALITY)     +;
            Chr(DEFAULT_PITCH)       +;
            PADR("Times New Roman"+Chr(0),32)
    
        * copying the LOGFONT data into the global memory object
        * because CHOOSEFONT structure uses the pointer
        lnLogFontSize = 60
        hLogFont = GlobalAlloc(GMEM_FIXED, lnLogFontSize)
    
        * this function is re-declared below
        * with different parameter types
        DECLARE RtlMoveMemory IN kernel32 As String2Heap;
            INTEGER Destination, STRING @ Source,;
            INTEGER nLength
        = String2Heap (hLogFont, @lcLogFont, lnLogFontSize)
    
        * initializing CHOOSEFONT structure
        lcChooseFont = num2dword(60) +;
            num2dword(0) +;
            num2dword(0) +;
            num2dword(hLogFont) +;
            num2dword(0) +;
            num2dword(CF_SCREENFONTS + CF_EFFECTS +;
                CF_INITTOLOGFONTSTRUCT + CF_FORCEFONTEXIST) +;
            num2dword(0) +;
            num2dword(0) +;
            num2dword(0) +;
            num2dword(0) +;
            num2dword(0) +;
            num2dword(0) +;
            num2dword(0) +;
            num2dword(0) +;
            num2dword(0)
    
        IF ChooseFont (@lcChooseFont) <> 0
        * displaying selection
            * re-declaring API function with different parameters
            DECLARE RtlMoveMemory IN kernel32 As Heap2String;
                STRING @Dest, INTEGER Source, INTEGER nLength
    
            * copying data from the global memory object to VFP string
            = Heap2String (@lcLogFont, hLogFont, lnLogFontSize)
    
            ? "*** CHOOSEFONT Structure:"
            ? "Point size:", buf2dword(SUBSTR(lcChooseFont, 17,4))
            ? "RGB color: ", buf2dword(SUBSTR(lcChooseFont, 25,4))
    
            ?
            ? "*** LOGFONT Structure:"
            ? "Font Weight:", buf2dword(SUBSTR(lcLogFont, 17,4))
            ? "Italic:     ", Iif(Asc(SUBSTR(lcLogFont, 21,1))=0, "No","Yes")
            ? "Underline:  ", Iif(Asc(SUBSTR(lcLogFont, 22,1))=0, "No","Yes")
            ? "Strikeout:  ", Iif(Asc(SUBSTR(lcLogFont, 23,1))=0, "No","Yes")
    
            lcFontFace = SUBSTR(lcLogFont, 29)
            lcFontFace = SUBSTR(lcFontFace, 1, AT(Chr(0),lcFontFace)-1)
            ? "Font Face:  ", lcFontFace
        ENDIF
    
        * releasing system resources
        = GlobalFree (hLogFont)
    RETURN
    
    PROCEDURE  decl
        DECLARE INTEGER ChooseFont IN comdlg32 STRING @lpcf
        DECLARE INTEGER GlobalFree IN kernel32 INTEGER hMem
        DECLARE INTEGER GlobalAlloc IN kernel32;
            INTEGER wFlags,;
            INTEGER dwBytes
    
    FUNCTION  num2dword (lnValue)
    #DEFINE m0       256
    #DEFINE m1     65536
    #DEFINE m2  16777216
        LOCAL b0, b1, b2, b3
        b3 = Int(lnValue/m2)
        b2 = Int((lnValue - b3*m2)/m1)
        b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
        b0 = Mod(lnValue, m0)
    RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)
    
    FUNCTION  buf2dword (lcBuffer)
    RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
        Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
        Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
        Asc(SUBSTR(lcBuffer, 4,1)) * 16777216
    
    

    User rating: 10/10 (1 votes)
    Rate this code sample:
    • ~
    4817 bytes  
    Created: 2001-09-20 12:00:00  
    Modified: 2009-02-25 15:22:31  
    Visits in 7 days: 232  
    Listed functions:
    ChooseFont
    GlobalAlloc
    GlobalFree
    Printer friendly API declarations
    My comment:
    GETFONT(cFontName [, nFontSize [, cFontStyle [, nFontCharSet])
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright 2001-2014 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.68), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.205.221.22)
    4 sec.Function: 'GetInterfaceInfo'
    Function group: 'IP Helper'
    5 sec.Function: 'NetWkstaGetInfo'
    Function group: 'Network Management'
    8 sec.Function: 'CreateSolidBrush'
    11 sec.Example: 'Testing serial ports'
    17 sec.Example: 'How to display Windows On-Screen Keyboard'
    Language: 'C#'
    Google
    Advertise here!