Click here to Skip to main content
15,923,789 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Set height or width of control bar Pin
nguyenvhn12-May-04 17:57
nguyenvhn12-May-04 17:57 
GeneralRe: Set height or width of control bar Pin
alex.barylski12-May-04 18:03
alex.barylski12-May-04 18:03 
Generaldefine Vs. const Pin
Ernesto D.12-May-04 17:31
Ernesto D.12-May-04 17:31 
GeneralRe: define Vs. const Pin
nguyenvhn12-May-04 17:51
nguyenvhn12-May-04 17:51 
GeneralRe: define Vs. const Pin
Maxwell Chen12-May-04 18:10
Maxwell Chen12-May-04 18:10 
GeneralRe: define Vs. const Pin
Ernesto D.12-May-04 20:25
Ernesto D.12-May-04 20:25 
GeneralRe: define Vs. const Pin
Joe Woodbury13-May-04 9:21
professionalJoe Woodbury13-May-04 9:21 
GeneralSyntax and Missing Identifiers---LONG Pin
---Mark----12-May-04 17:17
suss---Mark----12-May-04 17:17 
Ok this is a really dasic dialog program but I can't figure what I'm donig wrong?? The problem I am having is get the dialog title to change to the caption of the button pressed. Help!!

--------------------Configuration: Retry - Win32 Debug--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
Retry.cpp
c:\c++ projects\retry\retrydlg.h(18) : error C2061: syntax error : identifier 'UNIT'
c:\c++ projects\retry\retrydlg.h(19) : error C2146: syntax error : missing ';' before identifier 'm_nIDofLastButton'
c:\c++ projects\retry\retrydlg.h(19) : error C2501: 'UNIT' : missing storage-class or type specifiers
c:\c++ projects\retry\retrydlg.h(19) : error C2501: 'm_nIDofLastButton' : missing storage-class or type specifiers
RetryDlg.cpp
c:\c++ projects\retry\retrydlg.h(18) : error C2061: syntax error : identifier 'UNIT'
c:\c++ projects\retry\retrydlg.h(19) : error C2146: syntax error : missing ';' before identifier 'm_nIDofLastButton'
c:\c++ projects\retry\retrydlg.h(19) : error C2501: 'UNIT' : missing storage-class or type specifiers
c:\c++ projects\retry\retrydlg.h(19) : error C2501: 'm_nIDofLastButton' : missing storage-class or type specifiers
C:\C++ Projects\Retry\RetryDlg.cpp(208) : error C2660: 'ChangeDialogTitle' : function does not take 1 parameters
C:\C++ Projects\Retry\RetryDlg.cpp(213) : error C2660: 'ChangeDialogTitle' : function does not take 1 parameters
C:\C++ Projects\Retry\RetryDlg.cpp(218) : error C2660: 'ChangeDialogTitle' : function does not take 1 parameters
C:\C++ Projects\Retry\RetryDlg.cpp(221) : error C2065: 'UNIT' : undeclared identifier
C:\C++ Projects\Retry\RetryDlg.cpp(221) : error C2146: syntax error : missing ')' before identifier 'nID'
C:\C++ Projects\Retry\RetryDlg.cpp(221) : error C2182: 'ChangeDialogTitle' : illegal use of type 'void'
C:\C++ Projects\Retry\RetryDlg.cpp(221) : error C2350: 'CRetryDlg::ChangeDialogTitle' is not a static member
C:\C++ Projects\Retry\RetryDlg.cpp(221) : error C2059: syntax error : ')'
C:\C++ Projects\Retry\RetryDlg.cpp(222) : error C2143: syntax error : missing ';' before '{'
C:\C++ Projects\Retry\RetryDlg.cpp(222) : error C2447: missing function header (old-style formal list?)
Generating Code...
Error executing cl.exe.

Retry.exe - 18 error(s), 0 warning(s)

// RetryDlg.h : header file
//

#if !defined(AFX_RETRYDLG_H__4A3C71B3_E316_48A5_B38E_7F3E778D47DD__INCLUDED_)
#define AFX_RETRYDLG_H__4A3C71B3_E316_48A5_B38E_7F3E778D47DD__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/////////////////////////////////////////////////////////////////////////////
// CRetryDlg dialog

class CRetryDlg : public CDialog
{
// Construction
public:
// Trouble Rigth Here Line 18
void ChangeDialogTitle(UNIT nID);
// Trouble Rigth Here Line 19
UNIT m_nIDofLastButton;
CRetryDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
//{{AFX_DATA(CRetryDlg)
enum { IDD = IDD_RETRY_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CRetryDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
HICON m_hIcon;

// Generated message map functions
//{{AFX_MSG(CRetryDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnSh();
afx_msg void OnEd();
afx_msg void OnL();
afx_msg void OnC();
afx_msg void OnR();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_RETRYDLG_H__4A3C71B3_E316_48A5_B38E_7F3E778D47DD__INCLUDED_)


// RetryDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Retry.h"
#include "RetryDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
afx_msg void OnPlus();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
ON_BN_CLICKED(IDC_Plus, OnPlus)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRetryDlg dialog

CRetryDlg::CRetryDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRetryDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRetryDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CRetryDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRetryDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CRetryDlg, CDialog)
//{{AFX_MSG_MAP(CRetryDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_SH, OnSh)
ON_BN_CLICKED(IDC_ED, OnEd)
ON_BN_CLICKED(IDC_L, OnL)
ON_BN_CLICKED(IDC_C, OnC)
ON_BN_CLICKED(IDC_R, OnR)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRetryDlg message handlers

