CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Nov 2001
    Posts
    244

    Resolving Compiler warnings C4311 and C4312

    Can someone please help me resolve this warnings? Ive fixed many of the others, its just these ones that I'm stuck at.

    I'm using Visual Studio 2005 Standard w/SP1. MFC Dialog App (non-unicode)


    warning C4311: 'type cast' : pointer truncation from 'HICON' to 'int'
    warning C4312: 'type cast' : conversion from 'unsigned long' to 'HICON' of greater
    Code:
        #define	BTNST_AUTO_GRAY					(HICON)(0xffffffff - 1L)
        // Set icon when the mouse is IN the button
    	hIconIn = (HICON)::LoadImage(hInstResource, MAKEINTRESOURCE(nIconIn), IMAGE_ICON, nCxDesiredIn, nCyDesiredIn, 0);
    
    
    	switch ((int)hIconIn) // C4311
    	{
    		case NULL:
    			break;
    		case (int)BTNST_AUTO_GRAY: // C4312
    			hIconOut = BTNST_AUTO_GRAY;
    			break;
    		case (int)BTNST_AUTO_DARKER:
    			hIconOut = BTNST_AUTO_DARKER;
    			break;
    		default:
    			hIconOut = (HICON)::LoadImage(hInstResource, MAKEINTRESOURCE(nIconOut), IMAGE_ICON, nCxDesiredOut, nCyDesiredOut, 0);
    			break;
    	} // switch


    C4311: 'type cast' : pointer truncation from 'LRESULT (__stdcall *)(HWND,UINT,WPARAM,LPARAM)' to 'DWORD'
    C4312: 'type cast' : conversion from 'LONG' to 'WNDPROC' of greater size
    Code:
    WNDPROC oldWindowProc;
    oldWindowProc = (WNDPROC)::SetWindowLong(GetParent()->m_hWnd, GWL_WNDPROC, (DWORD)SubclassWindowProc); // C4311 and 4312
    Last edited by Anarchi; May 14th, 2009 at 05:59 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured