How do I display an image as the background in CMDIFrameWnd

I have a VC++ MFC 7.1 application and I am looking for a way to display a 
background image in the application's frame window behind any child windows 
that may be displayed. It is a CMDIFrameWnd derived class.

I have found a couple of examples that are to change the background color in 
the CMyMDIFrameWnd::OnEraseBkgnd() handler.

But it doesn't seem to work. The background color always remains the same.

Is there something that I am missing?

I am running on Windows XP Professional.
-- 
Thanks,
Bruce 


0
bwolven1 (7)
3/22/2007 4:53:28 PM
vc.mfc 33608 articles. 0 followers. Follow

8 Replies
1145 Views

Similar Articles

[PageSpeed] 50

On Mar 22, 11:53 am, "Bruce" <bwol...@nospam.nospam> wrote:
> I have a VC++ MFC 7.1 application and I am looking for a way to display a
> background image in the application's frame window behind any child windows
> that may be displayed. It is a CMDIFrameWnd derived class.
>
> I have found a couple of examples that are to change the background color in
> the CMyMDIFrameWnd::OnEraseBkgnd() handler.
>
> But it doesn't seem to work. The background color always remains the same.
>
> Is there something that I am missing?
>
> I am running on Windows XP Professional.
> --
> Thanks,
> Bruce


You will need to subclass MDIClient window which occupies the client
area of mainframe and do it in its OnEraseBkgnd. See here:

http://www.codeguru.com/forum/archive/index.php/t-319786.html

---
Ajay

0
ajaykalra (6842)
3/22/2007 5:41:59 PM
You will have to subclass the m_hWndMDIClient of the CMDIFrameWnd with your 
own window and then catch the WM_ERASEBKGND and WM_PAINT messages there.

So create class that inherits from CWnd, lets call it CClientWnd. Then 
subclass m_hWndMIDClient in the Frame's OnCreateClient method.  Take over 
the WM_ERASEBKGND message and paint your bitmap there and return TRUE.  If 
you bitmap won't takeup the entire client area then you might want to it in 
WM_PAINT.

class CClientWnd : public CWnd
{
   DECLARE_DYNAMIC(CClientWnd)

public:
   CClientWnd();
   virtual ~CClientWnd();

protected:
   DECLARE_MESSAGE_MAP()
public:
   afx_msg BOOL OnEraseBkgnd(CDC* pDC);
};



BEGIN_MESSAGE_MAP(CClientWnd, CWnd)
   ON_WM_ERASEBKGND()
END_MESSAGE_MAP()




BOOL CClientWnd::OnEraseBkgnd(CDC* pDC)
{
   //draw bitmap here
   pDC->BitBlt(....);

   return TRUE;
}

class CMainFrame : public CMDIFrameWnd
{
private:
   CClientWnd m_Client;
};

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* 
pContext)
{
   if (CMDIFrameWnd::OnCreateClient(lpcs, pContext))
   {
      m_Client.SubclassWindow(m_hWndMDIClient);
      return TRUE;
   }
   return FALSE;
}


AliR.

"Bruce" <bwolven@nospam.nospam> wrote in message 
news:uEi4fKKbHHA.4720@TK2MSFTNGP04.phx.gbl...
>I have a VC++ MFC 7.1 application and I am looking for a way to display a 
>background image in the application's frame window behind any child windows 
>that may be displayed. It is a CMDIFrameWnd derived class.
>
> I have found a couple of examples that are to change the background color 
> in the CMyMDIFrameWnd::OnEraseBkgnd() handler.
>
> But it doesn't seem to work. The background color always remains the same.
>
> Is there something that I am missing?
>
> I am running on Windows XP Professional.
> -- 
> Thanks,
> Bruce
> 


0
AliR3470 (3236)
3/22/2007 5:45:09 PM
I saw this example but it didn't make sense to me.

Why does the erase background on the child window paint the frame?

I'm not trying to change the background of the client window that gets open, 
only the MDI frame window.

If that's the way it must be done, why can't I just add a WM_ERASEBKGND 
handler to the child class to do the same thing?

Is the framework getting in the way?

Also, will this method work with VS2005 since we are in the process of 
moving our source to it?

-- 
Thanks,
Bruce

