Click here to Skip to main content
16,009,318 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: Selecting Text - Pls Help!! Pin
Jose Lamas Rios14-Jul-05 21:27
Jose Lamas Rios14-Jul-05 21:27 
c121hains wrote:
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)!!

Try the following. I tested it with an edit control in the same dialog and it worked... May or may not work in your case, but I hope you'll let us know Smile | :)

static INPUT GetKeyboardInput(short key, DWORD dwFlags)
{
   INPUT input;
 
   input.type = INPUT_KEYBOARD;
   input.ki.dwExtraInfo = 0;
   input.ki.time = 0;
   input.ki.wScan = 0;
   input.ki.wVk = key;
   input.ki.dwFlags = dwFlags;
 
   return input;
}
 
void CFindInWindowDlg::Select(CWnd* window, int start, int count)
{
   window->BringWindowToTop();
 
   INPUT input[4];
   input[0] = GetKeyboardInput(VK_SHIFT, KEYEVENTF_EXTENDEDKEY);
   input[1] = GetKeyboardInput(VK_SHIFT, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY);
   input[2] = GetKeyboardInput(VK_RIGHT, 0);
   input[3] = GetKeyboardInput(VK_RIGHT, KEYEVENTF_KEYUP);
 
   // move to start
   for (int i = 1; i < start; i++)
   {
      SendInput(2, &input[2], sizeof(INPUT));
   }
 
   // press shift key
   SendInput(1, &input[0], sizeof(INPUT));
 
   // move cursor
   for (int j = 0; j < count; j++)
   {
      SendInput(2, &input[2], sizeof(INPUT));
   }
 
   // release shift key
   SendInput(1, &input[1], sizeof(INPUT));
}

I think your problem was:

1. Not using KEYEVENTF_EXTENDEDKEY for the shift key.
2. Sending too many shift keys (where you say "release the right key" you were actually sending [shift down + right up], and after the loop you were sending [shift up + right up]).

Hope that helps,

--
jlr
http://jlamas.blogspot.com/[^]
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 
GeneralProblem displaying Unicode characters Pin
JFarlette14-Jul-05 6:56
JFarlette14-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.