|
I use the class and it works fine on XP. On Vista the bitmap window disappears when the mouse moves over it. Anyone know what is going on?
Paul Runner
|
|
|
|
|
Hi Paul,
Have you find a solution?
Thanks,
Andrew
|
|
|
|
|
Hi,
I got this to work OK for dialogs. I would like it to work with a splash screen. i.e. before the main window of my app starts.
In the CFaderWnd constructor the AfxGetMainWnd() returns not with the main window CWnd* but with the same CWnd* as the window to be faded. I think this is screwing it up.
When this happens it jumps straight to the destructor of CFaderWnd and no fading takes place.
Any suggestions?
|
|
|
|
|
If you haven't yet created your main window then AfxGetMainWnd will not be able to return a pointer to it; it will return a pointer to the only window it can find - your splash dialog.
You could try creating (but not necessarily showing) your main window before you construct the splash dialog (or at least before you construct the CFaderWnd).
Alternatively you could try fading the splash dialog with AnimateWindow()
Regards,
Phil
|
|
|
|
|
UpdateLayeredWindow doesnt seem to work if the TopLeft x-coordinate of the
original window is negative. I have a dual display setup with desktop
extended to the left of the primary display (such that the TopLeft
coordinate for the desktop on that monitor is {-1600,0} ). Coordinates
for any window on this extended desktop will have a negative x value.
If I drag the mainframe window of the fader demo onto the extended
desktop, the fade doesnt work anymore. Of course, it does work on the
primary display.
How can I get UpdateLayeredWindow to work on the secondary display? I
tried dragging Windows Explorer onto the sec display; the fade-away tooltips
in Explorer continue to work. Thus there must be a way to make it work
somehow (or do the Explorer tooltips use an API different than
UpdateLayeredWindow?)
|
|
|
|
|
Did you ever resolve this? I have come into the same problem and would appreciate learning anything you found from your experience.
Thanks.
-b
|
|
|
|
|
Nope- tried everything I could think of but just couldnt
get UpdateLayeredWindow to work.
What I did instead (and which works exactly as you'd want) is use
SetLayeredWindowAttributes(0, alphaval, LWA_ALPHA).
I set up a timer and in the timer handler, I update the alphaval
and call SetLayeredWindowAttributes. Note that you dont need to call
RedrawWindow or somesuch after this; SetLayeredWindowAttributes
itself causes a redraw.
Hope this helps.
|
|
|
|
|
What could be the reason why I am encountering an error: errorcode 998 - Invalid access to memory location.
Thanks.
Will
|
|
|
|
|
You'll need to supply more detailed information than that if you expect a useful reply.
Maybe in the course of gathering sufficient information about the circumstances of the error and where it occurs you will find the reason for it anyway.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
I know it does not directly relate to the demo,but is there a way to use the Layered Windows API to direct the rendering of the underlaying window's image (the one beneath the top) to an off-screen bitmap and have it refresh automatically whenever the original window repaint itself? say i want another console have real time remote view of a IE session, like in a classroom, is there a way to use Layered Windows to produce a real time image of the source window?
|
|
|
|
|
UINT nElapse = nFadeTime / (byAlpha / ALPHA_STEP);
if byAlpha equals to zero, it happends!
|
|
|
|
|
I believe I found a small memory leak in the code. However, I also have a simple solution.
In the constructor, towards the end of the code you will find:
m_pUpdateLayeredWindow(GetSafeHwnd(), NULL, NULL, &size, ::GetDC(m_pWndToFade->GetSafeHwnd()), &ptSrc, 0, &m_Blend, ULW_ALPHA);
The memory from the DC never gets freed up. To fix this simply change the code to:
HDC hDC = ::GetDC(m_pWndToFade->GetSafeHwnd()); <br />
m_pUpdateLayeredWindow(GetSafeHwnd(), NULL, NULL, &size, hDC, &ptSrc, 0, &m_Blend, ULW_ALPHA);<br />
::ReleaseDC( NULL, hDC );
Thus, releasing the DC when finished with it.
|
|
|
|
|
is there eny way to use layerd window on winodws 9x
or do somthing that look like layerd window ?
amit kuzi
|
|
|
|
|
Layered windows are not supported on 9x (or Me). Lots of other things are not supported either ... stop using it!
It would theoretically be possible to do something that looks like a layered window but it would be very complex and slooooooow. If the PC is fast enough to do that then it should not be running 9x anyway.
Phil
|
|
|
|
|
Hi there,
I was hoping perhaps you could shed some light on this little problem of mine... Sorry to bother, but you seem to know a bit about alpha blending.
I'm trying to use the ::AlphaBlt function to perform a simple fade effect on the screen. Basically I need to create a transition between the current bitmap on a dc, and a new bitmap which is to "fade in".
I have hacked up the following code, and it works somewhat. The problem is that it is not smooth. Also, it takes way toooo much cpu to do, and this causes inconsistencies in timing. Usually in runs in about a few seconds at 1024x768, but on some machines at 1280x1024, it takes 10 seconds or worse!
Here's the code. Hopefully it won't be too hard to read through the irrelevant stuff...
void
cPkpPhotoImage::BlitStretchedFromProprietaryBlitEffectFade(CDC& DestDc,
const cRect& PassedSourceRect, const cRect& DestRect, uint32 rop,
const sEffectInfo& EffectInfo)const
{
LBitmap* Bitmap = GetBlitBitmap();
if(!Bitmap)
{
// Should not get here.
ASSERT(false);
}
else
{
cSize ThisSize = GetCurrentImageSize();
cRect SourceRect(ThisSize);
BLENDFUNCTION BlendInfo;
BlendInfo.BlendOp = AC_SRC_OVER;
BlendInfo.BlendFlags = 0;
BlendInfo.AlphaFormat = 0;
BlendInfo.SourceConstantAlpha = (BYTE)grain;
CDC ThisDc;
if(LockDcInternal(ThisDc, Bitmap))
{
cTimer Timer;
cTimeTag WhenCanProgress;
cBitmap NoFlickerBitmap(DestDc, DestRect.GetSize());
cDC NoFlickerBitmapDc(&NoFlickerBitmap, &DestDc);
// First copy what's in the dest dc onto our temporary bitmap so we
// can do the fade.
NoFlickerBitmapDc.BitBlt(0, 0, DestRect.GetWidth(),
DestRect.GetHeight(), &DestDc, DestRect.left, DestRect.top, rop);
int numIterations = ((256 / grain) * 2) + 1;
for(int i = 0; i < numIterations; i++)
{
// Do the alpha blend onto the temporary bitmap.
::AlphaBlend(NoFlickerBitmapDc.m_hDC, 0, 0,
DestRect.GetWidth(), DestRect.GetHeight(), ThisDc.m_hDC,
SourceRect.left, SourceRect.top, SourceRect.GetWidth(),
SourceRect.GetHeight(), BlendInfo);
// Now we wait a bit if we're too quick. Note that we do as much
// processing before waiting, to ensure delay accuracy.
for(;
{
if(Timer > WhenCanProgress)
{
// Can progress.
break;
}
else
{
int sleepTime = -(Timer - WhenCanProgress);
if(sleepTime > 0)
{
::Sleep(sleepTime - 2);
}
}
}
// Then blit that bitmap onto the dest dc.
DestDc.BitBlt(DestRect.left, DestRect.top, DestRect.GetWidth(),
DestRect.GetHeight(), &NoFlickerBitmapDc, 0, 0, rop);
WhenCanProgress = cTimeTag(Timer, delay);
}
// Now do the final, non-transparent blit.
{
DestDc.StretchBlt(0, 0, DestRect.GetWidth(), DestRect.GetHeight(),
&ThisDc, SourceRect.left, SourceRect.top, SourceRect.GetWidth(),
SourceRect.GetHeight(), rop);
}
UnlockDcInternal(ThisDc, Bitmap);
}
}
}
Note that I use NoFlickerBitmap (cBitmap is just an extended version of CBitmap), into which I create the composite semi faded image. This image I then opaquely blit onto the destination dc. I have to do this because ::AlphaBlend() doesn't do a nice clean blit; rather it does some kind of iterative scan, which can be seen and looks quite ugly.
One way I could do this is create a window over the region i was to fade, and just use the dialog fading code article. Unfortunately, this seems kind of like a hack, and I'm reluctant to do it. There must be a better way!
Thanks!
swinefeaster
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
implement the sentence("new CFaderWnd(this)"),
"new" seem that it don't action. Next,Implementthe EndDialog(), OnTimer don't work And ~CFaderWnd() be Called.if don't Implementthe EndDialog(),OnTimer can work but Dialog will die.
|
|
|
|
|
It seems that it does'nt work with maximized windows like ChildFrames.
Christian Probst
|
|
|
|
|
this was an excellent supplement to some work that i did when i first heard about this win2000 feature during its beta phase.
my one suggestion is to simplify the class interface so that the user is not required to have to **know** that CFaderWnds must be created on the heap.
make both the constructor and destructor protected and provide instead a single static function as follows:
static void CFaderWnd::Fade(...)
{
new CFaderWnd(...);
}
|
|
|
|
|
hi my name is jemis in korean
i don't wirte english well. but i know it
how can display on window 98
please teach me .
please tell me. tell me tell me
have a nice day~ by
|
|
|
|
|
it cann't work in win98 or winnt.
it do works in only win2k
|
|
|
|
|
Here is an explain of the FaderWnd.cpp in lame terms -
Basicly, it simply takes the Window/Dialog propties by using various functions,
(GetWindowRect) and then he uses the retrived propeties to create a duplicate of the
Wnd/Dialog and then he destroyes the original.
After that and by using the given value which is set in the UINT nFadeTime var
this value is used in the AlphaBend and it specify the time of the fade,
after creating the transperency, it reduces the AlphaBend until 0 and then there is total
tranperency and then we Destroy the WND/Dialog.
*Function Explain:
CFaderWnd - This is the main fucntion which the Dialog/WND calls as this is
the function that 'do' it all and by calling her we call the entire FaderWND.CPP.
GetWindowRect - Gets the (left, top, right, bottom) rect strcutre of the specified wnd.
CreateEx - This function creats the duplicated Window/Dlg.
UpdateLayeredWindow- The UpdateLayeredWindow function updates the position, size, shape, content,
and translucency of a layered window.
Mean - Every time we reduce the Alpha (SourceConstantAlpha )
value (the transp level) it updated the Window
with it. the function includes as a parameter a pointer into a Blend functions strcutre.
AlphaBend-(BLENDFUNCTION_) - This is a function that sets the transp of a WND/Dialog it has a value (SourceConstantAlpha ) that specified the transp level and we reduce
it as the time pass by making it equal to the time value var of as ->
SourceConstantAlpha = UINT nFadeTime = nElapse = byAlpha = ALPHA_STEP
and this is the deal as we reduce the nElapse in the Timer we also reduce the ALPHA_STEP
which reduce the SourceConstantAlpha.
|
|
|
|
|
Is that correct in general?
By creating a "copy" of the original dialog, you can't guaranty that the state of all child's is the same. Especially, as the constructor of the original dialog will be called again, that might have unexpected behaviour.
Romout
|
|
|
|
|
Is that correct in general?
By creating a "copy" of the original dialog, you can't guarantee that the state of all child's is the same. Especially, as the constructor of the original dialog will be called again, that might have unexpected behaviour.
Romout
|
|
|
|
|
The copy is not of the original dialog but of the screen image of the dialog at the time the CFaderWnd is created. The constructor is not called again.
|
|
|
|
|
Why not use the AnimateWindow!?
Another great thing is creating a window allways semi-transparent, for this we just have to use the SetLayeredWindowAttributes function.
One question:
How can we create a window with different per-pixel alpha values?
(not with constant alpha-value for all pixel in the window)
Bye,
Rui Lope
|
|
|
|
|