|
First of all, I'd like to thank you and the forum for your time, learning somthing is much easier when you can ask directly from someone who knows about what your trying to learn.
Regarding CStrings, I noticed a BSTR type in ATL and gave it a try by:
STDMETHODIMP CFirst_ATL::.... (BSTR *strTemp)
{
*strTemp = "Hello World";
...
return S_OK;
}
error: cannot convert from char[6] to unsigned short*
I also can't find a variable type for a character (char MyChar for VC).
I think there's additional method regarding BSTRs, got to look for it.
MFC dll seems OK as I tried it just a few hours ago with simple application but haven't tried it yet when passing a string and other var types. I'll give ActiveX a try, i've seen a lot of .ocx ready for download because that's what my partner been using in his programs, but his using a pre-created .ocx from the internet and I never thought that it can also be created in VC.
Thanx again
|
|
|
|
|
Hi
I have a problem with a certain application which causes a runtime library error. This error is not frequently shown, the program can run about 3+ weeks non-stop, working perfectly .. sometimes it only lasts about 2 weeks.
When it crashes, i get an runtime error :
Microsoft Visual C++ Runtime library
Runtime Error !
Program: myprogram.exe
abnormal program termination
'OK'
I want to catch c++ runtime librarys errors and avoid having to click on the 'OK' button. The program is build in release-mode, so i don't understand why i still get that message. I thought this would only happen on debug-programs.
The program should crash & close yes, but not show any dialog. We monitor the program frequently & rerun the program automatically if necessary.
I know i should find the error first, but i shouldn't swear neither
Best regards,
Jens
|
|
|
|
|
Check how much memory is your application consuming while executing.
Check every day, Is it only incremental. Eventually your system will run out of memory and in some place you might have allocated memory (which failed) and written at that location which currupted certain memory area which is throwing that error.
or
you need you have a good logging info generated to figure out why and where it is failing.
-prakash
|
|
|
|
|
Hi,
i have already done that. The memory is not incremental, memory usages stays the same.
Catching std::overflow_error& exception, won't this catch the runtime exception and prevent the program from displaying the error?
Greetings,
Jens
|
|
|
|
|
The message looks to be getting generated via a call to "abort" which turns aronud and calls "_NMSG_WRITE". To change where this information gets logged, change the "__error_mode" to "_OUT_TO_STDERR" via a call to "_set_error_mode".
This will have to be done for the EXE and DLL that uses statically linked CRTL or just the EXE if everyone is linking dynamically to CRTL.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi, I want to customize FileOpen (CWinApp::OnFileNew), and FileSave dialogs such that they do not allow open or save files except spesific directory I give. Is it posisble to add this property?
|
|
|
|
|
You may need to derive a CXXXFileDialog from CFileDialog and show it by yourself when open or save.
Refer to MSDN's "CFileDialog". See the override functions. You can validate the path by overriding CFileDialog::OnFileNameOK() etc.
To handle open, you must write your own CXXXApp::OnFileOpen(). In this funcion, you can show your "open file" dialog and call OpenDocumentFile() to open the document(s).
To handle save, you must override CDocument::DoFileSave(). Perform you save operation after the save file dialog.
I'm not sure if this meets your goal.
Lane
China
|
|
|
|
|
hello,
I will be very thankfull to you if you can give me a very simple demo project(SDI with doc/view support) in which, a view class is derived from CListView, only LVS_REPORT style is used and it contains some column. One Important thing I need there is if i double click an item in the row it becomes an editable box and i can enter a new string and when i say enter it should save the new string as itemtext.
I read most of the arti on codeproject but i couldn't make any head or tail of it.
Thanks a lot
Max I can give is 5 points and Regards from bottom of my heart.
|
|
|
|
|
|
karmendra_js wrote:
I read most of the arti on codeproject but i couldn't make any head or tail of it.
If that is the case, I'm curious what you would hope to glean from someone offering you a sample project that would, for all intents and purposes, look just like the code you'd see with a CP article.
How much of this project have you already completed? What specific piece do you need help with?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi
I just want to get a process Id from a Processhandle which has been opened with PROCESS_TERMINATE access . I tried methods like enumerating the processes and NtQueryProcessInformation . All these funtions are failing if the Process has been opened with the PROCESS_TERMINATE access . But if the Process is opened with any other access I am able to get the process id by using the above mentioned methods . I request you to help me in this regard
|
|
|
|
|
Hi,
I have got a good link for list control. but i am not able to make something as follows.
I need to have two columns items to be editable (by user) of 5 coloumns in a Report style list ctrl.
Also i am not able to select any row in list ctrl.
Tell me a solution purely in MFC.
thanks a lot
|
|
|
|
|
|
hey...
i am wrirtng data to a text file...including large values like 3000000...how to write these values to a file in form of exponents
thanks
karnal
|
|
|
|
|
|
FILE *f;
f = fopen("1.txt", "w");
if( f )
{
float fNumber= 3000000.0f;
fprintf( f, "%e", fNumber );
fclose( f );
}
c++;
|
|
|
|
|
how do i typecast a CString to TCHAR type?
|
|
|
|
|
Anonymous wrote:
how do i typecast a CString to TCHAR type?
there are many ways:-
#1 By TypeCast
(LPSTR)(LPCTSTR)CString Variable //return Char*
#2 By Using GetBuffer()..
CStringVar::GetBuffer() //return Char*
..............
Do your Work
..............
CStringVar::RelaseBuffer()
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
i dont think the first one works!?
u see,
here is my code:
strcpy((char *)cFilePath, ( LPCSTR )( LPCTSTR )RawFile.GetPathName() ) ;
where cFilePath is TCHAR type
anyideas?
|
|
|
|
|
i forgot to put up one more point,that is ,
in teh above 'strcpy' does compile,but only the first letter of the whole word gets copied!
the declaration for cFilePath is
TCHAR cFilePath[_MAX_PATH]
|
|
|
|
|
TCHAR is a char in ANSI/MBCS but wchar_t for Unicode. You are probably compiling for a Unicode build. The following would work fine in either configuration (that's what TCHAR macros are for):
TCHAR cFilePath[_MAX_PATH];
_tcsncpy(cFilePath, (LPCTSTR) RawFile.GetPathName(), _MAX_PATH);
cFilePath[_MAX_PATH-1] = _T('\0');
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
thank u sir .....
brilliant!!!!!
|
|
|
|
|
ThatsAlok wrote:
#1 By TypeCast
(LPSTR)(LPCTSTR)CString Variable //return Char*
This way is only for a const TCHAR*. That is, this address can only be read. It's not safe to write.
ThatsAlok wrote:
#2 By Using GetBuffer()..
CStringVar::GetBuffer() //return Char*
..............
Do your Work
..............
CStringVar::RelaseBuffer()
This is the standard way to get the address of the buffer. You should pass a max length for the buffer in GetBuffer(), and then the pointer can be written.
|
|
|
|
|
If you mean LPCTSTR or const TCHAR* (i.e., a pointer to a read-only string of TCHAR s):
CString sText = _T("This is a test");
LPCTSTR p = sText;
If you mean LPTSTR or TCHAR* (i.e., a pointer to a string of TCHAR s that you are allowed to modify):
CString sText = _T("This is a test");
LPTSTR p = sText.GetBuffer();
_tcscpy(p, _T("end of test");
sText.ReleaseBuffer(-1);
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
I use VS6. As I type in an object variable, VS6 provides me with a list of member variables and functions for autocompletion. But this list is outdated and doesnt take into account any new items added to the class. Is there any way to fix this?
|
|
|
|