Redraw Bitmap Window Message
-
I have this app that opens a bitmap image and displays it in the dialog. However, when I move it off screen then back on, the portion that was offscreen but is now on screen is not refreshed. I think I have to handle some kind of message like WM_PAINT somewhere but I don't know quite where to do this exactly. I'm thinking of overriding CCmdTarget::OnCmdMsg and doing it in there somehow. Rather than making an uninformed guess at the best way at doing this and wasting time writing code I don't need, I'd like to ask up front as to what's the best way to do this. I'd like to redraw when the window is placed in it's final location (after left mouse button is released) but I would like to redraw it more intelligently after I get this part figured out. Any help would be greatly appreciated and thanks to all the people that have helped me in the past with this app.
-
I have this app that opens a bitmap image and displays it in the dialog. However, when I move it off screen then back on, the portion that was offscreen but is now on screen is not refreshed. I think I have to handle some kind of message like WM_PAINT somewhere but I don't know quite where to do this exactly. I'm thinking of overriding CCmdTarget::OnCmdMsg and doing it in there somehow. Rather than making an uninformed guess at the best way at doing this and wasting time writing code I don't need, I'd like to ask up front as to what's the best way to do this. I'd like to redraw when the window is placed in it's final location (after left mouse button is released) but I would like to redraw it more intelligently after I get this part figured out. Any help would be greatly appreciated and thanks to all the people that have helped me in the past with this app.
You should do all your drawing in your WM_PAINT handler. Your window will recieve WM_PAINT messages from the system whenever it needs redrawing, for whatever reason.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
Honoured as one of The Most Helpful Members of 2004
-
I have this app that opens a bitmap image and displays it in the dialog. However, when I move it off screen then back on, the portion that was offscreen but is now on screen is not refreshed. I think I have to handle some kind of message like WM_PAINT somewhere but I don't know quite where to do this exactly. I'm thinking of overriding CCmdTarget::OnCmdMsg and doing it in there somehow. Rather than making an uninformed guess at the best way at doing this and wasting time writing code I don't need, I'd like to ask up front as to what's the best way to do this. I'd like to redraw when the window is placed in it's final location (after left mouse button is released) but I would like to redraw it more intelligently after I get this part figured out. Any help would be greatly appreciated and thanks to all the people that have helped me in the past with this app.
See the FAQ: 4.2 How do I change the background color of a dialog, or draw a picture as the background?[^] --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD
-
I have this app that opens a bitmap image and displays it in the dialog. However, when I move it off screen then back on, the portion that was offscreen but is now on screen is not refreshed. I think I have to handle some kind of message like WM_PAINT somewhere but I don't know quite where to do this exactly. I'm thinking of overriding CCmdTarget::OnCmdMsg and doing it in there somehow. Rather than making an uninformed guess at the best way at doing this and wasting time writing code I don't need, I'd like to ask up front as to what's the best way to do this. I'd like to redraw when the window is placed in it's final location (after left mouse button is released) but I would like to redraw it more intelligently after I get this part figured out. Any help would be greatly appreciated and thanks to all the people that have helped me in the past with this app.
hey use the WM_PAINT directly!!!!!.....dont waste ur time writing a fuction such as OnPaint() by urself when there is an already well handled one.....it will do all the repaintz that are required automatically!!!!! hope thiz helpz..... just select ur class wizard and set the class name as the class name of the dialog,then in the messages box,look for WM_PAINT,double click it and it adds to the member function box as "OnPaint()".....click on the OK button..... then in ur dialog cpp go to the added function(OnPaint())..... then write the code that is needed to diplay the bitmap on the screen using BitBlt()..... if u have to load an image in to ur screen u must be using the dc memory..... herez a n example code..... void CXYZDlg::OnPaint() { dc.BitBlt(offsetx,offsety,m_size.cx,m_size.cy,m_dcMem, 2, 0,SRCCOPY); } look into BitBlt for more info..... maybe thiz article could aso help u out!!!!!...... http://www.codeproject.com/bitmap/bmpscroll.asp[^] the time taken to writing ur own paint finction is a waste of time and unnessar effort when the OnPaint() od the MFC handles thiz cery neatly!!!!! :-Dcheerz..... "faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
-
I have this app that opens a bitmap image and displays it in the dialog. However, when I move it off screen then back on, the portion that was offscreen but is now on screen is not refreshed. I think I have to handle some kind of message like WM_PAINT somewhere but I don't know quite where to do this exactly. I'm thinking of overriding CCmdTarget::OnCmdMsg and doing it in there somehow. Rather than making an uninformed guess at the best way at doing this and wasting time writing code I don't need, I'd like to ask up front as to what's the best way to do this. I'd like to redraw when the window is placed in it's final location (after left mouse button is released) but I would like to redraw it more intelligently after I get this part figured out. Any help would be greatly appreciated and thanks to all the people that have helped me in the past with this app.
You no need to handle any other messages for this. Just write your code that displays the image inside the OnPaint or WM_PAINT.:cool: