|
There are two main things which could cause flickering :
1.) Not using a memory HDC/CDC when updating the bitmap or text.
2.) Not overriding OnEraseBkgnd in your View class.
The problem is probably caused by no.1 since otherwise your whole bitmap would flicker upon refresh too. What I think maybe happening is your program is drawing the bitmap directly to the screen, quickly followed by the text. This leaves a very very short period in which you see just the bitmap, thus a flickering effect is caused. What I recommend you do is create a new CDC called SrcDC, and use CreateCompatibleDC(NULL), and select the bitmap into it. I would then create another dc called DestDC (in same way), and BitBlt the SrcDC to the DestDC. I would then draw the text onto the DestDC (this has the effect of drawing onto the class) using DestDC's TextOut() function, before *finally* BitBlt'ing the DestDC to the screens *pDC that is found in your OnDraw routine. Basically *only* the final image should be drawn to the screen in 1 BitBlt, there shouldn`t be any other routines which draw to the same *pDC after this or else flickering may occur. Hope this helped,
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
Alan, thanks for the solution. So it goes like this:
SrcDC --> DestDC --> DestDC.DrawText() --> pDC->BitBlt(DestDC)
But usin' this approach, the final stage will involve the transferin' of the whole DestDC to pDC, right?
pDC->BitBlt(..., &DestDC, ..., SRCCOPY);
This will be heavy, because the interface redraws itself quite frequently (i.e. mouse movements makes the button change background, and stuff like that). I know InvalidateRect, but my bitmap class doesn't handle that, it will still draw the whole background all over again.
And I'm takin' over the whole dialog's paintin'. That means the background will even go up to the screen size, which might be 1024x768! (The whole window will repain, when resized, even InvalidateRect won't help in this case.)
I've tried that approach, but seems slow, maybe I should use InvalidateRect whenever possible. Thanks again for your solution man
Me,
Baling.
|
|
|
|
|
Dear Friends
In my project i am changing the font size but as it is increasing it is going beyond the limit of display size.How to control the dispaly according to the size of font.
Kindly help me in getting the solution.
Thanking you in advance.
Binnu
|
|
|
|
|
How can i get Dynamic IP address of my pc.
is there any API in vc++ for retreiving dynamic ip address of my pc?
please help me?
|
|
|
|
|
Check IP Helper functions: MSDN->Platform SDK->Networking and Directory services->Web Network Services->Internet Protocol Helper.
It seems that you need GetIpAddrTable.
Regards,
Gennady
|
|
|
|
|
Hello.
I began my journey to learn and practice programming using C++ four nearly four months ago and everything has been full speed thus far. I have little problem learning C++ because I practice and practice. I made up my own projects. I have one of them done, which I believe it quite impressive. I am working on the second project, which is going well especially because of all the insight from members throughout the web.
Sometimes I see students programming with Java. C++ is the first programming language I enjoy and made use of with in terms of practicality via projects. Frankly, I love C++! I would like to know how does C++ compare to Java in terms of extensiveness and future? Does C++ have the tools for anything if the programmer chooses to use them?
I know Java is a server based language. However, I am seeing more and more people programming with Java. Is it easier to learn? Not that I have any big problem with C++. I wonder why people sometimes move from C++ to Java.
Lastly, what is the future of C++ once Microsoft releases .NET? Already I am hearing people boast C#. Is it true C# is relatively Jave-clone? If yes, then that could make Java one step ahead of C++ if it infact has something that Microsoft has implemented in C#.
Frankly, I do not see any limitation with C++. Maybe that is just because of my inexperience. What do you think?
Kuphryn
P.S. Is it better to know one language really, really well? Or is it better to know many languages?
|
|
|
|
|
I cant find a decent C resource similiar to the code project. Can someone please direct me to a good site that deals with windows programming in C.
Most appreciated,
SAK
|
|
|
|
|
- CodeProject.com is the only one you need! -
If you want to learn C, buy a book! They are very helpful if you are serious to programming and want to have a job or bla bla, so my advice is: Buy a book!
If you don't have cash, see programmersheaven.com then
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
If anyone has had experience in writing and HTTP server I could use your advice.
I have been pulled into a project which involves modifyng existing HTTP server code to make the file down load work correctly. Where can I find the full spec on this. At present, unless the complete file is assembled in a buffer the server hangs. In the embedded environment we have serious memory constraints and can not prepare the data as a single large file and must send it in bits. The client end must however think it's a single file.
Any ideas on the structure of each packet would be welcome.
Happy programming!!
|
|
|
|
|
You're giving very little context to allow for an useful answer, but anyway...
The client should cope with the whole file as long as the server returns the contents of the file as the response to the HTTP request (i.e, thru the socket created in response to the HTTP request). It is not a matter of wheter you send it in chunks or all at once, what you have to investigate is the means of having the little chunks sent thru the same response socket. If this is already clear to you, then I guess little more can be said without knowing more about your environment.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm sorry, at this stage I don't much more about it myself. The source code is still on it's way (long story to do with international projects), but what I can work out is that when this server is sending out the chunks it omits something important in the chunk's header. That is why I'm trying to find a spec that will tell what the header in each chunk must have. Perhaps it's even the header of the first chunk is missing vital information.
I'm once I see the specification it won't be too hard to fix.
Happy programming!!
|
|
|
|
|
The HTTP spec is RFC 2616. Chunked transfers are described in section 3.6.1:
3.6.1 Chunked Transfer Coding
The chunked encoding modifies the body of a message in order to
transfer it as a series of chunks, each with its own size indicator,
followed by an OPTIONAL trailer containing entity-header fields. This
allows dynamically produced content to be transferred along with the
information necessary for the recipient to verify that it has
received the full message.
Chunked-Body = *chunk
last-chunk
trailer
CRLF
chunk = chunk-size [ chunk-extension ] CRLF
chunk-data CRLF
chunk-size = 1*HEX
last-chunk = 1*("0") [ chunk-extension ] CRLF
chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] )
chunk-ext-name = token
chunk-ext-val = token | quoted-string
chunk-data = chunk-size(OCTET)
trailer = *(entity-header CRLF)
The chunk-size field is a string of hex digits indicating the size of
the chunk. The chunked encoding is ended by any chunk whose size is
zero, followed by the trailer, which is terminated by an empty line.
The trailer allows the sender to include additional HTTP header
fields at the end of the message. The Trailer header field can be
used to indicate which header fields are included in a trailer (see
section 14.40).
|
|
|
|
|
Thank you heaps
THis is what I am looking for. I have found that not all of this is being put into the 'chunk' by the present server code.
Happy programming!!
|
|
|
|
|
|
Last month I posted a problem about my dialog buttons not responsive. Thanks to reply posted by Christian, that's solved by using a worker thread.
I'm now having a couple of problems after solving the above. Hope someone can advise.
The worker thread is started when the user clicks on the CONVERT button. I then change the Cancel to be the default button, so that a simple Enter
would abort the very lengthy conversion.
void CConvert::OnConvert()
{
// start the worker thread
AfxBeginThread(MyThreadProc,this);
// change the buttons
m_convert.SetButtonStyle(BS_PUSHBUTTON);
m_convert.EnableWindow(FALSE);
m_ok.EnableWindow(FALSE);
m_cancel.SetButtonStyle(BS_DEFPUSHBUTTON);
m_cancel.SetFocus();
}
// my worker thread
UINT MyThreadProc (LPVOID pParam)
{
CConvert * pObject = (CConvert*)pParam;
pObject->DoConvert();
return 0;
}
// my original code to do all the conversion
BOOL CConvert::DoConvert(void)
{
// lots of code up here not shown
//
if (AbortFlag)
{
// conversion was cancelled. Dialog box is gone.
return FALSE;
}
else
{ // normal completion. Dialog box still visible.
// make the OK button default
m_convert.SetButtonStyle(BS_PUSHBUTTON);
m_convert.EnableWindow(TRUE);
m_cancel.SetButtonStyle(BS_PUSHBUTTON);
m_ok.SetButtonStyle(BS_DEFPUSHBUTTON);
m_ok.EnableWindow(TRUE);
m_ok.SetFocus();
// UpdateData(FALSE); // Cause Assertion Fail. Why?
}
return TRUE;
}
1/ After sucessful conversion the OK button is shown as the Default button, but when I hit Enter, conversion starts again. Seems like the focus is still on the Convert button. How come?
2/ I tried UpdateData(FALSE) but it caused an Assertation Fail. Why?
3/ I think I'm wrong to put all these button manipulations in the worker thread. Maybe I should be using a timer in the Dialog to periodically check on the status of the worker thread and then do these manipulations after the thread is done. Your advise please.
|
|
|
|
|
Hello, the codegurus around the world.;)
I have the same experience about UpdateData (FALSE).
Even though I didn't do this, try to use SendMessage (or PostMessage)
to update Button stuffs by the user defined message.
I think that Timer is the good option.
BTW, why do you use UpdateData (FALSE)?
UpdateData(FALSE) updates the string by the memeber value in the class wizard
because you only use the control value in the class wizard.
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
et wrote:
2/ I tried UpdateData(FALSE) but it caused an Assertation Fail. Why?
Because MFC's design contains a map between HWNDs and CWnd objects. When you do any non-trivial operation on a window, MFC looks up the corresponding CWnd object in its map. However, each thread has its own map. Since the dialog was created by the main thread, the dialog is in the main thread's map. The worker thread can't find it in its map and asserts. (The previous calls work fine because it is safe to send messages between threads, which is what the calls boil down to.)
et wrote:
3/Maybe I should be using a timer in the Dialog to periodically check on the status of the worker thread
That's not the best way. Define a custom window message (WM_APP will do) and send that from the worker thread to the main thread right before the worker thread exits. Do your UI updating in response to that message.
--Mike--
http://home.inreach.com/mdunn/
Help! Help! I'm being repressed!!
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Hi All!
I made a dialog application. When I build it using the appWizard, I did not choose to have menu on the dialog. Now I need to have a menu, can I add it in?
Thanks in advance
Vu
vucsuf
|
|
|
|
|
Yes, just assign a menu to the dialog using the resource editor.
--Mike--
http://home.inreach.com/mdunn/
Help! Help! I'm being repressed!!
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
I am creating a 'server' that will talk TCP/IP to other devices. This server will need to be multithreaded. So questions. Does Winsock2 support threads? Some functions like WSAWaitForMultipleEvents and WSACreateEvent seems to 'be' threaded. Are there any examples of creating a socket server? Also interested in outright buying the sources for a professionaly built one.
Thanks
Ralph Krausse
|
|
|
|
|
|
Hello,
I am having difficulties dynamically creating a CScrollBar object in a CView derived class.
It seems to have a problem attaching to the window during the CScrollBar.Create() method.
The odd thing, all works fine in a dialog or CFormView class. I am quite stumped!
If anyone can shed some light on my problem, I would be very greatfull!
Thanks,
James
|
|
|
|
|
MSVC 6.0 SP4 Windows 98 second edition
On an application I am working on, the buttons on one property sheet dialog are disappearing intermittantly.
Cancel, Apply and OK are like disappearing, for no apparent reason. If you click the spot where they
would be, the BN_CLICKED message does infact work, and IDOK/IDCANCEL are sent, also
DoDataExchange works too.
WTHeck,
Asher
Whenever you have truth it must be given with Love, or the Message and the Messenger will be rejected.
-- Mahatma Ghandi
|
|
|
|
|
chk whether the buttons r set to OWNER DRAW or chk for other properties.
Ganesh Ramaswamy
|
|
|
|
|
Well,
the buttons are:
OK,APPLY and CANCEL...default properties.
ahoodin;)
Whenever you have truth it must be given with Love, or the Message and the Messenger will be rejected.
-- Mahatma Ghandi
|
|
|
|