How to detect selected text or file?

Can anyone tell me how to detect selected text or file? Do i have to install any library?
For example
http://imgur.com/a/sVxf0
And how can i experiment with selected text or file in Codeblocks or VisualStudio?
Last edited on
Where do you want to detect the selected text, in your own program ?
@Thomas1965
Both in my program and other programs.
In your own Windows applications you can use the EM_GETSEL message to get the selected text in a control.
https://msdn.microsoft.com/en-us/library/windows/desktop/bb761598%28v=vs.85%29.aspx
@Thomas1965
Can i write something like this->
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <sdl/sdl.h>
using namespace std;

int main(int argc, char** argv)
{
    char character;
    char input[10];
    int i, it;
    const Uint8* SDL_GetKeyboardState(int* numkeys);
    DWORD thestart, theend;
    Tchar buffer[];
    

    if (cin >> SendMessage(hEdit, EMGETSEL, (WPARAM)&thestart, (WLPARAM)&theend -1) 
        && (state[SDL_SCANCODE_LCTRL] || state[SDL_SCANCODE_RCTRL]) && state[SDL_SCANCODE_A] ) {
        for( i = 0 ; i <= 10 && character!='b' ; i++ ){
        cin >> character;
        input[i]=character;
        }}

    if (cin >>character == 'b'){
    for( it= (i-2); it>=0 ; it--){
        cout << "Variable is " << input[it] << ' ' << it << endl;
        cin >> character;
    }}
return 0;
}

I put -1 in line 15 to get just the selected text.
And why i get this error when i write cin in if statement->
error: no match for 'operator==' in 'std::operator>
I want to use cin in if statement sometimes, is it possible?
Last edited on
1
2
if (cin >> SendMessage(hEdit, EMGETSEL, (WPARAM)&thestart, (WLPARAM)&theend -1) 
        && (state[SDL_SCANCODE_LCTRL] || state[SDL_SCANCODE_RCTRL]) && state[SDL_SCANCODE_A] )

I don't know what you want to accomplish. SendMessage returns the begin and end of the selection. You can't input anything in it.
Topic archived. No new replies allowed.