|
There are some arbitrary precision numeric libraries on the net. Check for instance GMP[^].
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
You can use Decimal data type and Decimal arithmetic functions: VarDecAdd, VarDecMul etc. They are declared in oleauto.h. Decimal variables are stored as 12-byte signed integers and can store values from 0.0000000000000000000000000001 to 79,228,162,514,264,337,593,543,950,335
Alexander
|
|
|
|
|
for floating point, look up long double in the doc. Range is +/–1.2E4932 with at least 19 digits of precision.
|
|
|
|
|
long double is there for backward compatibility only - it's now the same as double (15 digits of precision).
Anna
Homepage | My life in tears
"Be yourself - not what others think you should be"
- Marcia Graesch
"Anna's just a sexy-looking lesbian tart"
- A friend, trying to wind me up. It didn't work.
Trouble with resource IDs? Try the Resource ID Organiser Visual C++ Add-In
|
|
|
|
|
Hi,
I faced really weird situation.
I wrote a code that opens some target file with Shellexecute() like following line.
ShellExecute(NULL, "open", szTargetName, NULL, NULL, SW_SHOWNORMAL);
This is written in independent cpp file which is included in some project.
I compiled it, and it was working in WIN 2K.
However, When I try to close MS WORD(***.doc) file which is opened by this project, windows freezes.
After long time, there was a pop up message that indicates "this process takes long time, do you want to continue?"
Everything is fine except MS WORD on WIN98.
I really wanna know what's going on and how to solve this problem.
PLEASE HELP ME.
Thanks in advance.
|
|
|
|
|
I've had this problem too - try putting in a wait for a few seconds after the open, and see what happens.
|
|
|
|
|
Hello.
I'm writing a forms processing app, using MFC, which reads form data
from an XML file. By form data I mean - what the form is supposed to look like, coordinates
of where each form element is located, type of form element (button, textfield, table, etc.)
So far I had no problems creating controls on a CDialog - I just used CreateWindow with preset classnames (COMBOBOX, EDIT, etc). However there are two elements I'm not quite sure how to display:
One is a Table, for which I thought I'd use MSFlexGrid and another - DataControl, for which I was going to use the Microsoft ADO Data Control.
The thing is I cannot find any docs on how to display those without making use of dialog templates.
Could anyone help me out?
Thank you.
Marat Garafutdinov.
|
|
|
|
|
MSHFlexGrid has a create function:
virtual BOOL Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = NULL)
Try using this function, and I think that the Class Name is not that important because I don't see it being used in the function's body.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
I am having problem with accessing a particular location of bitmap.
what i want to do is store the x,y coordinates of black pixels on a perfectly white background. The error code is "GetPixel' : cannot convert parameter 1 from 'struct HDIB__ ** ' to 'struct HDC__ *'"
I tried GetPixel (x,y) but it doent work neither.
Does anyone know?Thanks!
POINT* p=new POINT[length];
POINT* p2=new POINT[length];
int w=cxDIB;//the width of the image
int h=cyDIB;//the height of the bitmap
i=0;
for(w=0;w<=cxDIB;w++)
{
for(h=0;h<=cyDIB;h++)
{
p[i].x=w;
p[i].y=h;
i++;
}}
i=0;
for(w=0;w<=cxDIB;w++)
{
for(h=0;h<=cyDIB;h++)
{
if(GetPixel(m_hDIB2,p->x,p->y)==RGB(0,0,0)) p2[i] =p[i];
i++;
}}
delete [] p;
delete [] buf;
|
|
|
|
|
A DIB is not a device context the following code will hopefully start you on your way. It does not handle all DIB formats especially it does not handle RLL compressed DIBs. You need to consider the DIBInfo which will specify page vs interleaved pixels, number of color planes and bits per pixel. Also each scanline will be padded to 4 byte ie DWORD boundaries.
As you can see it was written a long time ago in Win32 but i doubt the basic structures have changed.
Depending on your requirements it might be easier to render the DIB into a CMemDC and retrieve the pixels from there ?
/*************************************************************************
*
* getDIBPixel(hDIB, x , y)
*
* Parameter:
*
* HDIB hDIB - handle to global memory with a DIB spec
* in it followed by the DIB bits
*
* Return Value:
*
* DWORD - index to color of pixel or RGB for 24 bit or
* RGBX for 32 bit per pixel bitmaps
*
* Description:
*
* This function finds the color of a DIB pixel
*
************************************************************************/
DWORD WINAPI getDIBPixel(HDIB hDIB, int x, int y)
{
DWORD dwColor;
WORD wBitCount;
DWORD dwWidth, dwHeight, dwX, dwY;
DWORD scanline_bytes;
LPSTR lpDIB; // pointer to packed-DIB
LPSTR lpDIBBits; // Pointer to DIB bits
LPBITMAPINFO lpbmi; // pointer to BITMAPINFO structure (Win3.0)
LPBITMAPCOREINFO lpbmc; // pointer to BITMAPCOREINFO structure (old)
lpDIB = (LPSTR) ::GlobalLock((HGLOBAL) hDIB);
lpDIBBits = ::FindDIBBits(lpDIB);
// get pointer to BITMAPINFO (Win 3.0)
lpbmi = (LPBITMAPINFO)lpDIB;
// get pointer to BITMAPCOREINFO (old 1.x)
lpbmc = (LPBITMAPCOREINFO)lpDIB;
// the number of bits per pixel for the DIB
if (IS_WIN30_DIB(lpDIB))
wBitCount = ((LPBITMAPINFOHEADER)lpDIB)->biBitCount;
else
wBitCount = ((LPBITMAPCOREHEADER)lpDIB)->bcBitCount;
// end of number of bits per pixel
dwWidth = ::DIBWidth(lpDIB);
dwHeight = ::DIBHeight(lpDIB);
dwX = (DWORD) x;
dwY = dwHeight - (DWORD) (y + 1);
// TRACE2("getDIBPixel dwX=%ld, dwY=%ld\n", dwX, dwY);
// WIDTHBYTES performs DWORD-aligning of DIB scanlines. The "bits"
// parameter is the bit count for the scanline (biWidth * biBitCount),
// and this macro returns the number of DWORD-aligned bytes needed
// to hold those bits.
scanline_bytes = (((dwWidth * (DWORD) wBitCount) + 31) / 32 * 4);
DWORD dwXoffset, dwYoffset, dwXBitoffset;
DWORD pixel_addr;
BYTE pixel_data;
dwXoffset = ((dwX * (DWORD) wBitCount) / 8);
dwXBitoffset = (dwX * (DWORD) wBitCount) - (dwXoffset * 8);
dwYoffset = (dwY * scanline_bytes);
// TRACE3("getDIBPixel dwXoffset=%ld dwXBitoffset=%ld dwYoffset=%ld\n",dwXoffset, dwXBitoffset, dwYoffset);
pixel_addr = dwYoffset;
pixel_addr += dwXoffset;
pixel_data = *( (BYTE huge *)lpDIBBits + pixel_addr );
// TRACE1("getDIBPixel pixel_data=0x%x\n", pixel_data);
//extract relevant bits
switch (wBitCount) {
case 1:
break;
case 2:
break;
case 4:
switch(dwXBitoffset) {
case 0:
pixel_data = pixel_data>>4;
pixel_data = pixel_data & 0x0F;
break;
case 4:
pixel_data = pixel_data & 0x0F;
break;
}
dwColor = (DWORD) pixel_data;
break;
case 8:
dwColor = (DWORD) pixel_data;
break;
case 24:
// TRACE1("Blue = 0x%x",pixel_data);
dwColor = (DWORD) pixel_data;
pixel_data = *( (BYTE huge *)lpDIBBits + pixel_addr + 1 );
// TRACE1("Green = 0x%x",pixel_data);
dwColor += (DWORD) pixel_data * 256;
pixel_data = *( (BYTE huge *)lpDIBBits + pixel_addr + 2);
// TRACE1("Red = 0x%x\n",pixel_data);
dwColor += (DWORD) pixel_data * 65536;
break;
}
::GlobalUnlock((HGLOBAL) hDIB);
// TRACE1("getDIBPixel dwColor=0x%lx\n", dwColor);
return(dwColor);
}
|
|
|
|
|
Thank you ever so much , I will try and inform you of the outcome
|
|
|
|
|
Hi,
Am trying to find an implemenation of the
Zero Proof Algorithm in C++.
Does anyone have any pointers, have found it
in C# but not in C++, does it exist?
many thanks
|
|
|
|
|
If i create a raw socket, build my own IP and UDP header, and then use sendto() to send a packet.. what does the buffer have to contain? just data.. or the entire packet data with the header data and everything?
Kuniva
--------------------------------------------
|
|
|
|
|
|
But how does the socket know the source address it should use? I mean, the idea of the raw socket is that we can use setsockopt() to tell it it should use OUR header, and not the one filled in by windows by default. But in sendto() it would only get the socket,the data and a sockaddr_in structure as parameters, so you are saying the data for the header should be somewhere in the socket handle... because the sockaddr_in structure only contains data for the destination. I don't see how this is possible since a SOCKET is just a handle, an int.. How does it know the header to use? Perhaps you have an example for sending a packet with your own header? It would clarify a lot for me...
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
Microsoft have an example of using SOCK_RAW here
|
|
|
|
|
Hey,
I'm thinking about creating a little "game" that will produce a little character on your monitor, the character will walk around and do random little things, and interact with the cursor, and (hopefully) other windows. I'd like to make this character appear to be IN the computer, not an application or game. I'd like all other windows to be seen, and icons to be clickable, etc. For example:
I load up my game, and then decide to open winamp. Without having to minimize anything, or move any windows, I can just double click the winamp icon on my desktop. My character (still visible the whole time) keeps walking around or dancing, or whatever he wants to do the whole time.
I hope I've explained myself well enough.
Thanks in advance!
-Brian
-untwisted
www.uber-ware.com
brian@uber-ware.com
|
|
|
|
|
|
If I create a web service in C#, is it possible to consume it in normal C++ ? Is it going to be a nightmare ? I'm trying to decide on a home project and thinking of an app to use sourcesafe remotely, web service one end, C++ app the other ( so that the .NET framework is not needed remotely ).
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Christian Graus wrote:
If I create a web service in C#, is it possible to consume it in normal C++ ?
If by "normal C++" you mean VC 7.x, then yes. You need to use ATL Server like in this example.
Christian Graus wrote:
Is it going to be a nightmare ?
For development, no. For deployment - it requires MSXML which is a drag.
|
|
|
|
|
Cool - thank you. MSXML is a lot smaller than the .NET framework, and included in IE 5.5 ( from memory ), so that's still a lot easier in terms of deployment IMO. So that suits me just great.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Not sure if this the answer you're looking for, but if the web service accepts HTTP GET requests, like CP's service, then you can call IXMLDOMDocument::load() and pass it the URL to the service, and let the XML parser do the rest. Check out my CP screen saver, which uses this method.
BTW MSXML comes with IE 5+, and is available as a redistributable for those poor people stuck on IE 4.
--Mike--
Latest blog entry: *drool* (Alyson) [May 10]
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
This example seems to write both server and client in ATL, is it possible to write the server in C#, or does that complicate things ?
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Christian Graus wrote:
is it possible to write the server in C#, or does that complicate things ?
Yes. In fact you can write the server in any programming language, as long as you have a valid SOAP library.
However, I've tried only the opposite combination: ATL server and C# client. It worked just fine, and I assume (but cannot guarantee) that your case will be fine too.
|
|
|
|
|
The web service will return an xml which you can "consume" in normal c++.
Jason Henderson My articles
"The best argument against democracy is a five-minute conversation with the average voter." - Winston Churchill
|
|
|
|
|