First, I prepared the class blow :
class UserDefinedWindow
{
public:
WNDCLASSEX WindowClass;
DWORD dwExStyle;
LPCTSTR lpClassName;
LPCTSTR lpWindowName;
DWORD dwStyle;
int x;
int y;
int nWidth;
int nHeight;
HWND hWndParent;
HMENU hMenu;
HINSTANCE hProgInst;
LPVOID lpParam;
char ClassName[MAX_LOADSTRING];
char Caption[MAX_LOADSTRING];
HWND hWnd;
UserDefinedWindow()
{
dwExStyle = 0; //These are default parameters for CreateWindowEx()
lpClassName = "ClassName";
lpWindowName = "Caption";
dwStyle = WS_MINIMIZEBOX | WS_SYSMENU | WS_VISIBLE;
x = 100;
y = 100;
nWidth = 100;
nHeight = 100;
hWndParent = HWND_DESKTOP;
hMenu = NULL;
hProgInst = hInstance;
lpParam = NULL;
WindowClass.cbSize = (UINT) sizeof(WNDCLASSEX); //Defaults for WNDCLASSEX
WindowClass.style = (UINT) CS_DBLCLKS;
WindowClass.lpfnWndProc = (WNDPROC) WindowProcedure;
WindowClass.cbClsExtra = (INT) 0;
WindowClass.cbWndExtra = (INT) 0;
WindowClass.hInstance = (HINSTANCE) hProgInst;
WindowClass.hIcon = (HICON) LoadIcon (NULL, IDI_APPLICATION);
WindowClass.hCursor = (HCURSOR) LoadCursor (NULL, IDC_ARROW);
WindowClass.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
WindowClass.lpszMenuName = (LPCTSTR) NULL;
WindowClass.lpszClassName = (LPCTSTR) ClassName;
WindowClass.hIconSm = (HICON) LoadIcon (NULL, IDI_APPLICATION);
}
void Create(void)
{
if (!RegisterClassEx(&WindowClass)) MessageBox(NULL, "Error registering.", "Error", MB_OK);
hWnd = CreateWindowEx( (DWORD) dwExStyle,
(LPCTSTR) lpClassName,
(LPCTSTR) lpWindowName,
(DWORD) dwStyle,
(int) x,
(int) y,
(int) nWidth,
(int) nHeight,
(HWND) hWndParent,
(HMENU) hMenu,
(HINSTANCE) hProgInst,
(LPVOID) lpParam);
}
};
And the main() block of the program is...
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
hInstance = hInst;
UserDefinedWindow MainWnd;
MainWnd.Create();
while (GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return (INT) Msg.wParam;
}
And finally the problem is, nothing appears. Program seems to be running, but no window appears on the screen. There is no errors or even warnings given.
Can you give an idea why the window doesn't pop up?
Notes
-----
-Compiler is Visual Studio 2005.
-I didn't use ShowWindow(), because WS_VISIBLE already exists in dwStyle.
-hInstance is global defined variable.