Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Color Me , C pure code with GUI
#1
Code:
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include<time.h>
#include<stdlib.h>
#define ID_EDIT 1
#define ID_BUTTON 2
#define ID_TEXT 3
static int len;
char str[900];
int i;
char temp[10000000];
char *Arry[38][20];
int r;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);


int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
            LPSTR lpCmdLine, int nCmdShow )
{
    strcpy(Arry[0], "Dodgerblue");
    strcpy(Arry[1], "Antiquewhite");
    strcpy(Arry[2], "Aqua");
    strcpy(Arry[3], "Aquamarine");
    strcpy(Arry[4], "Azure");
    strcpy(Arry[5], "Beige");
    strcpy(Arry[6], "Bisque");
    strcpy(Arry[7], "Black");
    strcpy(Arry[8], "Blanchedalmond");
    strcpy(Arry[9], "Blue");
    strcpy(Arry[10], "Blueviolet");
    strcpy(Arry[11], "Brown");
    strcpy(Arry[12], "Burlywood");
    strcpy(Arry[13], "Chartreuse");
    strcpy(Arry[14], "Chocolate");
    strcpy(Arry[15], "Coral");
    strcpy(Arry[16], "Cornflowerblue");
    strcpy(Arry[17], "Cornsilk");
    strcpy(Arry[18], "Crimson");
    strcpy(Arry[19], "Darkcyan");
    strcpy(Arry[20], "Darkgoldenrod");
    strcpy(Arry[21], "Darkgray");
    strcpy(Arry[22], "Darkgreen");
    strcpy(Arry[23], "Darkkhaki");
    strcpy(Arry[24], "Darkmagenta");
    strcpy(Arry[25], "Darkolivegreen");
    strcpy(Arry[26], "Darkorange");
    strcpy(Arry[27], "Darkorchid");
    strcpy(Arry[28], "Darkred");
    strcpy(Arry[29], "Darksalmon");
    strcpy(Arry[30], "Darkseagreen");
    strcpy(Arry[31], "Darkslateblue");
    strcpy(Arry[32], "Darkslategray");
    strcpy(Arry[33], "Darkturquoise");
    strcpy(Arry[34], "Darkviolet");
    strcpy(Arry[35], "Deeppink");
    strcpy(Arry[36], "Deepskyblue");
    strcpy(Arry[37], "Dimgray");
  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 |ES_MULTILINE|ES_AUTOHSCROLL|WS_HSCROLL|ES_AUTOHSCROLL|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 |ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOHSCROLL|WS_HSCROLL|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, str, len);
            srand(time(NULL));
            for(i=0; i<len-1; i++)
            {
                r= rand() % 37;
                strcat(temp,"[color=");
                strcat(temp, Arry[r]);
                strcat(temp, "]");
                strncat(temp, &str[i],1);
                strcat(temp, "[/color]");

            }
                SetWindowText(hwndEdit2, temp);
                strcpy(temp, "\0");

        }
                break;
    case WM_DESTROY:
    {
        PostQuitMessage(0);
        return 0;
    }
  }
  return DefWindowProc(hwnd, msg, wParam, lParam);
}

I made it from scratch. here's the bin

http://www.mediafire.com/?yrmdhxdcy2e

not gonna post virus scan, if you don't trust me just compile it.
Hello supportforums :)

This is my new app xDD

test run
Reply


Messages In This Thread
Color Me , C pure code with GUI - by Moudi - 03-16-2010, 02:14 AM
RE: Color Me , C pure code with GUI - by se7en - 03-27-2010, 09:20 AM
RE: Color Me , C pure code with GUI - by TomC - 06-15-2010, 08:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with GUI Dolan. 2 1,574 09-08-2012, 05:23 PM
Last Post: Dolan.
  GUI transparancy issues Raain 7 1,682 01-31-2011, 01:49 PM
Last Post: Raain
  [Links] - Making GUI in C++ using DirectX --([-S7N-])-- 3 4,900 05-09-2010, 02:49 PM
Last Post: Julie
  How to make this code into a gui? myposbussie 2 1,398 10-08-2009, 03:40 AM
Last Post: myposbussie

Forum Jump:


Users browsing this thread: 3 Guest(s)