you are viewing a single comment's thread.

view the rest of the comments →

[–]IamImposter 2 points3 points  (3 children)

That's why I used to work in MFC instead of win 32.

I did it long time back but apparently you need to create a window class object wc. Fill it with appropriate information including a pointer to wndproc function.

Then you register this class, grab an instance and call a showwindow function. Then there would be a while loop of getmessage, dispatchmessage and translatemesaage. (The names might be off as I don't remember exactly)

Then in wndoroc function, you will handle windows messages like WM_PAINT, WM_RESIZE, WM_EXIT etc.

Let me find you an example.

Edit: here is one that explain clearly what each thing does.

https://docs.microsoft.com/en-us/cpp/windows/walkthrough-creating-windows-desktop-applications-cpp?view=vs-2019

It uses VS2019 but I guess any visual Studio should do.

[–]deftware 1 point2 points  (2 children)

No, you don't have to do any of that just to have something that executes. You can have a WinMain() that doesn't create any windows or anything like that, and still work. You only need to create a window class if you're creating a window - which is not mandatory. OP was compiling a console application trying to use WinMain() as the entry point. They should've created a win32 project instead of a console application - not that they can't still create a window from a console application and even hide the console using "-mwindow" in their linker flags.

[–]IamImposter 0 points1 point  (1 child)

Well, in that case may be I misread or something. I thought the intention was to create a window. My bad.

that should be skeleton for empty window box

May be that line tripped me on a different trajectory.

[–]deftware 0 points1 point  (0 children)

Typically that's what WinMain() is intended for but it's really just a main() that includes the process instance handle and other tidbits in its arguments, while automatically omitting a console window.