"AliR (VC++ MVP)" <AliR@online.nospam> wrote in message 
news:FgzMh.521$rO7.19@newssvr25.news.prodigy.net...
> You will have to subclass the m_hWndMDIClient of the CMDIFrameWnd with 
> your own window and then catch the WM_ERASEBKGND and WM_PAINT messages 
> there.
>
> So create class that inherits from CWnd, lets call it CClientWnd. Then 
> subclass m_hWndMIDClient in the Frame's OnCreateClient method.  Take over 
> the WM_ERASEBKGND message and paint your bitmap there and return TRUE.  If 
> you bitmap won't takeup the entire client area then you might want to it 
> in WM_PAINT.
>
> class CClientWnd : public CWnd
> {
>   DECLARE_DYNAMIC(CClientWnd)
>
> public:
>   CClientWnd();
>   virtual ~CClientWnd();
>
> protected:
>   DECLARE_MESSAGE_MAP()
> public:
>   afx_msg BOOL OnEraseBkgnd(CDC* pDC);
> };
>
>
>
> BEGIN_MESSAGE_MAP(CClientWnd, CWnd)
>   ON_WM_ERASEBKGND()
> END_MESSAGE_MAP()
>
>
>
>
> BOOL CClientWnd::OnEraseBkgnd(CDC* pDC)
> {
>   //draw bitmap here
>   pDC->BitBlt(....);
>
>   return TRUE;
> }
>
> class CMainFrame : public CMDIFrameWnd
> {
> private:
>   CClientWnd m_Client;
> };
>
> BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* 
> pContext)
> {
>   if (CMDIFrameWnd::OnCreateClient(lpcs, pContext))
>   {
>      m_Client.SubclassWindow(m_hWndMDIClient);
>      return TRUE;
>   }
>   return FALSE;
> }
>
>
> AliR.
>
> "Bruce" <bwolven@nospam.nospam> wrote in message 
> news:uEi4fKKbHHA.4720@TK2MSFTNGP04.phx.gbl...
>>I have a VC++ MFC 7.1 application and I am looking for a way to display a 
>>background image in the application's frame window behind any child 
>>windows that may be displayed. It is a CMDIFrameWnd derived class.
>>
>> I have found a couple of examples that are to change the background color 
>> in the CMyMDIFrameWnd::OnEraseBkgnd() handler.
>>
>> But it doesn't seem to work. The background color always remains the 
>> same.
>>
>> Is there something that I am missing?
>>
>> I am running on Windows XP Professional.
>> -- 
>> Thanks,
>> Bruce
>>
>
> 


0
bwolven1 (7)
3/22/2007 7:08:44 PM
Here's a link with a couple of ideas on how to do it:

http://www.codeguru.com/forum/showthread.php?t=319786

Tom

"Bruce" <bwolven@nospam.nospam> wrote in message 
news:u0VREWLbHHA.960@TK2MSFTNGP03.phx.gbl...
>I saw this example but it didn't make sense to me.
>
> Why does the erase background on the child window paint the frame?
>
> I'm not trying to change the background of the client window that gets 
> open, only the MDI frame window.
>
> If that's the way it must be done, why can't I just add a WM_ERASEBKGND 
> handler to the child class to do the same thing?
>
> Is the framework getting in the way?
>
> Also, will this method work with VS2005 since we are in the process of 
> moving our source to it?
>
> -- 
> Thanks,
> Bruce
>
> "AliR (VC++ MVP)" <AliR@online.nospam> wrote in message 
> news:FgzMh.521$rO7.19@newssvr25.news.prodigy.net...
>> You will have to subclass the m_hWndMDIClient of the CMDIFrameWnd with 
>> your own window and then catch the WM_ERASEBKGND and WM_PAINT messages 
>> there.
>>
>> So create class that inherits from CWnd, lets call it CClientWnd. Then 
>> subclass m_hWndMIDClient in the Frame's OnCreateClient method.  Take over 
>> the WM_ERASEBKGND message and paint your bitmap there and return TRUE. 
>> If you bitmap won't takeup the entire client area then you might want to 
>> it in WM_PAINT.
>>
>> class CClientWnd : public CWnd
>> {
>>   DECLARE_DYNAMIC(CClientWnd)
>>
>> public:
>>   CClientWnd();
>>   virtual ~CClientWnd();
>>
>> protected:
>>   DECLARE_MESSAGE_MAP()
>> public:
>>   afx_msg BOOL OnEraseBkgnd(CDC* pDC);
>> };
>>
>>
>>
>> BEGIN_MESSAGE_MAP(CClientWnd, CWnd)
>>   ON_WM_ERASEBKGND()
>> END_MESSAGE_MAP()
>>
>>
>>
>>
>> BOOL CClientWnd::OnEraseBkgnd(CDC* pDC)
>> {
>>   //draw bitmap here
>>   pDC->BitBlt(....);
>>
>>   return TRUE;
>> }
>>
>> class CMainFrame : public CMDIFrameWnd
>> {
>> private:
>>   CClientWnd m_Client;
>> };
>>
>> BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* 
>> pContext)
>> {
>>   if (CMDIFrameWnd::OnCreateClient(lpcs, pContext))
>>   {
>>      m_Client.SubclassWindow(m_hWndMDIClient);
>>      return TRUE;
>>   }
>>   return FALSE;
>> }
>>
>>
>> AliR.
>>
>> "Bruce" <bwolven@nospam.nospam> wrote in message 
>> news:uEi4fKKbHHA.4720@TK2MSFTNGP04.phx.gbl...
>>>I have a VC++ MFC 7.1 application and I am looking for a way to display a 
>>>background image in the application's frame window behind any child 
>>>windows that may be displayed. It is a CMDIFrameWnd derived class.
>>>
>>> I have found a couple of examples that are to change the background 
>>> color in the CMyMDIFrameWnd::OnEraseBkgnd() handler.
>>>
>>> But it doesn't seem to work. The background color always remains the 
>>> same.
>>>
>>> Is there something that I am missing?
>>>
>>> I am running on Windows XP Professional.
>>> -- 
>>> Thanks,
>>> Bruce
>>>
>>
>>
>
> 

