5 Replies - 2334 Views - Last Post: 02 August 2009 - 06:45 AM Rate Topic: -----

#1 andrew001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-July 09

System Tray

Posted 29 July 2009 - 06:59 AM

Hello, my name is Andrew and this is my first post ever!! Alright..

I have created a Windows Application program that when minimized, it puts the program into the system tray (bottom right of your screen). I am going to use it for shortcuts etc. that i am going to create for it. But i recently thought of this problem: i am going to have a humungous menu!! The first items I have added is a Help option, exit option and calc.exe. I want to add a TON of useful shorcuts but the menu will go all the way to the top of my screen! haha.

OK. So my uestion is: Can someone please tell me how to program using C++ a SubMenu. Here is an example: When I right click my system tray program a menu pops up (which i already did) but i want to make it so that i move my cursor over to it and it EXPANDS to a whole nother menu...

Here is one more example of what I WANT IT TO BE LIKE (what I need you guys to help me with): I right click my system tray program, then the menu pops up, **i move my cursor over onto a menu option E.G. Windows Useful (which ill create), then it pops up with an expanded submenu that has all useful windows tools that i want in that.

Can someone please tell me how to create that expandable submenu? :)

--THANKING ALL OF YOU IN ADVANCE :D

P.S. Ask me anything that you have to, to help me make this :) Oh, and if you want me to post my .cpp file i can also do that, so that you guys can edit it for me :)

OH!! AND 1 MORE THING! I am using **Dev-C++**, on Windows Vista SP2.

Is This A Good Question/Topic? 0
  • +

Replies To: System Tray

#2 SwiftStriker00  Icon User is offline

  • No idea why my code works
  • member icon

Reputation: 433
  • View blog
  • Posts: 1,599
  • Joined: 25-December 08

Re: System Tray

Posted 29 July 2009 - 07:45 AM

Ok, i'll be the one to say it:

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

#3 andrew001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-July 09

Re: System Tray

Posted 30 July 2009 - 07:46 AM

Ok i am sorry i did not do it right. Let me try it again :) I assume you just want me to post the code? Alright.

I do not think I should post my full code because that would be too much haha. So I will just post the code that i think will help you help me :)

See it is soo hard to try and post my code on this topic because im not to sure where you need to look to find out what to do.

OK HERE IS THE BULK (MAIN AREA) OF MY CODE:


