News:

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

Tab control problem

Started by minor28, June 11, 2010, 11:16:36 AM

Previous topic - Next topic

minor28

I have an ownerdrawn tab control with vertical tabs. I can't figure out how to draw the text with 90 degr orientation.


mov edi,lParam
.if [edi].DRAWITEMSTRUCT.CtlType==ODT_TAB
invoke SetBkMode,[edi].DRAWITEMSTRUCT.hdc,TRANSPARENT
invoke SetTextColor,[edi].DRAWITEMSTRUCT.hdc,000000FFh

invoke GetCurrentObject,[edi].DRAWITEMSTRUCT.hdc,OBJ_FONT
mov ecx,eax
invoke GetObject,ecx,sizeof LOGFONT,addr lgf
mov edx,lgf.LOGFONT.lfOrientation

invoke CreateFontIndirect,offset MS_Sans_Serif_8V
invoke SelectObject,[edi].DRAWITEMSTRUCT.hdc,eax
push eax

invoke GetCurrentObject,[edi].DRAWITEMSTRUCT.hdc,OBJ_FONT
mov ecx,eax
invoke GetObject,ecx,sizeof LOGFONT,addr lgf
mov edx,lgf.LOGFONT.lfOrientation

invoke DrawText,[edi].DRAWITEMSTRUCT.hdc,addr buffer,-1,addr [edi].DRAWITEMSTRUCT.rcItem,DT_CENTER or DT_VCENTER

pop eax
invoke DeleteObject,eax
.endif


First GetObject shows orientation 0 and the second 900. But the text is drawn with orientation 0.

If I try with CreateCompatibleDC no text at all are drawn.

Anyone know how to do it?


jj2007

Does your font work with the main windows' dc?

invoke CreateFont, -12, 0, 900, 900, FW_SEMIBOLD, 0, 0, 0, 0, 0, 0, 0, 0, chr$("Arial")
mov hVertFont, eax

...
TestMe proc uses ebx
LOCAL rc:RECT
mov rc.left, 10
mov rc.top, 100
mov rc.right, 200
mov rc.bottom, 10
invoke GetDC, hMainWnd
mov ebx, eax ; the DC
invoke SelectObject, eax, hVertFont
invoke DrawText, ebx, chr$("A text"), 6, addr rc, 0
invoke ReleaseDC, hMainWnd, ebx
ret
TestMe endp

minor28

It the tab is not ownerdrawn and horizantal and I change it to vertical then the font works.


invoke GetWindowLong,hTab3,GWL_STYLE
add eax,TCS_VERTICAL
invoke SetWindowLong,hTab3,GWL_STYLE,eax
invoke CreateFontIndirect,offset MS_Sans_Serif_8V
invoke SendMessage,hTab3,WM_SETFONT,eax,TRUE

jj2007

Try exchanging top and bottom of rcItem.

minor28

QuoteTry exchanging top and bottom of rcItem.

No text at all.

The rectangle is correct but the text is horizantal and starts at the top and left of the rectangle and is truncated at the right side.

minor28

No I succeeded.

Set graphics mode to advanced and exchanging top and bottom of rcItem as you said solved the problem.

Thanks jj2007