|
You might have better luck posting this question in the C++/CLI forum.
|
|
|
|
|
When I compile my program, this is the error I get:
Compiling...
test proj.cpp
c:\program files\microsoft visual studio 8\vc\include\time.h(6) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
it is a simple program without any errors, is there anyone that knows how I can fix this?
|
|
|
|
|
Easiest fix would be to create a new header file in your project called "stdafx.h".
You could make it blank, just as long as it is there.
|
|
|
|
|
good day,
here is my problem on how to link the commandbutton to radio buttons (mfc) in c++:
i inserted 3 radiobuttons inside a groupbox with a caption "Mode of payments";
radio1 with a caption "1. Cash (10% discount)";
radio2 with a caption "2. Two payments (5 % interest)";
radio3 with a caption "3. Three payments (10% interest);
i also have two editboxes; editbox1 and editbox2.
1. with a static text "enter tuition fee:" value will be accepted in the first editbox.
2. with a static text "Your total tuition fee is:" will be displayed in the second editbox.
and one command button with a caption "Compute"
supposing i will select the second radio button which is "two payments (5% interest)" upon clicking
the command button "compute" the result should be displayed in the second editbox under "your total tuition
fee:" which is the computation on the value of the first editbox and on the second radiobutton and so on...
if i will not use a commandbutton "compute" caption (to do the calculation) i can do the code and get the right result by
calculating the value of the first editbox and on the radiobutton values, but when i will use commandbutton to do
the calculation on the value of the first editbox to the radiobuttons that is now my problem since i cannot link the radiobuttons
and the commandbutton...
Please anybody help me in solving this problem...i need sample code as guide in solving this problem and on my future related
projects...
code experts please help me...
thank again and thank you in advance...
neil
|
|
|
|
|
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.
|
|
|
|