Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

TWO icon questions

rahzan
New Contributor I
2,026 Views
Is there a way to hang an icon on a console app?

Is there a way to minimize the icon to system tray instead of the ol' task bar? (in any type of CVF app or a shortcut thereof?)

Thanks,
Tim
0 Kudos
7 Replies
gfthomas8
Novice
2,026 Views
Yes and yes.

The former was dealt with long ago and is available on the archieves
http://softwareforums.intel.com/ids/board/message?board.id=15&message.id=3399
The latter is far trickier. Iv'e done fro VC++ and VB but not VF.

Ciao,
Gerry T.

Message Edited by intel.software.network.support on 12-09-2005 10:50 AM

0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,026 Views
Re the second: it's relatively simple, but it requires a regular Windows app with a message loop and a window. I can dig out a sample if you wish.

Jugoslav
0 Kudos
rahzan
New Contributor I
2,026 Views
Thanks,
I did a search before posting (guessing that it is a common question) but no less than 920 topics were found on "console icon fortran".

It might be that I do not know how to do and ANDed search on the thing. At any rate a more direct reference on the first question would be useful.

as for the offer from Jugoslav, YES I would like to see your sample, and would appreciate it much.

Thanks again, Tim
0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,026 Views
Tim,

Re 1: see here
Here's a brief sketch of how to do it; the full sample application is 800 lines long and based on XFT library, so I won't post it here. I'll upload it to XFT home page today so try there later.

First, create your 16x16,16 colors icon (IDI_XNETSEND) and load it:
hicoSmall = LoadImageA(GetModuleHandle(0), &
MAKEINTRESOURCE(IDI_XNETSEND), 1, 16, 16, 0)
Declare your custom message (>WM_APP):
INTEGER, PARAMETER:: WM_ICONCLICKED = #8050
The message will be sent to your window whenever a mouse event occurs on the tray icon. Then, register your tray icon via Shell_NotifyIcon API:
TYPE(T_NOTIFYICONDATA)::   NID
...
NID%cbSize = SIZEOF(NID)
NID%hWnd = hFrame
NID%uID = IDI_XNETSEND
NID%uFlags = NIF_ICON + NIF_MESSAGE + NIF_TIP
NID%uCallbackMessage = WM_ICONCLICKED
NID%hIcon = hicoSmall
NID%szTip = "XNetSend"C
iSt = Shell_NotifyIcon(NIM_ADD, NID)
CASE(WM_ICONCLICKED)
IF (lParam.EQ.WM_LBUTTONDBLCLK) THEN
iSt = ShowWindow(hFrame)
iSt = SetForegroundWindow(hFrame)
ELSE IF (lParam.EQ.WM_RBUTTONDOWN) THEN
iSt = DestroyMenu(hMenu)
hMenu = CreatePopupMenu()
!InsertMenuItem's "Open" (ID_NOTIFY_OPEN) and
!"Close" (ID_NOTIFY_CLOSE)...
iSt = GetCursorPos(PT)
!SetForegroundWindow and WM_NULL are required
!according to KB135788.
iSt = SetForegroundWindow(hFrame)
iSt = TrackPopupMenu(hMenu, hFrame, PT%x, PT%y)
iSt = SendMessage(hFrame, WM_NULL, 0, 0)
END IF
CASE (WM_COMMAND)
IF (LOWORD(wParam).EQ.ID_NOTIFY_OPEN) THEN
!On "Open" from tray popup menu, show the window
iSt = ShowWindow(hFrame)
iSt = SetForegroundWindow(hFrame)
ELSE IF
0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,026 Views
Tim,

Re 1: see here
Here's a brief sketch of how to do it; the full sample application is 800 lines long and based on XFT library, so I won't post it here. I'll upload it to XFT home page today so try there later.

First, create your 16x16,16 colors icon (IDI_XNETSEND) and load it:
hicoSmall = LoadImageA(GetModuleHandle(0), &
MAKEINTRESOURCE(IDI_XNETSEND), 1, 16, 16, 0)
Declare your custom message (>WM_APP):
INTEGER, PARAMETER:: WM_ICONCLICKED = #8050
The message will be sent to your window whenever a mouse event occurs on the tray icon. Then, register your tray icon via Shell_NotifyIcon API:
TYPE(T_NOTIFYICONDATA)::   NID
...
NID%cbSize = SIZEOF(NID)
NID%hWnd = hFrame
NID%uID = IDI_XNETSEND
NID%uFlags = NIF_ICON + NIF_MESSAGE + NIF_TIP
NID%uCallbackMessage = WM_ICONCLICKED
NID%hIcon = hicoSmall
NID%szTip = "XNetSend"C
iSt = Shell_NotifyIcon(NIM_ADD, NID)
In your main window procedure, handle WM_ICONCLICKED. Normally, for tray-icon applications, the main window is hidden. You should handle double clicks on tray icon and, if you wish, right-click (for context menu):
CASE(WM_ICONCLICKED)
   IF (lParam.EQ.WM_LBUTTONDBLCLK) THEN
      iSt = ShowWindow(hFrame)
      iSt = SetForegroundWindow(hFrame)
   ELSE IF (lParam.EQ.WM_RBUTTONDOWN) THEN
      iSt = DestroyMenu(hMenu)
      hMenu = CreatePopupMenu()
      !InsertMenuItem's "Open" (ID_NOTIFY_OPEN) and 
      !"Close" (ID_NOTIFY_CLOSE)...
      iSt = GetCursorPos(PT)
      !SetForegroundWindow and WM_NULL are required
      !according to KB135788.
      iSt = SetForegroundWindow(hFrame)
      iSt = TrackPopupMenu(hMenu, hFrame, PT%x, PT%y)
      iSt = SendMessage(hFrame, WM_NULL, 0, 0)
   END IF
CASE (WM_COMMAND)
   IF (LOWORD(wParam).EQ.ID_NOTIFY_OPEN) THEN
      !On "Open" from tray popup menu, show the window
      iSt = ShowWindow(hFrame)
      iSt = SetForegroundWindow(hFrame)
   ELSE IF (LOWORD(wParam).EQ.ID_NOTIFY_CLOSE) THEN
      !Exit application
      iSt = DestroyWindow(hFrame)


Jugoslav
0 Kudos
rahzan
New Contributor I
2,026 Views
Dear Jugoslav,
0. Thanks for detailed reposnse.

1.Did you post the same msg twice?

2. I looked at the XFT page and did not see the 800 line sample. Where can I find it?

3. I have actually never done any GUIs with CVF. Are there samples for idiots for the XFT as well?

Many thanks, Tim
0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,026 Views
1) Looks as if I did; I had some problems with connection at the time.

2) It's the XNetSend sample.

3) Sigh... I wish there were. XFT is designed as simple wrapper around API; the basic idea is that, like with DFLOGM, you register callbacks for various messages you want to handle (XSetCommand/XSetHandler) and don't cope with message loop, register classes, deciphering lParam/wParam etc. XNetSend is not much more than a DFLOGM-based application (with slightly different syntax) -- most of these 800 lines is about functionality.

I'll see what I can do about "idiot" samples these days -- guess that a Hello, world + a XNotepad would be a good starting point. Heck, writing the documentation is tedious.

Jugoslav
0 Kudos
Reply