More than 32k in a EDIT ctrl
Erik Heuer -- erik.heuer@ks-t.no
Monday, May 06, 1996
Environment: VC++ 4.0, NT 3.51 SP4
There may be a simple solution to this, but sofar I have not succeeded in
implementing one. The problem is quite simple: How to break the 32k limit
on a multiline Windows EDIT control on Win95/NT?
My attempts so far have been based on a CEdit derived object. I have tried
the SetHandle/GetHandle method, but it does not work unless the edit control
is contained in a Dialog box (created with the DS_LOCALEDIT style flag).
I do not want to use it in a dialog box, and I get the EN_MAXTEXT message
after inserting a little less than 32k of text into it.
Ideally, I want a specialized CEdit to behave similary to the output
window in MSVC's IDE (but without the tab control, etc.). Sofar I have
almost accomplished that, except overcomming the 32k limit.
Erik Heuer, Kongsberg Simulation & Training, 3600 Kongsberg, Norway
E-mail: erik.heuer@ks-t.no Phone:(+47) 32735766 Fax:(+47) 32736965
Barry Tannenbaum -- barry@dddv.com
Thursday, May 09, 1996
[Mini-digest: 3 responses]
At 03:33 PM 5/6/96 +0100, you wrote:
>Environment: VC++ 4.0, NT 3.51 SP4
>
>There may be a simple solution to this, but sofar I have not succeeded in
>implementing one. The problem is quite simple: How to break the 32k limit
>on a multiline Windows EDIT control on Win95/NT?
Are you using SerializeRaw to read in your file? I found that it limits the
size of a file to 1MB. I simply implemented it myself; stealing the code
from SerializeRaw and removing the restriction.
- Barry
--------------------------------------------------------------------------------
3DV Technology, Inc Phone: (603) 595-2200 X228
410 Amherst St., Suite 150 Fax: (603) 595-2228
Nashua, NH 03063 Net: barry@dddv.com
-----From: Steve Downey
It's really very simple. Use SetLimitText on your edit control. For example:
m_Edit.SetLimitText(UINT_MAX); //set size of edit control to as large as
possible
-----From: John Moulder
I don't know about large edit controls on NT, but this works on Windows 3.1:
/*
* CreateEditWindow()
*
* creates a new window with styles appropriate for wordwrapping
*
* Allocates a data segment for an edit control.
*
* Allows up to 64k per edit control.
*
* See Microsoft Developer's CDROM, topic GLBEDIT.
*
* returns handle of new window
*
* parameters :
* hwndOwner window handle of owner
* nID ID of edit control
*/
HWND CreateEditWindow(HWND hwndOwner, int nID)
{
char *pFN = "CreateEditWindow";
GLOBALHANDLE ghEditDS; // global handle to data segment
LPVOID lpPtr; // pointer to data segment
UINT uDataSegment; // start address of data segment
UINT uEndAddress; // end address of data segment
DWORD dwStyle; // style to create new window
HWND hwndEdit; // window handle of edit control
UINT uInitialSize = 4096;
// allocate some global memory for our new data segment
ghEditDS = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE | GMEM_ZEROINIT,
uInitialSize);
if (!ghEditDS)
{
// cannot allocate any memory
return(NULL);
}
else
{
lpPtr = GlobalLock(ghEditDS);
uDataSegment = HIWORD((LONG)lpPtr);
// *must* have 16 bytes at start of heap
uEndAddress = (UINT)(GlobalSize(ghEditDS) - 16);
// initialise local heap in our data segment
LocalInit(uDataSegment, 0, uEndAddress);
// unlock data segment - still locked by our global lock
UnlockSegment(uDataSegment);
/*
* Create the edit control.
*
* Note that the allocated segment handle is passed
* in the CreateWindow call as the hInstance parameter.
*/
hwndEdit = CreateWindow("EDIT",
NULL,
(WS_CHILD | WS_VISIBLE | WS_VSCROLL |
WS_HSCROLL
| ES_LEFT | ES_MULTILINE
| ES_NOHIDESEL | ES_AUTOVSCROLL |
ES_AUTOHSCROLL) ,
0, 0,
0, 0,
hwndOwner,
nID,
uDataSegment, // NB not hInst
NULL);
/*
* The EM_LIMITTEXT function will allow the edit field to
* hold more than 32K. The default for an edit field is
* approximately 32K, but by sending a 0, 0L through as
* the parameters, the default then becomes all available
* memory or 64K which comes first.
*/
if (hwndEdit)
SendMessage(hwndEdit, EM_LIMITTEXT, 0, 0L);
/*
* Stash the data segment in the extra bytes for the MDI child window
* owning the edit control.
* This is so that we can free this memory when the edit control is
* destroyed.
*/
SetWindowWord(hwndOwner, GWW_EDIT_DATASEGMENT, uDataSegment);
return(hwndEdit);
}
} /* CreateEditWindow() */
Yoy may need to call FreeEditDataSegment() when the window owning
the edit control receives WM_DESTROY:
void FreeEditDataSegment(UINT uDataSegment)
{
HGLOBAL hBuffer; // global handle to buffer
DWORD dw;
if (uDataSegment)
{
dw = GlobalHandle(uDataSegment);
hBuffer = (HGLOBAL)LOWORD(dw);
if (hBuffer)
{
GlobalUnlock(hBuffer);
GlobalFree(hBuffer);
}
}
} /* FreeEditDataSegment() */
The limit in the size of the edit control is discussed in the MSDN, in an
article entitled edit controls. The storage requirement is roughly 2 bytes
per line + text size + some fixed overhead.
John
Dan Kirby -- dkirby@accessone.com
Saturday, May 11, 1996
Windows 95 has a 64K limitation for the edit control. If you need to get
more than that, one approach is to use the Rich edit control which has no
limits.
--dan
----------
From: Barry Tannenbaum[SMTP:barry@dddv.com]
Sent: Thursday, May 09, 1996 2:00 PM
To: mfc-l@netcom.com
Cc: erik.heuer@ks-t.no
Subject: Re: More than 32k in a EDIT ctrl
[Mini-digest: 3 responses]
At 03:33 PM 5/6/96 +0100, you wrote:
>Environment: VC++ 4.0, NT 3.51 SP4
>
>There may be a simple solution to this, but sofar I have not succeeded in
>implementing one. The problem is quite simple: How to break the 32k limit
>on a multiline Windows EDIT control on Win95/NT?
Are you using SerializeRaw to read in your file? I found that it limits
the
size of a file to 1MB. I simply implemented it myself; stealing the code
from SerializeRaw and removing the restriction.
- Barry
------------------------------------------------------------------------
--------
3DV Technology, Inc Phone: (603) 595-2200 X228
410 Amherst St., Suite 150 Fax: (603) 595-2228
Nashua, NH 03063 Net: barry@dddv.com
-----From: Steve Downey
It's really very simple. Use SetLimitText on your edit control. For
example:
m_Edit.SetLimitText(UINT_MAX); //set size of edit control to as large as
possible
-----From: John Moulder
I don't know about large edit controls on NT, but this works on Windows
3.1:
/*
* CreateEditWindow()
*
* creates a new window with styles appropriate for wordwrapping
*
* Allocates a data segment for an edit control.
*
* Allows up to 64k per edit control.
*
* See Microsoft Developer's CDROM, topic GLBEDIT.
*
* returns handle of new window
*
* parameters :
* hwndOwner window handle of owner
* nID ID of edit control
*/
HWND CreateEditWindow(HWND hwndOwner, int nID)
{
char *pFN = "CreateEditWindow";
GLOBALHANDLE ghEditDS; // global handle to data segment
LPVOID lpPtr; // pointer to data segment
UINT uDataSegment; // start address of data segment
UINT uEndAddress; // end address of data segment
DWORD dwStyle; // style to create new window
HWND hwndEdit; // window handle of edit control
UINT uInitialSize = 4096;
// allocate some global memory for our new data segment
ghEditDS = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE | GMEM_ZEROINIT,
uInitialSize);
if (!ghEditDS)
{
// cannot allocate any memory
return(NULL);
}
else
{
lpPtr = GlobalLock(ghEditDS);
uDataSegment = HIWORD((LONG)lpPtr);
// *must* have 16 bytes at start of heap
uEndAddress = (UINT)(GlobalSize(ghEditDS) - 16);
// initialise local heap in our data segment
LocalInit(uDataSegment, 0, uEndAddress);
// unlock data segment - still locked by our global lock
UnlockSegment(uDataSegment);
/*
* Create the edit control.
*
* Note that the allocated segment handle is passed
* in the CreateWindow call as the hInstance parameter.
*/
hwndEdit = CreateWindow("EDIT",
NULL,
(WS_CHILD | WS_VISIBLE | WS_VSCROLL |
WS_HSCROLL
| ES_LEFT | ES_MULTILINE
| ES_NOHIDESEL | ES_AUTOVSCROLL |
ES_AUTOHSCROLL) ,
0, 0,
0, 0,
hwndOwner,
nID,
uDataSegment, // NB not hInst
NULL);
/*
* The EM_LIMITTEXT function will allow the edit field to
* hold more than 32K. The default for an edit field is
* approximately 32K, but by sending a 0, 0L through as
* the parameters, the default then becomes all available
* memory or 64K which comes first.
*/
if (hwndEdit)
SendMessage(hwndEdit, EM_LIMITTEXT, 0, 0L);
/*
* Stash the data segment in the extra bytes for the MDI child
window
* owning the edit control.
* This is so that we can free this memory when the edit control is
* destroyed.
*/
SetWindowWord(hwndOwner, GWW_EDIT_DATASEGMENT, uDataSegment);
return(hwndEdit);
}
} /* CreateEditWindow() */
Yoy may need to call FreeEditDataSegment() when the window owning
the edit control receives WM_DESTROY:
void FreeEditDataSegment(UINT uDataSegment)
{
HGLOBAL hBuffer; // global handle to buffer
DWORD dw;
if (uDataSegment)
{
dw = GlobalHandle(uDataSegment);
hBuffer = (HGLOBAL)LOWORD(dw);
if (hBuffer)
{
GlobalUnlock(hBuffer);
GlobalFree(hBuffer);
}
}
} /* FreeEditDataSegment() */
The limit in the size of the edit control is discussed in the MSDN, in an
article entitled edit controls. The storage requirement is roughly 2 bytes
per line + text size + some fixed overhead.
John
begin 600 WINMAIL.DAT
M>)\^(BL``0:0" `$```````!``$``0>0!@`(````Y 0```````#H``$(@ <`
M& ```$E032Y-:6-R;W-O9G0@36%I;"Y.;W1E`#$(`0V ! `"`````@`"``$$
MD 8`& (```(````,`````P``, ,````+``\.``````(!_P\!````/P``````
M``"!*Q^DOJ,0&9UN`-T!#U0"`````&UF8RUL0&YE=&-O;2YC;VT`4TU44 !M
M9F,M;$!N971C;VTN8V]M```>``(P`0````4```!33510`````!X``S !````
M$0```&UF8RUL0&YE=&-O;2YC;VT``````P`5# $````#`/X/!@```!X``3 !
M````$P```"=M9F,M;$!N971C;VTN8V]M)P```@$+, $````6````4TU44#I-
M1D,M3$!.151#3TTN0T]-`````P``.0`````+`$ Z`0````(!]@\!````! ``
M``````,,`````P``, 0````+``\.`0````(!_P\!````0P````````"!*Q^D
MOJ,0&9UN`-T!#U0"```!`&5R:6LN:&5U97) :W,M="YN;P!33510`&5R:6LN
M:&5U97) :W,M="YN;P``'@`", $````%````4TU44 `````>``,P`0```!,`
M``!E``$P`0``
M`!,```!EK4A'/DBA$15-4`````!X`'@P!````!0```%--5% `````'@`?
M# $````5````9&MIL"@P!0$P-4`@!C: K 2D(8"!N">!D'1!O(/IG
M$@`@!& 6`!T1`Y$?T1QT+!XP`B =0&%P<+,#8 #0:" $`!\"=1'P&1T34FDA
M,1UJ('=HFR)2&Y)N'R <,W,N"H7Q"H4M+60`<"2L"HL<, @Q.# "T6DM,32>
M- WP#- H(PM9,38*H/T#8'0%D 5 )8 J1@J'*/OK## IQD8#83HK3BG(*$
M($(*P')Y(%0`< $>P&YB875M6U,P3510.B_ +R% 9,DPP'8N!:!M72KO*_U/
M!F ","T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