Hello,
Perhaps have you more idea than me.
The source code show no errors,no bug but works only with windbg and
with the flags debug (Zi,/DEBUG).
Open it with windbg and you will see.
There is only two modifies to made at this source.
use this:
Quote
IID_ITextServices GUID <8d33f740h,0cf58h,11ceh,<0a8h,9dh,00h,0aah,00h,6ch,0adh,0c5h>>
The source use the one in uuid.lib with EXTERNDEF,after a search it isn't in this lib.
The DrawText function must be change by DrawTextEx just adding a NULL parameter.
Quote
invoke DrawTextEx,hdc,addr asciihello, LENGTHOF asciihello -1,addr rect,DT_CENTER,NULL
I have not searched for why the function don't work
There is no need of the InvalidateRect function if you made the init in the WM-CREATE Message.He is needed if you use the WM_COMMAND.Put it just before
invoke put_RTFText,bstrRTF
Also add this:
Quote
.ELSEIF uMsg == WM_CLOSE ;return zero
;invoke MessageBox,NULL,SADR(" WM_CLOSE "),SADR("Titre"),MB_OK
.if ppvITextServices != 0
ITextServUnk Release
.endif
.if ppvITextDocument != 0
ITextDocument Release
.endif
.if m_editCookie.bstrText != 0
invoke HeapFree,Hheap,NULL,m_editCookie.bstrText
.endif
INVOKE DestroyWindow, hwnd
mov retour,0
Modifying the source take care of this:
Quote
The itextservice and ITextHost are not STANDARD COM.
They are in the textinclude.inc with the source code (see attachment here).
In the frame ecx = this and there is no This in the prototypes
The Implem_ItextHost.inc hold the implementation of ItextHost.He have all is needed in it ,constant,data,code .To reuse it just include it in your project and you have to write the lines using it ( the init and drawing operations).
Should it show different colored and sized text? - If so, it works (even without a debugger).
However, to get the text visible the window must be resized (-> InvalidateRect()).
Yes he must show all this colored and police effects.
I have just added those lines in the WM_PAINT message:
Quote
invoke BeginPaint,hwnd,ADDR Ps
mov hdc, eax
invoke GetClientRect,hwnd, addr rect
ajout>>>> invoke InvalidateRect,hwnd,addr rect,FALSE
invoke DrawText,hdc,addr asciihello, LENGTHOF asciihello -1,addr rect,DT_CENTER
.if INITTEXTDRAW != 0
And he can be view even by me !
Many thanks for answer
there are a few problems, Yves
first, the return value in WndProc does not seem to be getting set properly for some messages
this causes the window to behave strangely
for example, if i move the cursor to the edge, i get the sizing cursor
and the sizing cursor does not go away until i move to some non-client area that resets it
second, you already have a rectangle in the PAINTSTRUCT that tells you what needs to be painted
no need to get client recatngle, there
and - you can pass a NULL parm to InvalidateRect and it will use the entire client rectangle
but, thirdly, invalidating the rectangle between BeginPaint and EndPaint is messed up
you want some external event to invalidate the rectangle and UpdateWindow
InvalidateRect tells the OS that there is a region that needs to be redrawn
UpdateWindow tells the OS that a WM_PAINT message (and maybe a few others) needs to be sent
The InvalidRect() should be placed at the end of the WM_CREATE-Handler thus the text get visible.
huh ?
you shouldn't have to invalidate the rectangle in WM_CREATE
the OS usually sends WM_SIZE and WM_PAINT after WM_CREATE is complete
what may be missing is the standard order of...
CreateWindow
UpdateWindow
the code is split up into so many INC files that it is hard to read
Quote from: dedndave on August 25, 2012, 01:04:18 AM
you shouldn't have to invalidate the rectangle in WM_CREATE
the OS usually sends WM_SIZE and WM_PAINT after WM_CREATE is complete
what may be missing is the standard order of...
CreateWindow
UpdateWindow
yes you are rigth.
AFAICS he is using PostMessage to force WM_COMMAND, which then creates the object - after the creation, the window must be invalidated.
I have windows XP3.I have put InvalidateRect in various places but i couldnt view now the colored text.
I have also made minor changes in the window loop.
Seems the result is random.
The one I post couldn't be show for me...
When building the EXE with your SDK, the program fails to create ITextServices: "No such interface supported"?
The itextservice and ITextHost are not translated in the SDK.
They are in the textinclude.inc with the source code (see first post).
Take care there frame are not standard.need ecx = this and there is no this:dword in the define prototype.
I have find the origin of the trouble.
use
Quote
IID_ITextServices GUID <8d33f740h,0cf58h,11ceh,<0a8h,9dh,00h,0aah,00h,6ch,0adh,0c5h>>
And not the one in the uuid.lib
The InvalidateRect is at the right place in the WM_PAINT message.
Now i have no more random results.
I have forgotten two things
There is a modyfy to do in the sdkrc7 files CHARFORMAT2W structure
Richedit.sdk
Quote
szFaceName WORD LF_FACESIZE dup (?) ;WORD and not BYTE
size 74h for CHARFORMAT2W
The source code is cut in parts to allow the insertion of the implemention of ITextHost without writing a single line.Just include it where you want.
Quote from: ToutEnMasm on August 25, 2012, 04:45:42 AMThe InvalidateRect is at the right place in the WM_PAINT message.
Definitely not! You may take a look at the taskmanger.
As said, the invalidation is (probably) needed after creation of the object or if it's state has changed.
i have been using this with good success
many of the programs i have looked at have an XOR EAX,EAX after .ENDIF that is used for all handled messages
but - i like this a little better because i can return different values for different messages
for example, with WM_CTLCOLORSTATIC (et al) you return a brush handle in EAX
mov eax,uMsg
.if eax==WM_CLOSE
INVOKE DestroyWindow,hWnd
xor eax,eax ;return 0
.elseif eax==WM_DESTROY
INVOKE PostQuitMessage,NULL
xor eax,eax ;return 0
.else
DefPrc: INVOKE DefWindowProc,hWnd,uMsg,wParam,lParam
.endif
ret
The hourglass that was shown was the effect of a conflict when painting.
Here is the soluce.
Quote
.elseif uMsg == WM_PAINT ;return 0
invoke GetClientRect,hwnd, addr rect
invoke BeginPaint,hwnd,ADDR Ps
mov hdc, eax
invoke DrawText,hdc,addr asciihello, LENGTHOF asciihello -1,addr rect,DT_CENTER
mov eax,rect.top
add eax,20 ;exclude the last drawing to be invalidate
mov rect.top,eax
;declare this rect to be redraw
invoke InvalidateRect,hwnd,addr rect,FALSE ;
>>>>>>>>>> now we can draw the colored without problem
I don't know why there isn't this conflict with c++.
It must be perfect now.
The last modify is here ,changed DrawText by DrawTextEx
Quote
invoke DrawTextEx,hdc,addr asciihello, LENGTHOF asciihello -1,addr rect,DT_CENTER,NULL
Quote from: ToutEnMasm on August 25, 2012, 05:06:57 PMIt must be perfect now.
run your program, open the task manager and look for the CPU usage - its far away from perfect.
seem he consume some times of the processor.
Perhaps have you an idea ?.
The more simple is responsible of this
Quote
invoke DrawText,hdc,addr asciihello, LENGTHOF asciihello -1,addr rect,DT_CENTER
I will search a little,perhaps msdn will answer.
The InvalidRect() must not be called from WM_PAINT. The invalidation forces the system to resend WM_PAINT endless. Call the function when the state of the graphic object has change (e.g. after creation).
ALL is good now
I have just replace the DrawText function by the DrawTextEx and added a NULL parameter that all.
Now that all is good ,I have deleted the InvalidateRect function.
I change the textdraw_final.zip in the post,so you can see the difference.
I have not searched why DrawText don't want to work,all parameter are good.