BOOL CRetryDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here

return TRUE; // return TRUE unless you set the focus to a control
}

void CRetryDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}

// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.

void CRetryDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CRetryDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CRetryDlg::OnSh()
{
BOOL bVisible = GetDlgItem(IDC_L) ->IsWindowVisible();

GetDlgItem(IDC_L) ->ShowWindow(bVisible? SW_HIDE : SW_SHOW);
GetDlgItem(IDC_C) ->ShowWindow(bVisible? SW_HIDE : SW_SHOW);
GetDlgItem(IDC_R) ->ShowWindow(bVisible? SW_HIDE : SW_SHOW);

GetDlgItem(IDC_SH) ->SetWindowText(bVisible? "SHOW" : "HIDE");

}

void CRetryDlg::OnEd()
{
BOOL bState = GetDlgItem(IDC_L) ->IsWindowEnabled();

GetDlgItem(IDC_L) ->EnableWindow(!bState);
GetDlgItem(IDC_C) ->EnableWindow(!bState);
GetDlgItem(IDC_R) ->EnableWindow(!bState);

GetDlgItem(IDC_ED) ->SetWindowText(bState? "ENABLE" : "DISABLE");
}

void CAboutDlg::OnPlus()
{
MessageBox ("Please Register Your Shareware", "!!!!!!");
}

void CRetryDlg::OnL()
{
ChangeDialogTitle(IDC_L);
}

void CRetryDlg::OnC()
{
ChangeDialogTitle(IDC_C);
}

void CRetryDlg::OnR()
{
ChangeDialogTitle(IDC_R);
}

void CRetryDlg::ChangeDialogTitle(UNIT nID)
{
CString strCaption;

GetDlgItem(nID) ->GetWindowText(strCaption);

strCaption += " was pressed";

if(m_nIDofLastButton == nID)
strCaption += " again";

SetWindowText(strCaption);

GeneralRe: Syntax and Missing Identifiers---LONG Pin
Maxwell Chen12-May-04 17:32
Maxwell Chen12-May-04 17:32 
GeneralRe: Syntax and Missing Identifiers---LONG Pin
---Mark---12-May-04 18:00
---Mark---12-May-04 18:00 
GeneralRe: Syntax and Missing Identifiers---LONG Pin
---Mark---12-May-04 18:04
---Mark---12-May-04 18:04 
GeneralRe: Syntax and Missing Identifiers---LONG Pin
Maxwell Chen12-May-04 18:22
Maxwell Chen12-May-04 18:22 
GeneralRe: Syntax and Missing Identifiers---LONG Pin
---Mark---12-May-04 18:43
---Mark---12-May-04 18:43 
GeneralAdvice for Books Pin
vnm612-May-04 16:18
vnm612-May-04 16:18 
GeneralRe: Advice for Books Pin
Anthony_Yio12-May-04 16:41
Anthony_Yio12-May-04 16:41 
GeneralRe: Advice for Books Pin
vnm613-May-04 21:01
vnm613-May-04 21:01 
GeneralCATCH_ALL and OnCtlColor Pin
Coremn12-May-04 15:01
Coremn12-May-04 15:01 
GeneralRe: CATCH_ALL and OnCtlColor Pin
monrobot1312-May-04 15:29
monrobot1312-May-04 15:29 
GeneralRe: CATCH_ALL and OnCtlColor Pin
Coremn12-May-04 15:42
Coremn12-May-04 15:42 
GeneralRe: CATCH_ALL and OnCtlColor Pin
Coremn12-May-04 16:17
Coremn12-May-04 16:17 
GeneralRe: CATCH_ALL and OnCtlColor Pin
Ryan Binns12-May-04 18:02
Ryan Binns12-May-04 18:02 
GeneralInterface Methods Pin
monrobot1312-May-04 14:20
monrobot1312-May-04 14:20 
GeneralRe: Interface Methods Pin
Milton Karimbekallil12-May-04 21:06
Milton Karimbekallil12-May-04 21:06 
GeneralEXCEPTION_BREAKPOINT not raised Pin
Brian Tietz12-May-04 14:18
Brian Tietz12-May-04 14:18 
GeneralRe: EXCEPTION_BREAKPOINT not raised Pin
Ryan Binns12-May-04 18:21
Ryan Binns12-May-04 18:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.