Page 1 of 1

Restoring Focus to NeoBook

PostPosted: Fri Feb 22, 2013 12:30 pm
by David de Argentina
Hi Plugin developer Gurus,

A customer ask me about an odd behaviour of one of my plugins.

He discovered when the plugin is launched, none of the following Neobook actions were executed.

The plugin preserves the focus and still waiting until a click of another neobook objects are pressed.

I tryed to restore the focus to the main neobook program in order to resume the next actions, but does not work.

the secuence of the Plugin actions are:

* Create the dialog, according the rectangle meassurements.

* Show the dialog MODELESS, and catch the Events on a callback function

* On the Callback Function, at the WM_INITDIALOG, i do the initial settings of the dialog. after this i send a private message telling the initialization is complete. the message is:
DIALOG POST CBHNDL, PWM_INIT_COMPLETE, %NULL, %NULL

* When this message is received, i try to restore focus to NeoBook main program using:
SetFocus nbWinHandle

But never the control is focused to the NeoBook program.

Do any know the correct way to return the control to the neobook program ?

Thanks in advance,
David de Argentina

Re: Restoring Focus to NeoBook

PostPosted: Fri Feb 22, 2013 1:53 pm
by Neosoft Support
I'm not at my development PC right now, but I think you need to use a different API function like SetActiveWindow.

Re: Restoring Focus to NeoBook

PostPosted: Fri Feb 22, 2013 8:25 pm
by David de Argentina
Thanks Dave,
I had tried your suggestion, but not success
Perhaps if i send you a piece of code...
Thanks again,
David de Argentina

Re: Restoring Focus to NeoBook

PostPosted: Sat Feb 23, 2013 12:39 pm
by Neosoft Support
Send the code. I can look at it next week.

Re: Restoring Focus to NeoBook

PostPosted: Sat Feb 23, 2013 12:53 pm
by dec
Hello,

What about SetForegroundWindow?

Re: Restoring Focus to NeoBook

PostPosted: Sat Feb 23, 2013 1:17 pm
by dec
Hello,

Maybe can use BringWindowToTop?

Re: Restoring Focus to NeoBook

PostPosted: Sat Feb 23, 2013 1:39 pm
by David de Argentina
Thanks DEC,

I tryed:

SendMessage( hDlg, %WM_KILLFOCUS,0,0)
SendMessage( nbWinHandle, %WM_SETFOCUS,0,0)
SetFocus nbWinHandle
SetActiveWindow nbWinHandle
SetForegroundWindow nbWinHandle

But no success...

I sent code to Dave, perhaps he will find the way...

Thanks again,
David de Argentina

Re: Restoring Focus to NeoBook

PostPosted: Mon Feb 25, 2013 12:01 pm
by Garic
Project (NB) does not geting control when your dialogue is open, or even after your dialog is closed?

Re: Restoring Focus to NeoBook

PostPosted: Mon Feb 25, 2013 1:22 pm
by David de Argentina
Hi Garic,

After Dialog is launched, no action of NB project is executed.

NB project actions are executed when a NB Button is clicked.

Thanks for your interest

David de Argentina

Re: Restoring Focus to NeoBook

PostPosted: Tue Feb 26, 2013 11:34 pm
by David de Argentina
Problem solved.

I think plugin API calls the functions synchronously, it's not going to return control to NeoBook main program until that function returns.

To solve problem, i need call functions Asynchronously - doing something like:

Code: Select all
THREAD CREATE  MyFunction_Start (param) to hThread
....
THREAD CLOSE hThread , 50


I Updated the Sample of NeoMediaPlayer Plugin. On my tests works fine.

Could you test it ? the download link is:

http://specialapps.software-zone.com/fi ... ayerV2.zip

Visible changes to test:

a) at init the program, you must see an alertbox telling the accel keys of the program

b) If you press on the keyboard F1 to F12 keys, some proceses will be done.

Please, tell me if it is working fine for you ( and what OS version you are using...)

Thanks in advance,

David de Argentina

Re: Restoring Focus to NeoBook

PostPosted: Wed Feb 27, 2013 12:25 am
by dec
Hello,

I try it and apparently work fine. The modal dialog appear showing diferents keys for the program. If press any of this keys until the dialog is show nothing happend. Once we close the modal dialog the program continue working and the refered keys works too. I test on Windows 7 (32 bits) Professional.

Edit: I test again this time on Windows 8 Professional and apparently work well too.

Re: Restoring Focus to NeoBook

PostPosted: Wed Feb 27, 2013 10:53 am
by Garic
Hi David,

I tested on WinXP SP3 - works fine, only very rarely when you quit you get this error:
Image

Re: Restoring Focus to NeoBook

PostPosted: Wed Feb 27, 2013 8:35 pm
by David de Argentina
Thanks Garic,

Problem detected & solved.

After 7 hours of continue playing with no errors, i think plugin is ready.

Thanks all,
David de Argentina