|
The function you are looking for is GetCheck()
it returns one of BST_UNCHECKED , BST_CHECKED or BST_INDETERMINATE
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Now I get...
c:\Projects\Simple Wizard\WC_Wizard.cpp(295): error C2039: 'GetCheck' : is not a member of 'CWnd'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(1913) : see declaration of 'CWnd'
|
|
|
|
|
Why not break the code down into easier to read lines:
CButton* pButton = (CButton*)GetDlgItem(IDC_MY_RADIO1);
ASSERT(pButton != NULL);
if (pButton->GetCheck() == BST_CHECKED)
{
}
It always helps to breakdown the code.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
first, a made an error on the function, but someone else correct the mistake for me.
secondly, GetCheck() is a member of CButton, not CWnd...
if stdafx.h is included into your project, you shouldn't encounter such error (C2039).
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
You are missing an open bracket at the start of the if statement.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Antony M Kancidrowski wrote:
You are missing an open bracket at the start of the if statement
correct... and corrected
but you understood what i would like to explain, isn't it ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I would like to set the listcontrol so that items (in the first column) *cannot* be selected. This can be done in a listbox, but is there any way to fix a listcontrol to behave this way ?
Thanks in advance,
Raymond Mercier
|
|
|
|
|
Hey,
Well a short question realy.
What does the ^ do in C++?
example:
int number = 0;
number ^= 1;
the output for number is 1. When in math would be 0.
Thanks.
humpa humpa
|
|
|
|
|
^ is the bitwise exclusive-or operator
SO :
0x1100
^ 0x1010
-----------
= 0x0110
that's why
number ^= 1;
means
number = number ^ 1;
means
number = 0 ^ 1; // == 1
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I see. Thanks for your quick answer.
humpa humpa
|
|
|
|
|
http://www.codeproject.com/cpp/bitbashing.asp[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Hi,
I'm using the following code to try to get a double variable from an edit box, but I keep getting an error: c2660
<br />
double x=0;<br />
CString strx;<br />
......<br />
<br />
for(int i=0;i<K,i++)<br />
{<br />
::GetDlgItemText(IDC_WELLRAD,strx);
x=atof((LPCTSTR)strx);<br />
...<br />
}
How can I fix this error, please? what is HWND hdlg??
|
|
|
|
|
aaadetos wrote:
what is HWND hdlg??
Is the handle to the dialog window.
Assuming you are running this code in a CDialog derived class.
You could try something like this:
HWND hWndDlg = GetSafeHwnd();
You can then use this to get the handle to the control.
HWND hWndCtrl = ::GetDlgItem(hWndCtrl, IDC_WELLRAD);
Then use the control handle with GetWindowText()
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
I'm sorry. Please see the revised code: i meant to type: GetDlgItemText , not GetDlgItem . the function in which I'm using GetDlgItemText is not in the CDialog class. How would I use GetSafeHwnd() then?
|
|
|
|
|
The easiest way is to have a pointer to your dialog class within the class that you have the code.
Header file
CMyDialog* m_pMyDialog;
CPP file
HWND hWnd = m_pMyDialog->GetSafeHwnd();
etc...
IMPORTANT: Note that you need to set m_pMyDialog to point at your dialog class before using it.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
CString strEdit;
((CEdit*)GetDlgItem(IDC_MY_EDIT))->GetWindowText(strEdit); TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
You do not need to cast to CEdit as CWnd will do
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
[Perplexed!]
I already tried to do the following:
<br />
{<br />
...<br />
CString strx;<br />
CDialog *pDialog;<br />
<br />
pDialog -> GetDlgItemText(IDC_WELLRAD,strx); <br />
x = atof((LPCTSTR)strx);<br />
...<br />
}
and toxcct's code as well. The first gave an ASSERT error while the other gave an unhandled exception in mfc42d.dll, in wincore.cpp ->C:\...\MFC\SRC\WINCORE.CPP at the line *** below:
<br />
HWND hWnd = ::GetDlgItem(m_hWnd, nID);<br />
if (hWnd != NULL)<br />
{<br />
int nLen = ::GetWindowTextLength(hWnd);<br />
::GetWindowText(hWnd, rString.GetBufferSetLength(nLen), nLen+1);
rString.ReleaseBuffer();<br />
}<br />
I'm trying to get the value of an edit box for use in a function outside CDialog, which would carry out computations on the value entered by a user. I don't understand why i get these errors.
|
|
|
|
|
aaadetos wrote:
I'm trying to get the value of an edit box for use in a function outside CDialog, which would carry out computations on the value entered by a user.
The function in which you are getting the Text is outside CDialog??
|
|
|
|
|
Yes, it is. The text: numerical data of type double, is to be used as a variable in a math computation in a function outside of CDialog.
|
|
|
|
|
If what i understood is correct ...
you are doing like this....
void CXDialog::Function1()
{
SomeOtherClassObj.YourMathFunction();
}
void CSomeOtherClass::YourMathFunction()
{
GetTheText();
//TODO
}
Think you have to pass the dialog pointer to your function outside the dialog class...
like...
void CXDialog::Function1()
{
SomeOtherClassObj.YourMathFunction(this);
}
void CSomeOtherClass::YourMathFunction(CDialog *pDialog)
{
pDialog -> GetDlgItemText(IDC_WELLRAD,strx);
x = atof((LPCTSTR)strx);
//TODO
}
Or get the Edit control text inside the Dialog class which contains the control and pass the text to your math function...
Hope this will help you ....
|
|
|
|
|
Thanks a lot Dreamz...
I actually decided to add a member function to my dialog's class, viz:
<br />
double CKuchukDlg::getrw(double x)<br />
{<br />
CString strx;<br />
<br />
GetDlgItemText(IDC_WELLRAD,strx);<br />
x = atof(strx);<br />
<br />
return x;<br />
}
i then used the function in my math function, to get the value of the edit box:
<br />
void bessk0(double *x,double *k0,int nSize);<br />
void bessk1(double *x,double *k1, int nSize);<br />
void ei(double *x, double *expi, int nSize);<br />
<br />
void unbound(double *unbd, int nSize)<br />
{<br />
enum{nSize = 100};<br />
double A[nSize],B[nSize],k0[nSize],k1[nSize],s[nSize],expi[nSize],a[nSize],b[nSize];<br />
<br />
<br />
double x=0;<br />
s[0] = 1;<br />
a[0] = x*sqrt(s[0]);<br />
b[0] = 2*sqrt(s[0]);<br />
<br />
bessk0(a,k0,nSize);<br />
bessk1(a,k1,nSize);<br />
ei(b,expi,nSize);<br />
<br />
A[0] = k0[0]/(x*sqrt(s[0])*k1[0]);<br />
B[0] = (1-exp(-2*sqrt(s[0])))/(2*sqrt(s[0]));<br />
<br />
unbd[0]=0.5*(A[0]-B[0]-expi[0]);<br />
<br />
<br />
CKuchukDlg MyClass;<br />
MyClass.getrw(x);<br />
x = MyClass.getrw(x);<br />
<br />
for (int t=1;t<nSize;t++)<br />
{<br />
<br />
s[t] = 2*t*PI;<br />
a[t] = x*sqrt(s[t]);<br />
b[t] = 2*sqrt(s[t]);<br />
<br />
bessk0(a,k0,nSize);<br />
bessk1(a,k1,nSize);<br />
ei(b,expi,nSize);<br />
<br />
A[t] = k0[t]/(x*sqrt(s[t])*k1[t]);<br />
B[t] = (1-exp(-2*sqrt(s[t])))/(2*sqrt(s[t]));<br />
<br />
unbd[t]=0.5*(A[t]-B[t]-expi[t]);<br />
}<br />
}
While the code compiles without error, i still obtain a debug assertion failure in wincore.cpp!!
Is there a better way of calling my getrw(double x) in my math fxn without having this problem?
Thank you.
|
|
|
|
|
aaadetos wrote:
CKuchukDlg MyClass;
MyClass.getrw(x);
x = MyClass.getrw(x);
You have got a dialog displayed already from where you get the Edit control' text.That is an existing instance of the class CKuchukDlg.You have to use the same instance for further operations.
Here what you do is,you have created an instance of CKuchukDlg.But no Dialog window is there for the paticular instance.And you are trying to get the Text from the Edit control.There is no such window to get the Text from.So you are getting the assertion failure.
This why i asked to use "this" poiter.
If you are calling "unbound(double *unbd, int nSize)" from your dialog class
pass the pointer of your "Current Dialog Window" to the function.
void unbound(double *unbd, int nSize,CDialog *pDialog)
{
........
//x = MyClass.getrw(x);
x = pDialog->getrw(x);
........
}
You can call the function like this...
SomeObj.unbound(x,y,this);
Better you can pass the Text from the edit control itself to the function.
void unbound(double *unbd, int nSize,double DataFrom_getrw)
{
........
//x = MyClass.getrw(x);
x = DataFrom_getrw;
........
}
|
|
|
|
|
In your code
CDialog *pDialog;<br />
<br />
pDialog -> GetDlgItemText(IDC_WELLRAD,strx);
you have not assigned a value to pDialog after declaring it and before using it.
pDialog must be assigned as a pointer to your dialog.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Antony M Kancidrowski wrote:
You do not need to cast to CEdit as CWnd will do
i know, but i prefer a most "understandable" code than one that works, but which you cannot debug...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|