|
|
Hi,
I'm very new to ATL and need your help. I am trying to create a com dll using ATL which should contain a tabbed control and each tab page should be able to contain many other controls (or a composite control). Please let me know how I can create a control like that. Also how do I interact with individual controls in each pages (how to initialize, modify, store etc).
Please give me some pointers or, a link to page which explains it in detail.
Thanks in advance
|
|
|
|
|
As the topic suggest, I was wondering how you could go about converting a CString to a CInt?
I'm basically making a basic calculator which when a button with 5 on it is pressed will do something along the lines of
<br />
outcome += "5";<br />
and so on until the user presses the equals button.
How could I make it convert the string outcome which is storing all the operations and numbers, convert into a CInt?
Thanks
|
|
|
|
|
Considering that there is no such class as CInt, it's nigh well impossible.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Pardon me, but what is a CInt ?
At least my MFC/MSDN/ATL reference does not know any such thing. Did you mean a normal integer ?
You should draw a quick schema of how a basic calculator works. Sketch an outline of the possible states your calculator can have, and all the possible ways to move from one state to another. For example, there is a 'neutral' state, from which you can press a button to move into 'entering a number' state. Take all possible ways into account, how a person could use a calculator, what buttons he/she might press. If you have a real calculator at hand, you can easily determine the possible routes.
But, this is all about designing your software. For the actual conversion, which you asked, you need to use the LPCTSTR -operator implemented in CString class. This gives you a pointer to a constant character buffer that efficiently represents the C-language version of the string. Then, depending if you have Unicode enabled, you can use the wide- or normal-versions of _atoi and _itoa routines that can convert a string representation of a number, e.g. "42341", into a number 42341, and vice versa.
As for the calculator itself, you need several CString objects and a few integers. The first one is bound to the actual text output (an edit box), and displays a formatted string looking like a calculator's output.
Then, the user interface of your calculator has buttons. Each of these buttons has a click handler. Basically, you need to implement each click handler (or a range handler) so, that it determines what button was pressed, and adds a raw number into a background number buffer accordingly.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
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 ??
|
|
|
|