0
tom.nospam (3240)
3/22/2007 7:24:24 PM
On Mar 22, 2:08 pm, "Bruce" <bwol...@nospam.nospam> wrote:
> I saw this example but it didn't make sense to me.
>
> Why does the erase background on the child window paint the frame?
>
> I'm not trying to change the background of the client window that gets open,
> only the MDI frame window.
>
> If that's the way it must be done, why can't I just add a WM_ERASEBKGND
> handler to the child class to do the same thing?
>
> Is the framework getting in the way?
>
> Also, will this method work with VS2005 since we are in the process of
> moving our source to it?
>
> --
> Thanks,
> Bruce
>
> "AliR (VC++ MVP)" <A...@online.nospam> wrote in messagenews:FgzMh.521$rO7.19@newssvr25.news.prodigy.net...
>
> > You will have to subclass the m_hWndMDIClient of the CMDIFrameWnd with
> > your own window and then catch the WM_ERASEBKGND and WM_PAINT messages
> > there.
>
> > So create class that inherits from CWnd, lets call it CClientWnd. Then
> > subclass m_hWndMIDClient in the Frame's OnCreateClient method.  Take over
> > the WM_ERASEBKGND message and paint your bitmap there and return TRUE.  If
> > you bitmap won't takeup the entire client area then you might want to it
> > in WM_PAINT.
>
> > class CClientWnd : public CWnd
> > {
> >   DECLARE_DYNAMIC(CClientWnd)
>
> > public:
> >   CClientWnd();
> >   virtual ~CClientWnd();
>
> > protected:
> >   DECLARE_MESSAGE_MAP()
> > public:
> >   afx_msg BOOL OnEraseBkgnd(CDC* pDC);
> > };
>
> > BEGIN_MESSAGE_MAP(CClientWnd, CWnd)
> >   ON_WM_ERASEBKGND()
> > END_MESSAGE_MAP()
>
> > BOOL CClientWnd::OnEraseBkgnd(CDC* pDC)
> > {
> >   //draw bitmap here
> >   pDC->BitBlt(....);
>
> >   return TRUE;
> > }
>
> > class CMainFrame : public CMDIFrameWnd
> > {
> > private:
> >   CClientWnd m_Client;
> > };
>
> > BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*
> > pContext)
> > {
> >   if (CMDIFrameWnd::OnCreateClient(lpcs, pContext))
> >   {
> >      m_Client.SubclassWindow(m_hWndMDIClient);
> >      return TRUE;
> >   }
> >   return FALSE;
> > }
>
> > AliR.
>
> > "Bruce" <bwol...@nospam.nospam> wrote in message
> >news:uEi4fKKbHHA.4720@TK2MSFTNGP04.phx.gbl...
> >>I have a VC++ MFC 7.1 application and I am looking for a way to display a
> >>background image in the application's frame window behind any child
> >>windows that may be displayed. It is a CMDIFrameWnd derived class.
>
> >> I have found a couple of examples that are to change the background color
> >> in the CMyMDIFrameWnd::OnEraseBkgnd() handler.
>
> >> But it doesn't seem to work. The background color always remains the
> >> same.
>
> >> Is there something that I am missing?
>
> >> I am running on Windows XP Professional.
> >> --
> >> Thanks,
> >> Bruce



In a MDI application, the client area of mainframe is a special window
called MDIClient. Thats the grey portion that you see. You can use Spy+
+ to see the details. Thats the window you need to subclass and use
OnEraseBkgnd on it.

---
Ajay

0
ajaykalra (6842)
3/22/2007 7:25:06 PM
As Ajay pointed out I wasn't talking about the child views, m_hWndMDIClient 
is different than the client views. The client MDIClient that I was talking 
about is the center (gray) part of the frame.  You see, the frame window is 
not just the gray part, it is a window encompasses the gray part, the menu, 
the toolbars, the status bar and all of that.  It has a separate window 
handle for each one of these components.
So the reason that you can't simply take over the WM_ERASEBKGND of the frame 
window and do you work there is the fact that the MDIClient will cover up 
every thing that you just did in the WM_ERASEBKGND of the frame (which I 
must add does nothing by default).

AliR.


