|
i found how to complete it.thx all the same
|
|
|
|
|
what was the solution ?
I'd rather be phishing!
|
|
|
|
|
use method UpdateResource
|
|
|
|
|
I am dealing with tons of functions, and i am using sendmessage and other macros as well, but somehow each time i use sendmessage the handles in taskmanger get increased, even using createfont as this
Hfont = createfont(.....)
deleteobject(Hfont)
but as i know deleteobject will delete the Gdi object, but what abut its handle? I am not sure why this happens, even this
listview_setitemcount(.....)
bty I am destroying my HWND object each time i use X button, so i make a new one (I have no problem with Gdi they all fine) except those handles? has anyone faced this?
Update; now 100% sure that using sendmessage(....) increasing my handles 1 time, but why?
modified 25-Sep-13 5:17am.
|
|
|
|
|
Just “discovered” that I can post a message into application main window from a secondary thread: AfxGetMainWnd()->PostMessage(WM_GRAPH, 0, 0);
No biggie, but I can also process the message using MFC PreTranslateMessage.
Still “so what?”
The catch is – the PreTranslateMessage “walker” starts in main app window and goes <b>DOWN the MFC </b>hierarchy and the message is eventually processed by correct object.
Just exactly the opposite what the doc say.
It does the work I need, but I wonder if my VC++ is broken again or is this normal?
Cheers Vaclav
|
|
|
|
|
Hi,
The documentation is correct. Note that 'PreTranslateMessage' is an MFC invention. Basically it boils down to this:
In Win32 each window has a default WindowProc callback function[^]. However the MFC does its own internal command routing. You should probably read some of the older MFC documentation from MSDN that explains it in detail.
Found one from Paul Dilascia (circa 1995):
http://www.microsoft.com/msj/0795/dilascia/dilascia.aspx[^]
Best Wishes,
-David Delaune
|
|
|
|
|
I am using sockets derived from CSocket
I am getting details about the client IP address and Port after calling Accept(socket).
Eg:
void CListenSocket::OnAccept(int nErrorCode)
{
CSocket::OnAccept(nErrorCode);
m_pSocket->Accept(*pSocket);
}
Anyone Please let me know if it is possible to know the details about the client IP address and Port before calling Accept(socket).
|
|
|
|
|
Perhaps this[^] link will help.
|
|
|
|
|
How to check outdated driver programmatically?
|
|
|
|
|
Check it for what specifically? A detail or three would be nice!
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Maybe this[^] link will get you started in the right direction.
|
|
|
|
|
You cant really since you have no idea just what it does at a functional level, however running it through Microsofts WHQL will tell you whether it is fit or not. You can also enable Verifier on it and select pretty much everything except Low Resource SImulationn.
If it fails these, junk it and tell who wrote it their product is garbage.
|
|
|
|
|
You can use GetFileVersionInfoSize() , GetFileVersionInfo() and VerQueryValue on a driver-file just the same way as a DLL/EXE.
It is a bit complex, but see here for an example.
Gisle V.
# rm -vf /bin/laden
/bin/rm: success
|
|
|
|
|
Dear All,
when its required explicit keyword in constructor? and what is the purpose?
Regards,
Ranjith
|
|
|
|
|
It is used to prevent the constructor to be used for implicit conversion, see explicit (C++)[^] for an example.
0100000101101110011001000111001011101001
|
|
|
|
|
Hey there,
I have the raw image data and now want to convert it to PNG image. How can i do that? The raw image data is stored in a unsigned char *.
I know how to convert it to Bitmap, but have no idea how to convert it to PNG.
Thanks in advance.
|
|
|
|
|
|
Hi,
If you are on the Microsoft Windows operating system and don't mind using the GDI+ library then you could use the Bitmap Class[^] which inherits from the Image Class[^] that has an Image::Save[^] method and can be used for image encoding[^].
Best Wishes,
-David Delaune
|
|
|
|
|
Yes i am using MFC in Visual Studio 2012 IDE.
Does Image Encoding can convert raw image date to PNG format?
I know Image.Save() can save a BMP file in PNG or JPG format, but here the purpose is not convert and save into the hard drive. But i want the PNG formatted data, which can be later used for other purposes.
|
|
|
|
|
Hi,
Don Guy wrote: Does Image Encoding can convert raw image date to PNG format? No
I gave you a link to the Bitmap Class[^]. You should consider using one of these class constructors to generate your Bitmap object.
Bitmap.Bitmap(INT, INT, INT, PixelFormat, BYTE*) constructor[^]
Bitmap.Bitmap(const BITMAPINFO*, VOID*) constructor[^]
Don Guy wrote: I know Image.Save() can save a BMP file in PNG or JPG format, but here the purpose is not convert and save into the hard drive. But i want the PNG formatted data, which can be later used for other purposes.
Great. Since you already know that you can call Image.Save[^] to save to disk. Then surely you would know that you can also save to an in-memory IStream[^]:
Image.Save(IStream*, const CLSID*, const EncoderParameters*) method[^]
Here is an example from one of my personal projects. In this project I am taking screenshots of websites via the Webkit backing store and converting them to PNG image thumbnails and serving them over HTTP. This example reads from a HBITMAP to a Bitmap object then saves as an encoded PNG image into an in-memory IStream.
BYTE * WebKitWnd::GetPNGImageFromBackingStore(UINT& iLength)
{
BYTE *pRet = nullptr;
iLength = 0;
CDC memDC;
memDC.CreateCompatibleDC(NULL);
DIBSECTION ds;
BITMAPINFOHEADER &bmInfo = ds.dsBmih;
if(NULL != m_hBacking && NULL != ::GetObject(m_hBacking, sizeof(ds), &ds))
{
Bitmap bmp(m_hBacking,NULL);
Graphics g(&bmp);
CLSID encoderClsid;
BYTE *png_buffer = nullptr;
if(TRUE == GetEncoderClsid(L"image/png", &encoderClsid))
{
IStream *buffer;
VERIFY_SUCCEEDED(::CreateStreamOnHGlobal(NULL, FALSE, &buffer));
bmp.Save(buffer,&encoderClsid,NULL);
STATSTG statstg;
VERIFY_SUCCEEDED(buffer->Stat(&statstg, STATFLAG_DEFAULT));
ULONG m_bmpBufferSize = (ULONG)statstg.cbSize.LowPart;
BYTE *png_buffer = new(std::nothrow) BYTE[m_bmpBufferSize];
if(png_buffer)
{
LARGE_INTEGER li = {0};
buffer->Seek(li, STREAM_SEEK_SET, NULL);
ULONG m_nRead;
buffer->Read(png_buffer,m_bmpBufferSize, &m_nRead);
pRet = png_buffer;
iLength = m_bmpBufferSize;
buffer->Release();
}
}
}
memDC.DeleteDC();
return pRet;
}
Best Wishes,
-David Delaune
|
|
|
|
|
I get an error @ GetEncoderClsid - Error undefined function call.
So i added the below function i got from MSDN and this throws an exception.
Is GetEncoderClsid a Windows function?
int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
UINT num = 0; // number of image encoders
UINT size = 0; // size of the image encoder array in bytes
ImageCodecInfo* pImageCodecInfo = NULL;
Gdiplus::GetImageEncodersSize(&num, &size);
if(size == 0)
return -1; // Failure
pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // Failure
Gdiplus::GetImageEncoders(num, size, pImageCodecInfo);
for(UINT j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
*pClsid = pImageCodecInfo[j].Clsid;
free(pImageCodecInfo);
return j; // Success
}
}
free(pImageCodecInfo);
return -1; // Failure
}
|
|
|
|
|
The exception is being thrown inside file - GdiplusImageCodec.h in fucntion GetImageEncodersSize
It says "Access violation writing to location................"
|
|
|
|
|
Unhandled exception at 0x000000007772E4E4 (ntdll.dll) in My.exe: 0xC0000005: Access violation writing location 0x0000000000000024.
|
|
|
|
|
|
Thanks a lot David Delaune
|
|
|
|