|
I "think" you may be able to use a 32-bit ARGB DIBsection - I put together this test just to
make sure the alpha channel stuff was working.
(My "hdc" would be your "dcMem" and you wouldn't want to delete it or un-select your alpha bitmap
like I have if you pass it to UpdateLayeredWindow())
Image TransparentSrcBitmap(L"clockbg.bmp");
LONG lImageWidth = TransparentSrcBitmap.GetWidth();
LONG lImageHeight = TransparentSrcBitmap.GetHeight();
WORD wBitsPerPixel = 32;
LONG lBytesPerRow = lImageWidth * 4;
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = lImageWidth;
bmi.bmiHeader.biHeight = lImageHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = wBitsPerPixel;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = lBytesPerRow * lImageHeight;
HDC hdc = ::CreateCompatibleDC(0);
BYTE* pBitmapBits;
HBITMAP hBitmap = ::CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**)&pBitmapBits, NULL, 0);
if (hBitmap)
{
memset(pBitmapBits, 0, bmi.bmiHeader.biSizeImage);
HGDIOBJ hOldBitmap = ::SelectObject(hdc, hBitmap);
Graphics DstGraphics(hdc);
DstGraphics.DrawImage(&TransparentSrcBitmap, 0, 0, TransparentSrcBitmap.GetWidth(), TransparentSrcBitmap.GetHeight());
BLENDFUNCTION bf;
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0;
bf.SourceConstantAlpha = 0x7F;
bf.AlphaFormat = AC_SRC_ALPHA;
HDC hClientDC = ::GetDC(*this);
::AlphaBlend(hClientDC, 50, 50, TransparentSrcBitmap.GetWidth(), TransparentSrcBitmap.GetHeight(),
hdc, 0, 0, TransparentSrcBitmap.GetWidth(), TransparentSrcBitmap.GetHeight(), bf);
::ReleaseDC(*this, hClientDC);
::SelectObject(hdc, hOldBitmap);<code>
::DeleteObject(hBitmap);<code>
}
::DeleteDC(hdc); <code>
Sorry about all the strange extra variables - I cut and paste from assorted working code to throw
together a test - saves some typing.
-- modified at 15:30 Friday 1st June, 2007
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
thank you Mark very much for taking the time, it mean as lot me.
but is not quite there is coming out pixalated, the alpha value is being replace by a black colour.
program running image:
http://img118.imageshack.us/img118/8953/testwindowhu9.png
.
.
.
Code: the main method.
http://rafb.net/p/1Dfouz58.html
thank you so much ....
|
|
|
|
|
No problem!
Can you show your latest code?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
What's "image" and what's "program window" in your screenshot?
Never mind I get it LOL
I'd still like to see your updated code if you can
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Code: the main method.
http://rafb.net/p/1Dfouz58.html
^i posted here
|
|
|
|
|
Try replacing
int t = UpdateLayeredWindow(hwnd, NULL, NULL, &sz, hdc, &ptSrc, NULL, &bf, ULW_COLORKEY );
with
int t = UpdateLayeredWindow(hwnd, NULL, NULL, &sz, hdc, &ptSrc, NULL, &bf, ULW_ALPHA );
You probably want to set bf.SourceConstantAlpha = 0xFF; (instead of 0x7F) too.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
And comment out these lines - they were there for testing only (leave in the BLENDFUNCTION
since you're using that)...
// comment these out
HDC hClientDC = ::GetDC(hwnd);
::AlphaBlend(hClientDC, 50, 50, TransparentSrcBitmap.GetWidth(), TransparentSrcBitmap.GetHeight(),
hdc, 0, 0, TransparentSrcBitmap.GetWidth(), TransparentSrcBitmap.GetHeight(), bf);
::ReleaseDC(hwnd, hClientDC);
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
thanks a million
one more thing since i've got you here.
will i be able to draw on this window?
i.e:
Graphics graphics(GetDC(hwnd));
Bitmap bitmap(L"clockbg.bmp");
graphics.DrawImage(&bitmap, 100,100);
i did a quick test it dont seem to be working.
my goal would be to be as great as you one day lol
|
|
|
|
|
Lamefif wrote: will i be able to draw on this window?
Absolutely not!
Just kidding.
The DIBSection bitmap is already in a DC which is associated with a Graphics object (DstGraphics).
That's where you should draw. Example...
DstGraphics.DrawImage(&TransparentSrcBitmap, 0, 0, TransparentSrcBitmap.GetWidth(), TransparentSrcBitmap.GetHeight());
Bitmap bitmap(L"clockbg.bmp");
DstGraphics.DrawImage(&bitmap, 100,100);
You have full access to the bitmap that IS your window. You can write directly to the pixel
bytes, use GDI+ to draw, use GDI to draw, or any combination of those
You may need to call UpdateLayeredWindow() again to see changes (i think the hdcSrc param can be
NULL for updates).
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Cheers Mark man
i new i could do it. :->
|
|
|
|
|
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi Experts,
I want to create instance of a inteface(IPropertyBag) ,defind in a abc.dll file.
And same name interface exist in ocidl.h file.How can i pass a correct GUID
so that i can access method defind in abc.dll.
i try like this
IPropertyBag* Properties;
hr=CoCreateInstance(__uuidof(PropertyBag),NULL,CLSCTX_INPROC_SERVER,
__uuidof(IPropertyBag),(void**) &Properties);
|
|
|
|
|
pther wrote: I want to create instance of a inteface(IPropertyBag) ,defind in a abc.dll file.
You don't "create" interfaces.
You create a component and ask for one, or several, of its interfaces.
When you create a component you have to specify which component you want to create and which interface you want to access in that component.
This is what the arguments to ::CoCreateInstance() is for.
The first parameter should be the CLSID of the component you want to create, have a look here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
You can use the Visual Studio Ole View tool to see the CLSID of the object.
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.
|
|
|
|
|
I saw the CLSID by ole Tool as u suggested.And i try to put the CLSID directly in CoCreateInstance().
Like:
hr=::CoCreateInstance(uuid(47000673-7DB2-44C9-8AC1-65266117D280),NULL,CLSCTX_INPROC_SERVER,
__uuidof(IPropertyBag),(void**) &Properties);
But it dispaly syntext error.
error C2059: syntax error : ')'
error C2059: syntax error : 'bad suffix on number'
error C2059: syntax error : 'bad suffix on number'
error C2059: syntax error : 'bad suffix on number'
How can i make it correct
|
|
|
|
|
pther wrote: hr=::CoCreateInstance(uuid(47000673-7DB2-44C9-8AC1-65266117D280),NULL,CLSCTX_INPROC_SERVER,
__uuidof(IPropertyBag),(void**) &Properties);
You cannot use the CLSID string (47000673-7DB2-44C9-8AC1-65266117D280) that way, you have EITHER TO:
(1) Properly initialize the GUID struct members (The following example deals with MsComm control, asking for IUnknown interface):
GUID guid;
IUnknowun *pUnk;
guid.Data1 = 0x648A5600;
guid.Data2 = 0x2C6E;
guid.Data3 = 0x101B;
guid.Data4[0] = 0x82;
guid.Data4[1] = 0xB6;
guid.Data4[2] = guid.Data4[3] = guid.Data4[4] = guid.Data4[5] = guid.Data4[6] = 0x00;
guid.Data4[7] = 0x14;
hr = CoCreateInstance( guid, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **) &pUnk);
OR
(2) Use the UuidFromString to perform the task, i.e.
GUID guid;
IUnknown * pUnk;
RPC_STATUS Status = UuidFromString((unsigned char *)"648A5600-2C6E-101B-82B6-000000000014", &guid);
hr = CoCreateInstance( guid, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **) &pUnk);
Please note that point (2) requires the rpc.h header in your source file and to link your project with rpcrt4.lib library.
Hope that helps.
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.
|
|
|
|
|
Why does we pass a const reference object parameter in copy constructor?
|
|
|
|
|
why not ? maybe because we don't want to modify the original object ?
|
|
|
|
|
If you would pass an object instead of a reference, this would in turn call the copy constructor (because a copy of the object is made and passed to the function), so you will end in an infinite loop of calling copy constructor.
And for the const, it makes sense that you want to make a copy of the original object and not modify it.
|
|
|
|
|
toxcct wrote: hey, will you stop asking dummy question and think a little by yourself...
And another thread (How to Authorize a Dll Loading[^]):
that's stupid...
Did someone pee in your Cheerios today?
Jeff
|
|
|
|
|
You have posted several questions within a short amount of time that suspiciously look like homework.
__________________
Bob is my homeboy.
|
|
|
|
|
I dunno, they've been trying to figure out copy constructors since January. December
|
|
|
|
|
Remembering copy constructors I want to know if anyone knows the optimization issues with it. Does a compiler automatically synthesise a copy constructor if it is not found. What is the performance hit vis a vis a contructor although they both serve the different purpose.
Does anyone have debugged a copy constructor when it is not exclusively mentioned for a class.
|
|
|
|
|
Plz tell me how events are processed (flow of direction from WinApp to Doc)in Doc-view architecture in VC++?
|
|
|
|
|
Plz look it up in MSDN.
WM_CONTROL is one of the words you could try searching.
Failure is not an option - it's built right in.
|
|
|
|
|