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

Posted on 2009-04-07
Last Modified: 2012-05-06
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;
                =   0;
             wndclass.cbClsExtra        =   0;
             wndclass.cbWndExtra        =   0;
             RegisterClass  (   &wndclass);
    g_hWnd  =   CreateWindow    (   "InvisibleDummyWnd",
    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);
    default:            return  (   DefWindowProc   (   hWnd,
   return 0L;

Open in new window

Question by:susansyriac
  • 2
LVL 53

Accepted Solution

Infinity08 earned 250 total points
ID: 24084892
afaik, WinMain takes two HINSTANCE's as first parameters, and not two HANDLE's.
LVL 53

Expert Comment

ID: 24084903
So :
int PASCAL  WinMain (   HINSTANCE hInstance,
                        HINSTANCE hPrevInst,
                        LPSTR  lpszCmdLine,
                        int    cmdShow

Open in new window

LVL 39

Expert Comment

ID: 24085023
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.


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question