Software Archive
Read-only legacy content
17060 Discussions

EM_LIMITTEXT doesn't work

Intel_C_Intel
Employee
588 Views
In my QuickWin-Application, I wanted to limit the possible Input-character-number of an Edit-Box. Therefore I used:
iret= DlgSendCtrlMessage(Dlg,IDC_EDIT,EM_LIMITTEXT,16,0)
But it didn't work, I could input many more characters than 16.
I also tried the Original API-calls
iret= SendDlgItemMessage(Dlg&hwnd,IDC_EDIT,EM_LIMITTEXT,16,0)
and
iret= SendMessage(hwndEditbox,EM_LIMITTEXT,16,0)
but they didn't work either.

Where is the mistake?
Thank you for your help.

Burkhard
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
588 Views
IIRC in CVF 6.1 and later there's flag DLG_LIMITTEXT for DlgSet (not sure about exact name -- see docs).

In any version, though, SendMessage or its variations will not work from the same routine from which you call DlgInit; dialog is actually created on DlgModal and Dlg%hWnd is invalid before that. To overcome this, you have to use callback for dialog init:
iSt = DlgSetSub(Dlg, IDD_MYDIALOG, OnDialogInit)
which is called immediately before dialog is displayed (i.e. on DlgModal) and do any initial SendMessages from OnDialogInit.

Jugoslav
0 Kudos
Intel_C_Intel
Employee
588 Views
Many Thanks to you Yugoslav!
Your solution with "iSt = DlgSetSub(Dlg, IDD_MYDIALOG, OnDialogInit)" works.
The other type of solution with correct spelling
"DlgSet(Dlg,IDC_EDIT,16,DLG_TEXTLENGTH)"
does something else: The edit Box is filled with 16 Blanks, but the user is not limited to maximum input of 16 Characters.
Thanks again!! Burkhard
0 Kudos
Reply