Hello! I am making a Win32 program, and I working on how to make a window... I have all the code to make it work, however, I want to make a function that I can call in order to open the window. It should work, however the problem is when I should call:
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int nshowcmd)
I understand that should be the entrance point for any Win32 API program, however, what if I want to create a "main.cpp" to call the function (to make the window) which is in a "window.h"? How would I either be able to call that function, or how would I get the parameters passed to the program when using that function call as the entrance point? All I really need are the parameters, because I need them for creating the window. Thanks for any help!
You probably don't want to hear this... but if you don't understand function parameters (a fundamental cornerstone of C++), I really doubt you are ready to tackle WinAPI.
Oh, no... That is not what I want to hear. I have been programming in C++ for about three years, and I would hope that I understand function parameters... With that said, the windows operating system passes certain parameters to the program when the program uses int WINAPI WinMain as the entrance point.
Just as every C application and C++ application must have a main function as its starting point, every Win32-based application must have a WinMain function.
No, the thing is that I do NOT want to call WinMain, but I still need the parameters that would be passed to it if I had called it at the beginning of the program.
Disch, I don't want WinMain to be the entrance point of the program. I want to have a window class in a separate .h file, that I can include into a main.cpp file, which has a int main() function where the program starts... From there, I want to be able to call window.open(); (from my window class) which would open a window. The problem comes in when I need the parameters for the creation of the window. Main just hinstance:
As you see, I need hinstance in order to make my window class.
So, modoran, all I need IS the arguments that would be passed to the program if I had WinMain as the entrance point.
I am probably just being a fool, and not able to find some sort of function call that would give me the information I need, so that is why I need your help.
I'm sorry modoran, I do not understand what you are trying to ask... I am making a small game engine that I can code in my free time, and I figured a good of a spot as any would be to make class for opening, closing, and dealing with windows. That is why I don't want to have to start in WinMain... I want the program to be as flexible as possible. So, I guess I do not want the console window, but I was going to get to that part later, because it was not my main concern as of right now... I wanted to only use C++, Windows, and OpenGL to make it. So, my next question would be if I am going at this the wrong way. Am I? If not, I'll happily just use GetModuleHandle(NULL); in order to get the hinstance I need...
From what you are saying maybe you are trying to write a library or a dinamic link library (*.DLL) ? http://en.wikipedia.org/wiki/Dynamic-link_library
These are a collection of functions which can be used by other programs.
Otherwise, if you don't want a console window and want to make a full program use WinMain. THere is no other way around.