"Bruce" <bwolven@nospam.nospam> wrote in message 
news:u0VREWLbHHA.960@TK2MSFTNGP03.phx.gbl...
>I saw this example but it didn't make sense to me.
>
> Why does the erase background on the child window paint the frame?
>
> I'm not trying to change the background of the client window that gets 
> open, only the MDI frame window.
>
> If that's the way it must be done, why can't I just add a WM_ERASEBKGND 
> handler to the child class to do the same thing?
>
> Is the framework getting in the way?
>
> Also, will this method work with VS2005 since we are in the process of 
> moving our source to it?
>
> -- 
> Thanks,
> Bruce
>
> "AliR (VC++ MVP)" <AliR@online.nospam> wrote in message 
> news:FgzMh.521$rO7.19@newssvr25.news.prodigy.net...
>> You will have to subclass the m_hWndMDIClient of the CMDIFrameWnd with 
>> your own window and then catch the WM_ERASEBKGND and WM_PAINT messages 
>> there.
>>
>> So create class that inherits from CWnd, lets call it CClientWnd. Then 
>> subclass m_hWndMIDClient in the Frame's OnCreateClient method.  Take over 
>> the WM_ERASEBKGND message and paint your bitmap there and return TRUE. 
>> If you bitmap won't takeup the entire client area then you might want to 
>> it in WM_PAINT.
>>
>> class CClientWnd : public CWnd
>> {
>>   DECLARE_DYNAMIC(CClientWnd)
>>
>> public:
>>   CClientWnd();
>>   virtual ~CClientWnd();
>>
>> protected:
>>   DECLARE_MESSAGE_MAP()
>> public:
>>   afx_msg BOOL OnEraseBkgnd(CDC* pDC);
>> };
>>
>>
>>
>> BEGIN_MESSAGE_MAP(CClientWnd, CWnd)
>>   ON_WM_ERASEBKGND()
>> END_MESSAGE_MAP()
>>
>>
>>
>>
>> BOOL CClientWnd::OnEraseBkgnd(CDC* pDC)
>> {
>>   //draw bitmap here
>>   pDC->BitBlt(....);
>>
>>   return TRUE;
>> }
>>
>> class CMainFrame : public CMDIFrameWnd
>> {
>> private:
>>   CClientWnd m_Client;
>> };
>>
>> BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* 
>> pContext)
>> {
>>   if (CMDIFrameWnd::OnCreateClient(lpcs, pContext))
>>   {
>>      m_Client.SubclassWindow(m_hWndMDIClient);
>>      return TRUE;
>>   }
>>   return FALSE;
>> }
>>
>>
>> AliR.
>>
>> "Bruce" <bwolven@nospam.nospam> wrote in message 
>> news:uEi4fKKbHHA.4720@TK2MSFTNGP04.phx.gbl...
>>>I have a VC++ MFC 7.1 application and I am looking for a way to display a 
>>>background image in the application's frame window behind any child 
>>>windows that may be displayed. It is a CMDIFrameWnd derived class.
>>>
>>> I have found a couple of examples that are to change the background 
>>> color in the CMyMDIFrameWnd::OnEraseBkgnd() handler.
>>>
>>> But it doesn't seem to work. The background color always remains the 
>>> same.
>>>
>>> Is there something that I am missing?
>>>
>>> I am running on Windows XP Professional.
>>> -- 
>>> Thanks,
>>> Bruce
>>>
>>
>>
>
> 


0
AliR3470 (3236)
3/22/2007 7:42:00 PM
Thanks.

I was able to get it to work.

One last question though.

Do I need to do a UnsubclassWindow() call when I am done in WM_DESTROY or 
WM_NCDESTROY?
-- 
Bruce

