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