Click here to Skip to main content
15,921,636 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralDo I hit some kind of Visual Studio limitation? Urgent help needed! Pin
DionChen14-Jul-05 16:51
DionChen14-Jul-05 16:51 
GeneralRe: Do I hit some kind of Visual Studio limitation? Urgent help needed! Pin
Anonymous14-Jul-05 17:02
Anonymous14-Jul-05 17:02 
GeneralRe: Do I hit some kind of Visual Studio limitation? Urgent help needed! Pin
Christian Graus14-Jul-05 17:10
protectorChristian Graus14-Jul-05 17:10 
GeneralRe: Do I hit some kind of Visual Studio limitation? Urgent help needed! Pin
Blake V. Miller14-Jul-05 17:31
Blake V. Miller14-Jul-05 17:31 
GeneralRe: Do I hit some kind of Visual Studio limitation? Urgent help needed! Pin
DionChen15-Jul-05 0:49
DionChen15-Jul-05 0:49 
GeneralExecute Twice Pin
aarontan14-Jul-05 16:12
aarontan14-Jul-05 16:12 
GeneralRe: Execute Twice Pin
Weiye Chen14-Jul-05 19:43
Weiye Chen14-Jul-05 19:43 
GeneralSelecting Text - Pls Help!! Pin
c121hains14-Jul-05 14:39
c121hains14-Jul-05 14:39 
Confused | :confused:

This should be easy. All i want to do is have some text highlighted in a control in another window. The control doesn't respond to any EM_* messages so i'm simulating the selection of text by sending a series of VK_RIGHT and VK_SHIFT key presses.

The problem is that it the 'right arrow' key gets pressed but the control doesn't have the effect of the 'shift' key. I know it gets pressed because once i move around in the control, the shift key is still down (when i uncomment the shift release key press - see last line of below method)!!

I have to do it this way as i have no other choice.

Here's the code:

window->BringWindowToTop();

//THIS PART WORKS
//Same effect as pressing the right arrow key 10 times
for (int a = 0; a < 10; a++){
wnd->SendMessage(WM_KEYDOWN, VK_RIGHT, 0);
wnd->SendMessage(WM_KEYUP, VK_RIGHT, 0);
}


//This part should select the next 5 characters of text.
//Simulates holding down shift and pressing 'Right Arrow' key 5 times
INPUT input[2];
for (int b = 0; b < 5; b++){
input[0] = GetKeyboardInput(VK_LSHIFT, 0);
input[1] = GetKeyboardInput(VK_RIGHT, 0);

//Press down shift and right arrow key
SendInput(2, input, sizeof(INPUT));

input[1] = GetKeyboardInput(VK_RIGHT, 2);

//Release right arrow key
SendInput(2, input, sizeof(INPUT));
}

//Release the shift key
input[0] = GetKeyboardInput(VK_LSHIFT, 2);
SendInput(2, input, sizeof(INPUT));



INPUT CFindInWindowDlg::GetKeyboardInput(short key, int downUp)
{
INPUT input;

input.type = 0x01; //INPUT_KEYBOARD
input.ki.dwExtraInfo = 0;
input.ki.time = 0;
input.ki.wScan = 0;
input.ki.wVk = key;
input.ki.dwFlags = downUp;

return input;
}


Any help would be greatly appreciated. My head is going to explode! WTF | :WTF:
GeneralRe: Selecting Text - Pls Help!! Pin
Jose Lamas Rios14-Jul-05 21:27
Jose Lamas Rios14-Jul-05 21:27 
GeneralRe: Selecting Text - Pls Help!! Pin
c121hains15-Jul-05 5:50
c121hains15-Jul-05 5:50 
GeneralI need help fatal Pin
TA-RS14-Jul-05 13:23
TA-RS14-Jul-05 13:23 
GeneralRe: I need help fatal Pin
Christian Graus14-Jul-05 13:34
protectorChristian Graus14-Jul-05 13:34 
GeneralRe: I need help fatal Pin
Bob Stanneveld14-Jul-05 21:53
Bob Stanneveld14-Jul-05 21:53 
GeneralRe: I need help fatal Pin
dandy7215-Jul-05 9:12
dandy7215-Jul-05 9:12 
GeneralContext Menu Extension with XP Visual Style Pin
Cyrus Dang14-Jul-05 13:13
Cyrus Dang14-Jul-05 13:13 
Generalinternet access? help Pin
faroqtam14-Jul-05 12:29
faroqtam14-Jul-05 12:29 
GeneralRe: I need help Pin
Christian Graus14-Jul-05 13:31
protectorChristian Graus14-Jul-05 13:31 
GeneralERROR_PIPE_BUSY in TransactNamedPipe Pin
Wander Costa14-Jul-05 9:59
Wander Costa14-Jul-05 9:59 
GeneralSynchronisation, timer and thread Pin
Watertreader14-Jul-05 9:20
Watertreader14-Jul-05 9:20 
GeneralRe: Synchronisation, timer and thread Pin
Blake Miller14-Jul-05 13:01
Blake Miller14-Jul-05 13:01 
GeneralRe: Synchronisation, timer and thread Pin
Watertreader19-Jul-05 9:24
Watertreader19-Jul-05 9:24 
GeneralRe: Synchronisation, timer and thread Pin
Blake Miller19-Jul-05 11:24
Blake Miller19-Jul-05 11:24 
Generalcannot save changes to source files Pin
htuba14-Jul-05 9:02
htuba14-Jul-05 9:02 
GeneralRe: cannot save changes to source files Pin
David Crow14-Jul-05 9:46
David Crow14-Jul-05 9:46 
QuestionCreate database at run-time? Pin
transoft14-Jul-05 6:56
transoft14-Jul-05 6:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.