I am working on a simple HTML editor with a styles wizard. I know how to generate the text but I can only figure out how to add the text to the end. I want to insert it wherever the cursor is but dont know how. This is what I have so far:
Code:
case IDOK:{
int len = GetWindowTextLength(GetDlgItem(hWnd, IN_HOVERCOLOR));
char* ret_color;
ret_color = (char*)GlobalAlloc(GPTR, len + 1);
GetDlgItemText(hWnd, IN_HOVERCOLOR, ret_color, 16);
//ret_color now has value of IN_HOVERCOLOR//
HWND hwndpar;
hwndpar = GetWindow(hWnd,GW_OWNER);
HWND hEdit;
hEdit = GetDlgItem(hwndpar, MAIN_EDIT);
char* before_text;
int txtlen = GetWindowTextLength(hEdit);
before_text = (char*)GlobalAlloc(GPTR, txtlen + 75);
GetWindowText(hEdit, before_text, txtlen+1);
char style_text[75];
strcpy(style_text,"<style>\r\n<!--\r\na:hover{color:");
strcat(style_text,ret_color);
strcat(style_text,";}\r\n-->\r\n</style>"); //22 len
//Style Text now has the style tag//
strcat(before_text, style_text);
SetWindowText(hEdit, before_text);
//Free up memory//
GlobalFree(before_text);
EndDialog(hWnd, wCommand);
}
break;