Shoutbox

Font Dialog - Enhanced Colour - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Font Dialog - Enhanced Colour (/showthread.php?tid=64590)

Font Dialog - Enhanced Colour by Dempsey on 08-07-2006 at 10:57 AM

As you know, Plus! replaces the colour combobox in the standard WLM font dialog, with the 'Enhanced Colour' picker.  And when you change the colour, it updates the colour in the sample frame.

But when you manually create your own Font dialog in a script, Plus! detects the creation of it and subclasses it etc and adds the Enhanced colour picker to that as well, which is ok, except it doesn't update the colour of the sample.  I know this is probably as it's not WLM that created or whatever, but I think one of two things needs to be done.

  1. Dont add the Enhanced colour picker to font dialogs created from scripts
  2. Add it, but also update the sample colour, as it does when WLM shows the dialog
    [/list]

    Hope Patchou reads this and can give some feeback :)

RE: Font Dialog - Enhanced Colour by Patchou on 08-12-2006 at 05:40 PM

Hey Dempsey,

my guess is that it has something to do with the way you create your font window. Can you send me a sample script that shows the bug? I'll fix it on my side or tell you what's wrong in the code :).

Patch


RE: Font Dialog - Enhanced Colour by Dempsey on 08-13-2006 at 01:32 AM

I'm guessing it's probably because I don't set some parts of the CHOOSEFONT structure correctly, here's the code I use:

code:
function ChooseFont(){
    var CF = Interop.Allocate(60);
    CF.WriteDWORD(0, CF.Size); //lStructSize
    CF.WriteDWORD(4, 0); //hwndOwner
    CF.WriteDWORD(8, 0); //hDC
    var LF = Interop.Allocate(92);
    LF.WriteDWORD(0,0); //lfHeight
    LF.WriteDWORD(4,0); //lfWidth
    LF.WriteDWORD(8,0); //lfEscapement
    LF.WriteDWORD(12,0); //lfOrientation
    LF.WriteDWORD(16,0); //lfWeight
    LF.SetAt(20,0); //lfItalic
    LF.SetAt(21,0); //lfUnderline
    LF.SetAt(22,0); //lfStrikethru
    LF.SetAt(23,0); //lfCharSet
    LF.SetAt(24,0); //lfOutPrecision
    LF.SetAt(25,0); //lfClipPrecision
    LF.SetAt(26,0); //lfQuality
    LF.SetAt(27,0); //lfPitchAndFamily
    LF.WriteString(28, ""); // lfFaceName
    CF.WriteDWORD(12, LF.DataPtr); //LPLF
    var iPointSize = Interop.Allocate(4);
    CF.WriteDWORD(16, iPointSize.DataPtr); //iPointSize
    CF.WriteDWORD(20, CF_INITTOLFSTRUCT | CF_SCREENFONTS | CF_EFFECTS ); //Flags
    CF.WriteDWORD(24, 0); // rgbColors
    CF.WriteDWORD(28, 0); // lCustData
    CF.WriteDWORD(32, 0); // lpfnHook
    CF.WriteDWORD(36, 0); // lpTemplateName
    CF.WriteDWORD(40, 0); // hInstance
    var lpszStyle = Interop.Allocate(514);
    CF.WriteDWORD(44, lpszStyle.DataPtr); // lpszStyle
    CF.WriteWORD(48, 0x2000); // nFontType
    CF.WriteDWORD(50, 0); // nSizeMin
    CF.WriteDWORD(54, 0); // nSizeMax
    var result = Interop.Call("comdlg32.dll", "ChooseFontW", CF);
        if(result > 0){
                Debug.Trace('Font: ' + LF.ReadString(28));
                Debug.Trace('Size: ' + LF.ReadDWORD( 0));
                //var weight = LF.ReadDWORD(16);
                if (LF.ReadDWORD(16) == 700){
                        Debug.Trace('Bold: 1');
                }else{
                        Debug.Trace('Bold: 0');
                }
                Debug.Trace('Italic: ' +LF.GetAt(20));
                Debug.Trace('Underline: ' + LF.GetAt(21));
                Debug.Trace('Strkethru: ' + LF.GetAt(22));
        }else{
                var error = Interop.Call('ComDlg32', 'CommDlgExtendedError');
                if(error > 0){
            LF.WriteDWORD(0,0);
                        //An error occurred, "error" contains the error code
                }else{
            LF.WriteDWORD(0,0);
                        //User closed font dialog
                }
        }
    return LF;
}