   My windows application does not display the window I create.
  I'm using MSVC++ 2005 Express but I also tried my code on Visual C++ 6, both compile without error but nothing appears during execution.I have my code right here:#include "stdafx.h"#include <windows.h>LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iShowCmd){WNDCLASS kWindow;kWindow.lpfnWndProc = (WNDPROC)WndProc;kWindow.hInstance  = hInstance;kWindow.hIcon = LoadIcon(NULL, IDI_APPLICATION);kWindow.hCursor = LoadCursor(NULL, IDC_ARROW);kWindow.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);kWindow.lpszClassName = (LPCWSTR)"Window";kWindow.style = CS_HREDRAW | CS_VREDRAW;if (!RegisterClass (&kWindow)) {return -9;}HWND hWindow;hWindow = CreateWindow ((LPCWSTR)"Window", (LPCWSTR)"WINDOW LOL", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);MSG kMessage; while (GetMessage(&kMessage, hWindow, 0, 0)){TranslateMessage(&kMessage);DispatchMessage(&kMessage);}return 0;}LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam){switch (iMessage) {case WM_CLOSE:PostQuitMessage(0);break;default:return DefWindowProc(hWindow, iMessage, wParam, lParam);}return 0;}[Edited by - Nickerous on May 25, 2006 6:56:56 PM]
  Try "WNDCLASS kWindow = {NULL};".P.S.Also, use the _T or TEXT macro...   ;  First, whenever you post code on this forum, try to use the [ source ] and [/ source] tags, which makes it easy to read. So let's do this now:#include "stdafx.h"#include <windows.h>LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iShowCmd){WNDCLASS kWindow;kWindow.lpfnWndProc = (WNDPROC)WndProc;kWindow.hInstance  = hInstance;kWindow.hIcon = LoadIcon(NULL, IDI_APPLICATION);kWindow.hCursor = LoadCursor(NULL, IDC_ARROW);kWindow.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);kWindow.lpszClassName = (LPCWSTR)"Window";kWindow.style = CS_HREDRAW | CS_VREDRAW;if (!RegisterClass (&kWindow)) {return -9;}HWND hWindow;hWindow = CreateWindow ((LPCWSTR)"Window", (LPCWSTR)"WINDOW LOL", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, NULL, NULL, hInstance, NULL);MSG kMessage; while (GetMessage(&kMessage, hWindow, 0, 0)){TranslateMessage(&kMessage);DispatchMessage(&kMessage);}return 0;}LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam){switch (iMessage) {case WM_CLOSE:PostQuitMessage(0);break;default:return DefWindowProc(hWindow, iMessage, wParam, lParam);}return 0;}OK, now the first thing that jumps out at me is that the window class structure (WNDCLASS) is not entirely filled out. The most important member that you are missing is WNDCLASS.size, which must always be set to sizeof(WNDCLASS). So in this case, you would put the following line just under WNDCLASS kWindow;:kWindow.size = sizeof(WNDCLASS);If that doesn't work then you will probably have to set each other member of WNDCLASS that you did not explicitly set.   ;Quote:WNDCLASS kWindow;:kWindow.size = sizeof(WNDCLASS);That's for WNDCLASSEX, no?   ;Quote:That's for WNDCLASSEX, no?Ah! Yes. My bad. I read your code too quickly :). Anyways, you might want to try either filling out the entire structure (the structure format can be found here), or by calling ZeroMemory() on the structure. Its probably better if you just fill out each member.   ;  The dangers of C-style casts.  You can't just cast an ansi-string to a wide character string.  Either make all of your string constants wide character strings by prefixing them with an L (i.e. L"Window"), or make use of the TEXT macro (i.e. TEXT("Window")) or else change your project settings to use ansi-strings by default.Σnigma   ;  Ahhh thank you so much guys. It works!Sorry about the code presentation, I thought it was 