Basically, I'm a PHP coder, and I've decided to take have a bash at C. The two languages are so similiar, I think I've pretty much picked it up ok. I can handle command line stuff fine, it's just this stupid windows thing that I can't do.
So, I'm having a bit of a problem with the windows api. I'm just trying to display a window with some text in it...
But the text just doesn't display!! I'm using DrawTextEx()...I would make a guess it's something to do with that. I'm on windows XP, and using CodeBlocks as my compiler.
Here's my code:
If you need any more info, please ask.
const char Window_Class = "WindowClass";
//window callback handler
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
MessageBox(hwnd, "Bye", ":)", 0);
HDC hdc = BeginPaint(hwnd, &ps);
DrawTextEx(hdc, "Hello...world?"+'\0', -1, &rcClient, DT_CENTER, NULL);
//register window process
return DefWindowProc(hwnd, msg, wParam, lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
char *lpCmdLine, int nCmdShow)
//register windows classes
//register window with....windows ;)
window.cbSize = sizeof(WNDCLASSEX);
window.style = 0;
window.lpfnWndProc = WndProc;
window.cbClsExtra = 0;
window.cbWndExtra = 0;
window.hInstance = hInstance;
window.hIcon = LoadIcon(NULL, IDI_APPLICATION);
window.hCursor = LoadCursor(NULL, IDC_ARROW);
window.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
window.lpszMenuName = NULL;
window.lpszClassName = Window_Class;
window.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
//create the window
hwnd = CreateWindowEx(
CW_USEDEFAULT, CW_USEDEFAULT, 500, 250,
NULL, NULL, hInstance, NULL);
//run the message loop
while(GetMessage(&msg, NULL, 0, 0) > 0)
Thanks for taking the time to read this!!