|
Hi,
In the strCommand I am having 2MB of Data and when i am trying to split with the new line it was throwing error.(to loop through all the data)
But it was working for minminum (ie 50 KB of datas like 0's and 1's).
How to over come this error? Very urgent.. Below is the code...
CString strCommand; // Holds 2MB of datas like 0's and 1's...
System::String* strDataReceived = "";
strDataReceived = strCommand;
__wchar_t split __gc[] = new __wchar_t __gc[1];
split [0] = '\n';
String *strSplitCommand[] = strDataReceived->Trim()->Split (split);
Please help..
Reg,
Subbu
|
|
|
|
|
spalanivel wrote: Very urgent..
It is so urgent to justify the cross-post [^]?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
spalanivel wrote: ...when i am trying to split with the new line it was throwing error.
My Magic 8-Ball is broken. What is the error that is being "thrown?"
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Try giving a little more detail about the error message - I just tried your code (reading > 2MB of data from a file) and it worked fine?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for your reply..
Actually while executing the Split statement we are storing the values String Array and it doesn't hold that much size to handle.
It will automatically goes to catch and print the error message.
After some processing the Size will be increased and it holds now 40 MB of datas and store it in string array. Thus it makes problem.
Thanks,
Subbu
|
|
|
|
|
As you're using C++.NET classes, the array is dynamically sized, so there should be no issues...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi everybody !
Can you help me on finding the equivalant of these functions in MFC? Many thanks in advance.
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);<br />
bi.bmiHeader.biWidth = dstX;<br />
bi.bmiHeader.biHeight = dstY;<br />
bi.bmiHeader.biPlanes = 1;<br />
bi.bmiHeader.biBitCount = 32;<br />
bi.bmiHeader.biCompression = BI_RGB;<br />
bi.bmiHeader.biSizeImage = dstX * 4 * dstY;<br />
bi.bmiHeader.biClrUsed = 0;<br />
bi.bmiHeader.biClrImportant = 0;<br />
SetDIBits(hdcDst, hBmpDst, 0, dstY, dst, &bi, DIB_RGB_COLORS);
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);<br />
bi.bmiHeader.biWidth = nx;<br />
bi.bmiHeader.biHeight = - ny;<br />
bi.bmiHeader.biPlanes = 1;<br />
bi.bmiHeader.biBitCount = 32;<br />
bi.bmiHeader.biCompression = BI_RGB;<br />
bi.bmiHeader.biSizeImage = nx * 4 * ny;<br />
bi.bmiHeader.biClrUsed = 0;<br />
bi.bmiHeader.biClrImportant = 0;<br />
<br />
buf = (pBGR) malloc(nx * 4 * ny);<br />
bRes = GetDIBits(cdcSrc, cBmpSrc, 0, ny, buf, &bi, DIB_RGB_COLORS);
|
|
|
|
|
You know, Win32 API functions are available to MFC code...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
knowing that you know makes me happy
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
MFC uses CDC wrapper to handle device contexts as a wrapper for most sorts of images
there are no facts, only interpretations
|
|
|
|
|
Hi All,
Can anybody please tell me how to determine which disk is the boot disk ie the disk by which the system boot took place using mfc.
Regards
Abinash
|
|
|
|
|
"GetWindowsDirectory()" provides the path where windows is installed. From path you can retrive the drive letter (first character of the path). Through the drive letter you find out the physical drive number of the disk by using DeviceIOControl() and IOCTL_STORAGE_GET_DEVICE_NUMBER
|
|
|
|
|
It's a Win32 FAQ (on Win32 ng[^] , system, since 1995 )
|
|
|
|
|
MFC, STUDIO'2008, WINDOWS'XP 2003
#include <float.h>
_controlfp(_DN_FLUSH, _MCW_DN); // : error C3861: '__controlfp': identifier not found
// Denormal values flushed to zero by hardware on ALPHA and x86
// processors with SSE2 support. Ignored on other x86 platforms.
below some variants:
//+-1 _controlfp(0, MCW_EM);
<float.h>
// below following line is incorrect - don't display MessageBox(L"1\nDIVIDE BY ZERO");
_controlfp(_DN_FLUSH, _MCW_DN);
_controlfp(0, _MCW_DN);
_controlfp(_DN_SAVE, _MCW_DN);
_controlfp(0, _MCW_DN);
int err;
double fResult; // Bennet, pg.136
double x,y;
x = 5.0;
y = 0.0;
_try
{
fResult = x/y;
// _control87_2(0, 0,&fResult, 0);
//- _controlfp(0, 0,&fResult, 0); // : error C2660: '_controlfp' : function does not take 4 arguments
//- _controlfp(&fResult, 0); // : error C2664: '_controlfp' : cannot convert parameter 1 from 'float *' to 'unsigned int'
}
_except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO)
{
MessageBox(L"1\nDIVIDE BY ZERO");
MessageBox(_T("2\nDIVIDE BY ZERO"));
AfxMessageBox(_T("3\nDIVIDE BY ZERO"));
}
|
|
|
|
|
And the question is?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Why don't exec
MessageBox(L"1\nDIVIDE BY ZERO");
|
|
|
|
|
The following code works fine on my system
#include "Excpt.h"
#include <Windows.h>
#include "cmath"
#include <float.h>
void main()
{
_controlfp(0, MCW_EM);
float fResult;
float x,y;
x = 5.0;
y = 0.0;
_try
{
fResult = x/y;
}
_except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO)
{
MessageBox(NULL, L"DIVIDE BY ZERO", L"", MB_OK);
}
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hi all
How to retrieve the all drives in a computer and their size or their starting and end Sector using VC++ Code
|
|
|
|
|
Shiv Murti Pal wrote: How to retrieve the all drives in a computer
this might help!
MFS System Utility[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
To get the list of available drives, use GetLogicalDrives() . To get their size, use GetDiskFreeSpace() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
And see System Information Utility[^].
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hi everyone!
I am trying to convert a HDC to Bitmap so that I can have a final picture of all bitmap components. Basically in my code what I do is that I have a bitmap at the background then I add other small bitmaps on top of the main bitmap, thus my final goal is to have a "screenshot" such that it is sort of a bitmap containing all other added bitmaps.
However, for some reason the final bitmap comes out in black. Please I need help and suggestions.
The piece of code is the following(in bold is the part of the code to get the final bitmap, which is almost at the end of the code):
void CSpeedoMeter::OnPaint()
{
CPaintDC dc(this);
//HDC thisDC = CreateDC("Desktop", NULL, NULL, NULL);
HDC thisDC = dc.GetSafeHdc();
HDC hdcMem;
//
// Create a compatible DC.
//
hdcMem = CreateCompatibleDC(NULL);
int seconds2 = 300;
int seconds = 3600;
//clock_t endwait = 0;
//if(saveState == true)
{
//getting the number of CumVend from database
//tempDay = ConnectDBFast();
//tempDay = 42000;
//tempWeek = tempDay + ConnectDBWeek(hdcMem);
//tempMonth = tempDay + ConnectDBMonth();
//tempMonth = 7878996;
//tempYear = tempDay + ConnectDBYear();
//tempYear = 7334554;
saveState = false;
//endwait = 0;
endwait = clock() + seconds * CLOCKS_PER_SEC;
//SetCursor(LoadCursor(NULL,IDC_WAIT));
}
if(saveStateFast == true)
{
//getting the number of CumVend from database
//tempDay = ConnectDBFast();
saveStateFast = false;
endwait2 = clock() + seconds2 * CLOCKS_PER_SEC;
}
//
// Get the size of the client rectangle.
//
RECT rc;
GetClientRect(&rc);
//ndh = rc.right - rc.left;
//ndv = rc.bottom - rc.top;
ndh = rc.right - rc.left - 845;
ndv = rc.bottom - rc.top - 140;
C.x = ndh/2;
C.y = ndv/2;
if(ndh > ndv)
needlelength = (int)(ndv/2.5f);
else
needlelength = (int)(ndh/2.5f);
//needlepos.x = ndh/2;
//needlepos.y = ndv/2 + needlelength;
needlepos.x = ndh/2;
needlepos.y = ndv/2 + needlelength - 190;
HBITMAP hBitmap = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), "C:\\Speedometer\\res\\speedometer6.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
GetObject(hBitmap, sizeof(bitmap), &bitmap);
SelectObject(hdcMem, hBitmap);
SetNeedleColor(RGB(255, 126, 45));
// draw needle
DrawNeedle((int)tempDay, &dc, needlecolor, hdcMem);
// draw font
HFONT hfont, holdfont;
hfont = CreateFontIndirect(&lf);
holdfont = (HFONT) SelectObject(hdcMem, hfont);
//******************************* CODE TO DRAW NUMBERS FOR DAILY SELLS **********************************
RECT fntRc;
fntRc.left = 815;
fntRc.right = 1000;
fntRc.top = 830;
fntRc.bottom = 1080;
//tempDay = 0;
char numm1[20];
string strTotalDay = "";
strTotalDay = itoa(tempDay, numm1, 10);
//int ll = strTotalMonth.length();
string back1 = strTotalDay;
for(int b=0; b < strTotalDay.length(); b++)
{
back1[b] = strTotalDay[strTotalDay.length()-1-b];
}
strTotalDay = back1;
for(int b=0; b < strTotalDay.length(); b++)
{
if(b != 0)
{
//RECT fntRc1;
fntRc.left -= 55;
fntRc.right -= 55;
}
drawNumbers(hdcMem, &dc, fntRc, strTotalDay[b]);
}
////////////////////////////////////////////////////////////////////////////////////////////////
//******************************* CODE TO DRAW NUMBERS FOR WEEKLY SELLS **********************************
RECT fntRc4;
fntRc4.left = 1683;
fntRc4.right = 1868;
fntRc4.top = 150;
fntRc4.bottom = 400;
//tempWeek = 17;
char numm[20];
string strTotalWeek = "";
strTotalWeek = itoa(tempWeek, numm, 10);
//int ll = strTotalMonth.length();
string back4 = strTotalWeek;
for(int b=0; b < strTotalWeek.length(); b++)
{
back4[b] = strTotalWeek[strTotalWeek.length()-1-b];
}
strTotalWeek = back4;
for(int b=0; b < strTotalWeek.length(); b++)
{
if(b != 0)
{
//RECT fntRc1;
fntRc4.left -= 55;
fntRc4.right -= 55;
}
drawNumbers(hdcMem, &dc, fntRc4, strTotalWeek[b]);
}
////////////////////////////////////////////////////////////////////////////////////////////////
//******************************* CODE TO DRAW NUMBERS FOR MONTHLY SELLS **********************************
RECT fntRc1;
fntRc1.left = 1683;
fntRc1.right = 1868;
fntRc1.top = 380;
fntRc1.bottom = 630;
//tempMonth = 11111111;
string strTotalMonth = "";
stringstream ss;
ss << tempMonth;
strTotalMonth = ss.str();
//TextOutA(hdcMem,5,5, strTotalMonth.c_str(),20);
string back = strTotalMonth;
for(int b=0; b < strTotalMonth.length(); b++)
{
back[b] = strTotalMonth[strTotalMonth.length()-1-b];
}
strTotalMonth = back;
for(int b=0; b < strTotalMonth.length(); b++)
{
if(b != 0)
{
//RECT fntRc1;
fntRc1.left -= 55;
fntRc1.right -= 55;
}
drawNumbers(hdcMem, &dc, fntRc1, strTotalMonth[b]);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
//******************************* CODE TO DRAW NUMBERS FOR YEARLY SELLS **********************************
RECT fntRc3;
fntRc3.left = 1683;
fntRc3.right = 1868;
fntRc3.top = 610;
fntRc3.bottom = 860;
//tempYear = 15556;
char numm2[20];
string strTotalYear = "";
strTotalYear = itoa(tempYear, numm2, 10);
string back2 = strTotalYear;
for(int b=0; b < strTotalYear.length(); b++)
{
back2[b] = strTotalYear[strTotalYear.length()-1-b];
}
strTotalYear = back2;
for(int b=0; b < strTotalYear.length(); b++)
{
if(b != 0)
{
//RECT fntRc1;
fntRc3.left -= 55;
fntRc3.right -= 55;
}
drawNumbers(hdcMem, &dc, fntRc3, strTotalYear[b]);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//HWND window;
const char* filename = "res\\speedomoterSCREEN.bmp";
// get screen rectangle
//GetWindowRect(&rc);
// bitmap dimensions
int bitmap_dx = rc.right - rc.left;
int bitmap_dy = rc.bottom - rc.top;
// create file
ofstream file(filename, ios::binary);
if(!file) return;
// save bitmap file headers
BITMAPFILEHEADER fileHeader;
BITMAPINFOHEADER infoHeader;
fileHeader.bfType = 0x4d42;
fileHeader.bfSize = 0;
fileHeader.bfReserved1 = 0;
fileHeader.bfReserved2 = 0;
fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
infoHeader.biSize = sizeof(infoHeader);
infoHeader.biWidth = bitmap_dx;
infoHeader.biHeight = bitmap_dy;
infoHeader.biPlanes = 1;
infoHeader.biBitCount = 24;
infoHeader.biCompression = BI_RGB;
infoHeader.biSizeImage = 0;
infoHeader.biXPelsPerMeter = 0;
infoHeader.biYPelsPerMeter = 0;
infoHeader.biClrUsed = 0;
infoHeader.biClrImportant = 0;
file.write((char*)&fileHeader, sizeof(fileHeader));
file.write((char*)&infoHeader, sizeof(infoHeader));
// dibsection information
BITMAPINFO info;
info.bmiHeader = infoHeader;
// ------------------
// THE IMPORTANT CODE
// ------------------
// create a dibsection and blit the window contents to the bitmap
//HDC winDC = GetWindowDC(window);
HDC memDC = CreateCompatibleDC(NULL);
BYTE *memory = 0;
HBITMAP bitmap = CreateDIBSection(hdcMem, &info, DIB_RGB_COLORS, (void**)&memory, 0, 0);
SelectObject(memDC, bitmap);
BitBlt(thisDC, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hdcMem, 0, 0,SRCCOPY);
DeleteDC(memDC);
//ReleaseDC(window, winDC);
const char *memory1 = (char*)memory;
// save dibsection data
int bytes = (((24*bitmap_dx + 31) & (~31))/8)*bitmap_dy;
file.write(memory1, bytes);
DeleteObject(bitmap);
//DeleteObject(font1);
DeleteObject(hfont);
DeleteObject(holdfont);
DeleteObject(hBitmap);
DeleteDC(hdcMem);
DeleteDC(thisDC);
if(clock() >= endwait)
{
saveState = true;
}
if(clock() >= endwait2)
{
saveStateFast = true;
}
Invalidate();
}
|
|
|
|
|
LuisFilipeSa wrote: BitBlt(thisDC, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hdcMem, 0, 0,SRCCOPY);
It looks like (BTW your code appears a bit involute...) you're bit-blitting in the wrong direction, i.e. memory->screen instead of screen->memory.
Please, use the code block button for posting code snippets.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes but when bit-blitting in that direction it works fine, this is, the final bitmap is displayed properly on the screen. But when I try to copy that bitmap to a bitmap file it does not work.
That piece of code that you copied on your reply is working fine, this is:
BitBlt(thisDC, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hdcMem, 0, 0,SRCCOPY);
The problem is within the code in bold that I posted before.
The rest of the code which is not in bold works perfectly.
Any more advice please?
Thank you.
|
|
|
|
|