You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
I appreciate some input on display font command if user does not select font size, if there is a way to check if no font size has not been select. the font requester always return size 10 if no size has been selected, I assume it is the current font size the application is using.
PBWin901..
Looks like you should have a defpoints& value other than 0.
Then you will get that value returned when the user doesn't make a size selection (unless you use the %CF_NOSIZESEL flag).
Code:
#Dim All
#Register NONE
#INCLUDE "WIN32API.INC"
Function PbMain()
Dim fontname$, defpoints&, fpoints&, style&, color&, charset&
'DISPLAY FONT [hParent], [xpos], [ypos], defname$, defpoints&, defstyle&, flags& _
'TO fontname$, points&, style& [,color&, charset&]
defpoints = 12 ' initial (default) point size.
DISPLAY FONT 0, , , "Arial", defpoints, 0, %CF_TTONLY _ 'OR %CF_NOSIZESEL _
To fontname, fpoints, style ,color, charset
' adding %CF_NOSIZESEL flag overrides default 'defpoints' size
' - point size 10 returned instead, if user makes no size selection..
MsgBox str$(fpoints),,"PointSze"
End Function
'------------------/PBMain
Thank you both for the input, Dave , I already tried this and faced with the following problem, there is one font I have with only one size , and it is different from the default. now I am storing the user selection, if user selected this font, assuming we have the same setup,it will store the default size which does not fit the selected font , on restart,font will not be displayed correctly.
I assume you are using the DDT 'DISPLAY FONT' statement but code not shown.
If you change to the ChooseFont() Windows API call, when the user clicks OK you can get a LOGFONT structure returned with the selection. If he picked this font which is not available in some size, you can stop him right there.
However, if this font is not a trueType font, he should not even be able to select a font in a size which is not available. No, I have not tried DISPLAY FONT to see what that does.
Thank you MCM for the valuable reply, that will do it, but I was hoping for the DDT Display Font command to do it , it is much shorter,However, your answer made the day, Thanks again.
After getting MM suggestion, I thought this statement from Microsoft is accurate " When ChooseFont returns, this structure contains information about the user's font selection", it is not, the 10 size it returns is not user selection, if font has font's size 10 , there is no way to till, if it is the user or Microsoft who selected that.does it make a difference , yes, if font has only size 9 for example , the application will store the size 10 for this font.
@Dave,Thank you, I am trying to find a way to know if user did not select a size, because the default size returned is not always present in all fonts.
I think I have to enumerate font size for the selected font, and if it is within the range for the font , I will let it pass.This is the closest I can get at this moment.
Thank you all for trying to help, and it is appreciated..
However, if this font is not a trueType font, he should not even be able to select a font in a size which is not available. No, I have not tried DISPLAY FONT to see what that does.
Actually the user can select a font size that is not in the Font Size Combobox with either Display Font (DDT) OR the ChooseFont() API TTF (Yes I tried).
Using CF_FORCEFONTEXIST will cause an error indication if the user attemps to select a font or style that doesn't exist. But there is no corresponding flag to prevent the user from using a font size that isn't listed (TTF or not) .
The closest flag seems to be CF_LIMITSIZE - but that requires a Min and a Max value be set when the Choosefont call is made - so won't fit all fonts..
If it is important to control / filter what the user selects, one method could be to use Choosefont() with flag CF_ENABLEHOOK. Then, in the HookProc, examine the listed font sizes compared to the user selection when [ OK ] is clicked - 'eating' the button press (or forcing a size) if there is a mismatch or 'out of range' issue..
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment