The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: cman on March 15, 2012, 06:53:58 PM

Title: Edit Control Properties
Post by: cman on March 15, 2012, 06:53:58 PM
I'm trying to write an application that allows the user to paste a large number of text lines into an edit control and then process the pasted lines. I'm using Visual Studio to create a dialog with a large edit box , but the maximum lines that I can paste is something like 768. Not sure if I need a different control for this task ( rich edit ? ). I guess my Windows programming skills are a bit rusty. :bg Thanks for any information.....
Title: Re: Edit Control Properties
Post by: jj2007 on March 15, 2012, 07:24:54 PM
Try EM_LIMITTEXT.
Title: Re: Edit Control Properties
Post by: cman on March 15, 2012, 11:06:40 PM
Thanks for the information. I still can't get the edit to take more than 700 some lines. I take a 2000 line file and paste it into the edit but it only displays some 700 lines and then will not take anymore input from the keyboard or anything else. Not sure what the problem is. I read the default limit for lines of text in a edit control is 30000 , so I'm not sure what is wrong here.......
Title: Re: Edit Control Properties
Post by: qWord on March 15, 2012, 11:12:46 PM
The controls default maximum is 32767 characters, not lines.
can you supplie a example (exe,src) ?
Title: Re: Edit Control Properties
Post by: hutch-- on March 15, 2012, 11:19:35 PM
Whats wrong with using a rich edit control ?

Also be careful that the clipoard may not also limit what you are doing.
Title: Re: Edit Control Properties
Post by: P1 on March 15, 2012, 11:30:32 PM
Quote from: cman on March 15, 2012, 06:53:58 PM
I'm trying to write an application that allows the user to paste a large number of text lines into an edit control and then process the pasted lines.
Intercept the memory handle and parse the data directly from a Paste event.

There was an example of that some where on here before.

Otherwise code a HLL example(SetClipboardViewer) to MASM.

Clipboard limit is free memory of system(W2K or better). 

Regards,  P1  :8)
Title: Re: Edit Control Properties
Post by: cman on March 16, 2012, 12:45:06 AM
Quote from: qWord on March 15, 2012, 11:12:46 PM
The controls default maximum is 32767 characters, not lines.


Oops!  :red How many characters can a rich edit input. Maybe I'll try one of those!
Title: Re: Edit Control Properties
Post by: jj2007 on March 16, 2012, 05:08:14 AM
Quote from: cman on March 15, 2012, 11:06:40 PM
Thanks for the information. I still can't get the edit to take more than 700 some lines.

So you probably have got a virus, or the edit control has a personal aversion agsint you. On my puter at least, after using EM_LIMITTEXT the pastable text jumps from 723 lines to ... the full Windows.inc.
Title: Re: Edit Control Properties
Post by: dedndave on March 16, 2012, 05:11:55 AM
 :bg
i dunno about a virus
he probably just isn't mashing all the right buttons   :P
as always, we need to see some code to be more precise
Title: Re: Edit Control Properties
Post by: donkey on March 16, 2012, 05:46:54 AM
First off, without at least a bit of code, like say the clipboard and paste function you're not going to get many useable answers. The problem could easily be one or more of a few things. The buffer passed to the clipboard is too small to copy all of the text, the Edit control buffer is too small (Create a larger one and use EM_SETHANDLE to assign it to the Edit control), or your machine is low on resources and could not allocate one of the buffers. Another less likely scenario is that when you read the file you're not assignng a large enough number in the nNumberOfBytesToRead parameter of the ReadFile function.

