Dialog Tray

This is a discussion on Dialog Tray within the Windows Programming forums, part of the Platform Specific Boards category; Here is another issue that I have encountered, but I may have overlooked something, again. This program, listed below, is ...

  1. #1
    Registered User SpEcIeS's Avatar
    Join Date
    Aug 2004
    Posts
    56

    Post Dialog Tray

    Here is another issue that I have encountered, but I may have overlooked something, again.

    This program, listed below, is a dialog box that minimizes to the system tray, however, the icon that is listed in the resource does not appear. In the system tray a "i" in a dialog ballon is displayed. If another icon is added, and used, to the resource script a red circle with an x is displayed.

    The really odd thing about this is that the dialog box does show the icon in the taskbar.

    Since I have spent a lot of time starring at this code my eyes no longer see. Perhaps one of you programmers would be kind enough to correct this problem.

    Here is the application:
    Dialog Tray.zip
    Last edited by SpEcIeS; 01-01-2005 at 10:07 PM.
    SpEcIeS

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    I can't open the zip file.

  3. #3
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    I also can not download the zip file. In case you haven't already done so, be sure to include the source code to your program.

  4. #4
    Registered User SpEcIeS's Avatar
    Join Date
    Aug 2004
    Posts
    56

    Question Not Sure?

    I do not understand? I am able to download the ZIP file, which contains the whole project.

    I will have to get back to this.
    SpEcIeS

  5. #5
    Registered User
    Join Date
    Dec 2004
    Posts
    73
    For the zip file name, don't use spaces, use underscores. I think that is the problem here.

  6. #6
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    The problem is being discussed in General Discussions right now. You can no longer upload zip files, but they are working on alternatives. For now, just upload your source code - you can still do that.

  7. #7
    Registered User SpEcIeS's Avatar
    Join Date
    Aug 2004
    Posts
    56
    Ok.. I will try the underscore to see if that makes a difference. Here is the new link:

    Dialog_Tray.zip

    Hopefully this works for others. Again the link works on my machine.
    Last edited by SpEcIeS; 01-02-2005 at 05:55 PM.
    SpEcIeS

  8. #8
    Registered User
    Join Date
    Dec 2004
    Posts
    73
    The guy that knows what he's talking about above said that you can no longer upload .zip files. So just upload the source code and then we can get to your problem.

  9. #9
    Registered User SpEcIeS's Avatar
    Join Date
    Aug 2004
    Posts
    56
    Wow... that makes things a little more complicated. Anyway, here is the code listed below:

    Dialog Tray.cpp

    Code:
    #include <windows.h>
    #include "resource.h"
    #include "Dialog Tray.h"
    
    int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpszCmdLine, int iCmdShow)
    {
    	DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG),0,(DLGPROC) DialogProc);
    	return 1;
    }
    
    
    BOOL CALLBACK DialogProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    	switch (msg)
    	{		
    		case WM_INITDIALOG:
    			return (TRUE);
    		case WM_COMMAND:
    			if(wParam==IDOK) {
    				SendMessage(hWnd,WM_SIZE,SIZE_MINIMIZED,NULL);
    			}
    			else if(wParam==IDCANCEL) {
    				SendMessage(hWnd,WM_CLOSE,NULL,NULL);
    			}
    			break;
    		case WM_TRAYMESSAGE:
    			switch(wParam)
    			{
    			case ICONIDENT:
    				switch(lParam)
    				{
    				case WM_RBUTTONUP:
    					SendMessage(hWnd,WM_SIZE,SIZE_RESTORED,NULL);				
    					break;
    				case WM_LBUTTONUP:
    					MessageBox(hWnd,"You clicked the right mouse button!","Dialog Tray",MB_OK);
    					break;
    				}
    				break;
    			}
    			break;
    		case WM_SIZE:
    			if(wParam==SIZE_MINIMIZED) {
    				ShowWindow(hWnd,SW_HIDE);
    				NotifySysIcon(hWnd,IDI_ICON1,ToolTip,NIM_ADD);
    			}
    			else if(wParam==SIZE_RESTORED) {
    				ShowWindow(hWnd,SW_NORMAL);
    				Shell_NotifyIcon(NIM_DELETE,&Nicon);
    			}
    			break;			
    		case WM_CLOSE:
    			Shell_NotifyIcon(NIM_DELETE,&Nicon);
    			DestroyWindow(hWnd);
    			break;
    		case WM_DESTROY:
    			EndDialog(hWnd,0);
    			break;		
    	}
    	
    	return 0;	
    }
    
    int NotifySysIcon (HWND hWnd,int IconNum,PSTR ToolTip,DWORD NimType)
    {
    	Nicon.cbSize=sizeof(NOTIFYICONDATA);
    	Nicon.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IconNum));
    	Nicon.hWnd = hWnd;
    	Nicon.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP;		
    	Nicon.uCallbackMessage = WM_TRAYMESSAGE;		
    	Nicon.uID = ICONIDENT;
    	strcpy(Nicon.szTip,ToolTip);
    	Shell_NotifyIcon(NimType,&Nicon);
    	
    	return 0;
    }
    Dialog Tray.h

    Code:
    #define WM_TRAYMESSAGE	(WM_USER+1)
    #define ICONIDENT 0
    
    BOOL CALLBACK DialogProc (HWND, UINT, WPARAM, LPARAM);
    int NotifySysIcon (HWND,int,PSTR,DWORD);
    
    NOTIFYICONDATA  Nicon;
    HWND			hWnd;
    HINSTANCE		hInst;
    
    char ToolTip[] = {"This is the tooltip"};
    Resource.h

    Code:
    #define IDD_DIALOG                      101
    #define IDI_ICON1                       104
    Thanks for the help.
    SpEcIeS

  10. #10
    Registered User
    Join Date
    May 2002
    Posts
    132
    Please correct me if I am wrong, but your problem might lie in the NotifySysIcon() function. When your calling the LoadIcon() you are using the MAKEINTRESOURCE() macro with an int. I've always done MAKEINTRESOURCE(IDP_SOMEPIC). Unless you are setting the resource IDs as numbers, but #define 1 40003 wouldn't make a lot of sense to do.

    Unless IconNum (or whatever the variouble is), is being passed 104? Okay I guess that wouldn't help you, I didn't notice you were passing IDI_ICON1 into the NotifySysIcon function.

    Did you try testing the LoadIcon() call for errors?

    Tyouk
    Last edited by tyouk; 01-04-2005 at 02:59 PM.

  11. #11
    Registered User SpEcIeS's Avatar
    Join Date
    Aug 2004
    Posts
    56
    Sorry for not getting to this right away.

    Did you try testing the LoadIcon() call for errors?
    Thanks for the interest tyouk. I have yet to debug this application because I am finding that while running windows XP the symbols do not seem to work. This bothers me. However, I will have to get to that.

    Even though the NotifySysIcon procedure works great for a regular window, I really should remove the return value. The problem probably does exist in this procedure when it comes to the dialog box though.
    SpEcIeS

  12. #12
    Registered User SpEcIeS's Avatar
    Join Date
    Aug 2004
    Posts
    56
    Well after some brief investigation I have found that somehow my program is receiving the IDI_ASTERISK icon. I am not sure how but it is. Below is an update on the code:
    Attached Files Attached Files
    SpEcIeS

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. GTK+ Gnome desktop system tray app problem
    By BobS0327 in forum Linux Programming
    Replies: 2
    Last Post: 04-01-2006, 09:54 PM
  3. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 03:42 PM
  4. Getting the position of a dialog without parent on the screen
    By stormbringer in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2003, 03:59 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21