|
hi all,
when i execute application than its take some memory i check it from task manager.
when without closing wizard on click on back and next button the application memory usage inccrease.
please tell me how can i solve this.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Are you cleaning up after yourself ?
Are you making sure the memory you allocate is properly de-allocated ?
This signature was proudly tested on animals.
|
|
|
|
|
please tell me.How can i cleanup?
i cant understand where i can allocate memory or where i can deallocate memory.
i m simply use diffrent type of control like Edit,Text,DatetTime,Check Box,RadioButton,Group-Box,List,Combo-Box.and add there corresponding variables.
please help me.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
I believe (and I've been proved wrong numerous times) that when using a "wizard" the different UI pages are created as you go to them, but not destroyed as you leave them, so you application "might" grow in size, but not actually shrink.
but does that matter that much ?
This signature was proudly tested on animals.
|
|
|
|
|
yes , now what can i do?
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
"_$h@nky_" wrote: now what can i do?
Maybe answer why you're so concerned about what task manager is telling you?
Your job is to make sure you free any resources you explicitly allocate.
Let the OS manage the rest after that. There's often no need for the system to return
freed memory to the system unless it's needed, assuming you've actually properly released
resources you're no longer using.
The task manager is NOT a debugging tool!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have a CBitmap object and want to save it as a file .
Please help me how to achieve it.
Thanks & regards.
Dhiraj
|
|
|
|
|
Starting from CBitmap (MFC) or a GDI HBITMAP (what MFC wraps) it's not so easy:
A sample is on MSDN http://msdn.microsoft.com/en-us/library/ms532340(VS.85).aspx[^]
Otherwise, cosider using GDI+, where all this stuffs are wrappen in the Gdiplus::Bitmap class that can be created from an HBITMAP.
(but you have to link for GDI+ libraries and run startup/termination appropriately: just llok GDI+ under MSDN)
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
You may use CImage class [^], check out the CImage::Attach method.
I suppose (I didn't test it) the following code will do the trick:
CBitmap myBmp;
CImage myImg;
myImg.Attach(myBmp);
myImg.Save(_T("my.bmp"));
myImg.Detach();
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]
|
|
|
|
|
Its giving assertion related to size.
|
|
|
|
|
Dhiraj kumar Saini wrote: Its giving assertion related to size.
This is not a good way of getting help. You should be more precise and detailed when reporting errors.
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]
|
|
|
|
|
Did you trace it ? and can you show your code?
|
|
|
|
|
Ya sure.
void CCaptureDesktopDlg::OnBnClickedButton1()
{
CString sFName;
CDC ScreenDC;
ScreenDC.Attach(::GetDC(NULL));
CBitmap Capture;
CSize Dimensions(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
Capture.CreateCompatibleBitmap(&ScreenDC, Dimensions.cx, Dimensions.cy);
CDC MemDC;
MemDC.CreateCompatibleDC(&ScreenDC);
CBitmap *OldBitmap = MemDC.SelectObject(&Capture);
MemDC.BitBlt(0, 0, Dimensions.cx, Dimensions.cy, &ScreenDC, 0, 0, SRCCOPY);
CFileDialog fd( FALSE,
_T("BMP"),
NULL,
OFN_HIDEREADONLY &
OFN_OVERWRITEPROMPT,
NULL,
NULL);
fd.m_ofn.lpstrTitle = _T("Enter file name...");
fd.m_ofn.lpstrInitialDir = NULL;
fd.m_ofn.lpstrFilter = _T("BMP files (*.bmp)\000*.BMP\000");
if(fd.DoModal() == IDOK)
sFName = fd.GetPathName();
else
return;
HANDLE hDib = DDBToDIB( Capture, BI_RGB, NULL );
BOOL b = WriteDIB( sFName.GetBuffer(sFName.GetLength()) , hDib);
if(!b)
{
CString sMess = _T("Unable to write to file: \n");
sMess += sFName;
AfxMessageBox(sMess);
}
MemDC.SelectObject(Capture);
Capture.Detach();
MemDC.SelectObject(OldBitmap);
MemDC.DeleteDC();
::ReleaseDC(NULL, ScreenDC.Detach());
}
BOOL CCaptureDesktopDlg::WriteDIB( LPTSTR szFile, HANDLE hDIB)
{
BITMAPFILEHEADER hdr;
LPBITMAPINFOHEADER lpbi;
if (!hDIB)
return FALSE;
CFile file;
if( !file.Open( szFile, CFile::modeWrite|CFile::modeCreate) )
return FALSE;
lpbi = (LPBITMAPINFOHEADER)hDIB;
int nColors = 1 << lpbi->biBitCount;
if (nColors > 256)
nColors = 0;
hdr.bfType = ((WORD) ('M' << 8) | 'B');
hdr.bfSize = GlobalSize (hDIB) + sizeof( hdr );
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;
hdr.bfOffBits = (lpbi->biBitCount>8)?(DWORD) (sizeof(hdr) +
lpbi->biSize):(DWORD) (sizeof( hdr ) +
lpbi->biSize + nColors * sizeof(RGBQUAD));
file.Write( &hdr, sizeof(hdr) );
file.Write( lpbi, GlobalSize(hDIB) );
return TRUE;
}
HANDLE CCaptureDesktopDlg::DDBToDIB( CBitmap& bitmap, DWORD dwCompression, CPalette* pPal )
{
BITMAP bm;
BITMAPINFOHEADER bi;
LPBITMAPINFOHEADER lpbi;
DWORD dwLen;
HANDLE hDIB;
HANDLE handle;
HDC hDC;
HPALETTE hPal;
ASSERT( bitmap.GetSafeHandle() );
if( dwCompression == BI_BITFIELDS )
return NULL;
hPal = (HPALETTE) pPal->GetSafeHandle();
if (hPal==NULL)
hPal = (HPALETTE) GetStockObject(DEFAULT_PALETTE);
bitmap.GetObject(sizeof(bm),(LPSTR)&bm);
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = bm.bmWidth;
bi.biHeight = bm.bmHeight;
bi.biPlanes = 1;
bi.biBitCount = (short)(bm.bmPlanes * bm.bmBitsPixel);
bi.biCompression = dwCompression;
bi.biSizeImage = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
int nColors = (1 << bi.biBitCount);
if( nColors > 256 )
nColors = 0;
dwLen = bi.biSize + nColors * sizeof(RGBQUAD);
hDC = ::GetDC(NULL);
hPal = SelectPalette(hDC,hPal,FALSE);
RealizePalette(hDC);
hDIB = GlobalAlloc(GMEM_FIXED,dwLen);
if (!hDIB){
SelectPalette(hDC,hPal,FALSE);
::ReleaseDC(NULL,hDC);
return NULL;
}
|
|
|
|
|
Change to it:
if(fd.DoModal() == IDOK)
sFName = fd.GetPathName();
else
return;
CImage m2;
m2.Attach(Capture);
m2.Save(fd.GetPathName());
m2.Detach();
/*HANDLE hDib = DDBToDIB( Capture, BI_RGB, NULL );
BOOL b = WriteDIB( sFName.GetBuffer(sFName.GetLength()) , hDib);
if(!b)
{
CString sMess = _T("Unable to write to file: \n");
sMess += sFName;
AfxMessageBox(sMess);
} */
MemDC.SelectObject(Capture);
Capture.Detach();
|
|
|
|
|
|
You're welcome.
|
|
|
|
|
Hello,
I am not sure if this is the right forum to post this question as it relates more to ODBC & SQL, but I'm using C++ for this particular app, so here goes:
We are dynamically creating tables in a SQL 2005 database to store log data - a new table for each day. The problem is that it works fine for about 8 days to 2 weeks and then just creates the log table for the new day, but stops writing entries into the table. When I drop the oldest log table from the database it again starts logging into the newest table.
I've verified that autogrow is turned on for the database & that there is no size limit set. The funny thing is it does actually autogrow, but only to a certain point (there is more than enough hard drive space available). It is on various machines on various sites we are getting this behavior, so it can't be the SQL installation.
Has anyone dealt with something like this before?
Thanks in advance,
Riaan du Plessis
|
|
|
|
|
Is there any way to perform "TOUCH" (like TOUCH in UNIX) in windows, with out installing any tools?
From the site : "http://support.microsoft.com/kb/69581, I came to know that we can use COPY command to perform TOUCH like operation. and tried the below command. but I got the error "The system cannot find the file specified."
system ( "/COPY C:/Documents and Settings/ms56106/.tdm/CookieSession_Details.txt /B +");
So please help to fix this. Below are the different options I tried, but no clue.
1) I Have executed the below command from command prompt it works fine.
C:\Documents and Settings\ms56106\.tdm> COPY /B "C:/Documents and Settings/ms56106/.tdm/CookieSession_Details.txt" +
1 file(s) copied.
And if try the same from different folder it fails,
C:\Documents and Settings\ms56106> COPY /B "C:/Documents and Settings/ms56106/.tdm/CookieSession_Details.txt" +
The system cannot find the file specified.
0 file(s) copied.
What should I do to run for a different folder?
2) I want the same command to be used in C++ source, for this I tried the same with system(), but it is not working. Please correct me.
tem = C:/Documents and Settings/ms56106/.tdm/CookieSession_Details.txt
system ( "/COPY tem /B +");
Thanks,
Nandu
|
|
|
|
|
Shouldn't you be using \ instead of / in the paths? Like, "C:\Documents and Settings\ms56106..." instead of "C:/Documents and Settings/ms56106..."? Don't know if that makes any difference though...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
In system() function i am using "\". But this is not the problem.
|
|
|
|
|
All WIN32 API functions all accept both '/' and '\' (for NT at least), only some old command-line tools written for DOS might give you a problem there.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi All,
How can i pass , BYTE array parameter from VC++ 6.0 to OLE Server to SAFEARRAY Argument.
Regards
Vj
modified on Thursday, November 27, 2008 5:43 AM
|
|
|
|
|
How is the function you're calling declared?
[modified]
I mean the function in the server.
What kind of argument are you supposed to pass, a VARIANT that contains a SafeArray?
[/modified]
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi Roger,
Thanks for you reply ,
i have written a dll in C#.net and using RegAsm i created a .tlb file and i am using those functions in VC++6.0
C# function
void fun(byte[] input)
which is conveted to void fun(SAFEARRAY *input) in .tlb file .
now i dont know how to pass BYTE array to this fun function from VC++ 6.0
|
|
|
|
|
Ok, try the following:
- Create a SafeArray with a call to
::SafeArrayCreate() and set the VARTYPE parameter to VT_UI1 . - Get the data buffer of the SafeArray with a call to
::SafeArrayAccessData() and copy whatever data you'd like into the buffer. - Release the bufer when you're done with it with a call to
::SafeArrayUnaccessData() . - Call the
fun() function.
Look the SafeArray functions up for information on how to call and use them.
Begin at SafeArrayCreate[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|