A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Background Color for Outlook Property Page



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 2nd 06, 05:16 AM posted to microsoft.public.outlook.program_addins
paulmcd
external usenet poster
 
Posts: 2
Default Background Color for Outlook Property Page

Recently I was trying to get this working. I solved it. Here it is:

I used a great sample from he

http://thecodeproject.com/wtl/Themed...sp#xx1149261xx

////////////////////////////////////////////////////////////////////////////
// Copyright : Amit Dey 2002
//
// Email
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is
// not sold for profit without the authors written consent, and
// providing that this notice and the authors name is included.
//
// This file is provided 'as is' with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to your
computer.
//
// Do expect bugs.
// Please let me know of any bugs/mods/improvements.
// and I will try to fix/incorporate them into this file.
// Enjoy!
//
// Description : Outlook2K Addin
////////////////////////////////////////////////////////////////////////////

// PropPage.h : Declaration of the CPropPage

#ifndef __PROPPAGE_H_
#define __PROPPAGE_H_

#include "resource.h" // main symbols
#include atlctl.h
#import "c:\src\loop.old\include\msoutl9.olb" raw_interfaces_only
#include c:\src\loop.old\include\atlcontrols.h
using namespace ATLControls;
/////////////////////////////////////////////////////////////////////////////
// CPropPage
class ATL_NO_VTABLE CPropPage :
public CComObjectRootExCComSingleThreadModel,
public IDispatchImplIPropPage, &IID_IPropPage,
&LIBID_OUTLOOKADDINLib,
public CComCompositeControlCPropPage,
public IPersistStreamInitImplCPropPage,
public IOleControlImplCPropPage,
public IOleObjectImplCPropPage,
public IOleInPlaceActiveObjectImplCPropPage,
public IViewObjectExImplCPropPage,
public IOleInPlaceObjectWindowlessImplCPropPage,
public IPersistStorageImplCPropPage,
public ISpecifyPropertyPagesImplCPropPage,
public IQuickActivateImplCPropPage,
public IDataObjectImplCPropPage,
public IProvideClassInfo2Impl&CLSID_PropPage, NULL,
&LIBID_OUTLOOKADDINLib,
public CComCoClassCPropPage, &CLSID_PropPage,
public IPersistPropertyBagImplCPropPage,
public
IDispatchImplPropertyPage,&__uuidof(PropertyPage) ,&LIBID_OUTLOOKADDINLib
{
public:
CPropPage()
{
m_bWindowOnly = TRUE;
CalcExtent(m_sizeExtent);
m_hBrush = NULL;
m_bThemeActive = FALSE;
}

DECLARE_REGISTRY_RESOURCEID(IDR_PROPPAGE)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CPropPage)
COM_INTERFACE_ENTRY(IPropPage)
COM_INTERFACE_ENTRY2(IDispatch,IPropPage)
COM_INTERFACE_ENTRY(IViewObjectEx)
COM_INTERFACE_ENTRY(IViewObject2)
COM_INTERFACE_ENTRY(IViewObject)
COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceObject)
COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
COM_INTERFACE_ENTRY(IOleControl)
COM_INTERFACE_ENTRY(IOleObject)
COM_INTERFACE_ENTRY(IPersistStreamInit)
COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
COM_INTERFACE_ENTRY(IQuickActivate)
COM_INTERFACE_ENTRY(IPersistStorage)
COM_INTERFACE_ENTRY(IDataObject)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY(IPersistPropertyBag)
COM_INTERFACE_ENTRY(Outlook::PropertyPage)
END_COM_MAP()

BEGIN_PROP_MAP(CPropPage)
PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
// Example entries
// PROP_ENTRY("Property Description", dispid, clsid)
// PROP_PAGE(CLSID_StockColorPage)
END_PROP_MAP()

BEGIN_MSG_MAP(CPropPage)
MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColor)
CHAIN_MSG_MAP(CComCompositeControlCPropPage)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
END_MSG_MAP()
// Handler prototypes:
// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled);
// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl,
BOOL& bHandled);
// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

BEGIN_SINK_MAP(CPropPage)
//Make sure the Event Handlers have __stdcall calling convention
END_SINK_MAP()

STDMETHOD(GetControlInfo)(LPCONTROLINFO pCI);
STDMETHOD(SetClientSite)(IOleClientSite *pSite);

STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
{
if (dispid == DISPID_AMBIENT_BACKCOLOR)
{
SetBackgroundColorFromAmbient();
FireViewChange();
}
return IOleControlImplCPropPage::OnAmbientPropertyChang e(dispid);
}



