I just got Visual Studio 2005 and I tried to make a program using Win32. The program is just displaying a window. When I compile the code I get no errors at all, but nothing happens after that. My window doesn't pop up. I made sure that I had the functions: ShowWindow() and UpdateWindow, but apparently that wasn't the problem. Please help.

Problem seeing my window
dzeaman
Could you show your CreateWindow code
Mithun.Pentuker
Not just with Visual Studio. Any window (including child controls) needs the WS_VISIBLE style to be visible on screen. Some APIs may abstract this away into a SetVisible method or a Visible property, but the underlying code will use WS_VISIBLE on the windows.
Marcelo Ferrer
I tried to put the WS_VISIBLE in like this: CreateWindowEx(NULL, "Windows Class", "TITLE", WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hinstance, NULL);
That didn't work...I also tried to put SW_SHOW in like this: ShowWindow(hwnd,SW_SHOW);
That didn't work either. I tried both seperately, and together. Any other suggestions, or did I implement the suggestions incorrectly
esgibson
Not to try and argue, but I've never needed to do that before, and I've gotten plenty of windows to work.
Where do I put this, because I've never used it before
Davy de Kerf
error C3861: '_T': identifier not found
theczar
How do I do that
I have never had to do that before. Is that something that you have to do with visual studio only
tongueless
I believe the WS_VISIBLE style dates back to the Win16 days. Anyway, you need to pass that as a style to the CreateWindowEx call.
Alternatively, you could do a ShowWindow with SW_SHOW - perhaps that explains why you never had to use the WS_VISIBLE style before. Because you'd call ShowWindow later on.
Stuart Taylor
Nick
You know what I think it would be best for you to use the wizard to generate a Win32 project, and take a look at the code. The default code will create and show a window on screen. Looks to me that, that's exactly what you are trying to do, but you've missed out something somewhere.
cchau
I used:
while(1)
{
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
}
}
ANDY_DANDY
Most of the stuff in the generated project doesn't look the same as I am used to. I can't understand most of it. I have had a lot of problems with the switch from 2003 to 2005, and that might have something to do with it. The only code that I have written that works in 2005, works because it is converted when I open it with 2005. But it doesn't change the code, so I don't know what has been changed in it.
One big problem that I ran into was I got this error when I compiled my code:
error C2440: '=' : cannot convert from 'const char [14]' to 'LPCWSTR'
This error was at the places where I typed "Windows Class" and the title of my window. I fixed this by putting global variables as follows:
TCHAR szWindowClass[100];
TCHAR szTitle[100];
But, I can't figure out how to fix that problem when I try to display a bitmap or something because the same error message pops up at the name of my bitmap.
Would any of this effect why I can't see my window
Karel Kruizenruiker
You need to specify the WS_VISIBLE style.
Donaldinho
Well, it's really impossible to comment without seeing the code...
Have you set up a message loop such as this one
while (GetMessage (&msg, NULL, 0, 0)){
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
Guddy
Here is my CreateWindow code:
hwnd = CreateWindowEx(NULL,"Windows Class","TITLE",
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hinstance,NULL);
graham forbes
For string literals, use _T("...")
So if you had "abc.bmp", it should be modified to _T("abc.bmp")
That will automatically map it to an Ansi string for a non-Unicode build, and a wide string for a Unicode build.
Note that VC 2005, by default, generates projects as Unicode.