User forums > Help
Win API doesn't working
Michael:
--- Quote from: TDragon on June 22, 2006, 12:35:37 am ---
--- Quote from: Michael on June 21, 2006, 11:58:23 pm ---Strange, because MinGW seems not to support WinMain AFAIK (but I may be wrong).
--- End quote ---
Unless I've completely misunderstood you, you are wrong.
--- End quote ---
Hmmm. When compiling I got the same problem as here:
http://forums.codeblocks.org/index.php?topic=3374.0
May be I have forgotten to add a library or two.
Best wishes,
Michael
Vampyre_Dark:
MinGW always supported WinMain for me. You just add -mwindows or something. :| :?
thomas:
The reason it fails is that you use illegal byte sequences ("Ahoj světe") which somehow screws up the compiler.
If you save the document as UTF-8, it compiles just fine. As an alternative, you could tell gcc to use a different encoding.
sethjackson:
--- Quote from: Vampyre_Dark on June 22, 2006, 01:49:03 pm ---MinGW always supported WinMain for me. You just add -mwindows or something. :| :?
--- End quote ---
Uhh I never had to do that either..... :? Look in the C::B Win32 GUI template. You need to link gdi32, user32, and kernel32. There is no -mwindows to be found. Of course you have to include <windows.h>, and for MinGW you must download the winapi package for things to work. :)
@Michael
Umm that topic was talking about wmain not WinMain. The entry point for GUI (console apps don't count) apps on Windows is WinMain.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/winmain.asp
thomas:
The only real problem with this code snippet is that it is not properly encoded.
If you paste it into an empty document and save with "default encoding" (which is Windows-something) then it fails to compile on my machine, too. However, if you save the exact same file with UTF-8 encoding, all is fine.
This makes sense, too, since gcc uses UTF-8 as default encoding (unless told otherwise), and ět in Windows-something is not valid in UTF-8.
The only thing that is not quite right about it is that gcc does not report this as "illegal sequence" but simply fails silently, outputting an emtpy object file (which of course misses the WinMain function, as the linker correctly complains about).
Regarding main/WinMain, much to everybody's surprise MinGW is smart enough to wrap up everything so it still works, even if you use main instead of WinMain for a Windows application. The only obvious disadvantage is that you don't have easy access to hInstance and hPrevInstance, but they can be queried if needed (and who needs them anyway).
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version