switch (message)
  {
  case WM_CREATE:

	// create the menu once.
	// oddly, you don't seem to have to explicitly attach
	// the menu to the HWND at all.  This seems so ODD.
	g_menu = CreatePopupMenu();
	
	//////////////////////////////////////////////////////////////////////////////////////////
	AppendMenu(g_menu, MF_STRING, CALC,  TEXT( "Calculator" ));
	AppendMenu(g_menu, MF_STRING, HELP,  TEXT( "Help" ) );
	///////////////////////////////////////////////////////////////////////////////////////////

	AppendMenu(g_menu, MF_STRING, ID_TRAY_EXIT_CONTEXT_MENU_ITEM,  TEXT( "Exit" ) );

	break;

  case WM_SYSCOMMAND:
	switch( wParam & 0xfff0 )  // (filter out reserved lower 4 bits:  see msdn remarks http://msdn.microsoft.com/en-us/library/ms646360(VS.85).aspx)
	{
case SC_MAXIMIZE:
MessageBox(hwnd, "You cannot click the Maximize button, it does not do anything.\nPlease Minimize or Close that window.", "ERROR",
		  MB_OK | MB_ICONINFORMATION);
return 0;
break;

case SC_CLOSE:
PostQuitMessage( 0 );
return 0;
break;
	
	case SC_MINIMIZE:
	  Minimize();
	  return 0;
	  break;
	}
	break;

  // Our user defined WM_TRAYICON message.
  // We made this message up, and we told
  //
  case WM_TRAYICON:
	{
	  printf( "Tray icon notification, from %d\n", wParam );

	  switch(wParam)
	  {
	  case ID_TRAY_APP_ICON:
		printf( "Its the ID_TRAY_APP_ICON.. one app can have several tray icons, ya know..\n" );
		break;
	  }

	  if (lParam == WM_LBUTTONUP)
	  {
		printf( "You have restored me!\n" );
		Restore();
	  }
	  else if (lParam == WM_RBUTTONDOWN) // I'm using WM_RBUTTONDOWN here because
	  {
		printf( "Mmm.  Let's get contextual.  I'm showing you my context menu.\n" );

		// Get current mouse position.
		POINT curPoint;
		GetCursorPos( &curPoint );

		// should SetForegroundWindow according
		// to original poster so the popup shows on top
		SetForegroundWindow(hwnd); 

		// TrackPopupMenu blocks the app until TrackPopupMenu returns
		UINT clicked = TrackPopupMenu(

		  g_menu,
		  TPM_RETURNCMD | TPM_NONOTIFY, // don't send me WM_COMMAND messages about this window, instead return the identifier of the clicked menu item
		  curPoint.x,
		  curPoint.y,
		  0,
		  hwnd,
		  NULL

		);
		//SendMessage(hwnd, WM_NULL, 0, 0); // send benign message to window to make sure the menu goes away.
		if (clicked == ID_TRAY_EXIT_CONTEXT_MENU_ITEM)
		{
		  // quit the application.
		  PostQuitMessage( 0 );
		}
		
		
///////////////////////////////////////////////////////////////////////////////////////////  
// this goes with the other thing too	  
if (clicked == CALC)
{
system("start calc.exe");
// if you want it to quit after clicked				  PostQuitMessage( 0 );
}

if (clicked == HELP)
{
MessageBox(hwnd, "On the Main Window you have two options:\n1) Minimize that window\n2) EXIT by clicking the Close button."
"\n\n On the Main Window the Maximize button does not do anything."
"\n\n ", "HELP", MB_OK | MB_ICONQUESTION);
// if you want it to quit after clicked				  PostQuitMessage( 0 );
}
///////////////////////////////////////////////////////////////////////////////////////////		
	  }
	}
	break;




Oh, and I am not getting any errors, SwiftStriker00, everything works fine. I just want to create a submenu onto my current menu. Maybe you can supply me with the code? :) (if there is a certain code).

And another thing: I am not using this code with a console window, I have created my own little WinAPP that when minimized it goes to the system tray.

If you can please try and ignore the comments, I am a messy commenter :D haha.

Ok So now can someone please help me on how I can add a submenu to my orgininal menu?

Thanking all of you in advance again :)

-Andrew

P.S. SwiftStriker00, can you help me make the submenu? :)

This post has been edited by andrew001: 30 July 2009 - 07:50 AM

Was This Post Helpful? 0
  • +
  • -

#4 andrew001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-July 09

Re: System Tray

Posted 01 August 2009 - 06:41 AM

Can somebody PLEASE help me with this? I have been trying to figure it out on my own for like a month now :( i spend about 5 hours a day trying. PLEASE PLEASE anybody.

*sigh* -Andrew
Was This Post Helpful? 0
  • +
  • -

#5 jeff666  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 193
  • Joined: 30-December 08

Re: System Tray

Posted 01 August 2009 - 11:35 AM

View Postandrew001, on 1 Aug, 2009 - 05:41 AM, said:

Can somebody PLEASE help me with this? I have been trying to figure it out on my own for like a month now :( i spend about 5 hours a day trying. PLEASE PLEASE anybody.
*sigh* -Andrew

You can ask on Win32 grp
where it's a very classic code (in C).
Was This Post Helpful? 1
  • +
  • -

#6 andrew001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-July 09

Re: System Tray

Posted 02 August 2009 - 06:45 AM

OK, Thank You Jeff666 :)

I will try it out :)

I hope this works.

-Andrew
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1