|
Could you please restate more clearly what it is you want to do?
Do you want it to calculate the answer without having to click on the button?
|
|
|
|
|
i will select first on one of the radio buttons then by clicking on the command button which has a caption "compute" c++ will give an answer and it will be displayed in the second editbox.
|
|
|
|
|
So you want it to give a different answer depending upon which radio button is chosen?
|
|
|
|
|
yes sir if supposing i will select the first radio button which is "cash (10 % discount)" the calculated amount is the amount of the "enter tuition fee editbox1" * .90 since 10% will be deducted to the tuition fee. If radiobutton2 is selected "two payments (5% interest)" the calculated amount is the amount of the "enter tuition fee editbox1" + 5% interest. Please sir help me on this problem.
neil
|
|
|
|
|
All you have to do is use the GetCheck() function:
if ( radiobutton1.GetCheck() == BST_CHECKED )
{
}
if ( radiobutton2.GetCheck() == BST_CHECKED )
{
}
|
|
|
|
|
i will try this one sir...thank you very much for the help
neil
|
|
|
|
|
<big>thank you very much</big> chard your code solve my problem. I posted this problem because i dont have the sample code on how to connect the radiobutton to the command button. Spider and chandru never gave me the sample code to solve my problem.
here is now my code in c++
void CTuition1Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData();
if ( m_button1.GetCheck() == BST_CHECKED )
{
m_edit2 = m_edit1 * .9;
UpdateData(false);
}
if ( m_button2.GetCheck() == BST_CHECKED )
{
double x;
x = m_edit1 * .05;
m_edit2 = m_edit1 + x;
UpdateData(false);
}
if ( m_button3.GetCheck() == BST_CHECKED )
{
double x;
x = m_edit1 * .10;
m_edit2 = m_edit1 + x;
UpdateData(false);
}
UpdateData(false);
}
if its not for your code I cannot solve it...thank you very much
do you have ym sir chard?
i would like to ym you if i have a problem on programming and i wish that you will still help me.
Once again thank you...
neil
|
|
|
|
|
Hi all,
I am converting two floats to LPTSTR and trying to concatenate them. I have tried _tcscat, StringCbCatW, lstrcat, and lstrcatW. With all of these methods, after concatenation, I am only getting the value in "message" but not the concatenated part of "message1". And the application that uses this file (dll) crashes after showing the first part.
Can someone please suggest something? Any help is appreciated.
Here is a part of the code:
float a = 45.670;
float b = 2323.78;
LPTSTR message = TEXT("");
LPTSTR message1 = TEXT("");
std::stringstream sstr;
sstr << a;
std::string str1 = sstr.str();
message = (LPTSTR)str1.c_str();
std::stringstream sstr1;
sstr1 << b;
std::string str2 = sstr1.str();
message1 = (LPTSTR)str2.c_str();
_tcscat(message,message1);
//StringCbCatW(message,BUFSIZE,message1);
//lpvMessage = lstrcatW(message,message1);
|
|
|
|
|
akhanal wrote: And the application that uses this file (dll) crashes after showing the first part.
Can someone please suggest something? Any help is appreciated.
Because message does not point to any allocated memory that is large enough. Why not do something like:
float a = 45.670;
float b = 2323.78;
std::stringstream sstr1;
sstr1 << a;
std::stringstream sstr2;
sstr2 << b;
std::string str = sstr1.str() + sstr2.str();
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
That was great, it worked.
Thanks, appreciate your help.
|
|
|
|
|
I'm using a custom entry point.
instead of winMainCRTStartup=>WinMain, I'm using my own AppBoot().
Too make the exe a little leaner.
I've got custom new and delete and don't use exceptions.
That's all great.
But when I start using double and math funcs like sin(),
I get the above error.
my linker subsystem is windows and I have a custom entry point.
So I'm guessing one or some of the math funcs are pulling in mainCRTStartup??
Not sure why it'd pull that instead of the WinMainCRTStartup??
Anybody run into this before?
Thanks,
...Steve
|
|
|
|
|
Hi.
I want to name subgroups in regex:
For example, if I would use .Net it would be like this:
using namespace System::Text::RegularExpressions;
...
Regex^ re="(?<letters>[a-zA-Z]*)(?<numbers>[0-9]*)";
MatchCollection^ matches = re->Matches(szInput);
for each (Match^ match in matches){
MessageBox::Show(Match->Groups["letters"]->Value);
MessageBox::Show(Match->Groups["numbers"]->Value)
}
Can I do the same thing in MFC using Boost::Regex libraries?
|
|
|
|
|
I try to use Modal & Modeless dialog to show WARNING within 2 seconds as the following:
CDialog *dlg;
dlg = new CDialog;
int id = dlg->Create(IDD_DIALOG_MESSAGE, this);
dlg->ShowWindow(SW_SHOW);
Sleep(2000);
dlg->DestroyWindow();
But it always appearing under the other Window dialog, even I remove the comment out as parent, but it doesn't help
Any one know how to do it?
|
|
|
|
|
Try with BringWindowToTop[^]. However, freezing your GUI thread for 2 seconds (leaving it completely unresponsive and undrawn) isn't such a good idea, you could try bringing your window up and then removing it later using a timer (WM_TIMER)...anyways, if you insist on the sleep you might need to explicitly redraw [^] your warning window before the sleep.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Why not just use a modal dialog that automatically closes itself after 2 seconds?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Can you provide any link how to show it in 2 seconds?
|
|
|
|
|
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Dear everybody,
I have a question about the meaning of & operator in the following expression:
((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
1) What role does the & operator do here ?
2) Why do programmers often use & with hexadecimal, not integer or long integer or double ?
I'm looking forward to seeing your reply soon.
Best regards,
Jetflower
|
|
|
|
|
Thang wrote: 1) What role does the & operator do here ?
Bitwise AND.
Thang wrote: 2) Why do programmers often use & with hexadecimal, not integer or long integer or double ?
Bits, bytes, and words are easier to visualize in base-16.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Okay, lets say that l = 3131961357
This is the same as 0xBAADF00D
Which is the same as 10111010101011011111000000001101
Which means your expression looks a little something like this:
((WORD)(((DWORD)(0xBAADF00D) >> 16) & 0xFFFF))
3131961357 >> 16 = 47789
0xBAADF00D >> 16 = 0x0000BAAD
10111010101011011111000000001101 >> 16 = 00000000000000001011101010101101
47789 & 65535 = 47789
0x0000BAAD & 0x0000FFFF = 0x0000BAAD
00000000000000001011101010101101 & 00000000000000001111111111111111 = 00000000000000001011101010101101
Basically, the code simply takes a 32 bit number and returns the top (most significant) 16 bits of them.
The >> 16 followed by the & 0xFFFF is unnecessary - the bitshift right 16 bits automatically fills the top 16 bits with 0s.
This code is functionally the same:
(WORD)((DWORD)(l) >> 16)
See how much easier things are when we use hex/binary?
Edited && --> &
|
|
|
|
|
We're lucky that
0XDEADBEEF != 0XBAADFOOD
This signature was proudly tested on animals.
|
|
|
|
|
|
Dear Mr enhzflep and Mr DavidCrow,
First of all, thank you so much about your clearly explanation.
I just still have a consideration, why the small expression (& 0xFFFF) has been still used in the expression ((l) >> 16) & 0xFFFF) here .
And this expression origins from window library, hix.
Why they still have used this expression if it was not necessary in here ?
Once again, thanks for your help, Mr enhzflep and Mr DavidCrow.
Best regards,
Duong Quoc Thang
|
|
|
|
|
Hi,
I'm trying to place a slider control (CSliderCtrl) on the status bar. The slider bar appears fine and I can move it around (either manually or by calling SetPos). However, I can't find where the WM_HSCROLL messages from the slider bar are sent to! I set the parent of the slider control to the status bar, but no WM_HSCROLL is sent to that window! Any ideas?
Here's what my code looks like. First off, I derived a class from CStatusBar to handle WM_HSCROLL:
class CMyStatusBar : public CStatusBar
{
public:
DECLARE_MESSAGE_MAP()
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
};
In my view class (e.g. CMySimpleProjctView) I added two members:
CSliderCtrl videoPosSlider;
CMyStatusBar statusBar;
and also a function called InitSliderBar() which is something like this:
void CMySimpleProjctView::InitSliderBar()
{
CMainFrame* frame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
statusBar = (CMyStatusBar*)(frame->GetStatusBar());
RECT rc;
statusBar->GetItemRect(0, &rc);
VERIFY (videoPosSlider.Create(WS_CHILD | WS_VISIBLE, rc, statusBar, 1));
videoPosSlider.SetRange(0, 50, 1);
videoPosSlider.SetPos(5);
}
When I run the program, the slider bar appears and I can move it around, but CMyStatusBar::OnHScroll() is not called when I move the slider. To test if everything else is fine, I changed the parent of the slider control to the view window in the code as
VERIFY (videoPosSlider.Create(WS_CHILD | WS_VISIBLE, rc, m_hWnd, 1));
and now CMySimpleProjctView::OnHScroll *is* called (but of course the slider bar appears at the wrong place, not on the status bar). I tried Spy++ to see where the WM_HSCROLL is sent to (when parent=status bar) but no WM_HSCROLL is sent at all! In fact no messages are passed when I move the slider around!!
Any ideas? thanks.
-Babak
(by the way, videoPosSlider.GetOwner() and videoPosSlider.GetParent() both return pointers that are identical to statusBar)
|
|
|
|
|
Hello,
I'm maintaining an MFC application that reads and writes from/to the registry. Previously, it used the HKEY_LOCAL_MACHINE key. However, this meant that Vista users needed full OS administrative privileges, (and perhaps non-admin XP users, but there aren't a whole lot of those around) which isn't desirable. So, I changed the key used to HKEY_CURRENT_USER. This just appears to not work at all on Vista as a regular user, though it does work elsewhere.
How can I store values in the registry without administrative privileges?
Regards,
Sternocera
|
|
|
|