"AliR (VC++ MVP)" <AliR@online.nospam> wrote in message 
news:c_AMh.473$YL5.81@newssvr29.news.prodigy.net...
> As Ajay pointed out I wasn't talking about the child views, 
> m_hWndMDIClient is different than the client views. The client MDIClient 
> that I was talking about is the center (gray) part of the frame.  You see, 
> the frame window is not just the gray part, it is a window encompasses the 
> gray part, the menu, the toolbars, the status bar and all of that.  It has 
> a separate window handle for each one of these components.
> So the reason that you can't simply take over the WM_ERASEBKGND of the 
> frame window and do you work there is the fact that the MDIClient will 
> cover up every thing that you just did in the WM_ERASEBKGND of the frame 
> (which I must add does nothing by default).
>
> AliR.
>
>
> "Bruce" <bwolven@nospam.nospam> wrote in message 
> news:u0VREWLbHHA.960@TK2MSFTNGP03.phx.gbl...
>>I saw this example but it didn't make sense to me.
>>
>> Why does the erase background on the child window paint the frame?
>>
>> I'm not trying to change the background of the client window that gets 
>> open, only the MDI frame window.
>>
>> If that's the way it must be done, why can't I just add a WM_ERASEBKGND 
>> handler to the child class to do the same thing?
>>
>> Is the framework getting in the way?
>>
>> Also, will this method work with VS2005 since we are in the process of 
>> moving our source to it?
>>
>> -- 
>> Thanks,
>> Bruce
>>
>> "AliR (VC++ MVP)" <AliR@online.nospam> wrote in message 
>> news:FgzMh.521$rO7.19@newssvr25.news.prodigy.net...
>>> You will have to subclass the m_hWndMDIClient of the CMDIFrameWnd with 
>>> your own window and then catch the WM_ERASEBKGND and WM_PAINT messages 
>>> there.
>>>
>>> So create class that inherits from CWnd, lets call it CClientWnd. Then 
>>> subclass m_hWndMIDClient in the Frame's OnCreateClient method.  Take 
>>> over the WM_ERASEBKGND message and paint your bitmap there and return 
>>> TRUE. If you bitmap won't takeup the entire client area then you might 
>>> want to it in WM_PAINT.
>>>
>>> class CClientWnd : public CWnd
>>> {
>>>   DECLARE_DYNAMIC(CClientWnd)
>>>
>>> public:
>>>   CClientWnd();
>>>   virtual ~CClientWnd();
>>>
>>> protected:
>>>   DECLARE_MESSAGE_MAP()
>>> public:
>>>   afx_msg BOOL OnEraseBkgnd(CDC* pDC);
>>> };
>>>
>>>
>>>
>>> BEGIN_MESSAGE_MAP(CClientWnd, CWnd)
>>>   ON_WM_ERASEBKGND()
>>> END_MESSAGE_MAP()
>>>
>>>
>>>
>>>
>>> BOOL CClientWnd::OnEraseBkgnd(CDC* pDC)
>>> {
>>>   //draw bitmap here
>>>   pDC->BitBlt(....);
>>>
>>>   return TRUE;
>>> }
>>>
>>> class CMainFrame : public CMDIFrameWnd
>>> {
>>> private:
>>>   CClientWnd m_Client;
>>> };
>>>
>>> BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* 
>>> pContext)
>>> {
>>>   if (CMDIFrameWnd::OnCreateClient(lpcs, pContext))
>>>   {
>>>      m_Client.SubclassWindow(m_hWndMDIClient);
>>>      return TRUE;
>>>   }
>>>   return FALSE;
>>> }
>>>
>>>
>>> AliR.
>>>
>>> "Bruce" <bwolven@nospam.nospam> wrote in message 
>>> news:uEi4fKKbHHA.4720@TK2MSFTNGP04.phx.gbl...
>>>>I have a VC++ MFC 7.1 application and I am looking for a way to display 
>>>>a background image in the application's frame window behind any child 
>>>>windows that may be displayed. It is a CMDIFrameWnd derived class.
>>>>
>>>> I have found a couple of examples that are to change the background 
>>>> color in the CMyMDIFrameWnd::OnEraseBkgnd() handler.
>>>>
>>>> But it doesn't seem to work. The background color always remains the 
>>>> same.
>>>>
>>>> Is there something that I am missing?
>>>>
>>>> I am running on Windows XP Professional.
>>>> -- 
>>>> Thanks,
>>>> Bruce
>>>>
>>>
>>>
>>
>>
>
> 


0
bwolven1 (7)
3/22/2007 9:59:39 PM
You should unsubclass when you are done with it.

--
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com


