Invisible Forms

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Invisible Forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:39 pm

by synergyfocus >> Tue, 24 Sep 2002 1:56:38 GMT

Hi,
Does anyone know how to get rid of that message box that says "You only have invisible forms remaining".
The app is a background processor, so I am putting an icon in the system tray and want to remove the window from the task bar. When the window is minimised I want to make the window invisible so only the icon in the system tray shows. But I always get that message box, that makes me either close the app or show a window.

Note: The app.applicationType attribute is read only, so I can't just change it to non-gui when the window is minimised, then change it back to gui when the user double clicks the system tray icon.

Any ideas - or suggestions of alternative ways that I could get around this? Thanks!

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Invisible Forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:39 pm

by cdshearer >> Tue, 24 Sep 2002 2:05:36 GMT

There doesn't seem to be a way of doing this, but could you architect this as two separate apps - one background application and one normal application that could communicate with your background application (say, through notifications or sharedTransients?)

Craig

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Invisible Forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:39 pm

by allistar >> Tue, 24 Sep 2002 2:12:06 GMT

Hi there,
When the application closes couldn't you get a handle to the form
and delete it?

form := app.getForm("FormClassName");
if (form <> null) then
delete form;
endif;

Would that achieve what you want?

You shouldbe able to remove a window frmo the task bar by using some
C++ trickery to modify the window itself. There should be a way of
hiding it like that.

How are you putting an icon in the system tray? I would do it by
writing a C++ application that creates a CCmdTarget object for the
icon. The trick is in then communicating with your Jade application. I
am curious as to how you have implemented this.

Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer
Auckland, NEW ZEALAND

Greentree International,
Developer of Greentree Financial Software. ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Invisible Forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:39 pm

by synergyfocus >> Tue, 24 Sep 2002 2:44:36 GMT

Originally started looking into using the Windows API function Shell_NotifyIcon in the Shell32.dll file, which can add remove and modify an icon in the system tray.
Then found a little freebie ocx that did it for me - nice and simply, 5 properties:
Add - Add your icon to the system tray.
Delete - Delete your icon on the system tray.
Modify - Modify your currently loaded system tray icon.
SetPicture - Sets the picture location of the icon you will load onto the system tray
SetTip - Sets the Tool Tip of your icon on the system tray.
and a mouseClick event.

Used that instead of having to try and create the data structure required to pass to the Shell_NotifyIcon function.

Your response:
When the application closes couldn't you get a handle to the form and
delete it?

I don't want to close the application though, I just want to hide the form, I want it still running as essentially a non-gui app.
As for a bit of C++ thuckery to modify the window - Uggghhh! wouldn't know where to start!
So was kinda hoping for a Jade alternative, or an API function that could somehow do it I suppose.

Craig - your response, to use a background application.
Because I am using an ocx, it has to be on a form, so that means I can not use any sort of non-gui application.
If I did dare to venture back to using the api mentioned above, so wasn't restricted to having to use a form, would creating icons in the system tray be considered gui related and therefore not work from a non-gui app, or because its not in a window it would let me away with it?

Thanks

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Invisible Forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:39 pm

by allistar >> Tue, 24 Sep 2002 3:31:56 GMT

It seems to me that the issue is the fact that you need a form for the OCX. Try and find a way of getting a system tray icon that doesn't require a Jade form.

Allistar.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Invisible Forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:40 pm

by synergyfocus >> Thu, 26 Sep 2002 2:19:09 GMT

I have terfed the ocx and used the custom control provided in the post "System Tray Icon" on 28/01/2000. Just a few tweaks to do some other things I wanted and it works like a charm!
Thanks everyone!

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Invisible Forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:40 pm

by cdshearer >> Tue, 24 Sep 2002 3:39:38 GMT

<snip>
Craig - your response, to use a background application. Because I am using an ocx, it has to be on a form, so that means I can not use any sort of non-gui application.
If I did dare to venture back to using the api mentioned above, so wasn't restricted to having to use a form, would creating icons in the system tray be considered gui related and therefore not work from a non-gui app, or because its not in a window it would let me away with it?

Thanks

I don't see how JADE could detect that you're calling Windows API functions that create icons in the system tray. Mainly, I think JADE will just complain if you try to create JADE forms or controls etc. It would certainly be worth a try, but if Allistar's method is simpler, go with that.

Craig

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Invisible Forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:40 pm

by encos_dev >> Tue, 24 Sep 2002 20:53:35 GMT
I don't want to close the application though, I just want to hide the form, I want it still running as essentially a non-gui app.

I'm currently working on something similar. We have a TcpIp "Connection Monitor" for our software, it's a background app - but we still need a GUI interface to it for monitoring the connections. We separated out the GUI stuff, which could be launched from the system tray, into a separate application & all communication is via notifications. Hence the background app runs fine with no forms (as a non-gui, server application). Don't know if this is related to your problem, but it works great for us.


Glen
Encos Global Systems Limited

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Invisible Forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:40 pm

by allistar >> Tue, 24 Sep 2002 2:24:11 GMT

You may be able todo it this way:

- pass the hwnd of the form to a function in a c++ dll that you write that does this:
- modify the window style so it doesn't have the WS_EX_APPWINDOW bit
set. The comment for that flag is:

Forces a top-level window onto the taskbar when the window is visible.

Turning that flag off may remove it from the task bar.

You could also turn on the WS_EX_NOACTIVATE flag. The text for that
is:

Windows NT 5.0 and later: A window created with this style is not activated when the user clicks it. The system does not activate the window when the user minimizes or closes the active window. The window does not appear in the taskbar.

You could also try turning on the WS_EX_TOOLWINDOW flag. The text is:

Creates a tool window; that is, a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font.
A tool window does not appear in the task bar or in the window that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by right-clicking or by typing ALT+SPACE.

Just some ideas, hopefully one of them works.

Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer
Auckland, NEW ZEALAND

Greentree International,
Developer of Greentree Financial Software. ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Invisible Forms

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:40 pm

by encos_dev >> Tue, 24 Sep 2002 2:25:42 GMT

See the sample schema in the posting titled "System Tray Icon" on 28/01/2000. I was using the techniques explained there recently, & I remember reading something in the code about how to get rid of invisible forms. Hope it helps.

Glen


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 29 guests