|
Do you mean a forum for C++ Builder? No we haven't. Anyway you try to ask your question here.
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]
|
|
|
|
|
|
How to read footer at a sector using C++/VC++
|
|
|
|
|
Hi!
I want to write to PE run on empty OS.
It help winAPI run on "Empty OS"
Please,full code & guide
Thanks : -D
-D -D -D -D -D -D
Vietnam.
by:tuan1111
modified on Monday, July 20, 2009 9:24 PM
|
|
|
|
|
You're not giving up, are you?
tuan1111 wrote: I'm reading bootloader
Try to read an English course first.
Alternatively, run your post through several, randomly selected languages on translate.google.com, I'm sure it will make more sense then.
tuan1111 wrote: I say the hard things I want them
What?
tuan1111 wrote: Please provide code
Let me correct that for you:
Pleeze sendz codez
|
|
|
|
|
The above post wouldn't be out of place in this site[^]
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hello,
I'm developing an MFC application that I'd like to provide context sensitive help for. Does MFC provide such a facility? I think that .chm files are deprecated in Windows vista - something called MAML is used instead.
My questions is, what is the modern, preferred way to create context sensitive help within MFC?
Regards,
Sternocera
|
|
|
|
|
Is there anbody out there who has a working code snippet that uses WinApi function Alphablend()?
Can Alphablend() be used with a bitmap that has no alphachannel?
Thanx
modified on Sunday, June 28, 2009 5:00 AM
|
|
|
|
|
I use it on a splash screen.
header file:
typedef BOOL (WINAPI ALPHABLEND)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION);
typedef ALPHABLEND* LPALPHABLEND;
class ...
{
...
HINSTANCE m_hLib;
LPALPHABLEND m_lpfnAlphaBlend;
...
};
source file:
m_hLib = LoadLibrary(_T("msimg32.dll"));
if (m_hLib != NULL)
{
m_lpfnAlphaBlend = (LPALPHABLEND)GetProcAddress(m_hLib, "AlphaBlend");
}
if (m_hLib != NULL)
{
FreeLibrary(m_hLib);
m_hLib = NULL;
}
BOOL C*********::OnEraseBkgnd(CDC* pDC)
{
CDialog::OnEraseBkgnd(pDC);
if (m_lpfnAlphaBlend != NULL)
{
CRect rc;
GetClientRect(rc);
BITMAP b;
if (GetObject(m_hBitmap,
sizeof(BITMAP),
&b))
{
CDC DC;
DC.CreateCompatibleDC(pDC);
int s = DC.SaveDC();
DC.SelectObject(m_hBitmap);
BLENDFUNCTION bf = {0};
bf.BlendOp = AC_SRC_OVER;
bf.SourceConstantAlpha = 0x20;
m_lpfnAlphaBlend(*pDC,
(rc.Width() - b.bmWidth) / 2,
(rc.Height() - b.bmHeight) / 2,
b.bmWidth,
b.bmHeight,
DC,
0,
0,
b.bmWidth,
b.bmHeight,
bf);
DC.RestoreDC(s);
}
}
return TRUE;
}
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Tnx for an answer..
I spelled your code character by character and it seems that i do essentially the same. So this leaves me to ask you some stupid questions:
1. Is bf.BlendOp = AC_SRC_OVER; the same as: bf.BlendOp = 0; ??
2. To my opinion you do nothing to add an alpha channel to your bitmap. Thus your bitmap has no alpha channel - do you agree on that?
3. Because i use another language then you: what does int s = DC.SaveDC() ; do? Is this one essential to Alphablend?
Thanks
Rozis
|
|
|
|
|
Rozis wrote: 1. Is bf.BlendOp = AC_SRC_OVER; the same as: bf.BlendOp = 0; ??
from wingdi.h:
#define AC_SRC_OVER 0x00
Rozis wrote: 2. To my opinion you do nothing to add an alpha channel to your bitmap. Thus your bitmap has no alpha channel - do you agree on that?
From MSDN[^]:
When the AlphaFormat member is AC_SRC_ALPHA, the source bitmap must be 32 bpp. If it is not, the AlphaBlend function will fail. So you are correct, I did not worry about the alpha channel. I just set the AlphaFormat value to zero.
Rozis wrote: 3. Because i use another language then you: what does int s = DC.SaveDC() ; do? Is this one essential to Alphablend?
See http://msdn.microsoft.com/en-ca/library/dd162945(VS.85).aspx[^] and http://www.flounder.com/savedc.htm[^]
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
hmmm... im out of questions but it still doesn't run. This my code: (warning: this is not C-code, but i'll explain when needed)
hMemDC:=CreateCompatibleDC(hdc)
if hMemDC!=NULL_PTR
hbitmap:=CreatecompatibleBitmap(hdc,w,h)
hold:=SelectObject(hMemDC,hBitmap)
Rectangle(hmemDC,0,0,w,h)
blendfunc.BlendOp:=0
blendfunc.BlendFlags:=0
blendfunc.SourceConstantAlpha:=128
blendfunc.AlphaFormat:=0
AlphaBlend(hdc,x,y,w,h,hMemDC,0,0,w,h,@blendfunc)
SelectObject(hMemDC,hold)
DeleteObject(hBitmap)
DeleteDC(hMemDC)
endif
When i use StretchBlt() or BitBlt() instead it works (altough not transparent). I checked if x,y,w and h are possitive - they are. Think you may ask whats '@blendfunc'. It means 'pointer to structure'. Use this construct for years so must be correct (for example in GetClientRect()). Tried a demo-exe from the code project to find out if problem is system related - it worked ok. Checked the prototype and the structure. I must do something really stupid...
Rozis
|
|
|
|
|
Rozis wrote: Think you may ask whats '@blendfunc'. It means 'pointer to structure'.
That is the problem right there. AlphaBlend takes the structure, not a pointer to a structure, as the final parameter.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Guess what, you're right!! That was the thing i was overlooking. You're a genius!!!
Did a quick try, made 0x00800000 as the last parameter to Alphablend() and it does the job. And it is lightyears faster then the workaround i made with getpixel(). Problem solved!
The reason i never questioned it, is because a struct is a chunk of memory so i expected this would always be a pointer when used as a parameter. I mean: when a have a struct of let's say 200 bytes and use it as a parameter to a function would this mean these 200 bytes are allocated on the stack?
Saw you're living in Canada, although you have a dutch name. So whenever you are in holland, call me, i have a present for you. Thanks for taking your time.
Rozis
|
|
|
|
|
Rozis wrote: You're a genius!!!
Not really, I just read the documentation , I am just glad to be able to help.
Rozis wrote: Saw you're living in Canada, although you have a dutch name.So whenever you are in holland, call me, i have a present for you
My grandparents emigrated from Holland to Canada in the fifties. I would love to go there some day and see where my heritage comes from. Maybe when I do finally manage the trip I will try to look you up and take you up on your offer.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Hi,
i have a resource file in which i have changed the font property of the dialog to "Arial" regular
20....
then the font inside the dialog got increased...along with the text of the controls inside dialog..
and now i tried changing from the code in initDialog function like...
CFont newfont;
LOGFONT lf;
SecureZeroMemory(&lf, sizeof(lf));
lf.lfHeight = 20;
lf.lfWeight = FW_MEDIUM;
lstrcpy(lf.lfFaceName, _T("Arial"));
newfont.CreateFontIndirect(&lf);
GetDlgItem(IDC_CHECK1)->SetFont(&newfont);
GetDlgItem(IDC_STATIC)->SetFont(&newfont);
newfont.Detach();
and now when i build and see the output the look of the dialog with new font is not same and even the font looks smaller than the font of the dialog which i have tried to change manually the font property of the Dialog....
Please suggest me how can i make changes to my code so that both look similar....
modified on Friday, June 26, 2009 4:20 PM
|
|
|
|
|
Well, it looks like newfont goes out of scope.
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]
|
|
|
|
|
i mean even though thru code i have applied the font height as 20 font looks smaller
than the font which is obtained by manual change....
the font(thru code) is getting applied but it doesn"t looks same as the other font(manual)..
|
|
|
|
|
OK.
kumar sanghvi wrote: lf.lfHeight= 20;
From MSDN [^]:
For the MM_TEXT mapping mode, you may use the following formula to specify a height for a font with a given point size.
lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
where MulDiv is defined as follows:
#define MulDiv(a,b,c) (((a)*(b))/(c))
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]
|
|
|
|
|
Thanks for ur valuble response...
it improved than before but font looks a bit smaller than the font which i have modified manually....
both doesn"t looks exactly similar....
|
|
|
|
|
anybody please try to help me....
|
|
|
|
|
Hi all,
I've beating this around for a few days now and I'm totally lost.
I was given a DLL written in VB by a client with the idea of instantiating a class and calling some of the methods. I created a small test app (from code I found here) and attempted to use CoCreateInstance. This worked fine in the code shown below. The client then gave me a more up-to-date version of the DLL and with this new version, CoCreateInstance failed with a E_NOINTERFACE.
I've gone back and forth with the client about this and they have said that it was compiled with the same compiler (really old was the comment) and that all that was changed with the new release was couple of lines of code. They said they had recompiled the DLL under the highest compatibility. A couple of years has gone by since releases, so there may be underlying OS changes, if that would make a difference. They have said they have other users using the DLL without issues, though perhaps not with C/C++.
I modified the code so that instead of using CoCreateInstance, it uses CoGetClassObject and CreateInstance. CreateInstance fails with E_NOINTERFACE, the same error.
I would appreciate all help in understanding how to debug this, bearing in mind that I'm unfamiliar with COM.
This is a snippet from stdafx.h:
#import "TTExt.dll" no_namespace
This is a snippet from the area where I do the CoCreateInstance:
void CVCClientDlg::OnButton1()
{
HRESULT hresult;
CLSID clsid;
CoInitialize(NULL);
hresult=CLSIDFromProgID(OLESTR("TTExt.WebRes"), &clsid);
if(FAILED(hresult))
{
switch (hresult) {
case CO_E_CLASSSTRING:
AfxMessageBox("CLSID Failed -- registered CLSID for the ProgID is invalid");
break;
case REGDB_E_WRITEREGDB:
AfxMessageBox("CLSID Failed -- error occurred writing the CLSID to the registry.");
break;
default:
AfxMessageBox("CLSID Failed -- unknown reason");
break;
}
}
_WebRes *wr;
IClassFactory *pCF;
hresult=CoGetClassObject(clsid, CLSCTX_INPROC_SERVER, NULL, IID_IClassFactory, (LPVOID *)&pCF);
hresult = pCF->CreateInstance(NULL, __uuidof(_WebRes), (LPVOID *)&wr);
if(FAILED(hresult))
{
switch (hresult) {
case REGDB_E_CLASSNOTREG:
AfxMessageBox("Creation Failed -- Class not registered");
break;
case CLASS_E_NOAGGREGATION:
AfxMessageBox("Creation Failed -- class cannot be created as part of an aggregate.");
break;
case E_NOINTERFACE:
AfxMessageBox("Creation Failed -- class does not implement the requested interface");
break;
case E_POINTER:
AfxMessageBox("Creation Failed -- ppv parameter is NULL");
break;
default:
AfxMessageBox("Creation Failed -- unknown reason");
break;
}
return;
}
bool bCon = wr->Connect("GEX", "");
if (bCon)
MessageBox("Connect Succceded\n");
else
MessageBox("Connect Failed **********\n");
wr->Release ();
CoUninitialize();
}
This is a snippet from the top of the .tlh file:
#pragma once
#pragma pack(push, 8)
#include <comdef.h>
struct __declspec(uuid("f5171c2c-b846-47bc-8c7f-19658cfc0086"))
__TTExt;
struct __declspec(uuid("787d47a3-020f-4b1f-912e-003523277942"))
_WebRes;
struct WebRes;
_COM_SMARTPTR_TYPEDEF(_WebRes, __uuidof(_WebRes));
struct __declspec(uuid("787d47a3-020f-4b1f-912e-003523277942"))
_WebRes : IDispatch
{
I did a comparison of the .tlh files from the two different versions of the DLL and this is the result:
Compare: (<)C:\Documents and Settings\phild\My Documents\Visual Studio Code\VBDll\VCClient\Debug\tmp\v7.ttext.tlh (10755 bytes)
with: (>)C:\Documents and Settings\phild\My Documents\Visual Studio Code\VBDll\VCClient\Debug\tmp\v6.ttext.tlh (10755 bytes)
6c6
<
---
>
17,19c17,19
< struct __declspec(uuid("e897466c-75b0-459f-9512-21d42e1f5703"))
< __TTExt;
< struct __declspec(uuid("dc8718c4-d07f-4542-a799-f2015a0614cf"))
---
> struct __declspec(uuid("f5171c2c-b846-47bc-8c7f-19658cfc0086"))
> __TTExt;
> struct __declspec(uuid("787d47a3-020f-4b1f-912e-003523277942"))
33c33
< struct __declspec(uuid("dc8718c4-d07f-4542-a799-f2015a0614cf"))
---
> struct __declspec(uuid("787d47a3-020f-4b1f-912e-003523277942"))
311c311
< struct __declspec(uuid("d00de9f1-98eb-4cd9-8685-0ea4f283971f"))
---
> struct __declspec(uuid("0cab506a-1b4d-473f-9a8b-051277ae5603"))
modified on Friday, June 26, 2009 2:32 PM
|
|
|
|
|
Did you unregister the previous DLL and register the new one?
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]
|
|
|
|
|
Hi Pallini,
Thank you for responding.
Yes, in fact I can unregister the old DLL, register the new DLL, try the test code and it will fail. I can then unregister the new DLL and register the old DLL and it will work fine.
Other ideas?
|
|
|
|
|
BeerFizz wrote: hresult=CLSIDFromProgID(OLESTR("TTExt.WebRes"), &clsid);
BeerFizz wrote: hresult = pCF->CreateInstance(NULL, __uuidof(_WebRes), (LPVOID *)&wr);
Have you done, using the debugger, a constistency check between clsid and __uuidof(_WebRes) ?
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]
|
|
|
|
|