"Bruce" <bwolven@nospam.nospam> wrote in message
news:uIJKj1MbHHA.2552@TK2MSFTNGP06.phx.gbl...
> Thanks.
>
> I was able to get it to work.
>
> One last question though.
>
> Do I need to do a UnsubclassWindow() call when I am done in WM_DESTROY or
> WM_NCDESTROY?
> --
> Bruce
>
> "AliR (VC++ MVP)" <AliR@online.nospam> wrote in message
> news:c_AMh.473$YL5.81@newssvr29.news.prodigy.net...
> > As Ajay pointed out I wasn't talking about the child views,
> > m_hWndMDIClient is different than the client views. The client MDIClient
> > that I was talking about is the center (gray) part of the frame.  You
see,
> > the frame window is not just the gray part, it is a window encompasses
the
> > gray part, the menu, the toolbars, the status bar and all of that.  It
has
> > a separate window handle for each one of these components.
> > So the reason that you can't simply take over the WM_ERASEBKGND of the
> > frame window and do you work there is the fact that the MDIClient will
> > cover up every thing that you just did in the WM_ERASEBKGND of the frame
> > (which I must add does nothing by default).
> >
> > AliR.
> >
> >
> > "Bruce" <bwolven@nospam.nospam> wrote in message
> > news:u0VREWLbHHA.960@TK2MSFTNGP03.phx.gbl...
> >>I saw this example but it didn't make sense to me.
> >>
> >> Why does the erase background on the child window paint the frame?
> >>
> >> I'm not trying to change the background of the client window that gets
> >> open, only the MDI frame window.
> >>
> >> If that's the way it must be done, why can't I just add a WM_ERASEBKGND
> >> handler to the child class to do the same thing?
> >>
> >> Is the framework getting in the way?
> >>
> >> Also, will this method work with VS2005 since we are in the process of
> >> moving our source to it?
> >>
> >> --
> >> Thanks,
> >> Bruce
> >>
> >> "AliR (VC++ MVP)" <AliR@online.nospam> wrote in message
> >> news:FgzMh.521$rO7.19@newssvr25.news.prodigy.net...
> >>> You will have to subclass the m_hWndMDIClient of the CMDIFrameWnd with
> >>> your own window and then catch the WM_ERASEBKGND and WM_PAINT messages
> >>> there.
> >>>
> >>> So create class that inherits from CWnd, lets call it CClientWnd. Then
> >>> subclass m_hWndMIDClient in the Frame's OnCreateClient method.  Take
> >>> over the WM_ERASEBKGND message and paint your bitmap there and return
> >>> TRUE. If you bitmap won't takeup the entire client area then you might
> >>> want to it in WM_PAINT.
> >>>
> >>> class CClientWnd : public CWnd
> >>> {
> >>>   DECLARE_DYNAMIC(CClientWnd)
> >>>
> >>> public:
> >>>   CClientWnd();
> >>>   virtual ~CClientWnd();
> >>>
> >>> protected:
> >>>   DECLARE_MESSAGE_MAP()
> >>> public:
> >>>   afx_msg BOOL OnEraseBkgnd(CDC* pDC);
> >>> };
> >>>
> >>>
> >>>
> >>> BEGIN_MESSAGE_MAP(CClientWnd, CWnd)
> >>>   ON_WM_ERASEBKGND()
> >>> END_MESSAGE_MAP()
> >>>
> >>>
> >>>
> >>>
> >>> BOOL CClientWnd::OnEraseBkgnd(CDC* pDC)
> >>> {
> >>>   //draw bitmap here
> >>>   pDC->BitBlt(....);
> >>>
> >>>   return TRUE;
> >>> }
> >>>
> >>> class CMainFrame : public CMDIFrameWnd
> >>> {
> >>> private:
> >>>   CClientWnd m_Client;
> >>> };
> >>>
> >>> BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*
> >>> pContext)
> >>> {
> >>>   if (CMDIFrameWnd::OnCreateClient(lpcs, pContext))
> >>>   {
> >>>      m_Client.SubclassWindow(m_hWndMDIClient);
> >>>      return TRUE;
> >>>   }
> >>>   return FALSE;
> >>> }
> >>>
> >>>
> >>> AliR.
> >>>
> >>> "Bruce" <bwolven@nospam.nospam> wrote in message
> >>> news:uEi4fKKbHHA.4720@TK2MSFTNGP04.phx.gbl...
> >>>>I have a VC++ MFC 7.1 application and I am looking for a way to
display
> >>>>a background image in the application's frame window behind any child
> >>>>windows that may be displayed. It is a CMDIFrameWnd derived class.
> >>>>
> >>>> I have found a couple of examples that are to change the background
> >>>> color in the CMyMDIFrameWnd::OnEraseBkgnd() handler.
> >>>>
> >>>> But it doesn't seem to work. The background color always remains the
> >>>> same.
> >>>>
> >>>> Is there something that I am missing?
> >>>>
> >>>> I am running on Windows XP Professional.
> >>>> --
> >>>> Thanks,
> >>>> Bruce
> >>>>
> >>>
> >>>
> >>
> >>
> >
> >
>
>


0
ajaykalra (6842)
3/23/2007 2:20:31 AM
Reply:

Similar Artilces:

