Page 1 of 6

EditBox control: increase capacity

Posted: Tue Jul 09, 2013 12:31 am
by srvet_claudio
Hi all.
I will outline here a doubt that I answered in another forum.

For default the EditBox control accept as maximum 32,767 characters.
This maximum can be increased to 2,147,483,646 characters if you send the following message to the control:

Code: Select all

#define EM_LIMITTEXT 197
SendMessage (GetControlHandle("EditBox_1","Form_1"), EM_LIMITTEXT, 0, 0)
This increases the capacity of EditBox control in 65,538 times.

Best regards,
Claudio.

Re: EditBox control: increase capacity

Posted: Tue Jul 09, 2013 12:52 am
by esgici
srvet_claudio wrote:Hi all.

Code: Select all

#define EM_LIMITTEXT 197
SendMessage (GetControlHandle("EditBox_1","Form_1"), EM_LIMITTEXT, 0, 0)
Thanks to tip, doc :)

Re: EditBox control: increase capacity

Posted: Tue Jul 09, 2013 1:22 am
by Leopoldo Blancas
Entendido y anotado...

Gracias por el Tip Claudio...
Polo
*-----------------------------------------------------
Understood and annotated ...

Thanks for the Tip Claudio...
Polo

EditBox control: increase capacity

Posted: Tue Jul 09, 2013 1:30 am
by Pablo César
We are very lucky to have Dr. Soto in our xBase community.

Your knowledges and sharing make us very rich.

Thank you again Dr. Soto !

Re: EditBox control: increase capacity

Posted: Tue Jul 09, 2013 3:02 am
by Rathinagiri
That's great Claudio.

Re: EditBox control: increase capacity

Posted: Tue Jul 09, 2013 3:49 am
by bpd2000
Excellent, Thank you Dr. Claudio.

EditBox control: increase capacity

Posted: Tue Jul 09, 2013 2:45 pm
by Pablo César
srvet_claudio wrote:I will outline here a doubt that I answered in another forum.
Dear Claudio, probably something different need to take effect for change capacity, because was tested and still with problem in that example of: http://www.pctoledo.com.br/forum/viewto ... 583#p83583

Please, if you can give a look again would find a solution.

Re: EditBox control: increase capacity

Posted: Tue Jul 09, 2013 4:31 pm
by Carlos Britos
Pablo César wrote:
srvet_claudio wrote:I will outline here a doubt that I answered in another forum.
Dear Claudio, probably something different need to take effect for change capacity, because was tested and still with problem in that example of: http://www.pctoledo.com.br/forum/viewto ... 583#p83583

Please, if you can give a look again would find a solution.
HI
try with
SendMessage (GetControlHandle("EditBox_1","Form_1"), EM_LIMITTEXT, nVALUE, 0)
or
SendMessage (GetControlHandle("EditBox_1","Form_1"), EM_LIMITTEXT, -1, 0)

EditBox control: increase capacity

Posted: Tue Jul 09, 2013 7:34 pm
by Pablo César
Carlos Britos wrote:try with
SendMessage (GetControlHandle("EditBox_1","Form_1"), EM_LIMITTEXT, nVALUE, 0)
or
SendMessage (GetControlHandle("EditBox_1","Form_1"), EM_LIMITTEXT, -1, 0)
Hellow Carlos, thank you for your interest. This was solved with this code C:

Code: Select all

#pragma BEGINDUMP

#define COMPILE_HMG_UNICODE

#include "HMG_UNICODE.h"

#include <windows.h>
#include <commctrl.h>
#include "hbapi.h"

HB_FUNC (MSG_SETTEXT)
{ 
   SendMessage ((HWND) hb_parnl(1), WM_SETTEXT, 0, (LPARAM) HMG_parc(2));
}

#pragma ENDDUMP
According to Claudio this crash is due one problem in HMG internal function for assigning which he will solve for next releases.

Re: EditBox control: increase capacity

Posted: Tue Jul 09, 2013 9:41 pm
by srvet_claudio
The problem occurs because when using a very large text there is a crash in the system because the internal functions of HMG to set/get text in the editbox does not support a very large text. In the next release I try fix.

I developed two functions to work with very long texts in EditBox control.

To work with very large texts must change:
Form_1.EditBox_1.Value := cHugeText
for:
MSG_SETTEXT (GetControlHandle("EditBox_1","Form_1"), cHugeText)

and:
cHugeText := Form_1.EditBox_1.Value
for:
cHugeText := MSG_GETTEXT (GetControlHandle("EditBox_1","Form_1"))

Code: Select all

#pragma BEGINDUMP

#define COMPILE_HMG_UNICODE

#include "HMG_UNICODE.h"

#include <windows.h>
#include <commctrl.h>
#include "hbapi.h"

HB_FUNC (MSG_SETTEXT)
{ 
   SendMessage ((HWND) hb_parnl(1), WM_SETTEXT, 0, (LPARAM) HMG_parc(2));
}


HB_FUNC (MSG_GETTEXT)
{  UINT nLen = 0;
   TCHAR *cText = NULL;
   nLen = (UINT) SendMessage ((HWND) hb_parnl(1), WM_GETTEXTLENGTH, 0, 0);
   if (nLen > 0)
   {  cText = (TCHAR*) hb_xgrab ((nLen+1) * sizeof(TCHAR));
      if (cText)
      {   SendMessage ((HWND) hb_parnl(1), WM_GETTEXT, nLen+1, (LPARAM) cText);
          HMG_retc( cText );
          hb_xfree( cText );
      }
      else
         HMG_retc(_TEXT(""));
   }
   else
      HMG_retc(_TEXT(""));
}


#pragma ENDDUMP