From: k.sahici on 11 Jun 2010 16:46 I found a library on CodeProject, named CPictureEx, to be able to load jpeg images in an MFC application. I created a control of type CStatic and then converted to this type(CPictureEx) to be able to associate this control to an image. I'm using this library in a dialog based project. No SDI/MDI. I have a user-defined message to update the region of this CPictureEx variable. When the main dialog receives my user-defined message it successfully updates the region and displays the jpeg file. However, it fails when it comes to unloading the jpeg file. I realized that WM_PAINT message has to be generated explicitly to be able to unload the image. Because when I minimized and then maximized this window, this jpeg file diappeared as I expected it to be. I have used various combinations of InvalidateRgn, UpdateWindow, etc. The only one that worked was "AfxGetMainWnd()->Invalidate();". As you might guess, this causes an annoying flickering. I guess this is a simple problem but unfortunately I'm not experienced with MFC. I'd be grateful if anyone could give me an idea to solve it.
From: ScottMcP [MVP] on 11 Jun 2010 17:26 On Jun 11, 4:46 pm, "k.sahici" <k.sah...(a)gmail.com> wrote: > I found a library on CodeProject, named CPictureEx, to be able to > load > jpeg images in an MFC application. I created a control of type > CStatic > and then converted to this type(CPictureEx) to be able to associate > this control to an image. > I'm using this library in a dialog based project. No SDI/MDI. > I have a user-defined message to update the region of this CPictureEx > variable. When the main dialog receives my user-defined message it > successfully updates the region and displays the jpeg file. > However, it fails when it comes to unloading the jpeg file. I > realized > that WM_PAINT message has to be generated explicitly to be able to > unload the image. Because when I minimized and then maximized this > window, this jpeg file diappeared as I expected it to be. > I have used various combinations of InvalidateRgn, UpdateWindow, etc. > The only one that worked was "AfxGetMainWnd()->Invalidate();". As you > might guess, this causes an annoying flickering. > I guess this is a simple problem but unfortunately I'm not > experienced > with MFC. > I'd be grateful if anyone could give me an idea to solve it. The control (CPictureEx) variable should be invalidated. m_cpex.Invalidate(); The will generate WM_PAINT to the control.
From: k.sahici on 12 Jun 2010 00:52 On Jun 12, 12:26 am, "ScottMcP [MVP]" <scott...(a)mvps.org> wrote: > On Jun 11, 4:46 pm, "k.sahici" <k.sah...(a)gmail.com> wrote: > > > > > > > I found a library on CodeProject, named CPictureEx, to be able to > > load > > jpeg images in an MFC application. I created a control of type > > CStatic > > and then converted to this type(CPictureEx) to be able to associate > > this control to an image. > > I'm using this library in a dialog based project. No SDI/MDI. > > I have a user-defined message to update the region of this CPictureEx > > variable. When the main dialog receives my user-defined message it > > successfully updates the region and displays the jpeg file. > > However, it fails when it comes to unloading the jpeg file. I > > realized > > that WM_PAINT message has to be generated explicitly to be able to > > unload the image. Because when I minimized and then maximized this > > window, this jpeg file diappeared as I expected it to be. > > I have used various combinations of InvalidateRgn, UpdateWindow, etc. > > The only one that worked was "AfxGetMainWnd()->Invalidate();". As you > > might guess, this causes an annoying flickering. > > I guess this is a simple problem but unfortunately I'm not > > experienced > > with MFC. > > I'd be grateful if anyone could give me an idea to solve it. > > The control (CPictureEx) variable should be invalidated. > m_cpex.Invalidate(); > The will generate WM_PAINT to the control. Thank you for your reply. I tried it but it didn't work. I still have to do something else for the control to be repainted, such as minimizing the dialog. Do you have any other idea?
From: Alex Blekhman on 12 Jun 2010 03:22 On 12-Jun-10 14:52, k.sahici wrote: >> The control (CPictureEx) variable should be invalidated. >> m_cpex.Invalidate(); >> The will generate WM_PAINT to the control. > > I tried it but it didn't work. I still have to do something else for > the control to be repainted, such as minimizing the dialog. > Do you have any other idea? Scott is right. If his code doesn't work for you, then you do something wrong. When you minimize the dialog, then WM_PAINT is generated for the window once it pops up. So, it seems that your call to CPictureEx::Invalidate doesn't invalidate the control. Alex
From: ScottMcP [MVP] on 12 Jun 2010 08:36 > On 12-Jun-10 14:52, k.sahici wrote: > > I tried it but it didn't work. I still have to do something else for > > the control to be repainted, such as minimizing the dialog. > > Do you have any other idea? Are you testing with a debug build? That checks a lot of things for you. Did you change the ID of the control? (IDC_STATIC won't work.) Does the control have a DDX_Control call? Can't guess very well if you don't show the code details.
|
Next
|
Last
Pages: 1 2 3 4 Prev: HttpQueryInfo and downloading a file Next: Question about files that start with \??\ |