|
Why are you asking this on the C++ forum, having found out how to do it in C# ? Is it a bad enough problem to change languages over ?
In C++, you have some functions called ::isalpha and ::isalnum. If the first returns false and the second returns true, you have a number. These functions take a character, not a string. You need to use these functions to parse your strings, then use atoi on the strings that you've verified have only numbers, or built to have only numbers.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
thanks a lot for your answer?
i hope you have found your answer?
r00d0034@yahoo.com
|
|
|
|
|
imran_rafique wrote:
thanks a lot for your answer?
You're welcome.
imran_rafique wrote:
i hope you have found your answer?
Yes, thanks. I asked a couple of questions a day or so ago, got some pointers, looked them up in the MSDN and all is well with me. Good luck with your project.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
I am afraid that you have to write your own function,test the left side of your string,if it's not a integer or a "+" or "-",trim it off,and then use the function "atoi" to convert the remainder string to integer.
|
|
|
|
|
Can someone explain what does it mean by saying "ascii coded hex"?
Does it mean treating 0x1000 as each single character '1' '0' '0' '0'
thanks
|
|
|
|
|
peter ho wrote:
0x1000
"0x1000" is 'ascii coded hex'.
1984 : that is ascii coded decimal
0001010101 : that is ascii coded binary
'ascii coded hex' means : 'the number has been printed in hexadecimal form'.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
hey, i just have a plain project created by the MFC app wizard, and i'm trying to get a CTabCtrl working, i tried followinf the help...
1. Define the control in the view or window class.
2. Call the control's Create member function, possibly in OnInitialUpdate, possibly as early as the parent window's OnCreate handler function (if you're subclassing the control). Set the styles for the control.
but whatever i do it just comes up with a debug assertion failed, any ideas/advice ? thanks,
luke
|
|
|
|
|
Hi
I want to display time according to Windows settings. I tried this:
strftime(pString, nStringSize, "%#c", tmtime);
but it haven't done what I want, date is formatted in english (not in my windows language) and also don't look like my date settings. Thanks in advance for any hints.
Mariusz Popiolek
|
|
|
|
|
Check out ::GetLocaleInfo( ) and the LOCALE_SLONGDATE LCTYPE.
If you are using MFC then I suggest you check out COleDateTime::Format( ) as well.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Im trying this code in a dialog with only a button when you push it this code is executed:
void CBorradlgDlg::OnButton1()
{
OPENFILENAME ofn;
char szFile[512];
char title[]="Title openfilename";
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = GetSafeHwnd();
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "Object\0*.obj\0All\0*.*\0Text\0*.TXT\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
ofn.hInstance=0;
ofn.lpstrCustomFilter=NULL;
ofn.nMaxCustFilter=0;
ofn.lpstrTitle=(LPSTR)title;
ofn.nFileOffset=0;
ofn.nFileExtension=0;
ofn.lpstrDefExt=".obj";
ofn.lCustData=0L;
ofn.lpfnHook=NULL;
ofn.lpTemplateName=NULL;
if(GetOpenFileName( &ofn ) != TRUE)
{
DWORD Errval=CommDlgExtendedError();
switch(Errval)
{
case CDERR_DIALOGFAILURE: AfxMessageBox("CDERR_DIALOGFAILURE "); break;
case CDERR_FINDRESFAILURE: AfxMessageBox("CDERR_FINDRESFAILURE "); break;
case CDERR_NOHINSTANCE: AfxMessageBox("CDERR_NOHINSTANCE "); break;
case CDERR_INITIALIZATION: AfxMessageBox("CDERR_INITIALIZATION "); break;
case CDERR_NOHOOK :AfxMessageBox("CDERR_NOHOOK "); break;
case CDERR_LOCKRESFAILURE: AfxMessageBox("CDERR_LOCKRESFAILURE "); break;
case CDERR_NOTEMPLATE: AfxMessageBox("CDERR_NOTEMPLATE "); break;
case CDERR_LOADRESFAILURE: AfxMessageBox("CDERR_LOADRESFAILURE "); break;
case CDERR_STRUCTSIZE: AfxMessageBox("CDERR_STRUCTSIZE "); break;
case CDERR_LOADSTRFAILURE: AfxMessageBox("CDERR_LOADSTRFAILURE "); break;
case FNERR_BUFFERTOOSMALL: AfxMessageBox("FNERR_BUFFERTOOSMALL "); break;
case CDERR_MEMALLOCFAILURE: AfxMessageBox("CDERR_MEMALLOCFAILURE "); break;
case FNERR_INVALIDFILENAME: AfxMessageBox("FNERR_INVALIDFILENAME "); break;
case CDERR_MEMLOCKFAILURE: AfxMessageBox("CDERR_MEMLOCKFAILURE "); break;
case FNERR_SUBCLASSFAILURE:AfxMessageBox("FNERR_SUBCLASSFAILURE "); break;
}
}
}
Debug version throws CDERR_INITIALIZATION error
Release version works fine
where is the error?
Im using XP VC6 SP5
Thanks.
|
|
|
|
|
oh my God what a silly bug some hours later i find the solution , there was an uninitialited variable
char szFile[512]<big>=""</big>;
|
|
|
|
|
Hi ya'll,
I'm using MFC and I've got a class 'CMyComboBox' that I've derived from 'CComboBox'.
When I subclass a combobox that was created from a dialog template resource, all messages that were intended for the combobox's original windproc go through my message map now . I can at my discretion pass them along to the original windproc. I'm fine with all of this behavior so far.
Now let's suppose the user clicks the drop down arrow. A 'WM_LBUTTONDOWN' message comes through my message map FIRST. Now suppose that I ignore it and pass it along to the original windproc, and it determines that it's time to drop down the list box portion of the combo. A 'CBN_DROPDOWN' notification message is sent to my PARENT window (the dialog, a CWnd based dialog), SKIPPING my message map entirely. Also suppose the dialog's message map has no handler for this notification so it is reflected back to the combobox. ONLY THEN does my message map get a chance to handle this notification message .
I want my CMyComboBox classes message map to receive the notification messages from the original combobox's windproc BEFORE they go to the parent window. AND what if the parent window handles the notification instead of just reflecting it?? Then 'CMyComboBox's message map will never know ???
does anybody know a way to receive notification messages from a subclassed window WITHOUT relying on reflection.
Part of my motivation is to port the control into an ATL activeX, and I'm not sure if the CWindow base class has all the same reflect functionality as MFC's CWnd base class.
thanks,
nebbish
Smart, Sexy, Sane. Pick two.
|
|
|
|
|
Maybe having a look at MFC source code can shed some light on how reflection is implemented in this framework --then maybe you can just replicate the method.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hi,
i was wondering how do you call updateallviews() from a dialog class? i'm working on a sdi(listview) program and i created a dialog for user to input information.. once the information is submitted, the information entered from the dialog is suppose to be transfer and display on the sdi(listview). can someone give me an example? thx..
|
|
|
|
|
There are several solutions. You may pass the dialog class a pointer to the doc class and class UpdateAllViews(NULL). Another solution is to send a message to mainframe or view and call OnDraw().
Kuphryn
|
|
|
|
|
I want to know the algorithm used to make a string from an integer, double, etc., to a string and the other way around.
Does anyone know this algorithm, I need to use this, because I'm making a garbage collected (Boehm-Weiser) string wrapper for use with TCHAR.
Thanks in advance,
Sjoerd van Leent
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
Maybe you can have a look at the source code for itoa and related files.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Logical, but I need to have the source files to do that, as far as I know, these files are all libraries, that's kinda problem.
Sjoerd van Leent
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
Maybe it depends on the installation, but at leat in mine the source code is under Microsoft Visual Studio/VC98/CRT/SRC
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You're right, I can find it. I looked it somewhat and made my own code doing it.
I've just finished the String to Integer algorithm.
int String::ToInteger(String string)
{
size_t index = 0;
bool leadSpace = true;
bool isValue = true;
bool minus = false;
int value = 0;
try
{
while(leadSpace)
{
TCHAR tcRet = string.GetCharAt(index);
if (((tcRet < TEXT('0')) || (tcRet > TEXT('9')) ) &&
(tcRet != TEXT('-')) && (tcRet != TEXT('+')))
{
index++;
}
else
{
leadSpace = false;
}
}
TCHAR tcRet = string.GetCharAt(index);
if (tcRet == TEXT('-'))
{
minus = true;
index++;
}
else if (tcRet == TEXT('+'))
{
index++;
}
while (isValue)
{
TCHAR tcRet = string.GetCharAt(index);
if (tcRet >= TEXT('0') && tcRet <= TEXT('9'))
{
int hold = (int)tcRet - (int)TEXT('0');
value *= 10;
value += hold;
index++;
}
else
{
if (minus)
return -value;
else
return value;
}
}
}
catch (Exception ex)
{
throw (ex);
}
return 0;
}
this is the code I'm using now to do it (if someone likes it, just use it) I'm now working on ToDouble, ToBoolean (easy!), ToUnsignedInteger, etc...
Sjoerd van Leent
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
I have a class that I put into a CArray object in another class. For example:
<br />
Class Person {<br />
<br />
CString FirstName;<br />
CString LastName;<br />
};<br />
<br />
Class Group {<br />
CArray<Person, Person&> Members;<br />
};<br />
<br />
int main()<br />
{<br />
...<br />
Group* Something=new Group;<br />
...<br />
(Add somethings into Members)<br />
...<br />
delete Group;<br />
}<br />
Is it OK to delete Group? Or should I loop through the CArray as well and delete any, and all objects added to it? I tried just the above method and I don't get a memory leak in VC++ but for some reason I don't feel all too comfortable with the above method.
TIA for any answers.
Code4Food
----
"There is no try; only do or do not"
-Yoda
|
|
|
|
|
It's OK: CArray takes care of deletion of its contained elements.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Whew! Thanks for the quick reply. For some reason it just didn't feel "right". Felt as if I was leaving something behind.
Code4Food
----
"There is no try; only do or do not"
-Yoda
|
|
|
|
|
Please note that you'd have to do the cleanup yourself should you have an array of pointers instead of actual objects.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Ahhh... That's probably why I don't get a memory leak error. I add actual objects and not pointers. I bet if I did it via pointers I probably would get the elusive "memory leak" error in VC++.
Code4Food
----
"There is no try; only do or do not"
-Yoda
|
|
|
|