|
Hello,
BaldwinMartin wrote:
so I am not really sure why my answer is wrong
There is nothing wrong with your answer!
But I disagree with that straight C is easier to learn. It is indeed faster and more reliable (if you know how to handle C) than MFC, but Doc/View Arch is ersier to learn. Since in C you'll have to do all the error handling yourself, in MFC this is done by the 'junk'.
Besides that, I rather maintain an application of 20 classes than an application of 500 api calls. But that's up to each individual to decide.
So if size and speed don't matter, I prefer the object oriented approch.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
MFC is not an own language.. it's an extension(additional classes etc)... u get the sys info via C API, NOT MFC!!!
better check if there's nothing wrong with u!
Don't try it, just do it!
|
|
|
|
|
Hello
There seem to be a barrier, perhaps it is language, it this is the case I bow to you as your multi-language skills are much better than mine. However one thing that transends all language is when a person being is being rude just for the thrill of hurting someone. I am afraid you fall into the latter.
Your response is so far off base I don't know where to start, but allow me to speculate.
1. Your home life is unsatisfactory.
2. You are abit of a recluse.
3. Friends seem to slip away.
I say these things not to hurt, rather to help. Seek some counciling, before you are to old or too far gone to be helped. Either way leave the newbies alone, they need help not your attempt at witt.
Please when you see my responses do not reply, I have several childern I am already responsible for.
|
|
|
|
|
I have the following line of the code where I am deleting the spaces after the last char. How do I delete the spaces before the char?
string.erase (string.find_last_not_of (" ") + 1 ) ;
|
|
|
|
|
i don't know how to do so using STL, but generally, u increase the pointer to the string by one for every space at the beginning of the string(but don't forget, if the string is allocated memory, you'll have to use the original pointer to free it)!
Don't try it, just do it!
|
|
|
|
|
Use the string "replace()" function.
string.replace(sp, n, rc);
where "sp" = starting position
"n" = number of characters to replace
"rc" = the replacing character
For example, if you have:
string str = "xxxABC";
str.replace(0, 3, "");
string str = " ABC";
str.replace(0, 5, "");
William
Fortes in fide et opere!
|
|
|
|
|
How to display VC++ .NET style MessageBox using Visual C++ 6? I am using VC6. I need to display the Windows XP style MessageBox in my project. I don't know how to do it. It is easy to modify dialog box to XP style. But I couldn't figure out how to modify the MessageBox.
Please help me.
Thanks a lot
Bin
|
|
|
|
|
I am writing a scientific program that uses multiples threads to separate the GUI from the scientific simulation. I am using the CRT library so I am using the _beginthreadex() routine to start the "worker" thread. The problem is this: every once in a while (it is not reproducible, I have worked weeks on coming up with a reproducible situation but have never been successful) the _beginthreadex() routine will return NULL. When I check the error using GetLastError(), it states that there is not enough memory to run the thread. Once this error occurs, the thread cannot be started and the program must be restarted before it will successfully start the thread. When this error occurs the system is not out of memory and the program is not using much memory itself (as evidenced by the Windows task manager. This is an extremely frustrating problem for me and the other people that use this program. Has anyone had any similar experiences and can point me in the right direction for handling this problem.
Thanks,
Jay
|
|
|
|
|
Anonymous wrote:
as evidenced by the Windows task manager
Are you absolutly sure of this? How much virtual memory is your process using? You may have run out of address space. Or have a highly fragmented address space such that there is no free block that is 1 MB to allocate a stack.
John
|
|
|
|
|
Because I want to plug-in my own specific memory/heap manager, I need to overrule the global new and delete operators, and the global malloc and free functions.
What is the best way to do this?
Simply overrule these 2 operators and 2 functions or do I need to overrule other functions as well?
Is there a good explanation or documentation in the MSDN somewhere on how to do this?
Apparently, the standard C run time library only allows some additional checking hooks, but I want to plug in my own complete memory/heap manager, not only perform some additiona checks. Also these additional checks only work in a debug version, not in a production version.
If I need to overrule more functions, how can I be guaranteed that this isn't depending on the version of the compiler (Visual Studio .Net, 7.1 in my case)?
Thanks.
Enjoy life, this is not a rehearsal !!!
|
|
|
|
|
you could try to overwrite it... i coded a c++ framework for kernel mode(i didn't have to overwrite the new/delete operator, cause there is none) and it works fine, also with different compiler versions.
Don't try it, just do it!
|
|
|
|
|
Hi all,
I had created a cab file for a MFC control so I can load on Internet Explorer. Whenever I click on the control is always output a message telling me this control is not safe. Is there a way I can turn it off and assume my control is safe??
Thanks
|
|
|
|
|
aglcic wrote:
Is there a way I can turn it off and assume my control is safe??
First thing is to implement the IObjectSafety interface in your control.
To help with implementing IObjectSafety and other helpful info read the MSDN Safe Initialization and Scripting for ActiveX Controls[^] article.
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
Hi,
I have a full server/container MFC app. I'm trying to serialize the embeded OLE objects in an independent file (e.g. I don't want my document file to save the ole objects, I want them in a separate one). This is what I'm doing:
//SAVE OLE OBJECTS
CFile fil( "test.ole", CFile::modeWrite | CFile::modeCreate );
CArchive ar( &fil, CArchive::store );
COleServerDoc::Serialize(ar);
(...)
//LOAD OLE OBJECTS
TRY
{
CFile fil( "test.ole", CFile::modeRead );
CArchive ar( &fil, CArchive::load );
COleServerDoc::Serialize(ar);
}
CATCH( CFileException, e )
{
(...)
}
END_CATCH
It seems that the file was properly saved, but when I try to load it, I get a debug assertion when COleServerDoc::Serialize(ar) is called.
What am I doing wrong?
Thanks,
|
|
|
|
|
I fix it, these two lines did the trick:
m_bCompoundFile = false;
ar.m_pDocument = (COleDocument*)this;
|
|
|
|
|
Hi all
i am using the below code to call a http post, this is what someone has given me, which i have ammended but its chucking me out an error on these two lines
pFile->AddRequestHeaders("User-Agent: GetWebFile/1.0\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
BOOL bOK = pFile->SendRequest();
can ne1 see where im going wrong
thanks
si
CString mob = argv[1];
CInternetSession is(_T(NULL));
CHttpConnection* pConn = NULL;
CHttpFile* pFile = NULL;
CString str_url = "http://62.232.41.434/Opera2003/Opera.asmx/";
CString str_path = "Receive?service=447781474224&Phone=447790775894&Message=Thank you for telling us your problem, we will look into what you’ve told us and take action if necessary. We are here to help you.&UserID=&Password=&UserData=&ContentType=0";
pConn = is.GetHttpConnection(str_url, (INTERNET_PORT)INTERNET_INVALID_PORT_NUMBER, NULL, NULL);
pFile = pConn->OpenRequest("POST", str_path);
pFile->AddRequestHeaders("User-Agent: GetWebFile/1.0\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
BOOL bOK = pFile->SendRequest();
ULONG nStatus = 0;
pFile->QueryInfoStatusCode(nStatus);
|
|
|
|
|
Hi,
I need to allocate memory for a large buffer (between 1 to 100 MB) in the RAM for a relatively short period (for recording data in an extremely high rate from USB2).
The problem is that i need to force the operating system NOT TO USE SWAPPING / PAGING on that buffer. This means that the whole buffer must be physically allocated in the RAM, and NOT in the hard disk.
does anybody know how to do that?
Programming language: C++
OS : windows 2000/xp
Tanks,
Oren.
|
|
|
|
|
Use VirtualLock, but you'll need to call SetProcessWorkingSetSize first to reserve so large buffer. A few problems though: you may not always get such large buffer, and if you get your machine will not run other programs nicely. Also you need admin or equivalent rights to call SetProcessWorkingSetSize.
|
|
|
|
|
Felix, Thanks!
I have just finished reading about these functions in the MSDN (the trick is to find them), and then I received your mail.
So, Thanks anyway!
Another small question:
the SetProcessWorkingSetSize function accepts the process's handle, and the arguments dwMaximumWorkingSetSize dwMinimumWorkingSetSize.
In what units are the last 2 arguments presented (bytes, or number of pages) ? if they represent number of pages, how do I get the size of each page in bytes?
Regards, Oren.
|
|
|
|
|
oren frenkel wrote:
In what units are the last 2 arguments presented (bytes, or number of pages) ? if they represent number of pages, how do I get the size of each page in bytes?
From memory - bytes. To get page size use GetSystemInfo.
|
|
|
|
|
|
Also do not let the application minimize. Windows will reduce the workingset to 2MB if the application is minimized.
John
|
|
|
|
|
Thank you very much! This is the exact kind of tip that i cannot get in the MSDN.
By the way - if the window is in the background (not in focus - another application is in focus) - does the same thing happen?
Does it also happen when the computer is being locked, or when in idle for a long time (for instance - the user starts recording data in a cyclic buffer, and leaves the computer idle for 30 minutes).
More important - if i set the working set to 64 MB, and allocated a 64 MB buffer and locked it, and only AFTERWARDS the user minimizes the window - does this also happen?
regards,
Oren.
|
|
|
|
|
oren frenkel wrote:
This is the exact kind of tip that i cannot get in the MSDN.
I found this out the hard way. I have an application that digitizes mamograms. A case of 4 images can be as much as 256MB. The digitizer only has a buffer to hold about 1/2 of an image so if you don't read the data in a 20 to 30 second period it will overflow. Well if the user pressed the minimize button the whole application thrashed for atleast that time and we got an overflow of the buffer and the pc had 512 MB of memory with almost atleast 150MB free. This was tested on NT4 and I believe Win2k but I have not tested it recently. Anyways this was because when the application minimizes the working set is trimmed. I did verify that was indeed what was happening on these operating systems.
oren frenkel wrote:
if the window is in the background (not in focus - another application is in focus) - does the same thing happen?
No. Only when the application is minimized. My solution was to not let the application minimize only during digitization.
oren frenkel wrote:
More important - if i set the working set to 64 MB, and allocated a 64 MB buffer and locked it, and only AFTERWARDS the user minimizes the window - does this also happen?
Yes. It would happen there too.
John
|
|
|
|
|
John - thanks for your time and effort!
Since my application has to record data in an extremely high speed from USB 2 (only graphics are the progress bar and status window) - I migh bypass the problem by running the engine on a different process (it now runs on a different thread). At the worst case - I will not enable the user to minimize the window during recording.
Thanks again,
Oren.
|
|
|
|