News:

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

TextOut.

Started by G`HOST, December 08, 2005, 05:25:12 PM

Previous topic - Next topic

Mincho Georgiev

You're wellcome Paul . I didn't thought about the resolution, i've made it on 1152x864, but universal resolution example can be easily implemented using GetSystemMetrics.
Bye for now  :U

shuttlebug

#16
    invoke GetDC,hWnd
    mov    hDc,eax

    invoke CreateFont,blah,blah
    mov    hFont,eax
    invoke SelectObject,hDc,hFont
 
    invoke TextOut,hDc,blah,blah
    invoke ReleaseDC,hWnd,hDc 


Mincho Georgiev

shuttlebug, the function SelectObject selects an object into the specified device context,i.e. the handle hFont we needet only for SelectObject function to Set Up the specified font into the specified DC. It'does not matter that after the Selecting (HGDIOBJ)hFont, the eax or the hFont value is not anymore the same,because we dont need it. If we had a handle of window to setting font into it, SendMessage with WM_SETFONT would do the job ,BUT we setting font into device context,that's why is SelectObject function witch actually fill the second argument with the needed value (hObj). I hope you understanding my point. If somewone had a question why is used the SaveDC function,i'll tell you that way: YES,you can remove it, but on some older machines or OS it may cause a problem.I put it on just to be sure that it will bi ok on GHOST's comp ,who actually begin the current post.

shuttlebug

It does matter if your going to use that second selectobject function with an invalid hFont handle pointer. And anyhow, i was replying to the original post not to you shaka.

Mincho Georgiev

I'm, nut sure if understand what you mean. The SelectObject function is not used twice,just once. You cannot use it and you don't need to use it twice,because after the first use ,you have a HGDIOBJ returned by the using of that function.

invoke CreateFont,14,0,0,0,FW_BOLD,0,0,0,
               ANSI_CHARSET,OUT_DEFAULT_PRECIS,
               CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, 18,ADDR FaceName
            mov hFont,eax
            invoke SelectObject,hdc,hFont
            mov hObj,eax
is 5.30 in the mornig now here,so see you soon  :U

G`HOST

shaka_zulu
Yup, your example worked just perfect. :thumbu
But my Original question was......... ""why"" responding to  WM_PAINT message doesnt work properly?

tenkey

Probably because you aren't handling WM_NCPAINT.

If you don't change the client area contents or increase its size, WM_PAINT does not get sent. WM_NCPAINT is sent when the nonclient area needs to change. When you lose focus, the title bar normally gets redrawn to turn off highlighting. That happens via a WM_NCPAINT message.

When you regain focus, the client area may need to be redrawn to make it "rise" to the top of the "stack". That happens via both a WM_NCPAINT and a WM_PAINT message. The frame is drawn first via WM_NCPAINT, followed by drawing the client area via WM_PAINT.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

Mincho Georgiev

The answer is simple: When the window looses focus ,windows by itself redraws the title bar area of your window (like changing it's color to gray), and the result of that WINDOWS repainting is disapearing of the posted text. Well ,we corected that - so every time that windows repaints the title bar, the PaintText Function will repaint the text too!
That's it.

Mincho Georgiev

i mean the title bar AND the status bar. If you pay attention to what's happening whe the main window loose focus,you will notice that WINDOWS repaints the title bar, the status bar and all other controls that needs to be set up as inactive (graying). I hope,you understand now  :U

G`HOST


Kongbo

How can I fill LOGFONT struct from CHARFORMAT struct when using RichEdit?

When I use RichEdit,I can use CHOOSEFONT and CHARFORMAT to change
the face or the size of FONT.
But when I control the DC, I find that what I can do with FONT is
ONLY LOGFONT struct.
LOGFONT and CHARFORMAT are different struct,I CANNOT transfer them form one to one.

How can I fill LOGFONT struct from CHARFORMAT struct?

Somebody told me , use the GetObject function.
But I try several formats,This function always return 0.

------------------------------------

LOCAL hDC:DWORD
LOCAL Font:LOGFONT

invoke GetObject,hDC, HFONT, addr Font
invoke GetObject,hDC,sizeof LOGFONT,addr Font

invoke GetObject,addr Font, HFONT, addr Font 
invoke GetObject,addr Font, sizeof LOGFONT, addr Font

invoke GetObject,HFONT,sizeof LOGFONT,addr Font

invoke GetObject,addr ,SIZEOF LOGFONT,OFFSET lf
invoke SelectObject,[edi+DRAWITEMSTRUCT.hdc],[edi+DRAWITEMSTRUCT.itemData]

-------------------------------------

Please, tell me,How can I fill LOGFONT struct from CHARFORMAT struct when using RichEdit?