|
I am trying to track reams of data and am getting exhausted of opening
multiple files. Anyone have a quick method for opening somewhere on the order
of 100 files?
I suppose I could generate filenames, but how do I open them all without coding 100 separate instances of:
ofstream DataFile1;
DataFile1.open("Data1.txt", ios::out | ios::trunc);
if ( DataFile.fail() )
throw "This disk is full.\n";
|
|
|
|
|
Could you try
ofstream* df[100];
for (int i=0;i<100;i++)
{
string filename("data");
filename.append(itoa(i));
filename.append(".txt")
df[i]->open(filename,ios...
...
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"Microsoft hasn't ever enforced its patents. Apparently they keep them for defensive reasons only. Or, they could be waiting 'til they have a critical mass of patents, enforce them all at once and win the game of Risk that they're playing with the world." Chris Sells Feb 18, 2003.
|
|
|
|
|
Is there a way to use MFC support in Win32 application? (especially Property Sheet class).
|
|
|
|
|
You are asking without adding MFC support to the application? Any win32 or ATL application you can add MFC by selecting the compiler option, adding afx.h to stdafx.h and then properly initializing MFC. Create a console application with MFC support to see what is needed.
John
|
|
|
|
|
How I can color my MessageBox in red, and Button in blue.
Thus I want to create my own MessageBox with my parameters.
Thanks.
Kostya
|
|
|
|
|
|
Is there any alternative to using GetDIBits for filling the lpvBits parameter of the function. It works fine for me on Windows XP and 2000 but the function always returns 0 on Windows 98. Are there a group of function I can use in a for loop (or something like that) to get everything pixel by pixel and store it into into a buffer?
|
|
|
|
|
CDC::GetPixel will get a pixel out of a DC (create a memory DC, select the HBITMAP, get the pixels, etc)
-c
To vote with no response is to follow the way of the coward.
|
|
|
|
|
I figured I would get this answer, unfortunately this would be too slow for me. Do you have any experience with GetDIBits and possible reasons the same code works fine on Windows XP/2000 and not on 98?
|
|
|
|
|
how big is the bitmap? 95/95 have GDI size limitations that NT/2000/XP don't have.
To vote with no response is to follow the way of the coward.
|
|
|
|
|
The bitmap is 544 Kb. I noticed somewhere on MDSN something about 64 KB but it mentioned that this applied to Windows 3.0...you think this is the problem?
|
|
|
|
|
georgiek50 wrote:
you think this is the problem?
it could be.
check out the GetDeviceCaps function. it can tell you if a device (the DC, in this case) supports GetDIBits, if it supports big bitmaps, etc..
-c
To vote with no response is to follow the way of the coward.
|
|
|
|
|
Apparently it supports bitmaps greater than 64K and the GetDIBits function. Any other ideas?
|
|
|
|
|
It probably doesn't like the format or color depth you're requesting the bits in. What's the code snippet?
Joel Lucsy
|
|
|
|
|
Here is the code snippet (not mine) but I also figured out a solution to the problem. As long the the bitmap width and height are evenly divisible by 4 then all is OK. I can't explain this fully:
YTE* Get24BitPixels(HBITMAP pBitmap, WORD *pwWidth, WORD *pwHeight)
{
BITMAP bmpBmp;
LPBITMAPINFO pbmiInfo;
BITMAPINFO bmiInfo;
WORD wBmpWidth, wBmpHeight;
GetObject(pBitmap, sizeof(bmpBmp), &bmpBmp);
pbmiInfo = (LPBITMAPINFO) &bmpBmp;
wBmpWidth = (WORD)pbmiInfo->bmiHeader.biWidth;
wBmpWidth -= (wBmpWidth%4);
wBmpHeight = (WORD)pbmiInfo->bmiHeader.biHeight;
*pwWidth = wBmpWidth;
*pwHeight = wBmpHeight;
BYTE *pPixels = new BYTE[wBmpWidth*wBmpHeight*3];
if (!pPixels)
return NULL;
HDC hDC = GetWindowDC(NULL);
bmiInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmiInfo.bmiHeader.biWidth = wBmpWidth;
bmiInfo.bmiHeader.biHeight = -wBmpHeight;
bmiInfo.bmiHeader.biPlanes = 1;
bmiInfo.bmiHeader.biBitCount = 24;
bmiInfo.bmiHeader.biCompression = BI_RGB;
bmiInfo.bmiHeader.biSizeImage = wBmpWidth * wBmpHeight * 3;
bmiInfo.bmiHeader.biXPelsPerMeter = 0;
bmiInfo.bmiHeader.biYPelsPerMeter = 0;
bmiInfo.bmiHeader.biClrUsed = 0;
bmiInfo.bmiHeader.biClrImportant = 0;
int iRes = GetDIBits(hDC, pBitmap, 0, wBmpHeight, (LPVOID)pPixels, &bmiInfo, DIB_RGB_COLORS);
ReleaseDC(NULL, hDC);
if (!iRes)
{
delete pPixels;
return NULL;
}
return pPixels;
}
</code>
It must have something to do with the alignment of the bytes which is done in the beginning of the function. Also trying to put in the original values retrieved from GetObject for width and height gives shady results.
What do you make of it?
|
|
|
|
|
dib scanlines have always been buffered to 4 byte DWORD boundaries.
this is so that blit functions etc do not force the processor to do expensive address fixups caused by starting on an non 32bit aligned memory address. Somewhere in the win16 / win32 sdk documentation all this was documented at sometime in the past like the early 90's. this does not mean that the actual image width has to be a multiple of 4 and should not relate to image height at all.
|
|
|
|
|
Should, could, would...it's all the same to me. After four days of debugging sessions I found the answer to the problem, if the width and height of the bitmap are evenly divisible by four it will receive the bits in Windows 98, and although this does not apply to all bitmaps tested, I will make it a personal rule of thumb to keep this rule because neither I, or anyone else I have asked can find an answer, so I will go with what works. Thanks...
|
|
|
|
|
Hi
I have created a ActiveX toolbar with VC++ 6, that uses a drop down list control (simular to the IE Address bar), everything works fine except i can not Cut and Paste into the list control box? Our control is created at runtime.
Does any one know how to modify the MS C++ List control to allow Cut and Paste using shortcuts (Ctrl V)? or know of or can help me create on that will allow hot key cut and paste.
Thanks for any information.
Scott
|
|
|
|
|
One solution is to to handle the keydown message and process the control.
Kuphryn
|
|
|
|
|
kuphryn wrote:
One solution is to to handle the keydown message and process the control.
Do you have an example? I am not shure what you mean.
Thanks for any information
Scott
|
|
|
|
|
I am developing COM Server and am unable to debug as i am unable to compile as I get the error
: error C2065: 'DEBUG_NEW' : undeclared identifier
development is getting real tough without the debugger . Please help
|
|
|
|
|
You are probably using MFC and you probably removed
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
from beginning of the file.
|
|
|
|
|
I am programming in c and would like to know how I can find the location of my executable programatically. So if the executable is moved to a new location my program will know its current path.
Thanks,
SAK
|
|
|
|
|
One solution is GetModuleFileName(). Another solution is GetCurrentDirectory().
Kuphryn
|
|
|
|
|
Kuphryn,
This is exactly what I was looking for.
Thank you
|
|
|
|