enum switchcase and windows message q

This is a discussion on enum switchcase and windows message q within the Windows Programming forums, part of the Platform Specific Boards category; Code: switch(msg) { case WM_Timer: .... } the api message labels work fine but when i try to use custom ...

  1. #1
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638

    enum switchcase and windows message q

    Code:
        switch(msg)
    {
        case WM_Timer:
         ....
    
    }
    the api message labels work fine but when i try to use custom labels i get this error.


    Error E2172 prog.cpp 768: Duplicate case in function __stdcall ClientProc(HW
    ND__ *,unsigned int,unsigned int,long)
    Error E2108 prog.cpp 787: Improper use of typedef 'SOCKET' in function __std
    call ClientProc(HWND__ *,unsigned int,unsigned int,long)
    Error E2379 prog.cpp 787: Statement missing ; in function __stdcall ClientPr
    oc(HWND__ *,unsigned int,unsigned int,long)
    Error E2134 prog.cpp 893: Compound statement missing } in function __stdcall
    ClientProc(HWND__ *,unsigned int,unsigned int,long)
    Warning W8070 prog.cpp 893: Function should return a value in function __std
    call ClientProc(HWND__ *,unsigned int,unsigned int,long)
    *** 4 errors in Compile ***
    i checked using the notepad find function there is no duplicate case in the switch case part of the prog.cpp period.
    there is no other "case WM_DESTROY:" in the prog.cpp period.


    Code:
    line 768
    
    		case WM_DESTROY:
    		{
                     	PostQuitMessage(0);
    		 break;       
    		}
    
    		 default: return DefWindowProc(hWnd, Msg, wParam, lParam); 
          }
    however above that there is

    Code:
    enum { alfaone,
           alfatwo,
           alfathree,
           betaone,
           betatwo,
           betathree,
    ....
    
         }
    
    ....
    
    					switch(LOWORD(wParam))
    					{
                                               case alfaone:
                                               ....
                                               break;
    
                                               case alfatwo:
                                               ....
                                               break;
    
                                               case alfathree:
                                               ....
                                               break;
    
    ....
    
     
    
    		                          case WM_DESTROY:
    		                          {
                                            	PostQuitMessage(0);
    		                           break;       
    		                          }
    
    		 default: return DefWindowProc(hWnd, Msg, wParam, lParam); 
          }
    even when i change "enum {alfaone ," to "enum {alfaone = 1 ," i get the same error. Or add "enum checkbox {alfaone = 1 , " i still get the same error.
    and when i use -b switch in bcc32 to "treat enum like int" still get same error.

    Should i put the custome labels in a seprate switchcase ? like so

    Code:
                switch(label)
                {
    
                  case customlabel1:
                  ....
                  break;
    
                  case customlabel2:
                  ....
                  break;
    
                  ....
                }
    i want it to work with the windows message q for checkboxes and other stuff. when ever i try to add custom labels i get the duplicate error.

  2. #2
    "I Win!" by U. Lose vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,745
    is the second switch inside some
    Code:
    case WM_COMMAND:
    {
       switch(LOWORD(wParam))
       {
          case alfaone:
                   ....
                   break;
       }
    }
    ?
    To be or not to be == true

  3. #3
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    it is in the "switch(LOWORD(wParam))". all custom labels are in that. i do not understand why i get duplicate error.

    Code:
    		case WM_COMMAND:
    		{
    			switch(HIWORD(wParam))
    			{
    				case BN_CLICKED:
    				{
    					switch(LOWORD(wParam))
    					{

  4. #4
    "I Win!" by U. Lose vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,745
    post your code...
    or evaluate it yourself by comenting it block by block
    To be or not to be == true

  5. #5
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    it is too long to post. it is also commented but not block by block.
    i did check for any missing "}" and ";" no missing found. checked it 4 times before posting. i was thinking that the enum is the prob. when i remove the custom labels it compiles. but does not do what i want.

    edit
    will comment block by block

  6. #6
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    ok done. commented block by block. the other errors wer fixd. down to 1 errors. still getting the duplicate case error.

    been thinking about that. "switch(LOWORD(wParam))" is latter 4
    bits 0-15dec so i thinking wm_destroy: and wm_create: and or other wParam also assigned same value thus creating duplicate prob.

    so where do i find the int values of wm_destroy: and the rest?

  7. #7
    "I Win!" by U. Lose vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,745
    WM_DESTROY message
    Declared in Winuser.h
    To be or not to be == true

  8. #8
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    k thank you for all your help.

Popular pages Recent additions subscribe to a feed

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