How do make a TextBox not display in an Access report when it is .
I have a report with two TextBoxes that I use to display information from a table. Often in the report, one or the other (or both) of the controls are emplty (i.e., no data is returned from the Table. I would like the report not to display the Label of the TextBox in those situations. Change the label to a text box (right-click it.) Put an expression in the Control Source of this text box so it is null when the main one is null. For example, if you want it to show "City:" only when the City text box has a value, use: =IIf([City] Is Null, Null, "City:") -- All...

Current date displayed on calendar.
I have an calendar displayed on a form, how can I get it to display the current date when I open the form? It always defaults back to 01/08/07. I have tried to remove this value from the properties to no avail. As ever, any help would be appreciated and thanks for your time. Hi Steve, I tried this and it's still not doing it. I am assuming I change where it says Value, above ValueIsNull? Thanks for you advice. "S.Clark" wrote: > Caution: Guessing > > Look for a default value property. Set it to =Date() ?? > > -- > Steve Clark, > Former Access ...

How can years be displayed in an Excel chart?
...

Icons not displaying
Following updates at the beginning of March 2010, icons no longer display in Windows Explorer, even for regular files such as HTML files. Has anyone else experienced this and has anyone discovered how to remedy it? I have tried increasing the IconCache but with no success. Chrystopher wrote: > Following updates at the beginning of March 2010, icons no longer display in > Windows Explorer, even for regular files such as HTML files. > Has anyone else experienced this and has anyone discovered how to remedy it? > I have tried increasing the IconCache but with no success. ...

Drawing Backgrounds
I have attempted to put built-in backgrounds into Visio 2003 drawings, and they all have a "washed out" appearance. Is there anyway to enhance the colors? Thank you Marsh On Fri, 29 Feb 2008 11:58:03 -0800, Marsh <Marsh@discussions.microsoft.com> wrote: >I have attempted to put built-in backgrounds into Visio 2003 drawings, and >they all have a "washed out" appearance. Is there anyway to enhance the >colors? That is the colours they are supposed to have, but you can edit them to suit your owen preferences. You can either edit the background shape o...

change display name in mail
Hi, I have exchange server 2003 installed. I want to change the name, which shows up in the 'from:' field at the receivers email system. I changed the display name in the active directory account properties, but this didn't work (I tested it using OWA to send mail to a yahoo mailbox). How can I achieve this? Thanks, Dani Try changing the alias on the Exchange General tab. -- Hope that helps, Dan Townsend This posting is provided "AS IS" with no warranties, and confers no rights. Please do not send email to this address, post a reply to this newsgroup. Use of inc...

how do I display last two digits of a SSN in a separate column
I am trying to create a formula to take an existing list of 8 or 9 digit numbers and display the last two numbers in a separate column. Is this possible? Try =RIGHT(A1,2) -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "katbone1" wrote: > I am trying to create a formula to take an existing list of 8 or 9 digit > numbers and display the last two numbers in a separate column. Is this > possible? Hi Use a formula =3Dright(A1, 2...

Pub2002 Can I display 2 different files at once and edit between t
Hi, I want to condense a 50 page Pub 2002 document into a separate new file. Rather than starting from scratch, can I display the old file and the new one side by side on the screen at the same time and drag and drop between them? If so, how? Thanks. thosdew Hi thosdew (thosdew@discussions.microsoft.com), in the newsgroups you posted: || I want to condense a 50 page Pub 2002 document into a separate new || file. Rather than starting from scratch, can I display the old file || and the new one side by side on the screen at the same time and drag || and drop between them? If so, how? Yes....

single Images in word document display twice...
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel When I open a word document from others (using PC), images appear double. The image will display small, and then behind it (in the same image box) will be a much larger version of the image. <br><br>I can not separate them or adjust them in any way outside of scaling the overall image. <br><br>I've had this problem on multiple macs running 10.6.x and office 2008 from multiple sources. <br><br>Any suggestions would be appreciated. I haven't witnessed anything of thi...

Subreport based on query: Display/print ID number or Full name onl
I have designed a summary report that shows average ratings respondents give for seminar sessions. I have several subreports based on different queries that give me a Respondents ID number, full name, and any verbatim comments the respondent made. Clients and instructors now only want to see the respondents ID number only if there is no name. I just started learning VB so, I'm way out of my comfort zone here! TextBox FullName's control source is =[RspFname]&" "&[RspLname] RspID (PK) visible property is set to true Private Sub Detail_Format(Cancel As Integer...

Pivot table question: How to display total and percent for data simultaneouly
I'd like to make a pivot chart that displays the same data both as a total and as a percentage at the same time: Example: Consider the following source data: Name Category Value a c1 10 a c2 20 b c1 5 b c2 30 It is easy enough to make a pivot table displaying: Sum of Value Category Name c1 c2 Grand Total a 10 20 30 b 5 30 35 Grand Total 15 50 65 It is also easy to display the percentages of the grand total for each entry. I'd like to display both simultaneously. Something like Name c...

Images Disappear when offline
I have Outlook 2003 on my laptop. When I am connected to my network and download my POP3 mail I can see the images in the HTML messages, however when I disconnect from the network and view the messages the images have gone!!! I have set the image download option to download the entire message and view the images but that hasn't helped. It's strange because if I reconnect the laptop to the Web all the images\banners etc reappear! Any ideas? Many messages include only a link to web based content, not the actual image. In those cases Outlook has nothing to download and you won't ...

How to add svcstart to OS image
Hello, i want to add svcstart.dll into the NK.bin. From solution explorer in VS2005 (PB WinCE 6.0) I have found the svcstart project and I have right click on it and I have selected "Open build windows". In this window I have executed "sysgen -p servers svcstart". Now the svcstart.dll is in the flat releaser directory and I want that make image put the file into the nk.bin. I have read the following lines in servers.bib file : ; @CESYSGEN IF SERVERS_MODULES_SVCSTART svcstart.dll $(_FLATRELEASEDIR)\svcstart.dll NK SH ; @CESYSGEN ENDIF ...

Unable to display public folder
I have 1 user (out of 60) that is unable to display 2 (out of a bunch) of public folders. Here are some of the things I've tried: - Set him to be an owner of the folders. - Removed and reinstalled Office 2000 and applied service packs (be we all know that a lot of the settings remain after a removal!) - Logged him in at a different machine...which works fine, so I'm assuming his problem is local with 2000 and not with the exchange 2003 server? Short of wiping his entire machine a reinstalling the OS, is there something else I could try? Maybe manually removing all the setup files? ...

Displaying Data in a Form
Using Access 2007, we have a form that has 14 controls bound to fields in a table. What we need to do find a method where a user picks a value from a ComboBox which is one of the 14 above mentioned controls, and have the other controls populated with the appropriate data. A simplistic example is to have a combo box with last names, and when Smith is chosen from the drop down 9 records with the last name Smith are available in the form. I can then navigate through the various Smiths and find the First Name, Address, City, State, Zip, etc for any of the Smiths. Thanks in advance...

unscroll picture background
I want to use the option (page colour - fill effects - picture ) to use a photo for a background to the body of an Outlook email. However, the picture becomes a scrolled picture instead of just being used once. Any fixes? -- lr That's not possible with background pictures. You can achieve it still though via; Insert-> Picture...-> right click picture-> Text Wrapping-> Behind Text -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsoft Outlook 2003 http://www.howto-outlook.com/ Outlook FAQ, HowTo, Downloads, Add-Ins and more http://www.msoutlo...

Draw image on modal dialog box
I have a CImageList and a modal dialog box. What is the proper way to draw an image from the list onto a static control on the dialog box? -- Regards, Frank "Frank S" <JazzedApps@community.nospam> wrote in message news:uYuXqG07HHA.5424@TK2MSFTNGP02.phx.gbl... >I have a CImageList and a modal dialog box. What is the proper way to draw >an image from the list onto a static control on the dialog box? You handle WM_PAINT for the static control and paint it yourself in that function. To set this up you derive your own class from CStatic. Then you add a control memb...

Word won't show images in Docs
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I've just upgraded to a new iMac and transferred files and programs from my iMac (Both running Snow Leopard). Now I can't see any image files in word docs. It will show it in print preview but not in the doc itself. This applies to pics already in the doc or new. I'm using version 12.2.3. <br><br>Thanks for any help. ...

Excel 2000 Font Drop Down Menu
I'm running Win 2000 SP4 with Excel 2000 SR1 and IE 5.01SP4 with the International Fonts package installed. When I use the Font Drop Down Menu in Excel, it displays all the standard installed fonts plus non English fonts: namely Arial, Courier New and Times New Roman in CE, CYR, Greek and TUR. I don't have this problem in any other application. Any ideas on how to correct this? Chas. verktyg@nospamski.aol.com ...

Adding a control and a background to a view, flickers
Hi, if I create a basic project, (SDI with CView). In my "OnInitialUpdate" I create a control, say a CTreeCtrl() for example, (yes it is a global value). My tree ctrl works fine, and I can resize the control, (in the OnSize() I call the MoveWindow to resize the control as I need). But the problem is when I add a background colour. If I use a bitmap and try to place it at the background picture, Where 'r' is the rectangle I want to stretch the bitmap over. I do... CMyView::OnDraw(...) { .... pDC->StretchBlt(0,0,r.Width(),r.Height(),pMemDC,0,0, bkwidth,bkheight , SR...

Displaying data in bar form on a line chart
I have a line chart that displays two sets of data. I have a third set of data I would like displayed on the same chart but in the form of bars. How do I do this? Add the data to the chart so you have three lines (or create the chart with three lines to start with), select the one series, and use Chart Type on the Chart menu to change it to a Line style. - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ "expo" <expo@discussions.microsoft.com> wrote in message news:ECB62435-8CD2-4BBF...

how attachments are displayed
I support a customized form that contains the message field. When attachments are pasted into the message, they display in a scrollable box that displays 1 line of attachments. I can size the entire message field, but don't know how to just size the display of the attachments. I'd like it to display 3 lines instead of 1. Thanks. ...

Money Plus Deluxe
I have downloaded transactions from three bank accounts to the corresponding accounts in Money. One account is OK and displays the "items to review" in the register. The other two accounts show that there are "items to review" but nothing is displayed in the registers. One of these accounts is from the same financial institution as the one that works OK. I have tried "repair Money file" and have also uninstalled and reinstalled Money. Any ideas? Many thanks. In microsoft.public.money, Peewee wrote: >I have downloaded transactions from three bank accounts to ...

Forwarding emails, images removed
We have SBS 2003 with Exchange. We were using Outlook 2003 on Windows 2000. I am the 'adminstrator' of the SBS server. Now we have two new computers with Windows XP and Office 2007. I have one, my boss has the other. The problem is when my boss forwards emails to me to print them out. The images are stripped out, leaving squares where the pictures were. Why is this happening and how do I correct this? It did not happen with Outlook 2003. Sometimes I get the same emails, say from Dell or HP, and the images are not stripped out. So it has to do with forwarding. Thank...

Expose the TO email address field rather than the display name.
Is there a way to expose the TO email address field rather than the display name so it may be used in the Outlook list view? I came across this article that shows how to do it fot the FROM address and would like to know if there is a way to use this technique for the TO field? [URL="http://www.slipstick.com/exs/customfields.htm"]http://www.slipstick.com/exs/customfields.htm[/URL] The purpose is that we have many users with multiple email addresses and we would like to know which address the email was sent to. Outlook is being too (or not too) smart here. There reall...