Original Post
I have the most basic window screation program When I run the program it doesnt display its window but I can see it in procesess. When I replace the line I marked problematic with this: wndclass.lpszClassName = "WindowProject"; then it works fine. Im still noob at c++ and I think this is a trivial problem but you can tell me whats happening.
//includes
#include <windows.h>
#include <string>
#include "res/resource.h"
#include "WinMain.h"
//using namespace std;
std::string strAppName = "WindowProject";
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
// Set up window class
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof(WNDCLASSEX);
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.lpfnWndProc = WndProc;
wndclass.hInstance = hInstance;
wndclass.lpszClassName = strAppName.c_str(); //Problematic
wndclass.lpszMenuName = NULL;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_ICON32);
wndclass.hIconSm = LoadIcon(hInstance, (LPCTSTR)IDI_ICON16);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH);
// Register the window class
if(0 == RegisterClassEx(&wndclass))
return 0;
// Create the window TODO: Enter Class name, titlebar message and starting position
HWND hWnd;
hWnd = CreateWindow("ClassNameHere","Application", WS_OVERLAPPEDWINDOW, 100, 100, 640, 480, NULL, NULL, hInstance, NULL);
// Display the window
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
// Process messages until the program is terminated
MSG msg;
while(GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
}