Link to home
Start Free TrialLog in
Avatar of susansyriac
susansyriac

asked on

I get errors with this approach : WinMain' : function cannot be overloaded , CreateWindowExA' : cannot convert parameter 11 from 'void *' to 'struct HINSTANCE__ *',

1. WinMain' : function cannot be overloaded ,
2. CreateWindowExA' : cannot convert parameter 11 from 'void *' to 'struct HINSTANCE__ *',
3.  wndclass.hInstance         =   hInstance;
error C2440: '=' : cannot convert from 'void *' to 'struct HINSTANCE__ *'
int PASCAL  WinMain (   HANDLE hInstance,
                        HANDLE hPrevInst,
                        LPSTR  lpszCmdLine,
                        int    cmdShow
                    )
{
WNDCLASS wndclass;
MSG      uMsg;
 
    //g_hInst =   hInstance;
 
// Do the usual initialization stuff ...
    if  (   !hPrevInst) 
        {
             wndclass.lpszClassName     =   "InvisibleDummyWnd";
             wndclass.hInstance         =   hInstance;
             wndclass.lpfnWndProc       =   WndProc;
             wndclass.hCursor           =   LoadCursor  (   NULL,   IDC_ARROW);
             wndclass.hIcon             =   LoadIcon    (   NULL,   IDI_APPLICATION);
             wndclass.lpszMenuName      =   NULL;
             wndclass.hbrBackground     =   ( HBRUSH)   COLOR_ACTIVEBORDER;
             wndclass.style             =   0;
             wndclass.cbClsExtra        =   0;
             wndclass.cbWndExtra        =   0;
 
             RegisterClass  (   &wndclass);
        }
 
 
    g_hWnd  =   CreateWindow    (   "InvisibleDummyWnd",
                                    "InvisibleDummyWnd",
                                    0,
                                    CW_USEDEFAULT,
                                    0,
                                    CW_USEDEFAULT,
                                    0,
                                    NULL,
                                    NULL,
                                    hInstance,
                                    NULL
                                );
 
 
    ShowWindow  (   g_hWnd, SW_HIDE);
 
    while   (   GetMessage  (   &uMsg,  0,  0,  0))
            {
                TranslateMessage(   &uMsg);
                DispatchMessage (   &uMsg);
            };
 
return( 0);
}
 
LRESULT CALLBACK WndProc    (   HWND          hWnd,
                                unsigned      uMsg,
                                WPARAM        wParam,
                                LPARAM        lParam
                            )
{
 
//	g_hWnd = hWnd;
  //Process messages  
 
  switch( uMsg)
  {
                                   
    case WM_DESTROY:    PostQuitMessage( 0);
                        break;
	
 
 
    default:            return  (   DefWindowProc   (   hWnd,
                                                        uMsg,
                                                        wParam,
                                                        lParam
                                                    )
                                );
  }
 
   return 0L;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So :
int PASCAL  WinMain (   HINSTANCE hInstance,
                        HINSTANCE hPrevInst,
                        LPSTR  lpszCmdLine,
                        int    cmdShow
                    )

Open in new window

To add to above comment:

In previous Windows versions API  HANDLE and HINSTANCE both were typedef'd as void* and the type difference could not be detected by the compiler.

The PASCAL specifier is obsolete. Use WINAPI instead.