#include <windows.h>
#include <stdio.h>
#include <string.h>
#define ID_EDIT 1
#define ID_BUTTON 2
#define ID_TEXT 3
#define ARRAY_SIZE 10000;
static int len;
char str[900];
int i;
char temp[1000000];
char Arry[20];
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg ;
WNDCLASS wc = {0};
wc.lpszClassName = TEXT( "Static Control" );
wc.hInstance = hInstance ;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc ;
wc.hCursor = LoadCursor(0,IDC_ARROW);
RegisterClass(&wc);
CreateWindow( wc.lpszClassName, TEXT("Change Text"),
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 500, 500, 0, 0, hInstance, 0);
while( GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
static HWND hwndEdit;
static HWND hwndEdit2;
static HWND hwndButton;
switch(msg)
{
case WM_CREATE:
{
hwndEdit = CreateWindow(TEXT("Edit"), NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,
10, 30, 465, 100, hwnd, (HMENU) ID_EDIT,
NULL, NULL);
hwndButton = CreateWindow( TEXT("button"), TEXT("Color Me !"),
WS_VISIBLE | WS_CHILD,
10,140,465,25,
hwnd, (HMENU) ID_BUTTON, NULL, NULL);
hwndEdit2 = CreateWindow(TEXT("Edit"), NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,
10, 178,465, 270, hwnd, (HMENU) ID_TEXT,
NULL, NULL);
break;
}
case WM_COMMAND:
if(HIWORD(wParam) == BN_CLICKED){
len = GetWindowTextLength(hwndEdit) + 1;
GetWindowText(hwndEdit, (LPWSTR)str, len);
for(i=0; i<len; i++)
{
[COLOR=Black] [/COLOR][COLOR=Black] strcpy(temp, "[color=blue");
strcpy(temp, "]");
[COLOR=Magenta] strcpy(temp, (const char *)str[i]);[/COLOR]
strcpy(temp, "[ / color]");[/COLOR]
}
SetWindowText(hwndEdit2, (LPCWSTR)temp);
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
SO you can see that the problem is in the str[i];i wonder why ! I've tried to cast it to (const char *) but it didn't work. so any idea's ?
Oh and i know i didn't use ARRAY_SIZE i'm using it later


Sign In
Create Account


Back to top









