The problem:
Im programming small gui which will gather information for encoding different video files to mpeg2 video
stream,with the help of mencoder ( http://www.mplayerhq.hu/design7/news.html ) .
Basicly Im creating one bat file with all options and values that user choosed and then execute that file with mencoder.exe,
btw mencoder.exe is command line tool so I programmed anonymous pipe to retrive console output to my edit box,
and that part is working well ,
but the problem is sorting data from console in my editbox.
(http://img349.imageshack.us/img349/7744/mcdprob4um%3Cbr%20/%3E.th.jpg) (http://img349.imageshack.us/my.php?image=mcdprob4um.jpg)
This is how encoding process looks when you start it manualy in console,
the last line is most important to me,it looks like this:
Pos: 0.0s 1f ( 0%) 0.00fps Trem: 0min 0mb A-V:0.000 [0:0]
Here I have info about current encoding position,number of frames etc...
Now there is nothing wrong with my pipe code part of program because coding is done properly and I have
my file.m2v in destination folder.This is THE problem.
(http://img428.imageshack.us/img428/9099/mcdprob27%3Cbr%20/%3Eke.th.jpg) (http://img428.imageshack.us/my.php?image=mcdprob27ke.jpg)
New info line doesnt replace old one , it is added to at the end of old info line...
Pipe code that read data is classic one ( basicly copy/paste from Iczelion tutorials :green )
and this is the snippet that control editbox input...
.while
invoke RtlZeroMemory,addr buff,1024
invoke ReadFile,hRead,addr buff,1023,addr bRead,NULL
.if eax==0
.break
.endif
invoke SendDlgItemMessage,hWin,IDC_EDT44,EM_SETSEL,0,-1
invoke SendDlgItemMessage,hWin,IDC_EDT44,EM_REPLACESEL,0,addr buff
.endw
so Im looking for a way to update that info line in a proper way ,
thx
Just use WM_SETTEXT to set the new text string.
Actually you need to highlight the line you want to replace. http://www.pbrennick.com has an editbox tutorial in the first page of his website. You might want to take a look at it. Someone showed it to me recently and I though it was great. Some typos but covers everything.
Casper
@arafel
if I use
invoke SendDlgItemMessage,hWin,IDC_EDT44,WM_SETTEXT,0,addr buff
editbox will be empty until encoding is over and then
will show the last info line buffer is received...
@Casper
thx for link , I will check it...
mov eax,istring(1,addr buff,chr$("Pos:"))
add eax,offset buff - 1
mov edx,cat$(addr new_buff,eax)
with this 3 lines of code I can select that only info line is updated ,
but still new info lines are added at the end of the last one... :(
Quote from: dancho on June 21, 2006, 04:24:48 AM
editbox will be empty until encoding is over and then
will show the last info line buffer is received...
This is because the window content not being repainted.
.while
invoke RtlZeroMemory,addr buff,1024
invoke ReadFile,hRead,addr buff,1023,addr bRead,NULL
.if eax==0
.break
.endif
invoke SendDlgItemMessage, hWin, IDC_EDT44, WM_SETTEXT, 0, addr buff
invoke InvalidateRect, hWin, 0, 0
invoke UpdateWindow, hWin
.endw
@arafel
thx for reply
invoke SendDlgItemMessage, hWin, IDC_EDT44, WM_SETTEXT, 0, addr buff
invoke InvalidateRect, hWin, 0, 0
invoke UpdateWindow, hWin
that is working,but edit box is showing just last line ( info line ),nothing more...
if you check the link I posted ( console encoding ) , you will see how is suposed to look...
thx
Ah, I thought you wanted to display only the last line.
If you need the whole text to be displayed with the last line being changed try something like:
invoke RtlZeroMemory,addr buff,1024
invoke ReadFile,hRead,addr buff,1023,addr bRead,NULL
test eax, eax
je _end
mov eax, dword ptr ":soP" ; calculate the number of character preceding the "Pos:" string
lea esi, buff
@@: inc esi
cmp [esi], eax
jne @b
lea eax, buff
sub esi, eax ; now esi contains the "Pos:" string offset from the begining of the buffer.
invoke SendDlgItemMessage, hWin, IDC_EDT44, WM_SETTEXT, 0, addr buff ; display the initial text
invoke InvalidateRect, hWin, 0, 0
invoke UpdateWindow, hWin
.while TRUE
invoke RtlZeroMemory,addr buff,1024
invoke ReadFile,hRead,addr buff,1023,addr bRead,NULL
.if eax==NULL
.break
.endif
invoke SendDlgItemMessage, hWin, IDC_EDT44, EM_SETSEL, esi, -1 ; replace the string.
invoke SendDlgItemMessage, hWin, IDC_EDT44, EM_REPLACESEL, FALSE, addr buff
.endw
_end:
@arafel
program is working , but crashes when I click button to encode ( button that start pipe process )... :(
thx for quick reply...
You may want to have a look at Iczelions Tutorial #21 (http://win32assembly.online.fr/tut21.html).
You can find the source as well in the \masm32\icztutes\ folder.
As far as I read here he is trying to do the very same as you.
Regards
@mnemonic
thx,
but Iczelions tutorials are the first place where did I study anonymous pipe...
:U
Perhaps a CR character only is being interpreted as CR+LF?
@Mark Jones
QuotePerhaps a CR character only is being interpreted as CR+LF?
no,no problem with that...
mov esi,offset buff -1
mov eax,istring(1,addr buff,chr$("Pos:"))
add esi,eax
mov esi,left$(esi,69)
invoke SendDlgItemMessage,hWin,IDC_EDT44,EM_SETSEL,0,len(esi)
invoke SendDlgItemMessage,hWin,IDC_EDT44,EM_REPLACESEL,0,esi
I tested my program with this little snippet ,
and editbox is showing exact info line like
console output is...
but thx anyway,
I solved this annoying problem(small GUI redesign),
now Im showing only last(info) line... :lol