Next, the references in the thread to 32767 bytes being the maximum are right however that limit applies only to single line edit controls (http://msdn.microsoft.com/en-us/library/windows/desktop/bb775456%28v=vs.85%29.aspx#text_buffer).

Finally the only other suggestion that I have without seeing any code is that a group of migratory book worms has moved into your computer and taken up residence in memory. In order to sustain themelves they have begun to eat any text that they find there, starting from the top and working down. With well over 10 MB of text to chomp through they become fat and bloated by the time they've eaten all but around 10K and can no longer slither through the traces in the memory chips. Since the worms have already entered the circuit traces and have become stuck, it only appears that you cannot paste the rest of the file when in reality you're just blocked by some worms fat ass.

Edgar
Title: Re: Edit Control Properties
Post by: MichaelW on March 16, 2012, 05:54:47 AM
This works as expected, and allows me to paste in multiple copies of the text from the current MASM32 windows.inc and still edit the contents.

;==============================================================================
; Build as a console app.
;==============================================================================
    include \masm32\include\masm32rt.inc
;==============================================================================
    .data
      hInstance dd 0
      hwndEdit  dd 0
      rc        RECT <>
    .code
;==============================================================================

DlgProc proc hwndDlg:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD

    SWITCH uMsg

        CASE WM_INITDIALOG

            invoke GetDlgItem, hwndDlg, 101
            mov hwndEdit, eax

            invoke SendMessage, hwndEdit, EM_GETLIMITTEXT, 0, 0
            printf("%d\t",eax)
            invoke SendMessage, hwndEdit, EM_SETLIMITTEXT, 10000000, 0
            invoke SendMessage, hwndEdit, EM_GETLIMITTEXT, 0, 0
            printf("%d\n",eax)

        CASE WM_SIZE

            invoke GetClientRect, hwndDlg, ADDR rc
            invoke MoveWindow, hwndEdit, 0, 0, rc.right, rc.bottom, TRUE

        CASE WM_COMMAND

            SWITCH wParam

                CASE IDCANCEL

                    invoke EndDialog, hwndDlg, 0

            ENDSW

        CASE WM_CLOSE

            invoke EndDialog, hwndDlg, 0

    ENDSW

    xor   eax, eax
    ret

DlgProc endp

;==============================================================================
start:
;==============================================================================

    invoke GetModuleHandle, NULL
    mov   hInstance, eax

    Dialog "Test", \
           "MS Sans Serif",10, \
           WS_OVERLAPPED or WS_SYSMENU or DS_CENTER, \
           1,0,0,400,300,1024

    DlgEdit WS_BORDER or ES_MULTILINE or ES_WANTRETURN or \
            WS_VSCROLL or WS_HSCROLL or ES_AUTOVSCROLL or ES_AUTOHSCROLL, \
            0,0,0,0,101

    CallModalDialog hInstance,0,DlgProc,NULL

    exit
;==============================================================================
end start
Title: Re: Edit Control Properties
Post by: dedndave on March 16, 2012, 02:47:11 PM
nice example, Michael   :U
Title: Re: Edit Control Properties
Post by: cman on March 16, 2012, 03:54:32 PM
Here's the code of the dialog I'm using. Maybe I've done something wrong ( I haven't programmed Windows for a while ). This is just a simple program shell to test the dialog box and edit control.
Title: Re: Edit Control Properties
Post by: jj2007 on March 16, 2012, 04:50:38 PM
Works like a charm.

