0

I am working on a legacy code vb6 - A form based application which has virtual keyboards but looses focus after it wakes up or logged in again (application usually runs on windows tablet) so i need to reset its focus to the fields where it has to be. I can't find any events which could do that!!

i found an vb.net event but can't get though with this on vb6

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

and also tried event handlers but that did'nt worked

For that i need to find some event which afterSleep or onWakeup which can handle that.any ideas?

scalauser
  • 1,327
  • 1
  • 12
  • 34
Avinash
  • 305
  • 6
  • 14
  • You're on the right track with subclassing WndProc (yes, even though your example is from .Net, the same is possible in .Net with the correct API calls and the correct message signature. Problem is you'll have to find the correct messages for afterSleep and onWakeup and handle those appropriately in your subclassed WndProc. [Here's](http://www.vbaccelerator.com/home/VB/Code/Libraries/Subclassing/SSubTimer/article.asp) a good intro to sublcassing in classic VB. – Eric Walker Aug 31 '15 at 14:21
  • is there any way to do this(http://stackoverflow.com/questions/1562474/how-do-i-check-when-the-computer-is-being-put-to-sleep-or-wakes-up ) in Vb? – Avinash Sep 01 '15 at 10:43
  • Yes, you can do that in VB, just change the line that adds the eventhandler to use the [AddHandler](https://msdn.microsoft.com/en-us/library/7taxzxka.aspx) method and obviously the switch needs changed to a Select. – Eric Walker Sep 01 '15 at 13:53
  • I can't say for sure that this is what you need, but you might want to investigate CBT hooking. Look at [this](https://msdn.microsoft.com/en-us/library/windows/desktop/ms644977(v=vs.85).aspx), in particular the HCBT_ACTIVATE parameter. There's a link there to the SetWindowsHookEx function that should give you enough to go on. The basic idea is to call a procedure when a window is activated, sort of a low-level event handler. – BobRodes Sep 03 '15 at 07:25

0 Answers0