NO

Author Topic: Pick a Font AddIn  (Read 5358 times)

Grincheux

  • Guest
Pick a Font AddIn
« on: May 23, 2021, 01:03:55 PM »
I made this addin because I have lost my snippets too often.
This one genrate source code for Assembleur and C

Quote
                           .Data
                           ALIGN   4

szMyFont      BYTE         "Verdana",0

                           .Code

                           ALIGN   16

                        MOV      RAX,OFFSET szMyFont                  ;   

                        MOV      QWORD PTR [rsp + 68h],RAX             ;   LOGFONT.lfFaceName
                        MOV      DWORD PTR [rsp + 60h],34              ;   LOGFONT.lfPitchAndFamily
                        MOV      DWORD PTR [rsp + 58h],1               ;   LOGFONT.lfQuality
                        MOV      DWORD PTR [rsp + 50h],2               ;   LOGFONT.lfClipPrecision
                        MOV      DWORD PTR [rsp + 48h],3               ;   LOGFONT.lfOutPrecision
                        MOV      DWORD PTR [rsp + 40h],0               ;   LOGFONT.lfCharSet (0 = ANSI_CHARSET)
                        MOV      DWORD PTR [rsp + 38h],0               ;   LOGFONT.lfStrikeOut
                        MOV      DWORD PTR [rsp + 30h],0               ;   LOGFONT.lfUnderline
                        MOV      DWORD PTR [rsp + 28h],0               ;   LOGFONT.lfItalic
                        MOV      DWORD PTR [rsp + 20h],700             ;   LOGFONT.lfWeight
                        XOR      R9D,R9D                               ;   LOGFONT.lfOrientation
                        XOR      R8D,R8D                               ;   LOGFONT.lfEscapement
                        MOV      EDX,0                                 ;   LOGFONT.lfWidth
                        MOV      ECX,-19                               ;   LOGFONT.lfHeight

                        CALL   CreateFontA                             ;

                        TEST   RAX,RAX                                 ;
                        JZ      @FontNotCreated                        ; You must define this label

                        MOV      _hYourFont,RAX                        ;

;   ****************************************************************************************************************************
;   * Don't forget to send : "SendMessage(hYourWindow,WM_SETFONT,(WPARAM) hYourFont,TRUE) ;" for using the font with a control *
;   * "WM_SETFONT" is defined as "#define WM_SETFONT 0x0030"                                                                   *
;   * Don't forget to delete the font on exit "DeleteObject(hYourFont) ;" generaly in WM_DESTROY message                       *
;   * Don't forget to add "PARAMAREA = 14* QWORD" on the "PROC" line                                                           *
;   ****************************************************************************************************************************
The C source code:
Quote
   hYourFont = CreateFont(-96,0,0,0,700,0,1,1,0,3,2,1,2,"David Libre") ;

   if(!hYourFont)
      goto   ErrorFont ;

//   ****************************************************************************************************************************
//   * Don't forget to send : "SendMessage(hYourWindow,WM_SETFONT,(WPARAM) hYourFont,TRUE) ;" for using the font with a control *
//   * "WM_SETFONT" is defined as "#define WM_SETFONT 0x0030"                                                                   *
//   * Don't forget to delete the font on exit "DeleteObject(hYourFont) ;" generaly in WM_DESTROY message                       *
//   ****************************************************************************************************************************
« Last Edit: May 23, 2021, 01:07:00 PM by Grincheux »

Offline John Z

  • Member
  • *
  • Posts: 858
Re: Pick a Font AddIn
« Reply #1 on: May 23, 2021, 04:56:20 PM »
That was fast - I'll give it a go.

John Z

Update:  Yup, it worked.  Inserted the code right in my C program  ;)

John Z
« Last Edit: May 23, 2021, 05:33:37 PM by John Z »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Pick a Font AddIn
« Reply #2 on: May 26, 2021, 04:17:26 PM »
Nice to see new Add-Ins :)
May the source be with you

Grincheux

  • Guest
Re: Pick a Font AddIn
« Reply #3 on: May 26, 2021, 04:21:58 PM »
I made it because it is difficult to do something without seeing what we do.
Because it was too long to do in assembly.
Now I will make others with CreateWindow, Create ListView and toolBar.
All of this was into my snippets but I re-installed Pelle and lost them.
I said to my self that it would be better if I had a program that creates the snippets.


I am happy to read you Timo.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Pick a Font AddIn
« Reply #4 on: May 27, 2021, 09:20:13 AM »
Similar Add-In
InsertText Add-In
May the source be with you

Offline John Z

  • Member
  • *
  • Posts: 858
Re: Pick a Font AddIn
« Reply #5 on: May 27, 2021, 12:22:48 PM »
TimoVJL -
Is your vast store of PellesC Add-Ins on GitHub all ones you wrote?  Quite an impressive number of them there.

John Z

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Pick a Font AddIn
« Reply #6 on: May 27, 2021, 12:27:36 PM »
Not all, but most of them :)
May the source be with you