|
hi
i have some CWnd object on the main window. each of them should to be transparent. each CWnd object contain a little bitmap that i draw it with double buffer technique.
even i move one of them i have to Invalidate(); that window to stop being affected by another windows content.
but Invalidate() a window cause Flickers badly .
is there any way to stop these fickers ?
///////////////////////////
void CTESTView::OnMouseMove(UINT nFlags, CPoint point) {<br />
b.LoadBitmap(IDB_BITMAP1);<br />
BITMAP bm;<br />
<br />
b.GetObject(sizeof(BITMAP),&bm);<br />
CClientDC h1(cw[1]);<br />
<br />
CDC *dc=new CDC;<br />
dc->CreateCompatibleDC(&h1);<br />
dc->SelectObject(&b);<br />
h1.SelectObject(cf);<br />
<br />
h1.BitBlt(0,0,bm.bmWidth,bm.bmHeight,dc,0,0,SRCAND);
<br />
cw[1]->Invalidate();<br />
cw[1]->MoveWindow(point.x,point.y,26,26,true);<br />
}
///////////////////////////
|
|
|
|
|
HellShrimp4free wrote:
each CWnd object contain a little bitmap that i draw it with double buffer technique
Not according to your code.
Also, you might consider to create the CDC "dc" on the stack instead of on the heap, that way you won't forget to delete the object (your current code _will_ crash after n mouse moves). :->
For examples of ways you could improve speed (and in the end help remove the flicker):
- Only load the bitmap once, probably at construction of CTESTView.
- The same goes for GetObject for that bitmap.
- Only invalidate the source rect and the destination rect of your view within the window (InvalidateRect instead of Invalidate - but maybe your "cw[1]" is only for your view/HWND rect?). Maybe even prefer to only tell Windows to invalidate (and repaint) the background on the old rect. There's no need to invalidate the background on the dest rect - you are after all going to overwrite it (maybe this is also done - it's however not possible to judge by this code).
- Do use double buffering - in the window's WM_PAINT handler (set up a bitmap, create a compatible DC... Well, you know the drill) and only when the painting is done you Blt it onto the screen.
- If you are just dragging around some gfx object, you could consider to make a bitmap representation of it (in the Window, not in the view) and just blit around the representation until you finally drop the Window/View, and just then you let the Window/View start handling its own drawing, at the new position.
The way I once did something similar was to trap NC_HITTEST and tell Windows "yup, this is HT_CAPTION" and then let Windows handle the movement of the child window within the parent (let me tell you it surprised me to no end when I got it wrong at first, and instead of selecting text in an EDIT control, I started to drag it around inside its parent frame! ).
|
|
|
|
|
How can I get information about installed graphic card?Any specific API or anywhere in registery?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Take a look on DirectX (DirectDraw) ... I think you can get information about your installed graphic card with the DirectDraw - Interface.
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hello everybody.
Once, I'm in need of catching even when a tab key is pressed. I've tried WM_KEYDOWN, WM_CHAR, MENU KEY, ... But it doesn't work. Can anyone help to catch the tab key even.
Thanks in advance.
NHH.
|
|
|
|
|
You should probably override PreTranslateMessage .
Merry XMas to you,
Bartosz Bien
|
|
|
|
|
Hello Bartosz Bien,
I've followed your help, and it works fine.
Thank you very much.
Have a good time.
|
|
|
|
|
just moved from a 266mhz to a 1.2g laptop
Will MS VC++ 6.0 with sp5 work and be stable on XP? That is the only licensed version I have.
Thanks
Joe
"You can't throw yourself a parade every time you win, and you can't bury yourselves when you lose."-Levon Kirkland Philadelphia Eagles
|
|
|
|
|
JoeSox wrote:
Will MS VC++ 6.0 with sp5 work and be stable on XP?
Work, yes. Stable, mostly. VC 6 crashes about once a day on my XP box at work, which is a shame because I've never had VC crash on non-XP. Thus I blame XP
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I use VC6 with SP4 (5?) on XP Pro and XP Home just fine. It doesn't crash for me.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Thanks, what kind of system do you have (Ram, processor, etc)?
Like your program and website
|
|
|
|
|
JoeSox wrote:
Thanks, what kind of system do you have (Ram, processor, etc)?
Desktop is a P3 550Mhz with 256M RAM running XP Home which is a heavy duty VC++ development machine. ie. Where I develop ED4W.
Notebook is a Dell Inspiron 4150 1GHz with 256M RAM running XP Pro, Wireless LAN etc.
JoeSox wrote:
Like your program and website
Thanks. Always interested in feedback from C++ developers. You might want to give the free trial a whirl.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Follow-up Q...
I was thinking of putting VC++ and .NET on the same OS (WinXP) but common sense tells me not to.
So I think I will use Virtual PC and make a Windows 98se install so I can flip-flop.
What do you think?
Thanks Mike, you da CP man!! Thanks for your articles!!
|
|
|
|
|
VC 6 and VS.NET get along fine, many folks have posted about it here. Just install VC 6 first, then VS.NET. (And VS.NET only runs on NT, so don't bother trying it on 98SE.)
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Michael Dunn wrote:
Work, yes. Stable, mostly. VC 6 crashes about once a day on my XP box at work, which is a shame because I've never had VC crash on non-XP. Thus I blame XP
Under my XP Pro, VS6 Std worked fine with SP4, and started to crash almost daily after applying SP5 to it. Either is it XP or VS, we can then blame... MS.
And also the just-in-time debugging feature fails to work when moved from 2000 to XP! If I run a program outside the debugger and it crashes, pressing Cancel doesn't get me into the code.
Merry XMas,
Bartosz Bien
|
|
|
|
|
My program used gdiplus.dll.i make another dll file name TransToGif.dll to Translate BMP to Gif which using gdiplus.dll.it run very very in my computer which install VS.net in it. and i want make it run in another computer.the computer only install Windows XP.i copyed Gdiplus.dll,TransToGif.dll into windows\system32 and windows\system and program directory. but when i run the program it told me that can't find TransToGif.dll.i kown that it acturlly can't find gdiplus.dll or the gdiplus.dll is not worked.but i don't kown how to make it work.i kown that gdiplus use COM to work.but what COM should i registe first. can anybody help me? thank you!
|
|
|
|
|
I need to load a image file from command line.And I do in this way,
<<in app="">>
cmdInfo.m_nShellCommand = CCommandLineInfo::FileOpen;
<<in doc="">>
OnFileOpen()
{
.....
}
But when this image is invalid image, I have to exit the program.In this Doc class, if I use exit(0) it will cause memroy leak.
How to avoid memory leak when I exit in this occasion?
Thx ahead.
|
|
|
|
|
Use PostQuitMessage(exit_code); .
Software Zen: delete this;
|
|
|
|
|
I have tried the PostQuitMessage() before. But it can not terminate the program immidiately from the OnFileOpen().After sending this message, it will go on to do following steps until main program deals with this message.
|
|
|
|
|
Someone asked me the other day "what if the thread dies unexpectedly?" And I don't mean exits normally but just somehow dies. Is that possible?
I can't remember ever seeing code that checked a thread for abnoral termination.
I know a thread can hang. What's the best way to detect if a thread has hung?
Todd Smith
|
|
|
|
|
I'm not an expert, but one can check the thread handle to see if the thread is valid or not.
I suppose that if correctly coded, the thread shouldn't hang but rather exit it's loop. There should be no reason that the thread would just die or hang other than a code bug. Usually the OS would not start the thread if there were not enough resources available.
The way I've kept an eye on the threads was by posting thread messages from the worker to the main thread that reflect thread status, or utilize some type of watchdog that keeps an eye on the thread. If something doesn't happen (or the thread's task isn't completed within X timeout), the watchdog kills the thread or posts a message to the main thread. I have yet to see a thread hang or die for no reason, but if it did and coding was correct, I suspect that the entire system would be hung too. Well, as was stated before, I'm not an expert.
Regards,
Paul...
|
|
|
|
|
A thread can end in three ways, a) it returns from its thread function (or main/WinMain if it's the primary thread in the process), b) it generates an unhandled exception (GPF, C++ exception), or c) some other thread kills it. b and c count as "unexpected", but the answer is "not much". Exceptions can be handled and dealt with, but there is no way to prevent some other app from calling TerminateThread() .
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
What's the typical technique of determining if a thread gets killed or hangs?
My main application launches a thread and then waits for a message to be posted from the thread. If a message never gets posted then the main application pretty much gets stuck waiting. What should my main process do to see if the thread is still alive?
Can a main process catch an exception thrown by a child thread?
Todd Smith
|
|
|
|
|
Todd Smith wrote:
What's the typical technique of determining if a thread gets killed or hangs?
DWORD dw;
dw = WaitForSingleObject ( thread_handle, 0 );
if ( WAIT_TIMEOUT == dw )
else if ( WAIT_OBJECT_0 == dw )
Can a main process catch an exception thrown by a child thread?
No, an exception can only be caught by the thread that generated it (the compiler goes up the stack looking for catch or __except handlers), so another thread can't handle it.
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Actually, there is a fourth way (even that technically, from the kernels POV it might be your "c").
I don't know if it has been fixed in NT5 or NT5.1 (not using Windows anymore for real server tasks), but in NT4 it was not unheard of by us doing heavy server development that some idiot forgotten to release a resource. From what we understood (not having access to the OS src has obviously been a problem in tracking such bugs), when some handle table got full (apparently "someone" decided to put hard-coded handle-table-sizes into even NT4) the thread, and actually the whole process, just vanished from the face of the earth. No log message, no error handling code run, no nothing. It just vanished.
|
|
|
|