Reputation: 67
So i have a .cpp file that has for example functions: drawLine(), drawSquare() and it has main(). In main() i want to invoke function (from other file) that creates a window using WinApi and after that invoke drawLine() and drawSquare() to paint some figures in that window. How can I invoke this WinMain() if it looks like that (only declaration):
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
And one more thing. Does this creating window have to be in WinMain or is there a way to put instructions in a regular function?
Upvotes: 0
Views: 2553
Reputation: 36896
main
is the entry point for console applications.
WinMain
is for GUI apps.
Your project should have only one of these, period.
You can put window creation code anywhere; it doesn't need to be in WinMain
.
Upvotes: 1
Reputation: 5674
Q. How can I invoke this WinMain() if it looks like that (only declaration)?
WinMain( 0, 0, 0, 0 );
Q. Does this creating window have to be in WinMain or is there a way to put instructions in a regular function?
--
It seems your setup is a little bit confusing. As far as I could understand, you don't really need WinMain... just call the Windows API functions in order to create your Window.
Upvotes: 1
Reputation: 1851
WinMain is the entry point and must be ( like main in c ) named like it is. AFAIK there is no possibility to rename this function. And calling this function from another file might perhaps work, but this is usually not done and should not be done, because ONLY windows os is a legitimate caller to all WinMain functions.
Upvotes: 0