|
the solution is to use CSocket , and don´t use CAsyncSocket
|
|
|
|
|
I compiled and linked some sample source code got from Microsoft SDK, there were some strange link errors:"error LNK2001: unresolved external symbol "error LNK2001: unresolved external symbol "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z)" and "error LNK2001: unresolved external symbol "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z)", it caused by such code:"_TCHAR *szName = new _TCHAR[100]" and "delete []szName".I tried to change the project setting option, but it still happened. I just wonder if there is anyone once met such problem before and how to solve it. Thank you.
Ray
|
|
|
|
|
sounds like either:
a: You are usinf functions from a library but havent added the lib to your project settings
or
b: You have a function defined that there is no prototype for.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
check this out, hopefully it might help you:
http://www.codeproject.com/cpp/cppforumfaq.asp#cl_errormain
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
|
Welcome to CP where everything is made up and points don't matter.
Thank you Nitron.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Hi, I have written a nice class (well, I think it's nice... may be other don't )
I have called it class Stream but I think it's a wrong name for that, but how do I name it ?!
What the class do:
Stream.begin();
void * Stream.end();
Stream.clear();
Stream.add(void * data, int size);
example on how to use it:
Stream myStream;
void * t1 = allocateMem(11);
void * t2 = allocateMem(21);
void * t3 = allocateMem(31);
memmove(t1,"1________x\0",11);
memmove(t2,"2________xa________x\0",21);
memmove(t3,"3________x_________xb________x\0",31);
myStream.begin();
printf(" fill stream:\n"); myStream.add(t1,11);
printf(" fill stream:\n"); myStream.add(t2,21);
printf(" fill stream:\n"); myStream.add(t3,31);
printf(" --- stream completed ---\n");
char * myData = (char *) myStream.end();
tStreamheader * pStreamheader = (tStreamheader *)myData;
printf(" num of blocks: %i\n",pStreamheader->numblocks);
unsigned long * pBlocksize;
char * pBlockdata = NULL;
unsigned long myoffset = sizeof(tStreamheader);
for (int i = 0; i< (int) pStreamheader->numblocks; i++)
{
pBlocksize = (unsigned long *) (myData + myoffset);
myoffset+=sizeof(unsigned long);
pBlockdata = (char *)allocateMem(*pBlocksize);
memmove(pBlockdata, myData + myoffset,*pBlocksize);
myoffset+=*pBlocksize;
printf(" Stream Block %i size = %u\n", i, *pBlocksize);
printf(" Stream Block data = %s\n",pBlockdata);
pBlockdata = freeMem(pBlockdata);
}
t1 = freeMem(t1);
t2 = freeMem(t2);
t3 = freeMem(t3);
So, how should I call this class ?!
Do anyone need such a class ? Because it's free code and I want to make it here available...
what do you all think ?!
thanks alot ,
Sendel
The only place for millions of bugs is the Rainforest
|
|
|
|
|
if you wanna be an MFC junkie (hungarian strain) you put a "C" in front of it (for "Class"), and then maybe camelize and call it something like: CMyCoolStream
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Strange , I always thought that "C" stands for MFC (Microsoft Foundation Class) so if you call your classes like "CMyClass" you say that your class is only for MFC. So I won't put any "C" before my class name
but anyway: My class isn't a real stream class, so I thought that "Stream" is not the right name for it: neither CMyVeryCoolAbsoluteUnbelivableWorkingBuglessSpiritRichMasterlyWorkOf ArtStream will do...
I thought about packing names because it is packing data to one big block. Also DataCollector, BufferPacker, DataPatcher, DataConnector, DataWeld, DataSoupPot or DataMashCollectingTank... ;P
So I am not sure what it really is... may be I have to expand it a littlebit more so it would be really a stream class: i have to overload the << and >> operators etc. in that way that you can use it as follows:
network_in<<MyStream<<MyClass;
...
network_out>>MyStream>>MyClass;
but I don't think that it is possible to create such an intelligent class
but any way: I will use this class to prepare Data to be send over network and also to be reconverted back to its old structure after receiving it on the second pc.
datastructure -> Stream -> sending -> receiving -> Stream -> datastructure
Thank you
Sendel
PS: I will release this code here for free anyway: if you want or if you don't!;P
The only place for millions of bugs is the Rainforest
|
|
|
|
|
Hi, all
I am working on a specialized editor using CScrollView.
I notice that for any given line of text that is in the view (screen), it is longer in print preview. The amount of overshoot varies depending on the printer selected. I suspect that printer metrics are involved.
The printed output appears to be exactly what I see in the print preview.
I want the screen to show exactly what I see in the print preview.
I notice that WordPad exhibits this problems, too. But, Word does not.
How do I go about fixing this this?
Tim
|
|
|
|
|
What is your Mapping Mode? If it is MM_TEXT, you are at the mercy of the resolution of the device that you are rendering on.
|
|
|
|
|
Yes, it is MM_TEXT. However, there are some programs out there (Word) that can render the screen much like it would come out on the printer.
I figure they are using some trick.
Tim
|
|
|
|
|
I'm trying to remember how I handled that in a previous project... I think that I changed the Mapping Mode to MM_ANISOTROPIC and set the Window extents to match the screen resolution.... something to try.
|
|
|
|
|
Actually, I mis-stated the mapping mode. I am using MM_TWIPS, since the project is a publishing program.
I have made some advancements since yesterday in that GetDC() seems to return the printer context, or something close to it. After setting the font into the context, the text measurement functions return a line width fairly close to the 'printed' page. It's not exact: some of the character widths are right-on, while a few others are off a little. Still, the errors are minor enough to move onto other aspects of the design.
The screen line widths are clearly long, and overshoots the right margin by a few characters. But, the overshoot is not enough to require wrapping. The importing thing is that it looks right in print preview and hence the actual page.
Tim
|
|
|
|
|
I have a little problem with distributing a program. As on other computers, which don't have installed VC6, don't exist some *.dll's, my application don't work. so, how do I have to register them during first install on computer?
|
|
|
|
|
Use depends.exe to see what dlls are needed by your application, and then you can copy them to the other computer.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
You need to ensure that all DLLS that your program explicitly and implicitly links to are available on the target machine. This includes, but is not limited to, MFC42.DLL and MFC42U.DLL. The DEPENDS.EXE utility can help you out with some of this. If you do need to install files along with your program, make sure it is legal to do so. Blindly copying files does have repercussions.
|
|
|
|
|
Also read the documentation regarding to redistributable files, is in a file redist.txt (I think) that will make clear if it is legal to redistribute or not...
i.e. you cannot redistribute a debug linked exe.
Hope this helps.
PS:
use dependency walker (depends.exe) and you'll see which files are you missing.
|
|
|
|
|
I am trying to hide the scrollbars in my FormView pages.
void CAnonWasherView::OnInitialUpdate()
{
CView::OnInitialUpdate();
SIZE se;
se.cx=0;
se.cy=0;
CFormView::SetScaleToFitSize(se);
}
But I get the following error:
'CScrollView::SetScaleToFitSize' illegal call of non-static member function
I don't know what I am doing wrong.
|
|
|
|
|
1. a CScrollView is not a CFormView.
2. SetScaleToFitSize is a CScrollView member function.
3. you can't call non-static member functions of a class unless you:
a. have an instance of that class or
b. are in a member function of that class
sizing CFormViews is not simple, but there is code on this site that can help you. look in the Doc / View section or the Dialog section (since a CFormView is a hybrid of a dialog and a view)
-c
|
|
|
|
|
Hi all,
I'm using fgetwc to get characters from a file.
In ALL cases BUT 1, It calls this like it is supposed to (in _FGETWC.C):
if ((stream->_cnt -= sizeof(wchar_t)) >= 0)
-----> return *((wchar_t *)(stream->_ptr))++;
else
return (wint_t) _filwbuf(stream);
In this single case (and there's about 300 of them), this gets called:
if ((stream->_cnt -= sizeof(wchar_t)) >= 0)
return *((wchar_t *)(stream->_ptr))++;
else
-------------> return (wint_t) _filwbuf(stream);
And my application goes out the window, along with my monitor
I can move the information around in the data file, and it's fine, but when in a specific order I get this every time.
I really have no idea what is going on here. My gut says it has something to do with the wide character buffer going out of whack. Any ideas or suggestions?
Thanks alot!
|
|
|
|
|
When CRTL (C-Runtime Library) routines start to crash, it almost always means you have other bugs in your program that is trashing memory. Data structures used by the CRTL are getting trashed and thus crashing.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Yes that is true. I found a really weird case though.
As it turns out, the FILE stream buffer is allocated in 4k segments. When you do an fread, the fread checks the size left in the buffer and puts as much as it can into that buffer and sets a flag saying the buffer is full. At that point a new buffer is allocated and fread continues along it's merry way.
In my case I'm using fgetwc, which gets 2 characters (4 bytes). It checks to see if there is enough space in the buffer for the 2 characters, and if so puts it in. If there is not enough space (meaning there is only 2 bytes left in the buffer), it returns 2 chars worth of jargen, causing the application to bomb.
Becuase it only occurs when there I am calling fgetwc and there is only 2 bytes left in the buffer, I am rarely seeing this case but am able to easily reproduce the problem.
My solution, to not use fputwc and fgetwc anymore, but to use fwrite and fread.
You can find this in the _FGETWC.C that came with VC++ 6.0
|
|
|
|
|
Hi all,
GDI has a way of making you feel stupid. I have been struggling with this the whole day and have not found a way to do this.
I have a custom control on top of a main window. It has a bitmap as a background. I can initialize it and it shows just fine.
Now, I have another custom control which has the first control as the parent and is displayed on top of the parent. Now, I want the control to be transperant i.e. the user should be able to see the parent's bitmap background. However, it grays out the client area of the second control.
I tried everything from all kinds of brushes and SetBkMode(TRANSPARENT) but to no avail. If anyone with some experience in this area and might have an idea to what I need to do, I would REALLY appreciate it. If they live near Stuttgart, I would do their laundry for a month and bring the morning coffee and bagels!
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
There's some things you can do with regard to "layered windows". Here's an article that deals with them a little bit, to create a transparent window, but I'm not sure if it will help:
http://www.codeproject.com/useritems/forecast.asp[^]
Chris Richardson
You can stash and you can seize
In dreams begin, responsibilities U2 - Acrobat[^]
Stop being PC and accounting for everyone and his momma's timeframe. Just enjoy your - Rohit Sinha in the content-challenged thread
|
|
|
|