Sign in to follow this  

Question on creating a windows application

This topic is 4223 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone I'm getting started in creating my first windows application. When I compile the following window definition, I get a warning on the last section that reads "41: [Warning] passing NULL used for non-pointer converting 1 of `HWND__* CreateWindowExA(DWORD, const CHAR*, const CHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)' "
 hwnd=CreateWindowEx(NULL,
                        "Test Class",
                        "Test Window",
                        WS_OVERLAPPED|WS_VISIBLE,
                        50,50,320,240,
                        HWND_DESKTOP,
                        NULL,
                        hinstance,
                        NULL);

What does this warning mean? Why is it a problem? How do I fix/avoid it? Also, when I run my full program, a console window opens in the background. Why is that there? And finally, is there a way to make a class local for describing it? As in, is there a way to skip typing the 'wndClassEx.' in 'wndClassEx.attribute=blah' when defining a window class? Thank you, TLAK

Share this post


Link to post
Share on other sites
Quote:
Original post by TLAK1001
What does this warning mean? Why is it a problem? How do I fix/avoid it?

Your compiler has recognised NULL as meaning the null pointer value. Since you are passing it as the first parameter of CreateWindowEx, which is not a pointer, the compiler is warning you that you might not have meant this (in particular if there were two versions of CreateWindowEx and one took a pointer as the first parameter and the other an integer then passing NULL would probably call the wrong one). To fix this simply replace the first parameter with the digit zero (0).
Quote:
Also, when I run my full program, a console window opens in the background. Why is that there?

You have created a console application. Change your project to a Windows application (there should be an option somewhere). You will also need to change your main function to a WinMain function.
Quote:
And finally, is there a way to make a class local for describing it? As in, is there a way to skip typing the 'wndClassEx.' in wndClassEx.attribute=blah' when defining a window class?

Not really.

Σnigma

Share this post


Link to post
Share on other sites
Thank you Enigma.

Changing my first parameter did solve the problem. As for the console opening, the program is a windows project/application and it does open the window it is supposed to (I was unclear, my bad). It just opens up a console window as well.

Tlak

Share this post


Link to post
Share on other sites
Quote:

And finally, is there a way to make a class local for describing it? As in, is there a way to skip typing the 'wndClassEx.' in 'wndClassEx.attribute=blah' when defining a window class?


You mean like this?

WNDCLASSEX wndClassEx = { blah, blah, blah, ... };

Share this post


Link to post
Share on other sites
Yes, that looks a lot easier. Can you please give me the definition for that? I can't figure out what order to put my parameters in.

By the way, how do I go about displaying text and getting input in a windows app? I'm brand new to this, if you couldn't tell :)

Share this post


Link to post
Share on other sites

This topic is 4223 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this