全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1423
推到 Plurk!
推到 Facebook!

Fonts with WM_SETFONT

 
conundrum
尊榮會員


發表:893
回覆:1272
積分:643
註冊:2004-01-06

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-02-19 20:49:57 IP:61.64.xxx.xxx 未訂閱
http://www.pfxcorp.com/news/newsletter/v10n01-pl.html#fonts         
Fonts with WM_SETFONT    --------------------------------------------------------------------------------    Christine Charalambous – POWERflex Corporation – Australia    There are a number of ways in which you can set the font in your Windows GUI mode applications.    One common method is to set the sFontName and sFontSize configuration items in the PFX.INI file, which sets the font name and size for the entire dialog. An alternative method is to set the fontName and fontSize properties of a FORM object in the definition hierarchy, which does the same.    Not so well known however, is the WM_SETFONT method. The major difference between WM_SETFONT and the above methods is that WM_SETFONT offers the ability to set the font properties for individual objects on a dialog, whereas the others can only be applied to the entire dialog.    WM_SETFONT is a Windows constant defined in the WINDEFS.PFI include file, and is easily used simply by passing it, the object handle and the font to the API call, winSendMessage.    Once the font of a particular object has been set using WM_SETFONT, it often becomes necessary to set the control height and/or width in the PFXplus Dialog Resource Editor to accommodate the new font size, especially where is it larger than the default.    Changing the font of a static is a bit different as there is no "static" object as such, so handles on statics need to be accessed in a different way to other controls. You will notice in the sample code below that two different methods have been used.    One of the methods utilised is to call the Windows function GetDlgItem. This function is passed the handle of the dialog on which the static resides, as well as the control ID of the static, as set by the resource compiler, MKRES. GetDlgItem returns a handle on the static control specified by the control ID.    The other method is to format a control as a static and pass the control object handle to winSendMessage.         The above is the output from a simple demonstration program, from which the block of code below was extracted. This program is available for download from this Web site.          Sample Code for Setting Fonts with WM_SETFONT
// Get handle using GetDlgItem
hStaticHandle= ;
      winGetDlgItem(oScreen1\handle(),1500)
sts=SetHeadingFont(hStaticHandle)    sts=SetStaticFont(s1_Static2\handle())    // Control formatted as a Static
FUNCTION SetHeadingFont integer hStaticHandle ;
      RETURNS indicator
 integer ijunk
 iStaticFont= WinCreateFont(20,; // Height
                            5,;  // Width
                            0,;  // Escapement
                            0,;  // Orientation
                            600,;// Weight
                            1,;  // Italic
                            0,;  // Underline
                            1,;  // StrikeOut
                            0,;  // CharSet
                            1,;  // Out Precision
                            2,;  // Clip Precision
                            1,;  // Quality
                            34,; // Pitch & Family
 string("Courier" character(0))) // Facename
 ijunk = WinSendMessage(hStaticHandle, ;
         WM_SETFONT, iStaticFont, True)
 RepaintWindow hStaticHandle
 result = true
END_FUNCTION     
系統時間:2024-05-01 11:52:09
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!