C++ - Code debug
This is my friend's code though.. He tells me that it has error because it
should run with AJAX or JavaScript or something like that.
He says that he mainly create it for chatting program.
C++ codes :
#include <Windows.h>
HINSTANCE hInstance;
// Function I made to get the size of the text
int GetTextSize (LPSTR a0)
{
for (int iLoopCounter = 0; ;iLoopCounter++)
{
if (a0 [iLoopCounter] == '\0')
return iLoopCounter;
}
}
LPSTR TextArray [] = {
"Hello World"
};
LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CLOSE:
DestroyWindow (hwnd);
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint (hwnd, &ps);
TextOut (hdc,
// Location of the text
10,
10,
// Text to print
TextArray [0],
// Size of the text, my function gets this for us
GetTextSize (TextArray
[0,1,2,3,4,5,6,7,8,9{Font.Size}]));
EndPaint (hwnd, &ps);
}
break;
}
return DefWindowProc (hwnd, msg, wParam, lParam);
}
int WINAPI WinMain (HINSTANCE hInstanace, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int nCmdShow)
{
WNDCLASSEX WindowClass;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.cbSize = sizeof (WNDCLASSEX);
WindowClass.lpszClassName = "1";
WindowClass.lpszMenuName = NULL;
WindowClass.lpfnWndProc = WndProc;
WindowClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
WindowClass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
WindowClass.hCursor = LoadCursor (NULL, IDC_ARROW);
WindowClass.style = 0;
WindowClass.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
RegisterClassEx (&WindowClass);
HWND hwnd = CreateWindowEx (WS_EX_CLIENTEDGE,
"1",
"Printing Text in Win32 C/C++",
WS_OVERLAPPEDWINDOW,
315, 115,
640, 480,
NULL,
NULL,
hInstance,
NULL);
ShowWindow (hwnd, SW_SHOWNORMAL);
MSG msg;
while (GetMessage (&msg, NULL, 0, 0) > 0)
{
TranslateMessage (&msg);
DispatchMessage (&msg);
if (VK_ESCAPE == msg.wParam)
break;
}
return 0;
}
Line 42 has errors in it..
No comments:
Post a Comment