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

2 Answers

0
IInspectable On Best Solutions

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.

0
montonero On

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.