Hi Friends,
I face memory leak and no response when I try to paint continuous bitmap.
(Firstly, I would like to admit that I don't know complicated commands and I just able to use few commands. So, please don't be mind if my question is too simple.)
Here is the process that I try.
I would like to draw random color transparent pixel on fixed bitmap. I wrote the following code in MFC Dialog-based Application, OnPaint event. Then, I can see what I want(random color transparent pixel on fixed bitmap).
CDC dc;
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP_TESTBITMAP);
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
CDC* pDC = this->GetDC();
dc.CreateCompatibleDC(pDC);
CBitmap* pOldBmp = dc.SelectObject(&bmp);
pDC->BitBlt(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, &dc, 0, 0, SRCCOPY);
for (int i = 0; i < bmpInfo.bmHeight; i++) {
for(int j = 0; j < bmpInfo.bmWidth; j++) {
dc.SetPixel(j, i, RGB(rand()%100, rand()%50, rand()%100)); }
}
pDC->BitBlt(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, &dc, 0, 0, SRCAND);
dc.SelectObject(pOldBmp);
bmp.DeleteObject();
dc.DeleteDC();
this->ReleaseDC(pDC);
CDialogEx::OnPaint();
In next step, I would like to set pixel from file data whenever the new file data is added to folder. So, I use
do {
ReadDirectoryChanges(...); pInfo = (FILE_NOTIFY_INFORMATION*) &buffer;
If (pInfo->Action == FILE_ACTION_ADDED) {
}
But the problem is after changing the program as above code and run it, just only the first file data is shown and no response after that. And also memory is occurred. What's big mistake with my code?
Thanks in advanced for your time and help.