News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Enumerate all fonts installed

Started by starzboy, December 17, 2008, 10:45:58 AM

Previous topic - Next topic

xandaz

   New version available. Allows selection tho it does nothing but its cool.

xandaz

   Does anyone know how many times WM_DRAWITEM is called when drawing an item. I was trying to make a window that'd display the alphabet for the selected font, but, when i select an item appears more than one window. The WM_DRAWITEM causes the CreateThread function when ODS_SELEECTED.

elmo

hi Donkey, your code will replace font type of all text that the user type on the Editor.
As the result, this can't be used by the user who want to use more than 1 font type in the editor. lol
I think how to modify your code. So, it only change the font type of the Text that User selected.

like the following code. It only do BOLD to the Text that the user selected in the Editor.


        .data?
cfm CHARFORMAT2 <>
nLastError DWORD ?
.
.
.

.code
.
.
.
.
mov cfm.cbSize, sizeof cfm
mov cfm.dwMask, (CFM_BOLD or CFM_FACE)
mov cfm.cbSize,60
;GET BOLD STATUS
invoke SendMessage, hEdit1, EM_GETCHARFORMAT, TRUE, ADDR cfm
;TOGGLE BOLD EFFECT
xor cfm.dwEffects, CFE_BOLD
;SET NEW BOLD STATUS
invoke SendMessage, hEdit1, EM_SETCHARFORMAT, SCF_SELECTION, ADDR cfm
.if eax == NULL
invoke GetLastError
mov nLastError,eax
invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM,NULL, nLastError, NULL, ADDR szMsgBuff, 128, NULL
invoke MessageBoxEx, NULL, ADDR szMsgBuff, SADD("Error in EM_SETPARAFORMAT"),MB_OK+MB_ICONINFORMATION, LANG_ENGLISH
.endif
xor eax, eax
be the king of accounting programmer world!

donkey

Hi elmo,

The code was only a demo to show how to enumerate fonts, if I remember correctly I only put in the edit window as an after thought, it was never meant to be a real editor. Feel free to modify it to your needs though.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable