billcaso
May 1st, 1999, 11:47 PM
I made a console App which tells what kind of a poker hand you have.
You type in 2s for 2 of spades, 11h for jack of hearts, 14c for Ace of clubs etc
I don't know how to get the card ( an int ) or the suit (char) into the struct
in VC++. I use an Edit box & cast it to int. Should I use another method? I
have 52 icons for the deck of cards & want to display them. I can do that via the
the Coriolis book by Gilbert & McCarty. My code works for console app. Another
problem is to build a string to put in the SetIcon function. It wouldn't allow me
to cast my CString m_hope with HICON(m_hope).
// CEasyPokerDlg dialog
class CEasyPokerDlg : public CDialog
{
// Construction
private:
CString s;
public:
CEasyPokerDlg(CWnd* pParent = NULL); // standard constructor
struct Poker
{
char suit;
int card;
}hand[5], hand1[3];
// Dialog Data
//{{AFX_DATA(CEasyPokerDlg)
enum { IDD = IDD_EASYPOKER_DIALOG };
CStatic m_Card5;
CStatic m_Card4;
CStatic m_Card3;
CStatic m_Card2;
CStatic m_Card1;
CButton m_hand;
CString m_hope;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CEasyPokerDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
HICON m_2H;
HICON m_2C;
HICON m_2D;
HICON m_2S;
HICON m_3H;
HICON m_3C;
HICON m_3D;
HICON m_3S;
HICON m_4H;
HICON m_4C;
HICON m_4D;
HICON m_4S;
// Generated message map functions
//{{AFX_MSG(CEasyPokerDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnChangeEdit1();
afx_msg void OnCheckHand();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
void CEasyPokerDlg::OnChangeEdit1()
{
// Poker hand[5], hand1[3];
int i=1;
while(i<6)
{
m_hope = "IDI_" & IDC_EDIT1.text;
hand[i].card = int(IDC_EDIT1.text);
IDC_EDIT1.text = "";
hand[i].suit = IDC_EDIT1.text;
m_hope += IDC_EDIT1.text;
IDC_EDIT1->text = "";
switch(i)
{
case 1: m_Card1.SetIcon(m_hope);
case 2: m_Card2.SetIcon(m_hope);
case 3: m_Card3.SetIcon(m_hope);
case 4: m_Card4.SetIcon(m_hope);
case 5: m_Card5.SetIcon(m_hope);
}
i++;
}
}
:\Projects\EasyPoker\EasyPokerDlg.cpp(205) : error C2228: left of '.text'
must have class/struct/union type
F:\Projects\EasyPoker\EasyPokerDlg.cpp(206) : error C2228: left of '.text'
must have class/struct/union type
F:\Projects\EasyPoker\EasyPokerDlg.cpp(206) : fatal error C1903: unable to
recover from previous error(s); stopping compilation
You type in 2s for 2 of spades, 11h for jack of hearts, 14c for Ace of clubs etc
I don't know how to get the card ( an int ) or the suit (char) into the struct
in VC++. I use an Edit box & cast it to int. Should I use another method? I
have 52 icons for the deck of cards & want to display them. I can do that via the
the Coriolis book by Gilbert & McCarty. My code works for console app. Another
problem is to build a string to put in the SetIcon function. It wouldn't allow me
to cast my CString m_hope with HICON(m_hope).
// CEasyPokerDlg dialog
class CEasyPokerDlg : public CDialog
{
// Construction
private:
CString s;
public:
CEasyPokerDlg(CWnd* pParent = NULL); // standard constructor
struct Poker
{
char suit;
int card;
}hand[5], hand1[3];
// Dialog Data
//{{AFX_DATA(CEasyPokerDlg)
enum { IDD = IDD_EASYPOKER_DIALOG };
CStatic m_Card5;
CStatic m_Card4;
CStatic m_Card3;
CStatic m_Card2;
CStatic m_Card1;
CButton m_hand;
CString m_hope;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CEasyPokerDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
HICON m_2H;
HICON m_2C;
HICON m_2D;
HICON m_2S;
HICON m_3H;
HICON m_3C;
HICON m_3D;
HICON m_3S;
HICON m_4H;
HICON m_4C;
HICON m_4D;
HICON m_4S;
// Generated message map functions
//{{AFX_MSG(CEasyPokerDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnChangeEdit1();
afx_msg void OnCheckHand();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
void CEasyPokerDlg::OnChangeEdit1()
{
// Poker hand[5], hand1[3];
int i=1;
while(i<6)
{
m_hope = "IDI_" & IDC_EDIT1.text;
hand[i].card = int(IDC_EDIT1.text);
IDC_EDIT1.text = "";
hand[i].suit = IDC_EDIT1.text;
m_hope += IDC_EDIT1.text;
IDC_EDIT1->text = "";
switch(i)
{
case 1: m_Card1.SetIcon(m_hope);
case 2: m_Card2.SetIcon(m_hope);
case 3: m_Card3.SetIcon(m_hope);
case 4: m_Card4.SetIcon(m_hope);
case 5: m_Card5.SetIcon(m_hope);
}
i++;
}
}
:\Projects\EasyPoker\EasyPokerDlg.cpp(205) : error C2228: left of '.text'
must have class/struct/union type
F:\Projects\EasyPoker\EasyPokerDlg.cpp(206) : error C2228: left of '.text'
must have class/struct/union type
F:\Projects\EasyPoker\EasyPokerDlg.cpp(206) : fatal error C1903: unable to
recover from previous error(s); stopping compilation