Click here to Skip to main content
15,921,646 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: enduring object in Visual Studion Pin
Mark Salsbery28-Jun-08 12:19
Mark Salsbery28-Jun-08 12:19 
GeneralRe: enduring object in Visual Studion Pin
bkelly1329-Jun-08 11:45
bkelly1329-Jun-08 11:45 
GeneralRe: enduring object in Visual Studion Pin
Mark Salsbery29-Jun-08 12:02
Mark Salsbery29-Jun-08 12:02 
QuestionIt makes me crazy.. help me plz. Pin
FR2ESOD28-Jun-08 6:32
FR2ESOD28-Jun-08 6:32 
AnswerRe: It makes me crazy.. help me plz. Pin
CPallini28-Jun-08 7:24
mveCPallini28-Jun-08 7:24 
GeneralRe: It makes me crazy.. help me plz. Pin
FR2ESOD28-Jun-08 13:21
FR2ESOD28-Jun-08 13:21 
AnswerRe: It makes me crazy.. help me plz. Pin
Ștefan-Mihai MOGA29-Jun-08 5:04
professionalȘtefan-Mihai MOGA29-Jun-08 5:04 
GeneralRe: It makes me crazy.. help me plz. Pin
FR2ESOD29-Jun-08 6:12
FR2ESOD29-Jun-08 6:12 
Thanks for your help...

but I didn't understand your message.
How to define it ??
My CAboutDlg source is added.
plz check this.
i'm spend time for 2 days about this. help me.

//////////////////////////////////////////////////////////////////////////////////
// MFC_4_2Dlg.cpp
//

#include "stdafx.h"
#include "MFC_4_2.h"
#include "MFC_4_2Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif



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

enum { IDD = IDD_ABOUTBOX };

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV


protected:
DECLARE_MESSAGE_MAP()
public:
};

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

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


// CMFC_4_2Dlg




CMFC_4_2Dlg::CMFC_4_2Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CMFC_4_2Dlg::IDD, pParent)
, m_strProdName(_T(""))
, m_strProdCode(_T(""))
, m_UnitCost(0)
, m_nQuantity(0)
, m_nTotalCost(0)
, m_strInfo(_T(""))
, m_bCodeViewed(FALSE)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_bCodeViewed = FALSE;
}

void CMFC_4_2Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_NAME, m_strProdName);
DDX_Text(pDX, IDC_EDIT_CODE, m_strProdCode);
DDX_Text(pDX, IDC_EDIT_UNIT_COST, m_UnitCost);
DDX_Text(pDX, IDC_EDIT_QUANTITY, m_nQuantity);
DDX_Text(pDX, IDC_EDIT_TOTAL_COST, m_nTotalCost);
DDX_Text(pDX, IDC_EDIT_INFO, m_strInfo);
}

BEGIN_MESSAGE_MAP(CMFC_4_2Dlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_EN_CHANGE(IDC_EDIT_NAME, &CMFC_4_2Dlg::OnEnChangeEditName)
ON_EN_CHANGE(IDC_EDIT_CODE, &CMFC_4_2Dlg::OnEnChangeEditCode)
ON_EN_CHANGE(IDC_EDIT_UNIT_COST, &CMFC_4_2Dlg::OnEnChangeEditUnitCost)
ON_EN_CHANGE(IDC_EDIT_QUANTITY, &CMFC_4_2Dlg::OnEnChangeEditQuantity)
ON_BN_CLICKED(IDC_SAVE, &CMFC_4_2Dlg::OnBnClickedSave)
ON_BN_CLICKED(IDC_OPEN, &CMFC_4_2Dlg::OnBnClickedOpen)
ON_BN_CLICKED(IDC_VIEW, &CMFC_4_2Dlg::OnBnClickedView)
END_MESSAGE_MAP()


// CMFC_4_2Dlg

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

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);
}
}

SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);


return TRUE;
}

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



void CMFC_4_2Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

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;

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

HCURSOR CMFC_4_2Dlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}


void CMFC_4_2Dlg::UpdateStockInfo(void)
{
UpdateData(TRUE);

m_nTotalCost = m_UnitCost * m_nQuantity;

m_strInfo.Format(_T("name : %s \r\n\r\n code : %s \r\n\r\n price : %d \r\n\r\n amount : %d \r\n\r\n total : %d \r\n\r\n"),m_strProdName, m_strProdCode, m_UnitCost, m_nQuantity, m_nTotalCost);
UpdateData(FALSE);
}

void CMFC_4_2Dlg::OnEnChangeEditName()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here
UpdateStockInfo();
}

void CMFC_4_2Dlg::OnEnChangeEditCode()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here
UpdateStockInfo();
}

void CMFC_4_2Dlg::OnEnChangeEditUnitCost()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here
UpdateStockInfo();
}

void CMFC_4_2Dlg::OnEnChangeEditQuantity()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here
UpdateStockInfo();
}

