|
I am writing a dialog based application with menus. Trying to place a check on a menu item using
pCmdUI->SetCheck(1);
in the UPDATE_COMMAND_UI message handler function, it has no effect. Doing the same thing in a SDI application works fine. Am I doing something wrong? and suggestions? I am using VC++ 6.0.
Thanks
Joseph Colosi
|
|
|
|
|
|
Managing memory (leaks and overwrites) was quite easy when were using plain C.
We just had to define malloc(size) and free(ptr) to point to our own OurMalloc(size) and OurFree(ptr).
From that moment on we could add wonderful stuff to OurMalloc and OurFree like pooling memory chunks, checking for overwrites (using red zones before and after the allocated areas), checking for leaks, even storing the call stack at the moment of the malloc so a decent memory leak could be reported at the end of the program.
Then came C++. This was a bit more difficult since we now also had to reroute the new and delete operator. But after some investigation we found out how to implement those operators to forward their calls again to OurMalloc and OurFree.
Then came MFC. MFC (we use the most recent Visual Studio .Net) does not like the redirection of the global new and delete. You get all kinds of nice linking errors and warnings and even if you succeed in compiling it, you're guaranteed to have run-time crashes because your own new and delete is used instead of the MFC ones --> BIG PROBLEM.
So we end up with our old plain C code using our own advanced memory manager, and the C++ code (using MFC) that uses the MFC memory manager.
That's not the only problem: once in a while, our defines of malloc and free causes problems if an external include file (of the compiler or a 3rd party) has a method free defined in a class and it is called in an inline method. Then our own OurFree is called instead of the class's free method --> BIG PROBLEM.
I tried to look up methods of using custom memory allocators but only find methods that can only be used in a debug version (e.g. malloc_dbg, _CrtSetAllocHook, DEBUG_NEW, ...) and no method that works in release executables as well.
What I want to obtain is the following:
Having a memory manager that performs memory pooling (in debug and release builds), checks for overwrites, leaks and reports the call stack for leaks (in debug builds). External tools like Purify often give rubbish output so that's not an option to check for leaks.
Having a memory manager that can be used for plain C calls (malloc,free) and C++ new and delete 'calls' with and without MFC.
Is there a good article on how to add a custom memory manager to C/C++/MFC?
Are there any good commercial or freeware or open source memory managers that perform these tasks and can be used with plain C, C++ and MFC?
Thanks for your input.
Enjoy life, this is not a rehearsal !!!
|
|
|
|
|
The question speaks for itself.
The function SetWizardButtons() does not have an option for
disabling the "Help" button which appears at the bottom of
the property sheet, after the "Finish" button.
Any ideas?
Have no fear of perfection - You will never reach it
|
|
|
|
|
From MSDN
Help in CPropertySheet is supported by the F1 key and the Help button only. The Help button appears in the application framework by default. No intervention by the user is necessary. When the user adds the help information for each of the pages inside the property sheet, the help mechanism automatically displays the help for that page when the Help button is clicked.
To remove the Help button from a property sheet, modify the sheet and all its pages as follows:
mySheet.m_psh.dwFlags &= ~PSH_HASHELP;
page1.m_psp.dwFlags &= ~PSP_HASHELP;
page2.m_psp.dwFlags &= ~PSP_HASHELP;
mySheet.AddPage( &page1 );
mySheet.AddPage( &page2 );
mySheet.DoModal();
The m_psh variable is of type PROPSHEETHEADER. The m_psp variables are of type PROPSHEETPAGE. If all the HASHELP flags are clear (PSH_HASHELP for the property sheet object, PSP_HASHELP for the property pages), the property sheet will be created without a Help button.
Michael
'Logic, my dear Zoe, merely enables one to be wrong with authority.' - The Doctor: The Wheel in Space
|
|
|
|
|
I get 11 for e_mcause in
if(!cRed.Open("E:\\red64.txt", CFile::modeRead,&e))
{
int h = e.m_cause;
}
the file exists in the dir. I searched in the vc folder for the 'cfileexception' to get the enumerated consts but it was only in .lib and .pdb files, but found it in:
appdefs.h which doesnt list my 11 (hex B).
#define DS_E_FILENOTFOUND 0x8004A004
#define DS_E_ENDOFFILE 0x8004A005
etc.......
Where do I find out what the error code is?
Thanks,
ns
|
|
|
|
|
m_cause is really only for backwards compatibility with 16-bit versions of MFC. It's a translation of the OS error code that can be found in m_lOsError (translated by CFileException::OsErrorToException ).
Code 11 maps to CFileException::sharingViolation (see AFX.H).
I worked this out by reading the source to CFile::Open in FILECORE.CPP , which is the usual technique for figuring out what MFC's up to. If you don't have the MFC source installed, install it from your Visual C++ or Visual Studio CDs.
|
|
|
|
|
Great! Thanks for the info!
I pointed my Open to another dir which has a copy of the same file, and it finds it there, even though the file is sitting in the original location I had Open pointing to. I dont know what I have done to the file that makes the exception happen in the original dir, i.e. how the sharing violation is happening.....
thanks,
ns
|
|
|
|
|
How do you resize a CListCtrl?
m_ctrlList.SetWindowPos(&CWnd::wndTopMost,0,0,cx,cy,SWP_SHOWWINDOW|SWP_DRAWFRAME);
I've also tested with SWP_NOCOPYBITS and SWP_FRAMECHANGED, but no change.
The listctrl is visible with the initial dimensions, but resizing doesn't seem to work.
Anybody with some help?
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
setting NULL for z-order ... and it works.
sorry for me being to fast with posting this question.
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
what is NNTP Addresss of this forum
|
|
|
|
|
|
|
My understanding of "isdigit()" is that it takes a parameter and checks whether it's a digit. It will then return true or false depending on what the parameter value turns out to be.
Fair enough, I constructed my "if" statement based on this understanding, only to find out that the opposite is what's happening. Here's some code.
string str;
int nbr = atoi(str.c_str());
...
if(isdigit(nbr))
else
Prior to reaching the "if" statement, "nbr" is assigned a numeric value (by making sure that 'str' is numeric), but instead of doing the digital processing, it does the error reporting routine. Interestingly, if I were to test for "!isdigit(nbr), it does the digital processing. (But then why would it do the digital processing if nbr is not numeric?)
Why is this? Am I using "isdigit()" wrongly?
Thanks for any insight.
William
Fortes in fide et opere!
|
|
|
|
|
isdigit() takes a character value, not an integer.
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1.4 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Then how come <ctype> and <ctype.h> defines it as:
int isdigit(int c);
William
Fortes in fide et opere!
|
|
|
|
|
Because passing char's as parameters tends to cause problems.
Just try it
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1.4 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
OK! I did try it. I substituted 'nbr' for a 'char' value and ran the program, and even though I entered a numeric value, the program crashed!
It didn't crash when I was using 'nbr' instead.
William
Fortes in fide et opere!
|
|
|
|
|
isdigit() tests whether a character is a digit. Pass in a char , not an int . The parameter is defined as an int because all the functions that operate on characters are defined that way. Yes, it's weird. (The reason is that EOF is -1, which is outside the range of char , so they had to use a larger type instead.)
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Laugh it up, fuzzball.
|
|
|
|
|
I need to convert CSV file into an Excel Sheet. Can I have suggesstions or article where can I get the information.
Thanks in advance
Warm Regards,
KKR
|
|
|
|
|
Assuming through code, just use the Excel COM object and tell it to open the csv file. Then tell it to save as Excel file.
|
|
|
|
|
There are two ways:
1.Using ODBC Excel driver which is available on all Windows PC's even without M$ Office installed, neither on your nor your user's PC.
For an example see this:
http://www.codeproject.com/database/excel_odbc_write.asp[^]
2.Using Excel automation, requires Office both on you and your user's PC
See Adam's message above, and MSDN for Office automation.
Peter Molnar
|
|
|
|
|
Hi lads, i have a challenging question for you all:
I'm using ReadDirectoryChangesW to monitor the file usage in the system.
Then i'm using the CFile constructor to (GetLenght, GetStatus, GetFilePath, etc) extract the file's informations.
I need a way to find the file physical address... address on the hardisk!!!
Your help is very much appreciated....
Ade
|
|
|
|
|
ReadDirectoryChanges uses a FILE_NOTIFY_INFORMATION struct to give you the paths of changed files.
FILE_NOTIFY_INFORMATION fni[100];
while (ReadDirectoryChangesW(...,&fni,...)
{
if (fni[0].Action == ...added || fni[0].Action == ...removed || fni[0].Action == ...Modified)
DoSomethingWhenAddedRemovedOrModified(..);
for (int i = 0; !fni[i].NextEntryOffset; i++)
ShowFileName(fni[i].FileName);
}
Peter Molnar
|
|
|
|
|
Hi peter,
thanks for your help, i know how to find a file path,
i just want to know how to find the files physical location / address in main memory (hardisk)!!! example
Sector 123542 Lenght: 3 Block ( or whatever unit: cluster / sector / block / etc )
anyone else ??? !!!!
|
|
|
|