|
Look up RAND_MAX. Do the math yourself (i.e. -RANDMAX/7.0-3.5). If that doesn't give you enough randmomness (in MSVC you only get 1/32k) perhaps some rand48 implementation?
|
|
|
|
|
it doesnt have to be very exact....
thanks for your answer
|
|
|
|
|
Hey guys
I have just about run out of ideasi have this piece of code below which is ment to copy one buffer to another.
void CMiscFunctions::CopyValueToBuffer(BYTE *pDataToCopy, BYTE *pBuffer, DWORD *dwLengthOfBuffer, DWORD dwSizeOfData)
{
DWORD i = *dwLengthOfBuffer;
DWORD y;
char sTest[10];
_ultoa(*dwLengthOfBuffer ,sTest, 10);
AfxMessageBox(sTest);
char sTest2[10];
_ultoa(i ,sTest2, 10);
AfxMessageBox(sTest2);
for(y = 0; y < dwSizeOfData; y++, i++)
{
pBuffer[i] = pDataToCopy[y];
if(y == 0x00000ED85)
{
AfxMessageBox("full");
break;
}
}
*dwLengthOfBuffer = i;
}
But it won't copy anything bigger then 59kb. I posted this before but didn't explain it very well basically it copies from pDataToCopy to pBuffer. i is the position to start copying data to in the pBuffer and y is 0 just to increment through the pDataToCopy buffer. I also put in an if statment to see what the largest value is before it crashes which is 0x00000ED85 in hex or 60805. Which seems like a very odd number to crash on to me.
Anyway all help is appreciated peter.
|
|
|
|
|
Are you using Win16? In that case you must use "huge" pointers.
Else, make sure that 1) The dest buffer can hold at least dwSizeOfData+(*dwLengthOfBuffer) bytes, 2) don't release this code.
I'd recommend you to look up e.g. memcpy.
|
|
|
|
|
At first sight there's nothing wrong with your code, objectionable as it is. You might want to check if you reserve space enough at pBuffer to copy past the boundary of 59 KB. Why don't you try something like
int main(void)
{
BYTE pDataToCopy [128*1024], pBuffer[128*1024];
DWORD dwLengthOfBuffer=0;
DWORD dwSizeOfData=sizeof(pDataToCopy);
CMiscFunctions::CopyValueToBuffer(
pDataToCopy,pBuffer,
&dwLengthOfBuffer,dwSizeOfData);
return 0;
} and see what happens?
Also, I suggest you take a look at standard functions for memory copying like memcpy and memmove which will outperform your handmade loop and take the pains of doing the job for you.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Cheers Guys
The reason i haven't used memcpy and memove is that earlier on i have a function that copys DWORDS to the beginning of the buffer and memove and memcpy overite this DWORDS see this (pBuffer) has lots of data taken from different places then it is all written into a buffer.
Also the size of the buffer is set me realloc() would this be causing the problems.
Peter
|
|
|
|
|
Good day,
Does anyone know how to request a read receipt through an smpt command like NOTIFY or RET or anything? I've been looking all over the internet but can't seem to find anything on it. I know how to do it programatically using MAPI and Outlook but I have an smtp wrapper class and want to use a straight code rather than using MAPI, etc. Any help is greatly appreciated.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Isn't this taken care of the header field Read-Reciept-To
?
|
|
|
|
|
Thanks for your response. Actually it is
Disposition-Notification-To:
It took me forever to find this. I first thought it was Read-Receipt-To but it never worked.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Here is a class which I want to use in a multi-threaded program:
class threadclass {
public:
void A();
void B();
};
void threadclass::A()
{
B();
}
void threadclass::B()
{
}
UINT WINAPI threadproc(LPVOID lpData)
{
threadclass xx;
xx.A();
return 0;
}
I use it like this:
CWinThread *pThread=AfxBeginThread(threadproc,NULL);
Will there be some error occured? Is the class thread-safe?
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
Aren't you missing anything in the exposition of your problem? The class is trivially thread safe, basically because it does nothing.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have a populated BITMAPINFOHEADER struct, and I have the bits of a device-independent bitmap. How do I get the RGBQUAD info out of those two items to build a BITMAPINFO struct?
|
|
|
|
|
I believe one of the many places this is explained can be found by a Google search for "rgbquad bitmapinfoheader" (to not promote codeguru after the takeover).
|
|
|
|
|
If you have the DIB bits as they are stored in a .bmp file, youu may have a look at this on MSDN (about BITMAPFILEHEADER): "A BITMAPINFO or BITMAPCOREINFO structure immediately follows the BITMAPFILEHEADER structure in the DIB file. "
Otherwise, you should have the palette stored somewhere, then use that instead.
I think the palette is fixed in size when it is stored in a file (16 or 256 RGBQUAD entries), but the last entries could be unused (usually zeroes) if biClrUsed < 2^biBitCount.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hi All,
I am looking for some help/example code/links for the above. What I want to do is write some code in Visual C++ which will create an object. I then want to be able to use this object in vbscript and use it's member functions etc. I think the solution is ATL/Com but I'm not sure.
Any help on the above would be greatly appreciated.
thanks in advance,
Dave.
|
|
|
|
|
Hi,
If want to use Visual C++ I think the best choice is ATL, if you are going to use your components from VBScript make sure to implement IDispatch. (that way you can use the components from ASP for instance)
You can find information on the MSDN (you will find tutoriales and articles), or look on www.amazon.com for books on the subject
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Anyone knows about debugging ISAPI Extensions ? I tried lot of the techniques supplied in KB but no chance .
What i'm searching for is some handy tools to do the job (and free tools please)
Thanks .
|
|
|
|
|
Hi,
I've got a function that launches a simple dialog. How do I get the function to wait for the OK button to be pressed before returning?
<br />
void Import_Shader_Dialog::OnImportShaders() <br />
{<br />
Some_Dlg Progress;<br />
Progress.Create(IDD_IMPORT_SHADER_PROGRESS, NULL); <br />
Progress.ShowWindow(SW_SHOW);<br />
<br />
<br />
while(its_not_ok);
<br />
<br />
return;<br />
}<br />
I've tried making the dialog modal but then of course none of the function gets executed while the dialog is up.
The way it is, it just appears as long as the function is executing(very quick).
So how can I get my child dialog to stay up and receive messages from my program until the OK button is pressed?
Thanks
Josh
josh@that-guy.net
|
|
|
|
|
Is this dialog intended to be some sort of progress dialog or monitoring dialog of some type for the other code thats processing?
"I never met anyone I didn't like" Will Rogers.
|
|
|
|
|
Yes, It just supposed to display output strings in a listbox.
Josh
josh@that-guy.net
|
|
|
|
|
In that case just follow Tomaz's advice.
"I never met anyone I didn't like" Will Rogers.
|
|
|
|
|
If I understand your problem correctly, you just want to display a progress dialog during lenghty operation. If this is the case, have a look at Feb'97 issue of MSJ; there's a column titled 'Wicked Code' which describes CWaitDialog class.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Cool, thanks...
Josh
josh@that-guy.net
|
|
|
|
|
use Progress.DoModal()
but put your function code into the dialog class's InitInstance() so that the function runs when the dialog opens up. Then you can send function-related info to the dialog using member variables of the dialog and UpdateData()
Hope this helps...
|
|
|
|
|
Hi,
I would like to respond to the message WM_DRAWITEM within a CFrameWnd derrived Class. Unfortuanetly it doesn't appear within the list provide by class wizzard.
I want to use this message, to support an owner drawn CListCtrl.
Can anyone offer me any advice?
Cheers
Rich
|
|
|
|