Okay, os heres the new problem.

Hello World shows up, but the window is invisable, and please do nnot tell me to paint it in, its futile that I be able to see the exit button, and other buttons

Thanks for anyone who helps, I figured since this was a different question it belonged in a different thread.




#include <windows.h>
#include <string.h>
#include <tchar.h>
#include <stdio.h>
#include <string.h>

bool d;

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{

PAINTSTRUCT paint;

HDC hDC;

char string[] = "Hello World";


switch(msg){
// Window is being created
case WM_CREATE:
return 0;
//Return it to make sureit works properly and displays the error messages
// And then break the switch statement for efficiency factors.

break;
case WM_CLOSE:
// see if the window is closes
PostQuitMessage(1);
// if so send a message to the window telling it to close
return 0;
// check for errors
break;
// break it again
DWORD COLORREF;
case WM_PAINT:
hDC = BeginPaint(hwnd, &paint);
SetTextColor(hDC, COLORREF = 0x00FF1000);
TextOut(hDC, 150, 150, string, sizeof(string)-1);
EndPaint(hwnd, &paint);
return 0;
break;

default:
break;

return (DefWindowProc(hwnd, msg, wParam, lParam));
}



}
int APIENTRY WinMain(HINSTANCE DERP,
HINSTANCE hp,
LPSTR CmdLine,
int cmdshow ){
//shortining up and tagging everything.

//first up the class of the window.
WNDCLASSEX WC;
// The windows handle is next
HWND hwnd;
// Now the messages sent back and forth telling the window what to do and when to do it (etc)
MSG mesg;
// I am not sure what the bool valye is for.

// Now on to making the Window

WC.cbSize = sizeof(WNDCLASSEX);
// Size of the window in pixels
WC.style = CS_HREDRAW||CS_VREDRAW;
// The windows style
WC.lpfnWndProc = WndProc;
WC.cbClsExtra = 0;
WC.cbWndExtra = 0;
WC.hInstance = DERP;
WC.hIcon = LoadIcon(NULL, IDI_ASTERISK);
WC.hCursor = LoadCursor(NULL, IDC_CROSS);
WC.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WC.lpszMenuName = "Prototype(In Progress)";
WC.lpszClassName = "Class";
WC.hIconSm = LoadIcon(NULL, IDI_WARNING);
//Register the window class

if(!RegisterClassEx(&WC)){

return 0;

}

//class registered so now create the window

hwnd = CreateWindowEx(NULL,
"Class",
"Prototype(In Progress)",
WS_OVERLAPPEDWINDOW|
WS_VISIBLE|
WS_DLGFRAME,
0,0,
950,500,
NULL,
NULL,
DERP,
NULL);

// We now check if the window creation was succsessful or a failure.

if(!hwnd){

d = false;
return 0;// loop condition variable needs to be initialized

}

while(!d){
PeekMessage(&mesg, NULL, NULL, NULL, PM_REMOVE);

if (mesg.message == WM_QUIT){ // Check for the quit message
d = true;

}else{ // otherwise send it to the library of events fired
TranslateMessage(&mesg);
DispatchMessage(&mesg);


}
}

}
closed account (Dy7SLyTq)
have you tried doing it in java?
I do not know java, and no offence but I do not plan on learning it.
closed account (Dy7SLyTq)
well it could be written a little better then. your problem might be in the unneccesary code
I am just starting in windows applications, I am learning from CPLUSPLUS.com, they make allot of errors >.>
Perhaps you should try out Visual Basic. It's specifically designed to make Windows...well...windows.
closed account (N36fSL3A)
DTS you can't just tell people do do problems in Java when people are in a C++ forum. What does that make us look like. O_o

Anyway Johnny you should use code tags, then we can help a little more.

Also, cplusplus.com isn't making a lot of errors, it might just be you.
closed account (Dy7SLyTq)
yes you can. c++ isnt an end all language. the program he is trying to do is very simple in java.it would be wrong to tell people to only program in one langauge
closed account (N36fSL3A)
I know, but what if it requires as much speed as it can get? What if he's planning onintegrating it with assembly because it is a gui for a large database?


Not saying he is though.
It was me, still not exactly sure what I did wrong, but I copied and pasted there code and tested it, it worked fine. I have just copied it wrong somewhere, although I am not sure where.
I believe CeateWindowEx was failing, testing a window handle like if(!hWnd) doesn't work AFAIK.
Last edited on
How would you suggest I test it then?
Disregard my previous post I was mistaken.
Topic archived. No new replies allowed.