SlickEdit Product Discussion > Slick-C® Macro Programming
forcing focus to editor window when application gets focus (on ALT-TAB)
(1/1)
jcelle:
Hello there,
Since ever I am facing a strange behavior with VSE.
9 times out of 10 when I try to activate VSE using Alt-Tab I end up on VSE window that does not have completely the focus:
VSE behaves as if the Alt key had been pressed.
- The cursor shape is a full block and I can move it around using arrow keys
- Pressing any character key is captured by the menu hotkeys (eg if I press F I get the File menu dropping down).
I have to press ESC to force the focus back.
Note that I am using VistaSwitcher as Alt Tab replacement which could explain that the Alt event is captured by VSE upon getting the focus (not being cleared from stack by VistaSwitcher).
What I would like to try is to use Slick-C to capture the WM_GETFOCUS and force putting focus to the buffer window.
Would that this be possible ?
Thanks for any hint.
All the best.
Jerome
Graeme:
Don't know if this would work but you could try running a timer callback that checked every half a second to see whether slick had just regained the focus and call mdisetfocus if so. This code is un-compiled and un-tested.
Also see this about using a timer.
https://community.slickedit.com/index.php/topic,15962.msg61149.html#msg61149
--- Code: ---
int timer_handle; // must be non static
static boolean slick_last_had_focus;
static void timer_callback1()
{
if (!_use_timers || timer_handle < 0)
return;
if (_no_child_windows() ) {
return;
}
_kill_timer(timer_handle);
if (_get_focus())
{
if (!slick_last_had_focus)
mdisetfocus();
slick_last_had_focus = true;
}
else
slick_last_had_focus = false;
timer_handle = _set_timer(500, timer_callback1);
}
definit()
{
if (arg(1)=="L") {
//If this is NOT an editor invocation
if ( timer_handle != -1 )
_kill_timer(timer_handle);
}
timer_handle = _set_timer(500, timer_callback1);
}
--- End code ---
--- Code: ---
/**
* @return Returns the id of the window which currently has the focus. Zero is
* returned if a Slick-C® window does not have focus.
*
* @see _set_focus
*
* @categories Miscellaneous_Functions
*
*/
int _get_focus();
/**
* Set focus on the editor. This command can be useful when
* you are trying to control an instance of SlickEdit from
* another application or using {@link dde} and you need to
* transfer focus to the editor to complete an operation.
*
* @param mdi_wid MDI window to accept focus. Set to 0 for
* current MDI window.
*
* @categories Miscellaneous_Functions
*/
_command void mdisetfocus(int mdi_wid=0) name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_MDI)
--- End code ---
jcelle:
Thanks Graeme, will definitely look into this !
Navigation
[0] Message Index
Go to full version