What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Resource] Font Class (Updated 24/09/07)

[Resource] Font Class (Updated 24/09/07)
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: [Resource] Font Class (Updated 24/09/07)
quote:
Originally posted by SmokingCookie
It may be a bit late, but how about using colours in the font?
You need a few changes for that, but it's quite simple. ;)
Note that this ONLY applies when you're about to use the Choose Font dialog through the Choose() dialog. The LOGFONT itself doesn't have a COLORREF entry, but the CHOOSEFONT structure does.

In the constructor function of Font, add the ColorRef parameter to the end, so you get:
code:
function Font(Height, Width, Escapement, Orientation, Weight, Italic, Underline, StrikeOut, CharSet, OutPrecision, ClipPrecision, Quality, PitchAndFamily, FaceName, ColorRef) {
Then, between "this.FaceName =" and "this.LOGFONT =", add this line:
code:
this.ColorRef = typeof(ColorRef) == "undefined" ? 0x0 : ColorRef;
Now, in the Choose method, make the following modifications. The added lines are in red.
code:
...
this.CHOOSEFONT.WriteDWORD(20, Flags);
this.CHOOSEFONT.WriteDWORD(24, this.ColorRef);
...
if(Interop.Call("comdlg32.dll", "ChooseFontW", this.CHOOSEFONT.DataPtr)) {
   this.Height = this.CHOOSEFONT.ReadDWORD(16).toLogical() / 10;
   this.ColorRef = this.CHOOSEFONT.ReadDWORD(24);
   this.UpdateHFONT();
...
And that's it! You can now use Font.ColorRef to get or set the new color in 0x00bbggrr format, or add it as last parameter for the Font class constructor. When calling Choose(), you'll receive the selected color in Font.ColorRef and, when you're using the CF_INITTOLOGFONTSTRUCT flag, the color will be set in the Choose Font dialog according to the ColorRef property. :)

This doesn't include support for Load(Cache) and Save(), but I think you can figure that out yourself if you'd need it. ;)

(It's quite funny, as I were doing this exact thing myself before you asked. I noticed you reading this topic and thought: "Hey, a font class! Could come handy.")

Besides, awesome class! Really helpful! :D

This post was edited on 09-11-2008 at 06:33 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
09-11-2008 06:31 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Resource] Font Class (Updated 24/09/07) - by phalanxii on 09-23-2007 at 08:26 AM
RE: [Resource] Font Class - by NanaFreak on 09-23-2007 at 08:49 AM
RE: [Resource] Font Class - by Matti on 09-23-2007 at 10:08 AM
RE: [Resource] Font Class - by Volv on 09-23-2007 at 11:28 AM
RE: [Resource] Font Class (Updated 24/09/07) - by phalanxii on 09-24-2007 at 10:10 AM
RE: [Resource] Font Class (Updated 24/09/07) - by SmokingCookie on 09-11-2008 at 05:59 PM
RE: [Resource] Font Class (Updated 24/09/07) - by Matti on 09-11-2008 at 06:31 PM
RE: RE: [Resource] Font Class (Updated 24/09/07) - by SmokingCookie on 09-12-2008 at 06:11 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On