|
I'd recommend Stroustrup's book on C++ (title "The C++ Programming Language"), one of his first examples is a calculator which reads numbers and expressions from the input and shows one way to parse it and extract numbers, symbols, labels etc..
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
have a look at boost's lexical cast[^]
The underlying implementation uses string streams (which is pretty slow) so you could do something similar yourself if you dont want to use their library
something along the lines of this...
<br />
stringstream ss;<br />
string input;<br />
int value;<br />
<br />
try<br />
{<br />
ss << input;<br />
ss >> value;<br />
}<br />
catch(cant remember exactly what is thrown)<br />
{<br />
}
|
|
|
|
|
start everything out using a char varable
char number[100]
then us a static_cast<int>
to turn it in to a int if the user enters a charcter they going to get sumthing crazy but other then that you could use if or catch statements
|
|
|
|
|
Gregory Bryant wrote: start everything out using a char varable
char number[100]
then us a static_cast
to turn it in to a int if the user enters a charcter they going to get sumthing crazy but other then that you could use if or catch statements
What ?? Are you kidding ? You mean you want to use a static_cast on the char array to convert it to an integer ? Oh man, that is just plain wrong.
|
|
|
|
|
Please don't answer questions until you know the answers. This is just plain wrong on so many levels.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I am just once again posting the question which I have posted a couple of days back. Of course, it hasn't attracted any member attention, but I am just posting again now with a hope that some members may respond. I assure you all that I don't bother and abuse this forum again by repeating the same question. Kindly understand.
Shanmukha
Hi,
I have a problem with one of my Doc-View Application. In fact, I am novice in doc-view apps. I have a CFormView based SDI app coded in Visual C++ 6.0 environment. The user interface has three modeless dialogs embedded in a CTabCtrl, One ChartCtrl and CListCtrl. I observed a funny behaviour while opening a stored document (not Word document) by double clicking on it. The view is not getting updated correctly. But if I open the the file by File-> Open command, every thing working fine.
Let me explain a bit about how I coded the app for better comprehension.
1. The document has a user defined class which handles the serialization on its own (based on Ravi Bhavnani code).
2. The List control paints its contents using NMCustomDraw feature.
3. By digging into the code I could find that OnNewDocument() function is not getting called while opening tha App from Shell (i.e. by double clicking on the file), instead the OnOpenDocument() is called. And all other Doc->DeleteContents() and Serailization, View->IntialUpdate() and View->OnUpdate() working OK but the List Control not getting updated.
4. But if you open the file by File ->Open command, since the SDI app gets started with a new document every thing looks OK.
5. Same is the case by opening with command line Start-> Run-> MyApp xyz.tnf .
6. I found even the OnCustomDraw() function getting called.
7. I then tried to get into the undocumented DocManager classes etc. but I couldn't get much help. Even opening file from the Shell, I find App gets one empty document. This I got confirmed with DocManager class other functions.
Finally what I could find is that, the View and Document connection in the low level framework is at fault.
I would be grateful for any help in this regard.
I remain,
Shanmukha
|
|
|
|
|
why the bellow code doesnt make CTreeCtrl lables trasparent?
the same method works fine for CListCtrl
SetBkMode() also if i uncomment it doesnt make lables trasparent
lables r painted with black color background instead of trasparent
butif i use any other color other than CLR_NONE or TRASPARENT .. it will paint with the color i used properly but doesnt work with trasparent.
help me plz
please some one give me solution
void CLeftPaneTreeCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
switch(pNMHDR->code)
{
case NM_CUSTOMDRAW:
{
LPNMTVCUSTOMDRAW lplvcd = (LPNMTVCUSTOMDRAW)pNMHDR;
//SetBkMode(lplvcd->nmcd.hdc,TRANSPARENT);
lplvcd->clrTextBk = CLR_NONE;
if(lplvcd->nmcd.dwDrawStage == CDDS_PREPAINT)
{
*pResult = CDRF_NOTIFYITEMDRAW;
return ;
}
if(lplvcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
{
*pResult = CDRF_NOTIFYPOSTPAINT;
return;
}
}
}
}
|
|
|
|
|
If you have a look through last week's postings on this forum, you will find a few questions about transparent tree controls, backgrounds and labels.
You can ignore the questions by George_George, so that will save you 50% of the effort.
(Just because he didn't ask it...)
Iain.
Iain Clarke appearing by Special Request of CPallini.
|
|
|
|
|
Iain Clarke wrote: You can ignore the questions by George_George, so that will save you 50% of the effort.
|
|
|
|
|
Hi,
I want to know the difference between the classes CToolBar & CToolBarCtrl
Thanks in advance
sairam
|
|
|
|
|
sairam madem wrote: I want to know the difference between the classes CToolBar & CToolBarCtrl
Ctrl.
Ok, more seriously... If you look up the controls in MSDN, you'll find that CToolbarCtrl is a thin wrapper around the common controls TOOLBAR window class. CToolbar is a warpper around CToolbarCtrl that makes it play nicely with MFC features like automatic state updating, docking windows, etc.
Iain.
Iain Clarke appearing by Special Request of CPallini.
|
|
|
|
|
Hi all..
I am new Visual studio 2006...I am including library file(.lib)file..whenever i restart the program i need to add the .lib file again..can anyone help...
I am going in Project,then to properties.then i go in Linker...CommandLine and include the lib file..plz can anyone help me...
I no its a silly question..
Thanks in advance
Hi,,
I am sharan.Working as a software Engineer in Indo-Fuji Software Company located in BTM Layout.Bangalore.India.
I have Completed my B.E(COmputers)in 2006.ANd I am having 2 years of Exp in VC++.
thanking you
sharan
|
|
|
|
|
vsproperty->linker->input->additional dependencies
|
|
|
|
|
add the .lib path to : Project / Properties / Linker / Input . Additional Dependencies.
|
|
|
|
|
sharanu wrote: I am new Visual studio 2006...
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Don't tell me you didnn't get it. He is the new Visual Studio, David.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Actually it is rather old: they forgot to put it on the market before and now it's a special bargain.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
I have to extract a few character from CString.
My CString is like this...
Here i have to get the number of Lbl..I mean 10.
My code is
CString sTemp = {"Tag-10,OnOff-19,Switch-5,Lbl-10,Signal-22,trip-1"};
int pos = sTemp.Find("Lbl-");
Here i get the pos value as 25,then i want to get the character after Lbl- (ie) 10.
How can i get ?Pls help me.
Anu
|
|
|
|
|
|
is this useful,
CString sTemp = _T("Tag-10,OnOff-19,Switch-5,Lbl-10,Signal-22,trip-1");
int pos = sTemp.Find(_T("Lbl")) + 3;
CString resToken;
resToken = sTemp.Tokenize(_T("- ,"),pos);
if (resToken != "")
{
int num = _ttoi(resToken);
};
|
|
|
|
|
That goes against OP title.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
modified on Tuesday, February 05, 2008 8:41:55 AM
|
|
|
|
|
may be more, but i think it covers what it needed
|
|
|
|
|
What? No solutions that use GetBuffer()??
I am shocked and appalled.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Only for you, to keep horror alive
strok(sTemp.GetBuffer(), "Lbl-");
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Ahhh yes - the world is balanced again.
And bonus points for using the little-known strok() function hehe
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|