// IViewObjectEx
DECLARE_VIEW_STATUS(0)

// IPropPage
public:

enum { IDD = IDD_PROPPAGE };
// PropertyPage
STDMETHOD(GetPageInfo)(BSTR * HelpFile, LONG * HelpContext);
STDMETHOD(get_Dirty)(VARIANT_BOOL * Dirty);
STDMETHOD(Apply)();



private:
CComVariant m_fDirty;
CComPtrOutlook::PropertyPageSite m_pPropPageSite;


HBRUSH m_hBrush;
BOOL m_bThemeActive;
CWindow m_Control;

void UpdateBackgroundBrush()
{

m_bThemeActive = IsAppThemed();

// Destroy old brush
if (m_hBrush)
:eleteObject(m_hBrush);

m_hBrush = NULL;

// Only do this if the theme is active
if (m_bThemeActive)
{
RECT rc;

// Get tab control dimensions
m_Control.GetWindowRect(&rc);

// Get the tab control DC
HDC hDC = m_Control.GetDC();

// Create a compatible DC
HDC hDCMem = ::CreateCompatibleDC(hDC);
HBITMAP hBmp = ::CreateCompatibleBitmap(hDC, rc.right - rc.left,
rc.bottom - rc.top);
HBITMAP hBmpOld = (HBITMAP)(::SelectObject(hDCMem, hBmp));

// Tell the tab control to paint in our DC
m_Control.SendMessage(WM_PRINTCLIENT, (WPARAM)(hDCMem),
(LPARAM)(PRF_ERASEBKGND | PRF_CLIENT | PRF_NONCLIENT));

// Create a pattern brush from the bitmap selected in our DC
m_hBrush = ::CreatePatternBrush(hBmp);

// Restore the bitmap
::SelectObject(hDCMem, hBmpOld);

// Cleanup
:eleteObject(hBmp);
:eleteDC(hDCMem);
m_Control.ReleaseDC(hDC);
}
}


void test();


LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
HRESULT hr = EnableThemeDialogTexture(GetParent(),
ETDT_ENABLETAB);

m_Control = GetParent();
DrawThemeParentBackground(m_hWnd, (HDC)wParam, NULL);
UpdateBackgroundBrush();


return 0;
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Return the created background brush
//
LRESULT OnCtlColor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*
bHandled */)
{
if (m_bThemeActive)
{
RECT rc;

// Set the background mode to transparent
::SetBkMode((HDC)(wParam), TRANSPARENT);

// Get the controls window dimensions
::GetWindowRect((HWND)(lParam), &rc);

// Map the coordinates to coordinates with the upper left corner of
dialog control as base
::MapWindowPoints(NULL, m_Control, (LPPOINT)(&rc), 2);

// Adjust the position of the brush for this control (else we see
the top left of the brush as background)
::SetBrushOrgEx((HDC)(wParam), -rc.left, -rc.top, NULL);

// Return the brush
return (LRESULT)(m_hBrush);
}

return FALSE;
}

};

#endif //__PROPPAGE_H_

Ads
  #2  
Old February 2nd 06, 04:23 PM posted to microsoft.public.outlook.program_addins
paulmcd
external usenet poster
 
Posts: 2
Default Background Color for Outlook Property Page

by the way, this is for an OUTLOOK ADDIN, add in

  #3  
Old February 15th 06, 07:38 AM posted to microsoft.public.outlook.program_addins
Mark W via OfficeKB.com
external usenet poster
 
Posts: 3
Default Background Color for Outlook Property Page

Paul,

Just wanted to say thanks (although I have not tested the code yet). This was
on my list to do using the same code project code - good call. Thanks!!!!

paulmcd wrote:
by the way, this is for an OUTLOOK ADDIN, add in


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...ddins/200602/1
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ability to place pictures as background in office outlook Hernan Gamboa Outlook - Installation 1 February 20th 06 07:07 PM
Background colors for calendars. johnk Outlook - Calandaring 3 February 12th 06 09:48 PM
HTML email has a grey background Chris Foster Outlook - Installation 0 January 31st 06 06:11 PM
why can't you add a page to a form just like you can add a page to the property page donald Outlook - Using Forms 2 January 25th 06 10:50 AM
Changing background colors in Outlook Express - HELP! will7370 Outlook - General Queries 2 January 21st 06 07:23 PM


All times are GMT +1. The time now is 09:05 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.