WM_SYSCOMMAND; SC_MINIMIZE never sent by application

This is a discussion on WM_SYSCOMMAND; SC_MINIMIZE never sent by application within the Windows Programming forums, part of the Platform Specific Boards category; I have a program where I would like to set a few things depending on maximized or minimized state. I ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    36

    WM_SYSCOMMAND; SC_MINIMIZE never sent by application

    I have a program where I would like to set a few things depending on maximized or minimized state. I tried the WM_SYSCOMMAND where it has SC_MAXIMIZE and SC_MINIMIZE of which SC_MAXIMIZE does work how I expect it to. SC_MINIMIZE, however, seems to never be sent when I click the minimize button. Is theresomething I'm missing?

  2. #2
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    You probably don't see some little mistake in your code.
    It happens to me all the time.
    You could post you'r WM_SYSCOMMAND statement code.

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    36
    Code:
    case WM_SYSCOMMAND:
    		SysCommandHandler(wParam);
                    return DefWindowProc(hwnd, msg, wParam, lParam);
    Code:
    void SysCommandHandler(WPARAM wParam)
    {
    	if(wParam == SC_MAXIMIZE)
    	{
             //...
    	}
    	else if(wParam == SC_MINIMIZE)
    	{
    	//...
    	}
    	return;
    }
    The SC_MINIMIZE is never processed. I stuck a message box in there it never goes off no matter how many times I hit the minimize button.

  4. #4
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    It appears that that should work. For reference, here is how I implement my minimize/maximize handlers:
    Code:
    case WM_SYSCOMMAND:
    {
         switch(wParam)
         {
              case SC_MINIMIZE:
              {
                   // do stuff
                   break;
              }
              case SC_MAXIMIZE:
              {
                    // do stuff
                    break;
              }
              default:
                   return DefWindowProc(hwnd, msg, wParam, lParam);
         }
         break;
    }
    Maybe try that in your code.

  5. #5
    Registered User
    Join Date
    Jun 2006
    Posts
    36
    Oh man...I'm at a loss here. I tried the absolute simplest thing I could think of and yet, it still doesn't work!

    Code:
    	case WM_SYSCOMMAND:
        		if(wParam == SC_MINIMIZE)
        		{
    			MessageBox(0, "This message box will never be shown", "!", 0);
    		}
                    SysCommandHandler(wParam); 
        		return DefWindowProc(hwnd, msg, wParam, lParam);
    I think I'm going to concede that I will not be able to get SC_MINIMIZE to be sent for some bizarro reason and will have to resort to some fake approach...So I ask is there anyway to catch minimize actions without SC_MINIMIZE?

  6. #6
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,262
    I just fired up Spy++ (a Visual Studio tool) and logged a window's messages as I clicked its Minimize button. WM_SYSCOMMAND, SC_MINIMIZE is sent. Perhaps you can check this with your window and Spy++ if you have it?

  7. #7
    Registered User
    Join Date
    Jun 2006
    Posts
    36
    This is the most ridiculous screw up I've done in recent time. I was clicking the restore button when I missclicked it and hit the minimize button instead. My message box appeared and it was revealed...I had the terminology wrong the whole time. I changed my handler to catch SC_RESTORE rather than SC_MINIMIZE and all was well. Sorry for your time...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cleanup of the application...
    By Petike in forum Windows Programming
    Replies: 1
    Last Post: 08-16-2008, 05:23 PM
  2. Problem with com application
    By amardon in forum C++ Programming
    Replies: 3
    Last Post: 10-06-2005, 05:50 AM
  3. MFC run application by clicking on file...
    By dug in forum Windows Programming
    Replies: 4
    Last Post: 12-02-2004, 03:33 AM
  4. Win application not very portable
    By swed in forum Windows Programming
    Replies: 5
    Last Post: 10-01-2001, 11:17 AM

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