The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: dancho on June 20, 2006, 09:33:40 PM

Title: Problem with data display in edit box
Post by: dancho on June 20, 2006, 09:33:40 PM
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
Title: Re: Problem with data display in edit box
Post by: arafel on June 20, 2006, 10:46:45 PM
Just use WM_SETTEXT to set the new text string.
Title: Re: Problem with data display in edit box
Post by: Casper on June 20, 2006, 11:29:01 PM
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
Title: Re: Problem with data display in edit box
Post by: dancho on June 21, 2006, 04:24:48 AM
@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...
Title: Re: Problem with data display in edit box
Post by: dancho on June 21, 2006, 02:43:45 PM
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...  :(
Title: Re: Problem with data display in edit box
Post by: arafel on June 21, 2006, 03:01:37 PM
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


Title: Re: Problem with data display in edit box
Post by: dancho on June 21, 2006, 03:34:44 PM
@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



Title: Re: Problem with data display in edit box
Post by: arafel on June 21, 2006, 04:17:53 PM
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:
Title: Re: Problem with data display in edit box
Post by: dancho on June 21, 2006, 04:38:52 PM
@arafel

program is working , but crashes when I click button to encode ( button that start pipe process )... :(

thx for quick reply...

Title: Re: Problem with data display in edit box
Post by: mnemonic on June 21, 2006, 05:17:00 PM
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
Title: Re: Problem with data display in edit box
Post by: dancho on June 21, 2006, 05:54:59 PM
@mnemonic

thx,
but Iczelions tutorials are the first place where did I study anonymous pipe...

:U
Title: Re: Problem with data display in edit box
Post by: Mark Jones on June 25, 2006, 11:48:20 PM
Perhaps a CR character only is being interpreted as CR+LF?
Title: Re: Problem with data display in edit box
Post by: dancho on June 26, 2006, 05:40:03 AM
@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