|
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)
|
|
|
|
|
Hello all!
I have a project designed with the MFC document/view architecture. In the App idle time I read some data from a data source (I call a function of my doc class). This data will be displayed in a chart.
But I need also to make some computation on this data but I want to make this in a separate thread (the computation take some times and it cannot stop the reading of the data).
When I start the new Thread, I pass a pointer to my document so it can access data and the data will be stored in a buffer (FIFO buffer).
I was wondering if this is safe to do such a thing ?
Something like that:
BOOL CMyAppDoc::idle()
{
pFIFOBuffer->AddData(Data);
}
And in the thread function:
pMyDoc->ComputeData();
void CMyAppDoc::ComputeData()
{
while (TRUE)
if (pFIFOBuffer->GetData(Data))
ProcessData(Data);
}
Thanks
|
|
|
|
|
Some tips:
You must use code to protect multiple multithreading access to any shared data, like critical sections:
CRITICAL_SECTION cs;
InitializeCriticalSection( &cs );
...
EnterCriticalSection( & cs );
shared data access
LeaveCriticalSection( & cs );
You can also use Event primitives to signal end processing, like: CreateEvent, SetEvent, ResetEvent and WaitForSingleObject.
Good luck
GuimaSun
www.nexsun.com.br
|
|
|
|
|
Thanks !
Yes I think I will use the critical section, that's easy to use and fit perfectly with my needs.
Thanks
|
|
|
|
|
Hi,
I want to put in a site links that would start my application. Something like yahoo has in the profile pages:
ymsgr:sendIM?yahoouser
I know how to make a handle that will send the call to my app using something like myapp:command?parameter but what do I have to do in my app to catch that command and get the parameter?
Thanks
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
Hi
I would like to palce a check mark for menu item, if user clicks a menu item. I would like to do this from CMainFrm class.Can u please give me an idea?
Thanks
JP
|
|
|
|