Loading Variable in EditBox
-
How do I load a variable inside an edit box? I have an edit box stated below, its called "OnCash", It's ID is "IDC_CASH". Source: ---------------------------------------------- void CTycoonDlg::OnCash() { //$cash(variable) } ---------------------------------------------- I want it to say in the editbox that is read only, $(cashvariable) so it would look like this inside the editbox: $100000 (default value for the cash, unsigned long) Can anyone help me?
-
How do I load a variable inside an edit box? I have an edit box stated below, its called "OnCash", It's ID is "IDC_CASH". Source: ---------------------------------------------- void CTycoonDlg::OnCash() { //$cash(variable) } ---------------------------------------------- I want it to say in the editbox that is read only, $(cashvariable) so it would look like this inside the editbox: $100000 (default value for the cash, unsigned long) Can anyone help me?
You need to create a variable for the value of the edit box do this by going to the resource viewer right click on the dialog select "Class Wizard" click on the Member Bariables tab select IDC_CASH and click Add Variable name it something like m_Cash then to set the text in it do this m_Cash = "$1000000"; UpdateData( TRUE ); // sets the edit boxes text to m_Cash's value to get the edit boxes text and store it in m_Cash call UpdateData( FALSE );
-
You need to create a variable for the value of the edit box do this by going to the resource viewer right click on the dialog select "Class Wizard" click on the Member Bariables tab select IDC_CASH and click Add Variable name it something like m_Cash then to set the text in it do this m_Cash = "$1000000"; UpdateData( TRUE ); // sets the edit boxes text to m_Cash's value to get the edit boxes text and store it in m_Cash call UpdateData( FALSE );
Problem is: I already made a value, and It's being read all across the program, im just trying to sorta make an active display in the MFC application on how much money I have... It's an edit box, displaying how much cash you have. This is part of the source: #include "stdafx.h" #include "Tycoon.h" #include "TycoonDlg.h" #include "BUY.h" #include "SELL.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif unsigned long cash = 100000; But Class Wizard makes a new variable, and I want to use my old variable.
-
Problem is: I already made a value, and It's being read all across the program, im just trying to sorta make an active display in the MFC application on how much money I have... It's an edit box, displaying how much cash you have. This is part of the source: #include "stdafx.h" #include "Tycoon.h" #include "TycoonDlg.h" #include "BUY.h" #include "SELL.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif unsigned long cash = 100000; But Class Wizard makes a new variable, and I want to use my old variable.
just delete the wizard-made variable and use your own. You will need to rename the variable in DDX macros section too. Jaime
-
just delete the wizard-made variable and use your own. You will need to rename the variable in DDX macros section too. Jaime
I did that and this is how it shows up, 100000, I added a command which increases the value by 1, ak,; cash++. I hit the button, and it shows up as it has been changed in the list box, but not the edit box. The List Box's purpose is to show changes, like if you buy a car, it will say you lost $10,000, and the edit box display's how much money you currently have, and updates accordingly... If I delete the preset in the DDX section it turns into -858993460, and so i deleted it being set in the begining of the file where it says unsigned long cash = 100000; to long cash. (I changed the unsigned part also) The two problems are that 1. The edit box doesn't update. 2. The edit box doesnt have a $ before the number, how do i do that? Thanks alot for your help. Here is how the source beginning is: ------------------------------------------------------------------------- #include "stdafx.h" #include "Tycoon.h" #include "TycoonDlg.h" #include "BUY.h" #include "SELL.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif long cash; unsigned int day = 01; unsigned int month = 01; unsigned int year = 04; unsigned int chp; unsigned int mhp; ///////////////////////////////////////////////////////////////////////////// // CTycoonDlg dialog CTycoonDlg::CTycoonDlg(CWnd* pParent /*=NULL*/) : CDialog(CTycoonDlg::IDD, pParent) { //{{AFX_DATA_INIT(CTycoonDlg) cash = 100000; //}}AFX_DATA_INIT m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CTycoonDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CTycoonDlg) DDX_Text(pDX, IDC_CASH, cash); //}}AFX_DATA_MAP } -------------------------------------------------------------------------