0

we have one desktop(1st screen) to display the image and another touchscreen(2nd screen) for the control, we wrote a virtual keyboard(html&javascript) on touchscreen, ideally when we touch the keys on the touchscreen, we could input text in editbox(in an input dialog window) in the 1st desktop. Now the problem is the mouse is lost(originally it is in a input dialog in 1st desktop) when we touch the touchscreen, so we have to create a global window in C++ program, and manually copy each possible input dialog window to this global window when it is in use, also we need to set focus for each possible editbox in this input dialog window. please see this:

for each possible input dialog, we add

    extern HWND activeInputWindow;
    activeInputWindow=m_Edit_Name.m_hWnd;

also for each possible input box in this window we have to add

    activeInputWindow=GetDlgItem(IDC_EDIT_TEST)->m_hWnd;

then the program always do this to get back the original window after clicking the touchscreen(2nd window)

extern HWND activeInputWindow;
if(IsWindow(activeInputWindow)) 
  ::SetFocus(activeInputWindow);

suppose we have 10 input window and 10 input boxes in each window,then I need to code 100 places! There must have some simple ways, windows osk.exe (virtual keyboard) have no problem for this but we have to use our own virtual keyboard.... I tried GetTopWindow() and GetForegroundWindow() but not working.. Many thanks for the help

drescherjm
  • 10,365
  • 5
  • 44
  • 64

2 Answers2

0

The problem is that your virtual keyboard is stealing the focus of the edit control. You'll need to prevent this.

Try to set the flag WS_EX_NOACTIVATE for a window's style or other approaches from this or this answers.

montonero
  • 1,363
  • 10
  • 16
0

This is trying to solve the problem using the wrong tools. What you really want is a window that receives input, but rejects activation. To achieve this, handle the WM_MOUSEACTIVATE message by returning MA_NOACTIVATE. This also works for touch input.

See How can I have a window that rejects activation but still receives pointer input? for all the ins and outs.

IInspectable
  • 46,945
  • 8
  • 85
  • 181
  • Thanks, I think it remembers the position of the mouse, after clicking the touchscreen, the mouse position is still kept in the main screen(even the mouse disappears, if you move the mouse a little bit, it appears at the old position), but the window is still shifted to touchscreen. I will continue to research about this. – user7768436 May 01 '19 at 05:09