home *** CD-ROM | disk | FTP | other *** search
/ CD Direkt 1995 #1 / Image.iso / cdd / winanw2 / wcdbrk2 / wcdbrk2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-16  |  16.1 KB  |  662 lines

  1. /*********************************************************************
  2.     PROGRAM: WCDBRK2.C
  3.  
  4.     PURPOSE: Code Break game
  5.  
  6.     AUTHOR:  Ken Fogel
  7.          Omnibus Systems
  8.          8108 Norfolk Road
  9.          Cote St-Luc, Québec
  10.          Canada   H4X 1A3
  11.          (514) 487-1565
  12.          CompuServe: 74646,2157
  13.  
  14.     REVISION:    February 24, 1993 Version 2.1 (Mike Kuhnkey [74250,1501]
  15.                     Modified for WIN31;STRICT (Borland Turbo C++)
  16.                     Help Option modified to use Help Compiler (Windows 3.1)
  17.                 June 1, 1991 - Version 2
  18.                     Full Colour/Bitmaps
  19.                 April 22, 1991 - Version 1.01
  20.                 April 15, 1991 - Version 1
  21.  
  22. *********************************************************************/
  23.  
  24. #include <windows.h>        /* required for all Windows applications */
  25. #include <stdlib.h>
  26. #include <stdio.h>
  27. #include <string.h>
  28. #include <time.h>
  29. #include "C:\BORLANDC\OWL\EXAMPLES\WCDBRK2\wcdbrk2.h"
  30.         /* specific to this program */
  31.  
  32. HINSTANCE    hInst;            /* current instance */
  33. HWND        hGameGrid[10][4];    /* array of buttons */
  34. int        board[10][4];            /* array of guesses */
  35. int        code[4];              /* secret code */
  36. char        clues[10][4];            /* array of clues */
  37. int          cur_round;               /* current row */
  38. int         cur_column;             /* current column */
  39. char        str[80];            /* general purpose string */
  40. HWND        DidIGetItRight;
  41. BOOL        Setup;
  42. BITMAP      Bitmap;
  43. HBITMAP     hOldBitmap;
  44. HBITMAP     hBoardmap;
  45. HBITMAP     hBlclpegmap;
  46. HBITMAP     hWhclpegmap;
  47. HBITMAP     hPegBoardmap;
  48. LPSTR       lpPegs[8] = {"Bluepeg","Dkpupeg","Grenpeg","Ltblpeg",
  49.                   "Oranpeg","Purppeg","Redpeg","Yellpeg"};
  50. HBITMAP hPegs[8];
  51. int     iXpos,iYpos;
  52. int     curcolour = 0;
  53. int     prevcolour = -1;
  54. int     winstate;
  55. long FAR PASCAL MAINWNDPROC(HWND hWnd,UINT message,UINT wParam,LPARAM lParam);
  56. /*********************************************************************/
  57. #pragma argsused
  58. int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
  59.            LPSTR lpCmdLine,int nCmdShow)
  60. {
  61.     MSG msg;                        /* message */
  62.  
  63.     Setup = FALSE;
  64.  
  65.     if (!hPrevInstance)                    /* Other instances of app running? */
  66.         if (!InitApplication(hInstance))
  67.                                 /* Initialize shared things */
  68.         return (FALSE);                    /* Exits if unable to initialize */
  69.  
  70.             /* Perform initializations that apply to a specific instance */
  71.  
  72.     if (!InitInstance(hInstance, nCmdShow))
  73.         return (FALSE);
  74.  
  75.  
  76.     /* Aquire and dispatch messages until a WM_QUIT message is received */
  77.  
  78.     while (GetMessage(&msg,            /* message structure */
  79.             NULL,             /* handle of window recieving the message */
  80.             NULL,             /* lowest message to examine */
  81.             NULL))             /* highest message to examine */
  82.     {
  83.         TranslateMessage(&msg);         /* Translates virtual key codes */
  84.         DispatchMessage(&msg);         /* Dispatches message to window */
  85.     }
  86.     return(msg.wParam);              /* Returns the value from PostQuitMessage */
  87. }
  88.  
  89. /*********************************************************************/
  90.  
  91. BOOL InitApplication(HINSTANCE hInstance)
  92. {
  93.     WNDCLASS wc;
  94.  
  95.     /* Fill in window class structure with parameters that describe the */
  96.     /* main window. */
  97.  
  98.     wc.style     = CS_DBLCLKS;       // Class style(s).
  99.     wc.lpfnWndProc    = MAINWNDPROC;         /* Function to retrieve messages for
  100.                               windows of this class */
  101.     wc.cbClsExtra    = 0;                  // No per-class extra data
  102.     wc.cbWndExtra    = 0;                  // No per-window extra data
  103.     wc.hInstance    = hInstance;           // Application that owns the class.
  104.     wc.hIcon    = LoadIcon(hInstance, "Wcdbrk2");
  105.     wc.hCursor    = LoadCursor(NULL, IDC_ARROW);
  106.     wc.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
  107.     wc.lpszMenuName    = "WndCdBrkMenu";       // Name of menu resource in .RC file
  108.     wc.lpszClassName = "WndCdBrkWClass";    // Name used in call to CreateWindow
  109.  
  110.     /* Register the window class and return success/failure code */
  111.  
  112.     return (RegisterClass(&wc));
  113.  
  114. }
  115.  
  116. /*********************************************************************/
  117.  
  118. BOOL InitInstance(HINSTANCE hInstance,int nCmdShow)
  119. {
  120.     HWND hWnd;                   /* Main window handle */
  121.  
  122.     hInst = hInstance;
  123.  
  124.     /* Create a main window for this application instance */
  125.  
  126.     hWnd = CreateWindow(
  127.             "WndCdBrkWClass",       /* See RegisterClass() call */
  128.              "Code Breaker II",      /* Text for window title bar */
  129.  
  130.          /* The following line creates a window which can be */
  131.          /* minimized to an icon and moved but not re-sized  */
  132.  
  133.              WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU,
  134.              120,          /* Initial column */
  135.              30,           /* Initial row    */
  136.              230,          /* Width          */
  137.              435,          /* Height         */
  138.              NULL,           /* Overlapped windows have no parent */
  139.              NULL,           /* Use the window class menu */
  140.              hInstance,    /* This instance owns this window */
  141.              NULL           /* Pointer not needed */
  142.              );
  143.  
  144.     /* If window could not be created, return "failure" */
  145.  
  146.     if (!hWnd)
  147.         return (FALSE);
  148.  
  149.     /* Make the window visible; update its client area; and return "success" */
  150.  
  151.     ShowWindow(hWnd, nCmdShow);     /* Show the window */
  152.     UpdateWindow(hWnd);         /* Sends WM_PAINT message */
  153.  
  154.     return (TRUE);             /* Returns the value from POSTQUITMESSAGE */
  155.  
  156. }
  157.  
  158. /*********************************************************************/
  159.  
  160. long FAR PASCAL MAINWNDPROC(HWND hWnd,UINT message,UINT wParam,LPARAM lParam)
  161. {
  162.     DLGPROC     lpProcAbout;    /* pointer to the "About" function */
  163.     int x,y;
  164.  
  165.  
  166.     switch (message)
  167.     {
  168.         case WM_CREATE:
  169.             if (!Setup)        /* Do this only once */
  170.             {
  171.             hBoardmap    = LoadBitmap(hInst,"Board");
  172.             hPegBoardmap    = LoadBitmap(hInst,"Pegboard");
  173.             hBlclpegmap    = LoadBitmap(hInst,"Blclpeg");
  174.             hWhclpegmap    = LoadBitmap(hInst,"Whclpeg");
  175.                 for (x=0;x<8;x++)
  176.                     hPegs[x] = LoadBitmap(hInst,lpPegs[x]);
  177.             if(!bMakeGameButtons(hWnd))
  178.                 {
  179.                 MessageBox(hWnd,"Failure to create buttons!",NULL,
  180.                         MB_OK | MB_ICONHAND);
  181.                  }
  182.                  Setup = TRUE;
  183.             }
  184.             vInitialize();
  185.             vMakecode();
  186.             break;
  187.  
  188.         case WM_LBUTTONUP:          /* Mouse button was pressed */
  189.             iXpos = LOWORD(lParam);
  190.             iYpos = HIWORD(lParam);
  191.             if (bCheckPosition(hWnd))
  192.             {
  193.                 board[cur_round][cur_column] = curcolour;
  194.                 vPutPeg(hWnd,curcolour,cur_round,cur_column);
  195.             }
  196.             break;
  197.  
  198.         case WM_PAINT:              /* Time to repaint */
  199.             vBasicScreen(hWnd);
  200.             vMarkColour(hWnd);
  201.             for (x=0;x<=cur_round;x++)
  202.             {
  203.                 for (y=0;y<4;y++)
  204.                     vPutPeg(hWnd,board[x][y],x,y);
  205.                     vDoClues(hWnd,x);
  206.             }
  207.             if (winstate == 1)
  208.                 vDoWin(hWnd);
  209.             else
  210.                 if (winstate == 2)
  211.                     vDoLoose(hWnd);
  212.  
  213.             break;
  214.  
  215.  
  216.         case WM_COMMAND:   /* message: command from application menu */
  217.             switch(wParam)
  218.             {
  219.                 case DIDIGETITRIGHT:
  220.                     if (!winstate)    /* If won or lost ignore commands */
  221.                     {
  222.                         if (!bCheckfill()) break;
  223.                         if (bCheckguess(cur_round))
  224.                         {
  225.                             vDoWin(hWnd);
  226.                             break;
  227.                         }
  228.                         else
  229.                         {
  230.                             vDoClues(hWnd,cur_round);
  231.                             cur_round++;
  232.                             if (cur_round == 10) /* You loose */
  233.                                 vDoLoose(hWnd);
  234.                         }
  235.                     }
  236.                     break;
  237.  
  238.                 case IDM_ABOUT:
  239.                     lpProcAbout =(DLGPROC)MakeProcInstance((FARPROC)About, hInst);
  240.  
  241.                     DialogBox(hInst,     /* current instance */
  242.                           "AboutBox",   /* resource to use */
  243.                           hWnd,        /* parent handle */
  244.                           lpProcAbout);    /* About() instance address */
  245.  
  246.                     FreeProcInstance((FARPROC)lpProcAbout);
  247.                     break;
  248.  
  249.                 case IDM_NEW:  /* Let's play again */
  250.                   InvalidateRect(hWnd, NULL, TRUE);
  251.                   SendMessage(hWnd,WM_CREATE,NULL,NULL);
  252.                   break;
  253.  
  254.                 case IDM_GIVEUP:
  255.                     vDoLoose(hWnd);
  256.                     break;
  257.  
  258.                 case IDM_HELP:
  259.                     WinHelp(hWnd,"wcdbrk.hlp",HELP_INDEX,0L);
  260.                     break;
  261.  
  262.                 default:               /* Lets Windows process it */
  263.                     return (DefWindowProc(hWnd, message, wParam, lParam));
  264.             }
  265.             break;
  266.  
  267.         case WM_DESTROY:            /* message: window being destroyed */
  268.             DeleteObject(hBoardmap);
  269.             DeleteObject(hPegBoardmap);
  270.             DeleteObject(hBlclpegmap);
  271.             DeleteObject(hWhclpegmap);
  272.             for (x=0;x<8;x++)
  273.                 DeleteObject(hPegs[x]);
  274.             PostQuitMessage(0);
  275.             break;
  276.  
  277.         default:                /* Passes it on if unprocessed */
  278.             return (DefWindowProc(hWnd, message, wParam, lParam));
  279.     }
  280.     return (NULL);
  281. }
  282.  
  283. /*********************************************************************/
  284. #pragma argsused
  285. BOOL FAR PASCAL About(HWND hDlg,UINT message,UINT wParam,LPARAM lParam)
  286. {
  287.     switch (message)
  288.     {
  289.         case WM_INITDIALOG:           /* message: initialize dialog box */
  290.             return (TRUE);
  291.  
  292.         case WM_COMMAND:           /* message: received a command */
  293.             if (wParam == IDOK ||       /* "OK" box selected ? */
  294.               wParam == IDCANCEL)       /* System menu close command ? */
  295.             {
  296.                 EndDialog(hDlg, TRUE);    /* Exits the dialog box */
  297.                 return (TRUE);
  298.             }
  299.             break;
  300.     }
  301.     return (FALSE);
  302. }
  303.  
  304. /*****************/
  305. /* Clear the board and the clues for a new game */
  306. void vInitialize(void)
  307. {
  308.     int x,y;
  309.  
  310.     for(x=0;x<=9;x++)
  311.         for(y=0;y<=3;y++)
  312.         {
  313.             board[x][y] = -1;
  314.             clues[x][y] = ' ';
  315.         }
  316.     cur_round = 0;
  317.     winstate = 0;
  318.     return;
  319. }
  320.  
  321. /*****************/
  322. /* Scramble the position of clues */
  323. void vScrambleclues(int round)
  324. {
  325.     int x,y=0,signal=1;
  326.     char tempclues[4]={'\0','\0','\0','\0'};
  327.  
  328.     while (signal)
  329.     {
  330.         x=(rand() % 4);
  331.         if (tempclues[x]=='\0')
  332.         {
  333.             tempclues[x] = clues[round][y];
  334.             y++;
  335.             if (y>3) signal = 0;
  336.         }
  337.     }
  338.     for(x=0;x <=3;x++)
  339.         clues[round][x]=tempclues[x];
  340.     return;
  341. }
  342.  
  343. /*****************/
  344. /* Check the guess for clues or win */
  345. BOOL bCheckguess(int round)
  346. {
  347.     int x,y=0;
  348.     int tempcode[4], temp[4];
  349.  
  350.     for(x=0;x<=3;x++)                   /* prepare temporary arrays */
  351.     {
  352.         temp[x]=board[round][x];
  353.         tempcode[x]=code[x];
  354.         clues[round][x] = ' ';
  355.     }
  356.  
  357.     for(x=0;x<=3;x++)            /* check for perfect match */
  358.         if (temp[x] == tempcode[x])
  359.         {
  360.             clues[round][x]='1';
  361.             temp[x]=0;
  362.             tempcode[x]=-1;
  363.             y++;
  364.         }
  365.  
  366.     if (y==4) return(TRUE);
  367.  
  368.     for(x=0;x<=3;x++)            /* check for right colour */
  369.         for(y=0;y<=3;y++)        /*   wrong position       */
  370.         {
  371.             if (tempcode[x]==temp[y])
  372.             {
  373.                 clues[round][y] = '0';
  374.                 temp[y] = 0;
  375.                 tempcode[x] = -1;
  376.                 break;
  377.             }
  378.         }
  379.     vScrambleclues(round);
  380.     return(FALSE);
  381. }
  382.  
  383. /*****************/
  384. /* Make sure all the buttons were clicked */
  385. BOOL bCheckfill(void)
  386. {
  387.     int x;
  388.  
  389.     for(x=0;x<=3;x++)
  390.         if (board[cur_round][x] == -1)
  391.             return(FALSE);
  392.     return(TRUE);
  393. }
  394.  
  395. /*****************/
  396. /* Generate the secret code */
  397. void vMakecode(void)
  398. {
  399.     int x;
  400.     time_t t;
  401.  
  402.     srand((unsigned) time(&t));
  403.  
  404.     for(x=0;x<=3;x++)
  405.         code[x]= (rand() % 8);
  406.  
  407.     return;
  408. }
  409.  
  410. /***********************/
  411. /* Create the buttons on screen */
  412. BOOL bMakeGameButtons(HWND hWnd)
  413. {
  414.  
  415.     if (DidIGetItRight != NULL) DestroyWindow(DidIGetItRight);
  416.     DidIGetItRight = CreateWindow("Button",
  417.                       "Did I Get It Right?",
  418.                        BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE,
  419.                        10, 350, 168, 20,
  420.                        hWnd,
  421.                        (HMENU)DIDIGETITRIGHT,
  422.                        hInst,
  423.                        NULL);
  424.     if (!DidIGetItRight)
  425.         return(FALSE);
  426.     ShowWindow(DidIGetItRight, SW_SHOW);
  427.     UpdateWindow(DidIGetItRight);
  428.     return(TRUE);
  429. }
  430.  
  431. /*******************************/
  432. /* The basic game board setup  */
  433. /*******************************/
  434. void vBasicScreen(HWND hWnd)
  435. {
  436.     HDC hDC,hMemoryDC;
  437.     PAINTSTRUCT ps;
  438.     int x,y;
  439.  
  440.     hDC = BeginPaint(hWnd, &ps);
  441.     hMemoryDC = CreateCompatibleDC(hDC);
  442.  
  443.     hOldBitmap =(HBITMAP)SelectObject(hMemoryDC,hBoardmap);        /* Game board */
  444.     GetObject(hBoardmap, sizeof(BITMAP), (LPSTR) &Bitmap);
  445.     BitBlt(hDC,10,10,Bitmap.bmWidth, Bitmap.bmHeight,
  446.              hMemoryDC,0,0,SRCCOPY);
  447.  
  448.     hOldBitmap =(HBITMAP)SelectObject(hMemoryDC,hPegBoardmap);     /* Peg board  */
  449.     GetObject(hPegBoardmap, sizeof(BITMAP), (LPSTR) &Bitmap);
  450.     BitBlt(hDC,190,154,Bitmap.bmWidth, Bitmap.bmHeight,
  451.              hMemoryDC,0,0,SRCCOPY);
  452.  
  453.     y = 158;
  454.     for (x=0;x<8;x++)                                      /* Pegs       */
  455.     {
  456.         hOldBitmap=(HBITMAP)SelectObject(hMemoryDC,hPegs[x]);
  457.         GetObject(hPegs[x], sizeof(BITMAP), (LPSTR) &Bitmap);
  458.         BitBlt(hDC,194,y,Bitmap.bmWidth, Bitmap.bmHeight,
  459.                  hMemoryDC,0,0,SRCCOPY);
  460.         y += 23;
  461.     }
  462.  
  463.     SelectObject(hMemoryDC, hOldBitmap);
  464.     DeleteDC(hMemoryDC);
  465.     ReleaseDC(hWnd, hDC);
  466.     EndPaint(hWnd, &ps);
  467.  
  468.     return;
  469. }
  470.  
  471. /***************************************/
  472. /* Check where mouse was clicked and   */
  473. /* decide if a peg was selected or a   */
  474. /* position on the board was selected. */
  475. /***************************************/
  476. BOOL bCheckPosition(HWND hWnd)
  477. {
  478.     int x,y,z,row=-1;
  479.     BOOL recX = FALSE;
  480.     BOOL recY = FALSE;
  481.  
  482.     if ((iYpos<=344-(cur_round*30)) && (iYpos>=314-(cur_round*30)))
  483.     {
  484.         recY = TRUE;
  485.         z = 0;
  486.         for(x=16;x<=118;x+=27)
  487.         {
  488.             if ((iXpos>=x) && (iXpos<=(x+27)))
  489.             {
  490.                 recX = TRUE;
  491.                 break;
  492.             }
  493.             z++;
  494.         }
  495.     }
  496.     if ((recX) && (recY))
  497.     {
  498.         cur_column = z;
  499.         return(TRUE);
  500.     }
  501.     else
  502.     {
  503.         for(y=0;y<=7;y++)
  504.         {
  505.             if ((iYpos>=(y*23+158)) && (iYpos<=(y*23+181)))
  506.             {
  507.                 row = y;
  508.                 break;
  509.             }
  510.         }
  511.         if ((row > -1) && ((iXpos>=194) && (iXpos<=218)))
  512.         {
  513.             curcolour = row;
  514.             vMarkColour(hWnd);
  515.         }
  516.     }
  517.  
  518.     return(FALSE);
  519. }
  520. /********************************/
  521. /* Place the selected peg at the*/
  522. /* appropriate position         */
  523. /********************************/
  524. void vPutPeg(HWND hWnd, int colour, int round, int column)
  525. {
  526.     HDC hDC,hMemoryDC;
  527.  
  528.     if (board[round][column] == -1) return;
  529.     hDC = GetDC(hWnd);
  530.     hMemoryDC = CreateCompatibleDC(hDC);
  531.     hOldBitmap =(HBITMAP)SelectObject(hMemoryDC,hPegs[colour]);
  532.     GetObject(hPegs[colour], sizeof(BITMAP), (LPSTR) &Bitmap);
  533.     BitBlt(hDC,column*27+16,314-round*30,Bitmap.bmWidth, Bitmap.bmHeight,
  534.              hMemoryDC,0,0,SRCCOPY);
  535.  
  536.     DeleteDC(hMemoryDC);
  537.     ReleaseDC(hWnd, hDC);
  538.  
  539.     return;
  540. }
  541.  
  542. /**************************/
  543. /* Display the secret code*/
  544. /**************************/
  545. void vShowCode(HWND hWnd)
  546. {
  547.     int x;
  548.     HDC hDC,hMemoryDC;
  549.  
  550.     hDC = GetDC(hWnd);
  551.     hMemoryDC = CreateCompatibleDC(hDC);
  552.     for (x=0;x<4;x++)
  553.     {
  554.         hOldBitmap =(HBITMAP)SelectObject(hMemoryDC,hPegs[code[x]]);
  555.         GetObject(hPegs[code[x]], sizeof(BITMAP), (LPSTR) &Bitmap);
  556.         BitBlt(hDC,x*27+16,15,Bitmap.bmWidth, Bitmap.bmHeight,
  557.                  hMemoryDC,0,0,SRCCOPY);
  558.     }
  559.  
  560.     DeleteDC(hMemoryDC);
  561.     ReleaseDC(hWnd, hDC);
  562.     return;
  563. }
  564.  
  565. /***************************/
  566. /* Winner's routine        */
  567. /***************************/
  568. void vDoWin(HWND hWnd)
  569. {
  570.     HDC         hDC;
  571.  
  572.     vShowCode(hWnd);
  573.  
  574.     hDC = GetDC(hWnd);
  575.     SetTextColor(hDC,RGB(0,255,0));
  576.     SetBkMode(hDC,TRANSPARENT);
  577.     strcpy(str,"WIN!");
  578.     TextOut(hDC,130,18,str,strlen(str));
  579.     ReleaseDC(hWnd, hDC);
  580.     winstate = 1;
  581.     return;
  582. }
  583.  
  584. /***************************/
  585. /* Looser's routine        */
  586. /***************************/
  587. void vDoLoose(HWND hWnd)
  588. {
  589.     HDC         hDC;
  590.  
  591.     vShowCode(hWnd);
  592.  
  593.     hDC = GetDC(hWnd);
  594.     SetTextColor(hDC,RGB(255,0,0));
  595.     SetBkMode(hDC,TRANSPARENT);
  596.     strcpy(str,"LOSE!");
  597.     TextOut(hDC,125,18,str,strlen(str));
  598.     ReleaseDC(hWnd, hDC);
  599.     winstate = 2;
  600.  
  601.     return;
  602. }
  603. /*************************/
  604. /* Display the clue pegs */
  605. /*************************/
  606. void vDoClues(HWND hWnd, int round)
  607. {
  608.     int x,y=0;
  609.     HDC hDC,hMemoryDC;
  610.     hDC = GetDC(hWnd);
  611.     hMemoryDC = CreateCompatibleDC(hDC);
  612.     for (x=0;x<4;x++)
  613.     {
  614.         if (clues[round][x] == '1')
  615.         {
  616.             hOldBitmap =(HBITMAP)SelectObject(hMemoryDC,hWhclpegmap);
  617.             GetObject(hWhclpegmap, sizeof(BITMAP), (LPSTR) &Bitmap);
  618.             BitBlt(hDC,y*12+125,320-(round*30),Bitmap.bmWidth, Bitmap.bmHeight,
  619.                      hMemoryDC,0,0,SRCCOPY);
  620.             y++;
  621.         }
  622.         else
  623.             if (clues[round][x] =='0')
  624.             {
  625.                 hOldBitmap =(HBITMAP)SelectObject(hMemoryDC,hBlclpegmap);
  626.                 GetObject(hBlclpegmap, sizeof(BITMAP), (LPSTR) &Bitmap);
  627.                 BitBlt(hDC,y*12+125,320-(round*30),Bitmap.bmWidth, Bitmap.bmHeight,
  628.                          hMemoryDC,0,0,SRCCOPY);
  629.                 y++;
  630.             }
  631.     }
  632.  
  633.     DeleteDC(hMemoryDC);
  634.     ReleaseDC(hWnd, hDC);
  635.     return;
  636. }
  637.  
  638. /*******************************/
  639. /* Mark the selected colour    */
  640. /*******************************/
  641. void vMarkColour(HWND hWnd)
  642. {
  643.     HDC         hDC;
  644.  
  645.     hDC = GetDC(hWnd);
  646.     if (prevcolour != -1)
  647.     {
  648.         SetTextColor(hDC,GetBkColor(hDC));
  649.         SetBkMode(hDC,TRANSPARENT);
  650.         strcpy(str,"*");
  651.         TextOut(hDC,220,prevcolour*23+165,str,strlen(str));
  652.     }
  653.     SetTextColor(hDC,RGB(0,0,0));
  654.     SetBkMode(hDC,TRANSPARENT);
  655.     strcpy(str,"*");
  656.     TextOut(hDC,220,curcolour*23+165,str,strlen(str));
  657.     prevcolour = curcolour;
  658.  
  659.     ReleaseDC(hWnd, hDC);
  660.     return;
  661. }
  662.