String Manipulation Example

#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc = {0};
MSG msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszClassName = TEXT("myWindowClass");
RegisterClassEx(&wc);
CreateWindowEx(WS_EX_CLIENTEDGE,TEXT("myWindowClass"),TEXT("String manipulation"),WS_THICKFRAME|WS_OVERLAPPEDWINDOW| WS_VISIBLE | WS_OVERLAPPEDWINDOW ,CW_USEDEFAULT, CW_USEDEFAULT, 340, 320, NULL, NULL, hInstance, NULL);
while(GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT Ps;
HDC hdc;
switch(msg)
{
case WM_PAINT://traps paint message
{
hdc = BeginPaint(hwnd, &Ps);
TCHAR OutputText[128]="STRING MANIPULATION";
int stringlength=lstrlen(OutputText);
TextOut(hdc, 0,0, OutputText,stringlength);
//change to lower case
CharLower(OutputText);
TextOut(hdc, 0,15, OutputText,stringlength);
//Retrieves text after 1st character in OutputText and stores in string newstring
LPCTSTR newstring=CharNext(OutputText);
TextOut(hdc, 0,30, newstring,stringlength-1);
//Retrieves text after 1st character in newstring and stores in newstring.
//iterates past the first 6 characters and outputs to screen
for(int i=2;i<=7;i++)
{
newstring=CharNext(newstring);
TextOut(hdc, 0,15+15*i, newstring,stringlength-i);
}
//copy newstring to outputstring
strcpy(OutputText,newstring);
stringlength=lstrlen(OutputText);
//change outputstring to upper case
CharUpper(OutputText);
TextOut(hdc, 0,135, OutputText,stringlength);
EndPaint(hwnd, &Ps);
DeleteDC(hdc);
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}