|
It may or may not be causing this issue, but the stack has limited space, and allocating 100,000 TCHARs on the stack is not a good idea.
you should instead use
LPTSTR buffer = new TCHAR[100000];
file.read();
delete []buffer;
|
|
|
|
|
Thank you very much Bruck. I will try with that.
|
|
|
|
|
I create a SDI project with VC 6.0.
I have to put
#include "testView.h"
in the file MainFrm.cpp, since I need to link testView to a splitted window pane using
wndSplitter_horizontal.CreateView(0,0,RUNTIME_CLASS(CTestView),CSize(50,50),pContext);
However, the compiler complaint with the following lines.
d:\vc_project\test\testview.h(27) : error C2143: syntax error : missing ';' before '*'
d:\vc_project\test\testview.h(27) : error C2501: 'CTestDoc' : missing storage-class or type specifiers
d:\vc_project\test\testview.h(27) : error C2501: 'GetDocument' : missing storage-class or type specifiers
The error can be replayed easily by creating a SDI project and typing in the MainFrm.cpp file
#include "TestView.h"
i have had a look online, but found no solutions.
modified on Friday, January 7, 2011 9:18 AM
|
|
|
|
|
You should include TestDoc.h as well since CTestView depends on it. In my opinion, that should have been taken care of in the TestView.h file, to make it self supporting. But sometimes compilation speed is preferred over ease-of-use.
|
|
|
|
|
Thank you for your reply.
when I create a SDI project with AppWizard,
I notice there are lines in the testView.h file
public:
CTestDoc* GetDocument();
but there is no #include "testDoc.h". The program works fine though.
However,when I simply put the line
#include "testView.h"
into the MainFrm.cpp file the error message pops up.
I think the error message is suppose to occur in the former case.
|
|
|
|
|
The reason it works fine in the first case is because in all files where testView.h is included (test.cpp and testView.cpp in a standard project), testDoc.h is included before testView.h.
#include "testDoc.h"
#include "testView.h"
So the advice to include testDoc.h first, is correct.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
|
i want to use bitmap image on button of media player usig active x contol
in mfc application
|
|
|
|
|
|
Hi,
This question is more from the point of view of Threads than C/C++. I have a destroy() function which waits on a thread (lets say _monitor) through PR_JoinThread(). The problem is that the _monitor thread has various time-oriented operations such as read()/write() socket calls so it takes time to finish off before exiting. Hence the destroy() function due to this PR_JoinThread which waits on the _monitor to exit is hanging the process (my product creates around 80-90 such threads) for around 6-7 minutes. Can anyone tell me the way to avoid such a situation? Is there any way other than using PR_JoinThread?
Thanks.
|
|
|
|
|
I don't know the api you are using (PR_JoinThread, google gives me something like NSPR API, whatever that might be) but generally if you don't want your "waiter thread" to block, you could either poll the other thread's state time to time, going on with your regular business in the meantime, or have somekind of messaging implementing with which the thread you would be waiting for can signal towards the waiter that it has finished processing, e.g. if you are working with VC++ you could use PostThreadMessage to send a message towards your GUI thread. Could this help?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
>Nothing is free in the universe.<
|
|
|
|
|
Hi All,
Please let me know some hints to convert a hex value to a string..
Regards,
Spk521
|
|
|
|
|
Click here->[^]
I believe in LOVE AT FIRST SITE...
Bcoz I have loved my Mother...
even since I opened my eyes...(ICAN)
|
|
|
|
|
It depends what you mean by convert. Do you want the hex value to appear as hex in the string (e.g. 0x3739 --> "0x3739") or do you want to display it as characters (e.g. 0x3739 --> "79")?
I must get a clever new signature for 2011.
|
|
|
|
|
ys.. i need to convert hex to its corresponding ascii value...
|
|
|
|
|
Hi,
Please try this..
char str[] = "01-15-43-43-34-37-37-41";
char delims[]="-";
CString strAscii = _T("");
CString strModelN0 = _T("");
char *result= NULL;
result = strtok(str,delims);
while(result != NULL)
{
result = strtok(NULL, delims);
if(NULL != result)
{
strAscii.Format(_T("%c"),hexToAscii(result));
strModelN0 += strAscii;
}
}
char hexToAscii(char *Num)
{
char hex[10]= "0x";
strcat(hex,Num);
return strtol(hex, NULL, 16);
}
Regards,
Spidy
|
|
|
|
|
Thanks laj its working....
|
|
|
|
|
You missed the first number.
I must get a clever new signature for 2011.
|
|
|
|
|
in addition to his above example, if your hex is in some int type variable, you may try this also,
int k = 0x3739;
CString out;
while(k > 0) {
out += (char)k % 0x100;
k /= 0x100;
}
strrev(out.GetBuffer(0));
cout <<(LPCTSTR)out <<endl;
|
|
|
|
|
S p k 521 wrote: ...convert hex to its corresponding ascii value...
This makes no sense? Are you wanting to convert from base-16 to base-10?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
You can do this easily using std::ostringstream[^].
Here is a small example for you:
#include <iostream>
#include <string>
#include <iomanip>
#include <sstream>
int main()
{
const unsigned int num1 = 0x1234, num2 = 1234;
std::ostringstream oss;
oss << "0x" << std::hex << num1;
std::string strFirstNumHex = oss.str();
oss.str(std::string());
oss << "0x" << std::hex << num2;
std::string strSecondNumHex = oss.str();
oss.str(std::string());
oss << std::dec << num1;
std::string strFirstNumDec = oss.str();
oss.str(std::string());
oss << std::dec << num2;
std::string strSecondNumDec = oss.str();
std::cout << "Numbers in HEX: " << strFirstNumHex << ", " << strSecondNumHex << "\t"
<< "Numbers in DEC: " << strFirstNumDec << ", " << strSecondNumDec;
std::cin.get();
return 0;
}
As you can see from the above example strFirstNumHex and strSecondNumHex contain hex string representations of the test integers (strFirstNumHex = 0x1234 and strSecondNumHex = 0x4d2 ). strFirstNumDec and strSecondNumDec contain decimal string representations of the test integers.
If you don't need the "0x" prefix for your Hex strings you can remove this prefix from specified lines in above example. I hope this helps.
NOTE: For clearing the content of the stream buffer I usually use: oss.str(""); , but it messes the formatting of the code block and I changed it to oss.str(std::string()); .
|
|
|
|
|
thank you very much experts...
|
|
|
|
|
Hi
Any sample code for ActiveX Component use 2D graph in MFC
Regards
M.Mathivanan
|
|
|
|
|
|
I am self-taught in C++ and this is as deep as I've ever been in messaging.
I have a modeless parent dialog maintaining a typed ptr list of modeless child dialog pointers. The children are all of the same class and hold memory and file resources (sets of parts and subassembly populations). The parent modeless supervises set operations on the children: unary transforms such as rotations, and binary operations such as set intersection, etc. So the parent is usually holding a kind of focus on one or two of the child operands.
I have been several days now, learning different ways that the parent dialog can crash via a null position pointer in the collection class operations, or crash via a pointer to a deleted child. I'm not crying about it, I needed the knowlege, anyway.
At this point my code no longer crashes but I have to perform two mouse clicks to close an inactive child; first click activates and second click closes ("close" means user clicked the X-button in the menu bar). The activation click causes the parent to lose its hold on current operands. Here are my event captures:
int CPop::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
if(nHitTest != HTSYSMENU)
{
GetParent()->PostMessageW(WMU_POP_TO_POPMAN_CHILD_M_ACTIVE, (WPARAM)0, m_ptoken);
}
return MA_ACTIVATEANDEAT;
}
void CPop::OnSysCommand(UINT nID, LPARAM lParam)
{
if((0xfff0 & nID) == SC_CLOSE)
{
OnClose();
}
else
{
GetParent()->PostMessageW(WMU_POP_TO_POPMAN_CHILD_M_ACTIVE, (WPARAM)0, m_ptoken);
}
}
I saw a #define HTCLOSE in winuser but it is not listed in the docs for OnMouseActivate(). Of course I tried it but it is unreliable.
Child acivation causes the parent to lose "currency" of previously activated children, a real pia.
I would like to know a method for one-click closing an inactive child. Just point me to an article if there is one.
Tadeusz Westawic
Sum quid sum.
|
|
|
|