c# - Keep Text Edit mode when setting another form as active -


i'm working on little clipboard helper using winforms. when user copies item, gets saved internal clipboard. when user presses , holds ctrl+v form displays, showing recent clipboard items , user can use up/down arrows change clipboard. means can paste historical clipboard items. it's working have problem can't find 'nice' way around.

when editing text, renaming folder in windows explorer, user presses ctrl+v, form comes front steals focus , exits text edit mode in windows explorer. use setwindowpos() winapi form not steal focus... problem need focus can capture up/down keys. have keyboard hook can capture key presses when select next item, gains focus , there quite few ugly scenarios i'd have capture.

so, there way set whole app never gain focus or can think of way around problem?

[edit] added of code, let me know if you'd more. keydown , keyup think need handle problem

private void khook_keydown(object sender, windowshooklib.keyboardeventargs e) {          if (selecting)             return; // selecting          if (e.keycode == keys.v && e.modifiers == keys.control) {             selecting = true;              whandle = winapi.getforegroundwindow();             // -----------------             // need display form here without losing text edit mode in whatever application in , editing text in.             winapi.showinactivetopmost(showclipboard);             //showclipboard.show();             // ------------------         }     }   private void khook_keyup(object sender, windowshooklib.keyboardeventargs e) {          // check if key 1 care         if (!keyisinteresting(e) || pasting)             return;          if (selecting) {             switch (e.keycode) {                 case keys.v:                     showclipboard.hide();                     winapi.setforegroundwindow(whandle);                     system.threading.thread.sleep(10); // wait original window gain regain focus                     pasting = true;                     sendkeys.send("^v");                     clipboard.movetobottom(); // add item bottom first on list next time                     pasting = false;                     selecting = false;                     break;                 case keys.delete:                     clipboard.removeitem();                     showclipboard.refreshclipboardlist();                     break;             }         }     } 


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -