WNDPROC editProcOld;
//usage:
//include it & put it after CreateWindow(”edit”,…)
//editProcOld = (WNDPROC)SetWindowLongPtr(my_edit,GWLP_WNDPROC, (LONG_PTR)editProc);
LRESULT CALLBACK editProc(HWND hWnd,UINT iMsg,WPARAM wParam, LPARAM lParam){
switch(iMsg) { //podobnie jak w tb_proc_new
case WM_CHAR:{
short tmp = GetKeyState(VK_CONTROL);
short flag = (HIBYTE(tmp))?MOD_CONTROL:0;
if(flag==MOD_CONTROL && HIBYTE(GetKeyState(VK_BACK))){
int dlugosc = SendMessage (hWnd, WM_GETTEXTLENGTH, 0, 0 ) + 1;
char* body_tmp = new char[dlugosc];
GetWindowText(hWnd,body_tmp,dlugosc);
string temp = body_tmp;
string reszta ;
int selectionBeg, selectionEnd;
SendMessage(hWnd, EM_GETSEL, (WPARAM)&selectionBeg, (LPARAM)&selectionEnd);
if(selectionBeg != selectionEnd) goto ret;
reszta = temp.substr(selectionBeg);
temp = temp.substr(0,selectionBeg);
int pos = temp.find_last_of(” “,temp.length()-2);
int pos2 = temp.find_last_of(”\r\n”,temp.length()-2);
int pos3 = temp.find_last_of(”.”,temp.length()-2);
int pos4 = temp.find_last_of(”,”,temp.length()-2);
if(pos < pos2) pos = pos2;
if(pos < pos3) pos = pos3;
if(pos < pos4) pos = pos4;
if(pos == -1) pos = 0;
selectionBeg = selectionBeg - (temp.length() - pos) + 1;
temp = temp.substr(0,pos+((pos==pos2)?-1:((pos == 0)?0:1)));
temp = temp + reszta;
SetWindowText(hWnd,(char*)temp.c_str());
SendMessage(hWnd,EM_SETSEL,(WPARAM)selectionBeg,(LPARAM)selectionBeg);
delete [] body_tmp;
return 0;
}else if(flag==MOD_CONTROL && HIBYTE(GetKeyState(0×41))){
int dlugosc = SendMessage (hWnd, WM_GETTEXTLENGTH, 0, 0 );
SendMessage(hWnd,EM_SETSEL,(WPARAM)0,(LPARAM)dlugosc);
return 0;
}
break;
}
}
ret:
return CallWindowProc(editProcOld,hWnd,iMsg,wParam,lParam);
}
Poprawiamy bugi z m$
Wnerwiało mnie wstawianie kwadracików, zamiast kasowanie ostaniego
wyrazu (CTRL+Backspace), i nie obsługiwanie CTRL+A w standardowym
editboxie windowsowym, więc poprawiłem

