Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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
3
Medium Priority
?
919 Views
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;
             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

0
Comment
Question by:susansyriac
  • 2
3 Comments
 
LVL 53

Accepted Solution

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

Expert Comment

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

Open in new window

0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
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.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
Suggested Courses

963 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