Pelles C forum

C language => Windows questions => Topic started by: gromit on October 11, 2008, 09:37:16 PM

Title: Delete last character
Post by: gromit on October 11, 2008, 09:37:16 PM
Hi All
Im sure i am missing something really obvious here

But i have hunted high and low an the net and cannot solve this simple question


Using
SendMessage(GetDlgItem(g_hwnd,IDC_GENERAL_ENTRYBOX),EM_REPLACESEL   ,(WPARAM)TRUE,(LPARAM)L"replacewith");

works fine when i want to insert at the caret or delete selection and insert another character

but what do i send in the !,(LPARAM)L"replacewith"!
to delete the last character

having tried all manner of "\?" characters
my last attempt was to try
SendMessage(GetDlgItem(g_hwnd,IDC_GENERAL_ENTRYBOX),EM_SETSEL ,(WPARAM)end,(LPARAM)end);
SendMessage((GetDlgItem(g_hwnd, IDC_GENERAL_ENTRYBOX)),WM_CLEAR,0,0);
that did not work either

Any help would be appreciated Thanks
 
Title: Re: Delete last character
Post by: JohnF on October 12, 2008, 01:02:22 PM
This seems to work.

Code: [Select]
txtlen = SendMessage(GetDlgItem(hwndDlg, 4002), WM_GETTEXTLENGTH, 0, 0);
SendMessage(GetDlgItem(hwndDlg, 4002), EM_SETSEL, txtlen-1, txtlen);
SendMessage(GetDlgItem(hwndDlg, 4002), EM_REPLACESEL, TRUE, (LPARAM)"");

John
Title: Re: Delete last character
Post by: gromit on October 13, 2008, 12:49:00 AM
 :-[

Indeed it does

I am sending soft button pentaps to this edit box and not keypresses

I was losing focus to the said editbox and not doing it right at all

Big Thanks John