...suppose the thread title sums it up!
Printable View
...suppose the thread title sums it up!
& orCode:GetWindowText(
HWND hWnd, // handle to window or control
LPTSTR lpString, // text buffer
int nMaxCount // maximum number of characters to copy
);
Code:GetDlgItemText(
HWND hDlg, // handle to dialog box
int nIDDlgItem, // control identifier
LPTSTR lpString, // pointer to buffer for text
int nMaxCount // maximum size of string
);
Actually, what I meant is how to highlight the text. As if the user had dragged the mouse over the text while holding down the left mouse button...BTW: thanks for the quick response though!
Hmm.....have a try at..
Code:SendMessage(hEdit, EM_SETSEL,
(WPARAM)nFirstChar,(LPARAM) nLastChar);
Hmm...interesting. That didn't work but you gave me a great starting point! Your suggestion led me directly to the windowsx.h header. What an interesting file! I will be back with a definite...thanks Rob...
Hmm didnt work huh?.....It should do.....it will highlight the selected range within an edit........I assume that's what you want right?
BTW, there are loads of EM_ messages you can send to an edit......have a look at the SDK docs for more info...
Ahh, well that file was a bum one. Just a bunch of cheap macros! Anyhow, I believe you gave the correct code. I am just overlooking something. I will figure it out. Oh and BTW: I am assuming the last two params are pointers to the first and last cells of the buffer that got the window text?
This function simply highlights text in an edit just like dragging a mouse over the text with the left button down...that is what you want right?Quote:
Originally posted by Sebastiani
Ahh, well that file was a bum one. Just a bunch of cheap macros! Anyhow, I believe you gave the correct code. I am just overlooking something. I will figure it out. Oh and BTW: I am assuming the last two params are pointers to the first and last cells of the buffer that got the window text?
The last 2 params are the start and end positions of the text you want highlighted.........simply send ints, but cast them to WPARAM & LPARAM for the purposes of the function...
Oh....and you may need to give the edit input focus before doing this.....
Yes to highlight text.
Here is what I was trying:
eTicker.Focus();
SendMessage(eTicker.hwnd, EM_SETSEL, (WPARAM)buff[0], (LPARAM)buff[strlen(buff) - 1]);
...and even the hard-coded:
eTicker.Focus();
SendMessage(eTicker.hwnd, EM_SETSEL, (WPARAM)'a', (LPARAM)'c');
//...the contents of the edit in that case being "abc"...
No sorry...you need the numerical index positions....
You dont even need to know the contents of an edit to set selections....Code:int nFirstChar = 1,nLastChar = 3;
//.......................
eTicker.Focus();
SendMessage(eTicker.hwnd, EM_SETSEL, (WPARAM)nFirstChar, (LPARAM)nLastChar );
Geez I'm a goober. Anyhow, now the effect is that the text is completely erased! Well I will work on that after more important aspects of the program are finished. But I thank you kindly, sir. Let me know if I can be of any assistance to you...
Try this
SendMessage(hWnd, EM_SETSEL, 0, MAKELONG(0,0xffff) );