void CMFC_4_2Dlg::OnBnClickedSave()
{
// TODO: Add your control notification handler code here
char Filter[] = "p42 File(*.p42) | *.p42 | All(*.*) | *.* |";
CFileDialog pDlg(FALSE, _T("p42 file(*.p42)"), _T("*.p42"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, (LPCTSTR)Filter, NULL);

UpdateData(TRUE);

if(!m_strProdName.IsEmpty() && !m_strProdCode.IsEmpty() && (m_UnitCost >0) && (m_nQuantity > 0) && (m_nTotalCost > 0))
{
if(pDlg.DoModal() == IDOK)
{
FILE *fp;
// fp = _tfopen(pDlg.GetPathName(), _T("w"));
fp = fopen(pDlg.GetPathName(), _T("w"));

fprintf(fp, "%s\n%s\n%d\n%d\n%d", m_strProdName, m_strProdCode, m_UnitCost, m_nQuantity, m_nTotalCost);

fclose(fp);
}
}
else
{
AfxMessageBox(_T("input your imformation : "));
}
}

void CMFC_4_2Dlg::OnBnClickedOpen()
{
// TODO: Add your control notification handler code here
char Filter[] = "p42 File(*.p42) | *.p42 | All(*.*) | *.* |";
CFileDialog pDlg(TRUE, _T("p42 file(*.p42)"), _T("*.p42"), OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, (LPCTSTR)Filter, NULL);

if(pDlg.DoModal() == IDOK)
{
FILE *fp;
// fp = _tfopen(pDlg.GetPathName(), _T("r"));
fp = fopen(pDlg.GetPathName(), _T("r"));
fscanf(fp, "%s\n", m_strProdName);
fscanf(fp, "%s\n", m_strProdCode);
fscanf(fp, "%d\n%d\n%d", &m_UnitCost, &m_nQuantity, &m_nTotalCost);

UpdateData(FALSE);
UpdateStockInfo();
fclose(fp);
}
}

void CMFC_4_2Dlg::OnBnClickedView()
{
// TODO: Add your control notification handler code here
if(!m_bCodeViewed)
{
m_dlgCodeTable.Create(IDD_DIALOG_CODETABLE, this);

CRect rectMain, rectCodeTable;

GetWindowRect(&rectMain);
m_dlgCodeTable.GetWindowRect(&rectCodeTable);

m_dlgCodeTable.MoveWindow(rectMain.right, rectMain.top, rectMain.Width(), rectMain.Height());

m_dlgCodeTable.ShowWindow(SW_SHOW);
m_bCodeViewed = TRUE;
}
else
{
m_dlgCodeTable.ShowWindow(SW_HIDE);
m_dlgCodeTable.DestroyWindow();
m_bCodeViewed = FALSE;
}
}
///////////////////////////////////////////////////////////////////////////////////////////
QuestionCaptuve encode and stream over a network Pin
Ethemind28-Jun-08 6:19
Ethemind28-Jun-08 6:19 
AnswerRe: Captuve encode and stream over a network Pin
Mark Salsbery28-Jun-08 7:44
Mark Salsbery28-Jun-08 7:44 
QuestionEvent Handling for Dynamically created ListBox Pin
chetanjoshi928-Jun-08 1:09
chetanjoshi928-Jun-08 1:09 
AnswerRe: Event Handling for Dynamically created ListBox Pin
MANISH RASTOGI28-Jun-08 2:11
MANISH RASTOGI28-Jun-08 2:11 
GeneralRe: Event Handling for Dynamically created ListBox Pin
chetanjoshi928-Jun-08 2:34
chetanjoshi928-Jun-08 2:34 
AnswerRe: Event Handling for Dynamically created ListBox Pin
Karthik Kalyanasundaram28-Jun-08 5:58
Karthik Kalyanasundaram28-Jun-08 5:58 
AnswerRe: Event Handling for Dynamically created ListBox Pin
Hamid_RT30-Jun-08 18:56
Hamid_RT30-Jun-08 18:56 
QuestionIncreasing font size of text in static text box Pin
VCProgrammer28-Jun-08 0:29
VCProgrammer28-Jun-08 0:29 
AnswerRe: Increasing font size of text in static text box Pin
leonigah28-Jun-08 2:16
leonigah28-Jun-08 2:16 
AnswerRe: Increasing font size of text in static text box Pin
Ștefan-Mihai MOGA28-Jun-08 3:36
professionalȘtefan-Mihai MOGA28-Jun-08 3:36 
AnswerRe: Increasing font size of text in static text box [modified] Pin
Karthik Kalyanasundaram28-Jun-08 6:04
Karthik Kalyanasundaram28-Jun-08 6:04 
AnswerRe: Increasing font size of text in static text box Pin
Hamid_RT30-Jun-08 18:54
Hamid_RT30-Jun-08 18:54 
Questionhow to return variable to VB.NET Pin
boyindie27-Jun-08 23:18
boyindie27-Jun-08 23:18 
QuestionHow to create "Bitmap Font " using Pixel Data. Pin
phanindra varma27-Jun-08 23:12
phanindra varma27-Jun-08 23:12 
AnswerRe: How to create "Bitmap Font " using Pixel Data. Pin
Hamid_RT30-Jun-08 18:51
Hamid_RT30-Jun-08 18:51 
QuestionProfiling in Visual Studio Pin
AndreFratelli27-Jun-08 22:48
AndreFratelli27-Jun-08 22:48 
AnswerRe: Profiling in Visual Studio Pin
Hamid_RT30-Jun-08 18:47
Hamid_RT30-Jun-08 18:47 

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.