|
CInt is a vb6 function used to convert a string to a 16 bit integer.
Use int atoi( const char *string );
|
|
|
|
|
oops, I got it wrong...No such thing as a CInt... Funny
Thanks alot for the help anyways.
|
|
|
|
|
atoi(outcome); // this would convert the string to an int.
in my programs i have used something like this for edit boxes.
CString ticket1conversion;
ticket1conversion.Format("%d",m_ticket1);//converts the int to a string
m_ticketcontrol.GetWindowText(ticket1conversion); // gets the value
// from edit box
int TicketHolder=0;
TicketHolder1 = atoi(ticket1conversion);
if (TicketHolder1==1)
{
...
}
Hope this helps. Some of the steps might not be needed but this is what works for me.
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
Ok i've converted the string to an int, but its not working as I planned..
What i've done is created a few buttons for a calculator.
Theres a string, and every time you click on a button a value is added to the end of the string. For example if you click a button with 5 on it, the code would be StringOutcome += "5".
I thought you may be able to do things like addition as well, so if you pressed 9 then + then 4, StringOutcome would be "9+4". If, in turn you converted this to an int it should see it as 9+4, therefore as 11. Only problem is that its not working like that... Its just displaying the first number you press.
Can anyone shed light on what is happening, and any kind of way around it?
|
|
|
|
|
Blue Pyre wrote:
If, in turn you converted this to an int it should see it as 9+4, therefore as 11. Only problem is that its not working like that
its not a problem, it will not work like that... Its a logic error. When the user clicks on +,-,/ or * you convert the string and store it in another variable and the operation to be performed like +,-,etc then take the second no also from the user. Now add/sub/mul/div the two no.
basically you need 2 seperate inputs and one operation input.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Just curious why are you using a string to begin with when your dealing with Integers? What I would do is this
you have your buttons number0-number9.
I would make an edit box which I assume you have done and give it a control variable of m_outvalue of type CEdit.
Also make you some variables:
bool minus; // true or false for minus button pushed
bool plus; // true or false for plus button pushed
int m_total; // integer value to hold the calculated value
Then click on the button say button 1 and it will make OnButton1();
void CCalculatorDlg::Onnumber1()
{
if (!minus && !plus)
m_total=1; // if neither the plus or the minus is pressed you add 1
if (plus)
{
m_total=m_total+1; // if plus was pressed add one to total
plus=false; // set the bool back to false
}
if (minus)
{
m_total=m_total-1; // if minus was pressed deduct one from total
minus=false; // set the bool back to false
}
CString TempString; // your temp string holder
TempString.Format("%d",m_total); // converts int to string
m_outvalue.SetWindowText(TempString); // outputs string to edit box
}
void CCalculatorDlg::Onplus()
{
plus=true; // turn the plus bool on for addition
m_outvalue.SetWindowText("+"); // display the plus sign in your edit box
}
void CCalculatorDlg::Onminus()
{
minus=true; // turn the minus bool on for subtraction
m_outvalue.SetWindowText("-"); // display the minus sign in your edit box
}
void CCalculatorDlg::Onnumber2()
{
if(!minus && !plus)
m_total=2; // if the minus or plus is not pressed make total 2
if (plus)
{
m_total=m_total+2; // if plus was pressed add two to the value
plus=false; // set plus bool to false
}
if (minus)
{
m_total=m_total-2; // if minus was pressed deduct two from value
minus=false; // set the minus bool to false
}
CString TempString; // temp string holder
TempString.Format("%d",m_total); // convert int to a string
m_outvalue.SetWindowText(TempString); // display string in edit box
}
void CCalculatorDlg::Onequals()
{
CString TempString; // temp holder for string
TempString.Format("%d",m_total); // convert int to a string
m_outvalue.SetWindowText(TempString); // display string in edit box
}
I hope this helps you.
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
I have a question...
Im trying to develop a application but there one thing thats confusing me
How do you develop a application that uses windows forms in C++ .NET that will shutdown you computer?
|
|
|
|
|
See this[^] article, from the relevant parts. Refer to the source code for an example how to shut down a Windows OS.
If you are allowed to call unmanaged functions, use ExitWindowsEx in the Platform API. This will shut down Windows.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi ppl.
I have this c++ class and i want to make it available to my vb app.
I need a good COM tutorial. (Net is full of CRAP).
All methods in my class are static.
Thx.
|
|
|
|
|
How can I get the dimension of the secondary display in windows xp?
GetSystemMetrics(SM_CXSCREEN) and GetSystemMetrics(SM_CYSCREEN) give me the primary screen dimension, but there is no way I can get the secondary display with GetSystemMetrics.
I can get all the virtual display dimension with SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN parameters, but this do not solve my problem.
Any tips?
Regards
Bernardo Faria
|
|
|
|
|
Hi
What is correct procedure for sending F5 key or left arrow key?
SendMesage(hwnd,WM_CHAR,?,?) or SendMesage(hwnd,WM_KEYDOWN,?,?)
Tomaz Rotovnik
|
|
|
|
|
Tomaz Rotovnik wrote:
What is correct procedure for sending F5 key or left arrow key?
None of these actually. Use keybd_event WIN32 API function instead. And if you are using Windows 98 or later, use SendInput for this purpose.
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|
|
|
I have a control I created from a CWnd that contains an edit control and a button.
What I am trying to do is allow a user viewing a screen with this control and other controls to tab through the controls. When the custom control containing the edit control and the button gets focus I want the focus to go to the edit first and then the button when tab is pressed again.
I can make it give the edit control focus but when I hit tab again my custom control loses focus and the button does not get focus.
Any suggestions or examples would be appreciated.
|
|
|
|
|
Does the button follow the edit control in the z-order?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Yes, it does.
Thank you for your response. I did a little more research and found the answer to my riddle. I used PreTranslateMessage() to capture the tab button being pressed and then I set focus to the child controls of my control accordingly.
|
|
|
|
|
Hi,
I recently started learning pure C++ and want to know what does "rhs" mean?
For example:
class MyClass
{
public:
MyClass& operator=(const MyClass& rhs);
};
I've investigated that "rhs" is frequently-used in operator overloaders in C++ classes. What is "rhs"? May I use another word (for example, "dog") instead "rhs"?
Sorry for stupid question.
Yours sincerely,
Alex Bash
|
|
|
|
|
rhs = Right Hand Side. And yes, you can use anything you want, but rhs is normally used because it does a good job of describing the fact that the parameter will be on the right hand side of the = sign.
Tim
|
|
|
|
|
hi,
"rhs" is just the name of the input parameter, you can also use "cat" if you want, but only if you like cats
Have a nice day!
hph
|
|
|
|
|
Hi !
I need to design a class that will encapsulate an ActiveX object (a chart control). I want to put these files (the .h and the .cpp files) in a library common to all of my projects so I can reuse this class.
The problem is that the files for the ActiveX object need to be in the project directory (I use Add To Project->Components and Control to add the ActiveX to my project).
Is there a macro that I can use like the following way:
#include "CURRENT_PROJECT_DIRECTORY\CChart.h"
in order to access the current project directory from a file within my library ??
The files for the ActiveX cannot be copied in the library. Any idea ??
|
|
|
|
|
Hello,
can someone tell me the meaning of the SYNCHRONIZE flag which can be used in OpenProcess ?
Thanks in advance!
|
|
|
|
|
This flag allows you to use the process handle in any of the wait functions to wait for the process to terminate. BTW, it is available in Windows NT/2000 or later only.
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|
|
Hi there
I am in need for the following information.
1. Any specific link where i can find info for writing Device-Drivers on Win NT.
2. Link where PCI bus access on Win NT is explained.
thanks in advance...
Bhaskar...
___________________________
When a thing is new, people say, "It's not true." Later, when its truth becomes obvious, people say, "It's not important." Finally, when its importance cannot be denied, people say, "Well, it's not new."
|
|
|
|
|
Hey there everyone,
I am a new member of the forum and relatively new to MFC. What I like to know how to create a graphical background and button.
If anyone can gave a specific example or link that will help, it will be very apperciated.
Thanks,
|
|
|
|
|
See if either of these help:
http://www.voidnish.com/articles/ShowArticle.aspx?code=bmpdlg01
http://www.flounder.com/bitmapbutton.htm
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|