.if uMsg == WM_INITDIALOG     ;Things to do when program starts
invoke GetDlgItem, hWin, 1000
invoke SendMessage, eax, EM_LIMITTEXT, 0, 0
Title: Re: Edit Control Properties
Post by: cman on March 16, 2012, 06:12:17 PM
Hmmm.... Must be my system.  I cut and paste windows.inc  and about 280 lines were copied into the edit box. Might be time to reinstall Windows. :( Thanks for the help!  :U
Title: Re: Edit Control Properties
Post by: dedndave on March 16, 2012, 06:30:50 PM
AV scanner ?
try uninstalling that, first   :P
Title: Re: Edit Control Properties
Post by: jj2007 on March 16, 2012, 06:44:58 PM
Zip your full code and executable and attach it here. We'll check. IMHO Windows cannot be corrupted to the point of sabotaging a single edit control.
Title: Re: Edit Control Properties
Post by: cman on March 17, 2012, 04:32:04 PM
Pretty much what I posted is the full code ( I was actually testing the dialog box in Visual Studio's resource editor when I noticed the edit box would not except large files. Thats when I came here and asked which edit control properties I should use to enter large files. I then wrote a small program to exhibit the problem when asked for code. ). Its strange because I can cut and paste the files into Wordpad and my programming editor but not my dialog box. I ran "Spybot Search and Destroy" and an anti-virus program on my system and found nothing wrong. Everything else works fine. Very strange...........
Title: Re: Edit Control Properties
Post by: jj2007 on March 17, 2012, 05:31:07 PM
This discussion remains abstract unless you post source and executable. In Olly, we can see what the EM_LIMITTEXT message does. Anything else is a waste of time.
Title: Re: Edit Control Properties
Post by: cman on March 17, 2012, 05:37:44 PM
Heres the new output with the changes made to the WM_INITDIALOG message handler.
Title: Re: Edit Control Properties
Post by: jj2007 on March 17, 2012, 05:47:54 PM
The executable works fine, no problem to paste the full Windows.inc...
Title: Re: Edit Control Properties
Post by: dedndave on March 17, 2012, 07:27:44 PM
works here - i am able to paste the entire windows.inc file
XP MCE2005 SP3 - 2 Gb RAM
Title: Re: Edit Control Properties
Post by: tenkey on March 19, 2012, 01:54:53 AM
Hope it's not Win9x you're running. The "legacy" controls were 16-bit and limited by that.

Wordpad uses the rich edit control.

If you cannot paste the text into Notepad, then you cannot use the EDIT control.

Is that what EDITTEXT uses?
Title: Re: Edit Control Properties
Post by: cman on March 19, 2012, 05:34:58 PM
I think tenkey has found the problem. It may be time to upgrade to XP. :'( Thanks for all the input and advice! :U
Title: Re: Edit Control Properties
Post by: dedndave on March 20, 2012, 12:29:20 AM
win98 ?
no wonder - lol
you should have mentioned that   :P
Title: Re: Edit Control Properties
Post by: P1 on March 20, 2012, 03:17:54 AM
Quote from: cman on March 19, 2012, 05:34:58 PM
I think tenkey has found the problem. It may be time to upgrade to XP. :'( Thanks for all the input and advice! :U
Splurge, upgrade from the green monochrome to color flat panel too !!!   :dance:

Regards,  P1  :8)
Title: Re: Edit Control Properties
Post by: dedndave on March 20, 2012, 04:10:45 AM
but, i liked the green phospher   :bg
Title: Re: Edit Control Properties
Post by: P1 on March 20, 2012, 05:57:38 PM
Quote from: dedndave on March 20, 2012, 04:10:45 AM
but, i liked the green phospher   :bg
Aaahhhhhh, I did not catch what planet you were from ???   :naughty:

Regards,  P1  :8)
Title: Re: Edit Control Properties
Post by: cman on March 20, 2012, 06:19:27 PM
Quote from: dedndave on March 20, 2012, 12:29:20 AM
win98 ?
no wonder - lol
you should have mentioned that   :P

Yeah , I'm still using Windows Me ( a free copy a got for filling out a survey from my college book store back in the day - I'm kind of a cheapskate  :bg  ). I'm running it on fairly modern hardware and it works fine for most things except for the occasional compatibility issue or something like this problem. I'm starting to consider the Windows Xp Pro install disk I have have in my software collection , though....
Title: Re: Edit Control Properties
Post by: hutch-- on March 21, 2012, 01:59:13 AM
Be convinced, win9x worked OK long ago but Win2000/XP has a lot more capacity and it is far more robust. You have to do something really bad to trash either where Win9x was relatively easy to crash.
Title: Re: Edit Control Properties
Post by: dedndave on March 21, 2012, 02:47:39 AM
ME is not really win98 on steroids, either
it was a middle-of-the-roader, i think - it's own beast
i think they wanted to try some things they intended to implement on win2k
it should have been left in the lab as an experiment   :P