|
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
|
|
|
|
|
Yes, and that is desirable in a lot of cases. Of course, if you used std::vector, you could write a function object and greatly simplify the deletion of your pointers from your container. Just one reason to use STL over CArray.
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
|
|
|
|
|
? What kind of scheme are you thinking about (just curious)?
PS: Of course I'm with you in preferring STL over CArray , but you already knew that
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Just a function object that calls delete, combined with for_each. Nothing fancy.
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 was looking into using the STL Vector template. But I read somwhere that compiling the STL with VC++ (I'm using the .NET version, but writing unmanaged code) gives a lot of warning, and because of compliance issues the MS compiler has problems with STL.
However, I also recall from some time ago that Dinkunware is the supplier of the MS STL library, however, doesn't the latest version of Dink, compile fine in VC++?!?!
But let me reevaluate my current design I may still switch over to "vector" if it greatly eases writing code and maintainence.
Code4Food
----
"There is no try; only do or do not"
-Yoda
|
|
|
|
|
Code4Food wrote:
But I read somwhere that compiling the STL with VC++ (I'm using the .NET version, but writing unmanaged code) gives a lot of warning, and because of compliance issues the MS compiler has problems with STL.
Um... no. The warnings you can get rid of with a pragma, and I doubt they exist in VC.NET, they have made major improvements to their STL implimentation. The major problem VC has is partial template specialisation, which STL does not rely on.
Code4Food wrote:
However, I also recall from some time ago that Dinkunware is the supplier of the MS STL library, however, doesn't the latest version of Dink, compile fine in VC++?!?!
Dinkumware learned to write an STL implimentation by providing one in VC6, and then made a fortune out of selling one that fixed all the bugs they wrote the first time around. I don't know if Dinkum wrote the newer STL in VC.NET, but it is overhauled and improved, not least being the addition of a hash_map.
Code4Food wrote:
But let me reevaluate my current design I may still switch over to "vector" if it greatly eases writing code and maintainence.
If you can still do that, I would certainly encourage it. I have written several STL articles on CP, as have others. That should get you pointed in the right direction. www.sgi.com/tech/stl ( from memory ) is the best online source of STL docs.
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
|
|
|
|
|
Christian and Joaquin I just want to say thank you to the both of you for your help and excellent advice. I currently evaluating my first project and think I can implement it without drastic changes.
The only thing I may have concern with is the reason I think I chose CArray is the built in Serialization support for MFC (I know MFC please don't look down upon me ) But if that was the case it must really be really lazy for me not to go out and just right my own file i/o function for the class... But as I get older I get lazier
Code4Food
----
"There is no try; only do or do not"
-Yoda
|
|
|
|
|
Code4Food wrote:
(I know MFC please don't look down upon me )
*grin* I did MFC work for about 18 months. I don't think it's ALL terrible, but the container classes were only ever written as a stopgap while the STL came to VC.
Code4Food wrote:
But as I get older I get lazier
Choosing the best solution is half the problem, but the best solution should be the one which will work best, and hopefully that means it provides the most built in support. That's the reason I recommend STL - I'm too lazy to write my own functions for sorting, etc.....
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
|
|
|
|
|
How can I do do for using it in a structured project ?
Best Regards
youssef
|
|
|
|