home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Games for Windows / Over1000GamesForWindows.iso / CARDS / 7andHalf / CardGameDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2003-02-09  |  16.9 KB  |  569 lines

  1. /* **************************************************************************************
  2.    File: CardGameDlg.cpp
  3.    By Mauro Mindoli January 2003
  4. ***************************************************************************************** */
  5.  
  6. // CardGameDlg.cpp : implementation file
  7. //
  8.  
  9. #include "stdafx.h"
  10. #include "CardGame.h"
  11. #include "CardGameDlg.h"
  12. #include "DlgHelp.h"
  13. #include <sstream>
  14. #include <mmsystem.h>
  15.  
  16. // Global Variables:
  17.  
  18. const int NumCards = 40;
  19. const int HIDDENCARD = 1;
  20. const int TIMEPCCARD = 1;
  21. LPPICTURE gpPic[NumCards+1];
  22. LPPICTURE gpPicHappy = NULL;
  23. LPPICTURE gpPicAngry = NULL;
  24. LPPICTURE gpPicCard = NULL;
  25. LPPICTURE gpPicJolly = NULL;
  26. LPPICTURE gpPicSound = NULL;
  27. LPPICTURE gpPicNoSound = NULL;
  28.  
  29.  
  30. template <class Num>
  31.   std::string to_string( Num n )
  32.   {
  33.     std::ostringstream oss;
  34.     oss << n;
  35.     return oss.str();
  36.   }
  37.  
  38.  
  39. // This function loads a file into an IStream.
  40. void myUtilities::LoadPictureFile(LPCTSTR szFile, LPPICTURE &gpPic)
  41. {
  42.    // open file
  43.    HANDLE hFile = CreateFile(szFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
  44.     _ASSERTE(INVALID_HANDLE_VALUE != hFile);
  45.  
  46.     // get file size
  47.     DWORD dwFileSize = GetFileSize(hFile, NULL);
  48.     _ASSERTE(-1 != dwFileSize);
  49.  
  50.     LPVOID pvData = NULL;
  51.     // alloc memory based on file size
  52.     HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
  53.     _ASSERTE(NULL != hGlobal);
  54.  
  55.     pvData = GlobalLock(hGlobal);
  56.     _ASSERTE(NULL != pvData);
  57.  
  58.     DWORD dwBytesRead = 0;
  59.     // read file and store in global memory
  60.     BOOL bRead = ReadFile(hFile, pvData, dwFileSize, &dwBytesRead, NULL);
  61.    if (!bRead)
  62.    {
  63.       CString msg("It is not possible to load the file");
  64.       msg += szFile;
  65.       AfxMessageBox(LPCTSTR(msg));
  66.       exit(1);
  67.    }
  68.  
  69.     _ASSERTE(FALSE != bRead);
  70.     GlobalUnlock(hGlobal);
  71.     CloseHandle(hFile);
  72.  
  73.     LPSTREAM pstm = NULL;
  74.     // create IStream* from global memory
  75.     HRESULT hr = CreateStreamOnHGlobal(hGlobal, TRUE, &pstm);
  76.     _ASSERTE(SUCCEEDED(hr) && pstm);
  77.  
  78.     // Create IPicture from image file
  79.     if (gpPic)
  80.         gpPic->Release();
  81.     hr = ::OleLoadPicture(pstm, dwFileSize, FALSE, IID_IPicture, (LPVOID *)&gpPic);
  82.     _ASSERTE(SUCCEEDED(hr) && gpPic);    
  83.     pstm->Release();
  84. }
  85.  
  86.  
  87. void myUtilities::RenderPic(CDialog* pDlg, HDC hDC, LPPICTURE pPic, long lx, long ly)
  88. {
  89.     long hmWidth;
  90.     long hmHeight;
  91.     CRect rect;
  92.     pDlg->GetClientRect(&rect);
  93.    pPic->get_Width(&hmWidth);
  94.     pPic->get_Height(&hmHeight);
  95.     // convert himetric to pixels
  96.     int nWidth    = MulDiv(hmWidth, GetDeviceCaps(hDC, LOGPIXELSX), HIMETRIC_INCH);
  97.     int nHeight    = MulDiv(hmHeight, GetDeviceCaps(hDC, LOGPIXELSY), HIMETRIC_INCH);
  98.    pPic->Render(hDC, lx, ly, 
  99.          nWidth, nHeight, 0, hmHeight, hmWidth, -hmHeight, &rect);
  100. }
  101.  
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CCardGameDlg dialog
  105.  
  106. CCardGameDlg::CCardGameDlg(CWnd* pParent /*=NULL*/)
  107.     : CDialog(CCardGameDlg::IDD, pParent)
  108. {
  109.     //{{AFX_DATA_INIT(CCardGameDlg)
  110.     m_MyPoints = 0.0;
  111.     m_MyDollars = 10;
  112.     m_PcDollars = 10;
  113.     m_PcPoints = 0.0;
  114.     m_Message = _T("Press <Card> button to play");
  115.     m_bet = 0;
  116.     //}}AFX_DATA_INIT
  117.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  118.     m_hIcon = AfxGetApp()->LoadIcon(IDR_SEVEN);
  119.    
  120.    // card selected;
  121.    m_itMyCard = m_CardMap.end();
  122.    m_itPcCard = m_CardMap.end();
  123.    m_end_hand = false;
  124.    m_iCountCards = 0;
  125.    m_bFirstCard = true;
  126.    m_bStopCard = false;
  127.    m_bSound = true;
  128.    m_gameResult = game::GAME_OK;
  129.    m_resultPic = gpPicCard;
  130. }
  131.  
  132. void CCardGameDlg::DoDataExchange(CDataExchange* pDX)
  133. {
  134.     CDialog::DoDataExchange(pDX);
  135.     //{{AFX_DATA_MAP(CCardGameDlg)
  136.     DDX_Text(pDX, IDC_MYPOINTS, m_MyPoints);
  137.     DDX_Text(pDX, IDC_MYDOLLARS, m_MyDollars);
  138.     DDX_Text(pDX, IDC_PCDOLLARS, m_PcDollars);
  139.     DDX_Text(pDX, IDC_PCPOINTS, m_PcPoints);
  140.     DDX_Text(pDX, IDC_MESSAGE, m_Message);
  141.     DDX_CBIndex(pDX, IDC_COMBOBET, m_bet);
  142.     //}}AFX_DATA_MAP
  143. }
  144.  
  145. BEGIN_MESSAGE_MAP(CCardGameDlg, CDialog)
  146.     //{{AFX_MSG_MAP(CCardGameDlg)
  147.    ON_WM_PAINT()
  148.     ON_WM_QUERYDRAGICON()
  149.     ON_BN_CLICKED(IDC_CARD, OnCard)
  150.     ON_BN_CLICKED(IDC_STOP, OnStop)
  151.     ON_BN_CLICKED(ID_EXIT, OnExit)
  152.     ON_WM_SETCURSOR()
  153.     ON_BN_CLICKED(IDC_HELPBUT, OnHelpbut)
  154.     ON_CBN_SELENDOK(IDC_COMBOBET, OnSelendokCombobet)
  155.     ON_BN_CLICKED(IDC_SOUND, OnSound)
  156.     //}}AFX_MSG_MAP
  157. END_MESSAGE_MAP()
  158.  
  159. /////////////////////////////////////////////////////////////////////////////
  160. // CCardGameDlg message handlers
  161.  
  162.  
  163. BOOL CCardGameDlg::OnInitDialog()
  164. {
  165.     CDialog::OnInitDialog();
  166.  
  167.     // Set the icon for this dialog.  The framework does this automatically
  168.     //  when the application's main window is not a dialog
  169.     SetIcon(m_hIcon, TRUE);            // Set big icon
  170.     SetIcon(m_hIcon, FALSE);        // Set small icon
  171.  
  172.  
  173.    for (int i = 0; i <= NumCards; i++)
  174.    {
  175.       MyPlaySound(".\\wav\\start.wav", NULL, SND_ASYNC | SND_FILENAME);
  176.       
  177.       std::string strPath(".\\napoletane\\");
  178.       strPath += to_string(i) + ".bmp";
  179.        myUtilities::LoadPictureFile(strPath.c_str(), gpPic[i]);
  180.  
  181.       // *************************************************************
  182.       // Building of a CardMap map<idCard, LPPICTURE>                *
  183.       // idCard = [(fam << 8) | val]                                 *
  184.       // (0, 9) [cups]coppe - (10, 19) [coins]denari -               * 
  185.       // (20, 29) [swards]spade - (30, 39) [woods]bastoni - 40 cover *
  186.       // *************************************************************
  187.       if (i != NumCards)
  188.          m_CardMap[(i/10 << 8) | ((i%10)+1)] = gpPic[i];
  189.       else // the cover
  190.          m_CardMap[0] = gpPic[NumCards];
  191.    }
  192.    myUtilities::LoadPictureFile(".\\napoletane\\happy.bmp", gpPicHappy);
  193.    myUtilities::LoadPictureFile(".\\napoletane\\angry.bmp", gpPicAngry);
  194.    myUtilities::LoadPictureFile(".\\napoletane\\card.bmp", gpPicCard);
  195.    myUtilities::LoadPictureFile(".\\napoletane\\jolly.bmp", gpPicJolly);
  196.    myUtilities::LoadPictureFile(".\\napoletane\\sound.bmp", gpPicSound);
  197.    myUtilities::LoadPictureFile(".\\napoletane\\nosound.bmp", gpPicNoSound);
  198.  
  199.    m_itMyCard = m_CardMap.find(0);
  200.    m_itPcCard = m_CardMap.find(0);
  201.     return TRUE;  // return TRUE  unless you set the focus to a control
  202. }
  203.  
  204. void CCardGameDlg::MyPlaySound(LPCSTR pszSound, HMODULE hmod, DWORD fdwSound)
  205. {
  206.          if (m_bSound)
  207.             PlaySound(pszSound, hmod, fdwSound);
  208.  
  209. }
  210.  
  211. // If you add a minimize button to your dialog, you will need the code below
  212. //  to draw the icon.  For MFC applications using the document/view model,
  213. //  this is automatically done for you by the framework.
  214.  
  215. void CCardGameDlg::OnPaint() 
  216. {
  217.    // Update dollars and points
  218.    SetDlgItemInt(IDC_PCDOLLARS, m_PcDollars, true);
  219.    SetDlgItemInt(IDC_MYDOLLARS, m_MyDollars, true);
  220.    if (m_gameResult != game::GAME_LOST)
  221.    {
  222.       SetDlgItemText(IDC_PCPOINTS, to_string(m_PcPoints).c_str());
  223.       SetDlgItemText(IDC_MYPOINTS, to_string(m_MyPoints).c_str());
  224.    }
  225.    SetDlgItemText(IDC_MESSAGE, m_Message);
  226.     CPaintDC dc(this); // device context for painting
  227.     // get width and height of picture
  228.     long hmWidth;
  229.     long hmHeight;
  230.    LPPICTURE pPic = 0;
  231.    if (m_itMyCard != m_CardMap.end())
  232.       pPic =(*m_itMyCard).second; // this is the current card picture pointer
  233.     pPic->get_Width(&hmWidth);
  234.     pPic->get_Height(&hmHeight);
  235.     // convert himetric to pixels
  236.     int nWidth    = MulDiv(hmWidth, GetDeviceCaps(dc.m_hDC, LOGPIXELSX), HIMETRIC_INCH);
  237.     int nHeight    = MulDiv(hmHeight, GetDeviceCaps(dc.m_hDC, LOGPIXELSY), HIMETRIC_INCH);
  238.     CRect rect;
  239.     //RECT rc;
  240.     GetClientRect(&rect);
  241.  
  242.    // display picture using IPicture::Render
  243.    // my cards
  244.    std::vector<LPPICTURE>::iterator itPic;
  245.    std::vector<LPPICTURE>::iterator itPicEnd;
  246.    
  247.    itPic = m_picMyVect.begin();
  248.    itPicEnd = m_picMyVect.end();
  249.    int vy = 220, vx = 15;
  250.    for ( ; itPic != itPicEnd; itPic++)
  251.    {
  252.       (*itPic)->Render(dc.m_hDC, vx, vy, 
  253.          nWidth, nHeight, 0, hmHeight, hmWidth, -hmHeight, &rect);
  254.       vx += (5*nWidth/4.0);
  255.    }
  256.  
  257.    //pc cards
  258.    itPic = m_picPcVect.begin();
  259.    itPicEnd = m_picPcVect.end();
  260.    vy = 30;
  261.    vx = 15;
  262.    for ( ; itPic != itPicEnd; itPic++)
  263.    {
  264.       (*itPic)->Render(dc.m_hDC, vx, vy, 
  265.          nWidth, nHeight, 0, hmHeight, hmWidth, -hmHeight, &rect);
  266.       vx += (5*nWidth/4.0);
  267.    }
  268.  
  269.    // result picture
  270.    if (m_resultPic)
  271.       pPic = m_resultPic; // happy (Pc) or cup (Me)
  272.    else
  273.       pPic = gpPicCard; // card cover pic
  274.    myUtilities::RenderPic(this, dc.m_hDC, pPic, 80, 154);   
  275.    // sound picture
  276.    if (m_bSound)
  277.       pPic = gpPicSound; // happy (Pc) or cup (Me)
  278.    else
  279.       pPic = gpPicNoSound; // card cover pic
  280.    myUtilities::RenderPic(this, dc.m_hDC, pPic, 610, 158);   
  281.     CDialog::OnPaint();
  282. }
  283.  
  284. // The system calls this to obtain the cursor to display while the user drags
  285. //  the minimized window.
  286. HCURSOR CCardGameDlg::OnQueryDragIcon()
  287. {
  288.     return (HCURSOR) m_hIcon;
  289. }
  290.  
  291. #define KEY_DOWN(vk_code)((GetAsyncKeyState(vk_code)&0x8000)?1 :0)
  292.  
  293. void CCardGameDlg::OnCard() 
  294. {
  295.    // initialisation at first card of every hand   
  296.  
  297.    if (m_bFirstCard)
  298.    {
  299.       if (m_MyDollars <= 0)
  300.       {
  301.          MyPlaySound(".\\wav\\match.wav", NULL, SND_ASYNC | SND_FILENAME);
  302.          AfxMessageBox("No Money? No Party! Pc Won the game :-(");
  303.          OnExit();
  304.       }
  305.       m_gn.ResetPoints(); // both pc and my points
  306.       m_bFirstCard = false; // this is not anymore the first card
  307.       m_bStopCard = false; // I still have not press stop
  308.       m_iCountCards = 0; // this counts the cards in my hand
  309.       m_Message = _T("Card to play again. Stop to let Pc play. Bet to change bet");
  310.       // at the start of every hand we erase the 2 vectors of cards
  311.       m_picMyVect.erase(m_picMyVect.begin(), m_picMyVect.end());
  312.       m_picPcVect.erase(m_picPcVect.begin(), m_picPcVect.end());
  313.       m_resultPic = gpPicCard;
  314.    }
  315.    else
  316.       m_Message = _T("Card to play again. Stop to let Pc play.");
  317.  
  318.    if (m_bStopCard)
  319.    {
  320.       MyPlaySound(".\\wav\\nostop.wav", NULL, SND_ASYNC | SND_FILENAME);
  321.       return;
  322.    }
  323.    m_gameResult = m_gn.Play(game::ME);
  324.    if (m_iCountCards == HIDDENCARD)
  325.    {
  326.       m_bet = GetDlgItemInt(IDC_COMBOBET);
  327.       if (m_MyDollars - m_bet < 0)
  328.       {
  329.          MyPlaySound(".\\wav\\change.wav", NULL, SND_ASYNC | SND_FILENAME);
  330.          AfxMessageBox("Change bet, you do not have enough money");
  331.          return;
  332.       }
  333.       m_MyDollars -=m_bet;
  334.    }
  335.    m_iCountCards++;
  336.    
  337.    CGameCardNapoletano card;
  338.    MyPlaySound(".\\wav\\card.wav", NULL, SND_ASYNC | SND_FILENAME);
  339.  
  340.    m_gn.GiveTheCard(card);
  341.    if (card.isJolly())
  342.    {
  343.       m_resultPic = gpPicJolly;
  344.       MyPlaySound(".\\wav\\matta.wav", NULL, SND_ASYNC | SND_FILENAME);
  345.    }
  346.    if (m_gameResult == game::GAME_LOST)
  347.    {
  348.       m_bFirstCard = true;
  349.       m_PcDollars += m_bet;
  350.       m_Message = _T("Pc won the hand!");
  351.       m_resultPic = gpPicHappy;
  352.       MyPlaySound(".\\wav\\loose.wav", NULL, SND_ASYNC | SND_FILENAME);
  353.    }
  354.    else
  355.       m_gn.GetPoints(m_MyPoints, m_PcPoints);
  356.    // take the idCard from the current card
  357.    int idCard = card.GetIdCard();
  358.    // with the idCard we can find the iterator to the picture by the map
  359.    m_itMyCard = m_CardMap.find(idCard);
  360.    LPPICTURE pPic = 0;
  361.    if (m_itMyCard != m_CardMap.end())
  362.    {
  363.       pPic =(*m_itMyCard).second; // this is the current card picture pointer
  364.       m_picMyVect.push_back(pPic); // we put it in the My vector pictures
  365.    }
  366.     CRect rect;
  367.     GetClientRect(&rect);
  368.    InvalidateRect(&rect, TRUE);   
  369. }
  370.  
  371.  
  372. void CCardGameDlg::OnPcCard() 
  373. {
  374.    if (m_bFirstCard)
  375.    {
  376.       m_gameResult = game::GAME_OK;
  377.       m_bet = GetDlgItemInt(IDC_COMBOBET);
  378.       m_PcDollars -=m_bet;
  379.       m_bFirstCard = false;
  380.       m_Message = _T("Pc is playing now");
  381.    }
  382.  
  383.    m_gameResult = m_gn.Play(game::PC);
  384.    CGameCardNapoletano card;
  385.    MyPlaySound(".\\wav\\pccard.wav", NULL, SND_ASYNC | SND_FILENAME);
  386.    m_gn.GiveTheCard(card);
  387.    if (card.isJolly())
  388.    {
  389.       m_resultPic = gpPicJolly;
  390.       MyPlaySound(".\\wav\\matta.wav", NULL, SND_ASYNC | SND_FILENAME);
  391.    }
  392.    if (m_gameResult == game::GAME_LOST)
  393.    {
  394.       m_bFirstCard = true;
  395.       m_end_hand = true;
  396.       m_MyDollars += 2*m_bet;
  397.    }
  398.    else
  399.    if (m_gameResult == game::GAME_WON)
  400.    {
  401.       m_gn.GetPoints(m_MyPoints, m_PcPoints);
  402.       m_end_hand = true;
  403.    }
  404.    else
  405.       m_gn.GetPoints(m_MyPoints, m_PcPoints);
  406.    // take the idCard from the current card
  407.    int idCard = card.GetIdCard();
  408.    // with the idCard we can find the iterator to the picture by the map
  409.    m_itPcCard = m_CardMap.find(idCard);
  410.    LPPICTURE pPic = 0;
  411.    if (m_itPcCard != m_CardMap.end())
  412.    {
  413.       pPic =(*m_itPcCard).second; // this is the current card picture pointer
  414.       m_picPcVect.push_back(pPic);
  415.    }
  416.    CRect rect;
  417.    GetClientRect(&rect);
  418.    InvalidateRect(&rect, TRUE);   
  419. }
  420.  
  421.  
  422. void CCardGameDlg::CheckWin()
  423. {
  424.    if (m_gameResult == game::GAME_WON)
  425.    {
  426.       m_PcDollars += 2*m_bet;
  427.       m_Message = _T("Pc won the hand!");
  428.       m_resultPic = gpPicHappy;
  429.       MyPlaySound(".\\wav\\loose.wav", NULL, SND_ASYNC | SND_FILENAME);
  430.       if (m_MyDollars <= 0)
  431.       {
  432.          MyPlaySound(".\\wav\\match.wav", NULL, SND_ASYNC | SND_FILENAME);
  433.          AfxMessageBox("No Money? No Party! Pc Won the game :-(");
  434.          OnExit();
  435.       }
  436.    }
  437.    else
  438.    {
  439.       m_Message = _T("You won the hand!");
  440.       m_resultPic = gpPicAngry;
  441.       MyPlaySound(".\\wav\\win.wav", NULL, SND_ASYNC | SND_FILENAME);
  442.       if (m_PcDollars < 0)
  443.       {
  444.          MyPlaySound(".\\wav\\match.wav", NULL, SND_ASYNC | SND_FILENAME);
  445.          AfxMessageBox("No Money? No Party! You won the match! :-)");
  446.          OnExit();
  447.       }
  448.    }
  449.    CRect rect;
  450.    GetClientRect(&rect);
  451.    InvalidateRect(&rect, TRUE);   
  452. }
  453.  
  454. // When we stop, this timer let the Pc play every second
  455. void CALLBACK EXPORT TimerPcCard(
  456.    HWND hWnd,      // handle of CWnd that called SetTimer
  457.    UINT nMsg,      // WM_TIMER
  458.    UINT nIDEvent,   // timer identification
  459.    DWORD dwTime    // system time
  460. )
  461. {
  462.    CCardGameDlg *pCardGameDlgInst = (CCardGameDlg *) CWnd::FromHandle(hWnd);
  463.    // m_end_hand is a flag to check the winner and stop the timer
  464.    if (pCardGameDlgInst->m_end_hand)
  465.    {
  466.      
  467.       KillTimer(pCardGameDlgInst->m_hWnd, TIMEPCCARD);
  468.       pCardGameDlgInst->CheckWin();
  469.       pCardGameDlgInst->m_end_hand = false;
  470.       pCardGameDlgInst->m_bFirstCard = true;
  471.       // this message is to OnSetCursor to change the cursor shape
  472.       pCardGameDlgInst->SendMessage(WM_SETCURSOR, (WPARAM)hWnd, (LPARAM) 0);
  473.       if (pCardGameDlgInst->m_PcDollars < 0)
  474.       {
  475.          pCardGameDlgInst->MyPlaySound(".\\wav\\match.wav", NULL, SND_ASYNC | SND_FILENAME);
  476.          AfxMessageBox("Pc No Money? You won the game!");
  477.          pCardGameDlgInst->OnExit();
  478.       }
  479.    }
  480.    else // every second the Pc plays
  481.       pCardGameDlgInst->OnPcCard();
  482. }
  483.  
  484. // To pass the hand to Pc
  485. void CCardGameDlg::OnStop() 
  486. {
  487.    // Forbidden to stop at the before the firs card or when
  488.    // already stopped
  489.    if (m_bFirstCard || m_bStopCard)
  490.    {
  491.       MyPlaySound(".\\wav\\nostop.wav", NULL, SND_ASYNC | SND_FILENAME);
  492.       return;
  493.    }
  494.    if (m_iCountCards == HIDDENCARD)
  495.    {
  496.       m_bet = GetDlgItemInt(IDC_COMBOBET);
  497.       if (m_MyDollars - m_bet < 0)
  498.       {
  499.          MyPlaySound(".\\wav\\change.wav", NULL, SND_ASYNC | SND_FILENAME);
  500.          AfxMessageBox("Change bet, you do not have enough money");
  501.          return;
  502.       }
  503.       m_MyDollars -=m_bet;
  504.    }
  505.    MyPlaySound(".\\wav\\stop.wav", NULL, SND_ASYNC | SND_FILENAME);
  506.  
  507.    m_bFirstCard = true;
  508.    m_bStopCard = true;
  509.    void (CALLBACK EXPORT* pTimerPcCard)(HWND, UINT, UINT, DWORD) = TimerPcCard;
  510.    SetTimer(TIMEPCCARD, 1000, pTimerPcCard);
  511. }
  512.  
  513. void CCardGameDlg::OnExit() 
  514. {
  515.   CDialog::OnOK();
  516. }
  517.  
  518. // To make a change to the cursor shape
  519. BOOL CCardGameDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
  520. {
  521.     // shape hourglass and shape 7&half
  522.    if (m_bStopCard == true && (m_resultPic == gpPicCard))
  523.       SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
  524.    else
  525.       SetCursor(AfxGetApp()->LoadCursor(IDC_CARDCURSOR));
  526.    return 0;
  527.     
  528. }
  529.  
  530. void CCardGameDlg::OnHelpbut() 
  531. {
  532.  
  533.    MyPlaySound(".\\wav\\help.wav", NULL, SND_ASYNC | SND_FILENAME);
  534.    DlgHelp DHelp(this);
  535.    DHelp.DoModal();
  536. }
  537.  
  538.  
  539. void CCardGameDlg::OnSelendokCombobet() 
  540. {
  541.     // TODO: Add your control notification handler code here
  542.    if ((m_iCountCards != 1) || m_bStopCard)
  543.    {
  544.       MyPlaySound(".\\wav\\bet.wav", NULL, SND_ASYNC | SND_FILENAME);
  545.       AfxMessageBox("You can only bet right after you have seen your hidden card!");
  546.       CComboBox *cbp = (CComboBox *)GetDlgItem(IDC_COMBOBET);
  547.       cbp->SetCurSel(0);
  548.    }
  549.    else
  550.       MyPlaySound(".\\wav\\money.wav", NULL, SND_ASYNC | SND_FILENAME);
  551.  
  552. }
  553.  
  554. void CCardGameDlg::OnSound() 
  555. {
  556.    if (m_bSound)
  557.       m_bSound = false;
  558.    else
  559.    {
  560.       m_bSound = true;
  561.       MyPlaySound(".\\wav\\stop.wav", NULL, SND_ASYNC | SND_FILENAME);
  562.    }
  563.     CRect rect;
  564.     GetClientRect(&rect);
  565.    InvalidateRect(&rect, TRUE);   
  566.   
  567. }
  568.  
  569.