If you want to create the file-mapping object so that it reflects the current size of the file, you can pass 0 for both parameters. If you intend only to read from the file or to access the file without changing its size, pass 0 for both parameters. If you intend to append data to the file, you will want to choose a maximum file size that leaves you some breathing room. If the file on disk currently contains 0 bytes, you can't pass two zeros to CreateFileMapping's dwMaximumSizeHigh and dwMaximumSizeLow parameters. Doing so tells the system that you want a file-mapping object with 0 bytes of storage in it. This is an error and CreateFileMapping will return NULL.
Since you are using PAGE_READWRITE in CreateFileMapping....Your intension might be to write something in file whose size you have given to be 0 in CreateFileMapping.
I think you can map (using flag PAGE_READWRITE)file whose size is zero by specifying some number > 0 as dwMaximumSizeLow parameter of CreateFileMapping(). This number will be equal to no.of bytes that you want to write to file. The file will be expanded to that size if its size was initially zero.
I am writing an application which try to show PNG file as a dialog background using GDI+
I have successfully using the PNG as background (using Graphics::DrawImage()), however, I found that the loaded PNG seems not apply the alpha channel information. What I should do?
I would like to have a transparent background (i.e. I set the desktop background to black/white, I hope the image boundary will be "blur" with the work of alpha bending).
I am not sure if what I do is right, however, with using the Graphics::SetCompositingMode(), it seems that the Graphics::DrawImage() method will not directly apply the alpha bending information? ( I use Bitmap::GetPixelFormat() to verify the input image is a PixelFormat32bppARGB type, which means it should include the alpha channel)
// Load a bitmap
Bitmap SrcBitmap(L"C:\\Test.png", FALSE);
// Draw the bitmap to the DC at 0,0
DstGraphics.DrawImage(&SrcBitmap, 0, 0, SrcBitmap.GetWidth(), SrcBitmap.GetHeight());
If something's not working I'd have to see a code sample to possibly help
I have made a worker thread in which i have defined a critical section using CCriticalSection class. I have started this worker thread inside a for loop.
Now my problem is when i want to stop my thread before completing the for loop(ie i want that all the threads already running should stop as well as no new thread should start). I am not getting the way to do this.
In general the way to do it is to use a flag to tell the thread to continue looping or not: the loop will check this flag and continue its work until it is set.
Then, from your main thread, you can set this flag in order to stop the thread.
But of course, this depends a lot of your current architecture.
I have a list control on my dialog box.Property is set to Report view & member name is m_Pressure.
CEdit* pEdit = m_Pressure.GetEditControl();
Above function is always returning NULL.
Please help me out
In Property of Control list i checked edit labels.
I included NM_Click function as below.
ptrPressInPSI is a pointer to the control list
ptrPressInPSI = &m_Pressure;
void list::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
// TODO: Add your control notification handler code here
CEdit* edit = ptrPressInPSI->GetEditControl();
*pResult = 0;
Any thing wrong in above code.It is still returning NULL
Thanks naveen. I got it.
But one question why am not able to use above code in other functions.I want to include copy & paste function for CListCtrl,Below is a code which i got from google
In the below code am facing two problems
1)As i told CEdit* edit = m_Pressure.GetEditControl(); is always NULL
2)when i include CListCtrl& m_list4 = GetListCtrl( ); am getting below errors
D:\JUNE\VC\test1\list.cpp(147) : error C2065: 'GetListCtrl' : undeclared identifier
D:\JUNE\VC\test1\list.cpp(147) : error C2440: 'initializing' : cannot convert from 'int' to 'class CListCtrl &'
BOOL list::PreTranslateMessage(MSG* pMsg)
// TODO: Add your specialized code here and/or call the base class
if ( pMsg->message == WM_KEYDOWN )