ActiveX control is not shown correctly in Access Reports print pre

N

Nitheesh

Hi All,
we are developing ActiveX control's to use in MS Access. The control works
fine with Access form in design mode and running mode. But in case of reports
the design mode shows the control correctly but when comes to print preview
mode, the size and drawing on the control is not working properly. The same
control works fine with Access 2002. The problem is found to be with Access
2000. We need to enable XP theme from UxTheme.dll(Microsoft provide) if theme
is avaible in the system. The drawing of theme is alo goes wrong in Access
2000 reports print preview mode.

please help us in solving this problem

Nitheesh
 
S

Stephen Lebans

I have not seen any differences with how my ActiveX controls are rendered on
versions of Access 97 through A2003.

Access builds its Print Preview with metrics supplied by the printer and
display drivers. I have seen several drivers, most notably HP and Ink Jet
drivers, that supply non standard metrics. Try changing Printer Drivers or
Display adapter settings to see if it effects Print Preview.

What language are you developing your ActiveX controls in?
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
N

Nitheesh

Hi Stephen ,

The control is developed in VC++ 6.0. It's a progress control for Ms Access.
When XP theme is enabled for progress control its chunks are not showing
correctly in print preview mode. we are using UxTheme.dll from Microsoft and
Its DrawThemeBackGround for drawing the theme The problem is found with
MsAccess 2000. We are using the rectangle dimensions from OnDraw function of
the ActiveX for drawing purpose.

thanks and regards,

Nitheesh.
 
S

Stephen Lebans

I'm afraid I have no experience with the UxTheme library.

There were a few report related bugs in the first release of A2000. Are you
sure your installs are all patched with the SR2 for A2K? Do the Print
Previews render correctly if your control is on a Form?

Can you post your OnDraw code so I can take a look at it? I'm leaving for a
Casino trip now and will not be able to look at your code until Monday
morning.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
N

Nitheesh

Hi Stephen ,

First of all thank you for your replies.
The checked the form print preview mode and is also not rendering correctly.
The chunk width is getting too small. So there are more chunks in print
preview than design or running mode in forms. i am including the code which
we used to implement the progress bar control.

Below is the OnDraw function of the progress control. its actually calling
its base call version

/////////////////////////////////////////////////////////////////////////////
// CprogCtrl::OnDraw - Drawing function
void CprogCtrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
CBaseCtrl::OnDraw(pdc,rcBounds,rcInvalid);
}

And this is the base class implemenation of CBaseCtrl::OnDraw
In which we check whether its print preview or not using the
iTechCaps==DT_RASPRINTER
condition.

/////////////////////////////////////////////////////////////////////////////
// CBaseCtrl::OnDraw - Drawing function

void CBaseCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect&
rcInvalid)
{
//assume mm_text since we are ui active, don't assume 0,0 though

int iTechCaps = pdc->GetDeviceCaps(TECHNOLOGY);
CRect rcNewBounds = rcBounds;
UINT nEdge = 0;

int iLogInch = pdc->GetDeviceCaps(LOGPIXELSX);
//going to screen, so 1 pixel is 1 pixel
m_iPixelSize = 1;

//O.K. Access no longer implements OnDrawMetafile.
//We now need to check for Raster printer.

if (iTechCaps == DT_RASPRINTER)
{
CClientDC dcScreen(NULL);
m_iPixelSize = (float) pdc->GetDeviceCaps(LOGPIXELSX) /
dcScreen.GetDeviceCaps(LOGPIXELSX);
CSize szW;
szW = pdc->GetWindowExt();
pdc->SetViewportExt(szW.cx,szW.cy);

DrawMe(pdc,rcNewBounds);// calls derived implementation CprogCtrl::DrawMe

}
else
{
// call virtual function DrawMe

DoDrawOffScreen(pdc,rcNewBounds,rcInvalid);
}
}

Here is the code for void CBaseCtrl::DoDrawOffScreen

/////////////////////////////////////////////////////////////////////////////
// CBaseCtrl::DoDrawOffScreen - Drawing function
void CBaseCtrl::DoDrawOffScreen(CDC* pdc, const CRect& rcBounds,const CRect&
rcInvalid)
{

CDC dcMem;
CBitmap bitOff;
CRect rcBoundsDP(rcBounds) ;
CRect rcInvalidDP(rcInvalid) ;

// Convert bounds to pixels.
pdc->LPtoDP(&rcBoundsDP) ;
pdc->LPtoDP(&rcInvalidDP) ;

// Create a DC that is compatible with the screen.
dcMem.CreateCompatibleDC(pdc) ;

// The bitmap bounds have 0,0 in the upper-left corner.
CRect rcBitmapBounds( 0,0,
rcBoundsDP.Width(),
rcBoundsDP.Height()) ;

// Create a really compatible bitmap.
bitOff.CreateBitmap(rcBitmapBounds.Width(),
rcBitmapBounds.Height(),
pdc->GetDeviceCaps(PLANES),
pdc->GetDeviceCaps(BITSPIXEL),
NULL) ;

// Select the bitmap into the memory DC.
CBitmap* pOldBitmap = dcMem.SelectObject(&bitOff) ;

// Save the memory DC state, since DrawMe might change it.
int iSavedDC = dcMem.SaveDC();


// Draw our control on the memory DC.
DrawMe(&dcMem, rcBitmapBounds) ;

// Restore the DC, since DrawMe might have changed mapping modes.
dcMem.RestoreDC(iSavedDC) ;

// We don't know what mapping mode pdc is using.
// BitBlt uses logical coordinates.
// Easiest thing is to change to MM_TEXT.
pdc->SetMapMode(MM_TEXT) ;
pdc->SetWindowOrg(0,0) ;
pdc->SetViewportOrg(0,0) ;

// Blt the memory DC to the screen.
pdc->BitBlt( rcInvalidDP.left,
rcInvalidDP.top,
rcInvalidDP.Width(),
rcInvalidDP.Height(),
&dcMem,
rcInvalidDP.left - rcBoundsDP.left,
rcInvalidDP.top - rcBoundsDP.top,
SRCCOPY) ;

// Clean up.
dcMem.SelectObject(pOldBitmap) ;
}


The Derive class(CprogCtrl) implementation for DrawMe is as follows,
which calls XP style drawing function such as
DrawLeftHorizontalWinXPBar(pdc,rcBar,percent)
in which m_hTheme is a handle in CThemeXp class to the dll.CThemeXp is
wrapper around the
UxTheme library.m_hTheme.DrawBackground is a function pointer to DLL's
DrawThemeBackground
function whose address is got through GetProcAddress.

/////////////////////////////////////////////////////////////////////////////
// CprogCtrl::DrawMe - Drawing function

void CprogCtrl::DrawMe(CDC *pdc,const CRect &rcBounds)
{
CBrush brBackColor(TranslateColor(GetBackColor()));
pdc->FillRect(rcBounds, &brBackColor);


long nValue = m_lValue;
long nMax = m_lMax;
long nMin = m_lMin;
long nRange = m_lMax - m_lMin;
float percent = ((float)nValue - nMin) / (float)nRange;


if (m_iOrientation == cHorizontal)
{
CRect rcBar(rcBounds);
rcBar.InflateRect(-1,-1);
if (m_iFillStyle == cLeft)
DrawLeftHorizontalWinXPBar(pdc,rcBar,percent);
else
DrawRightHorizontalWinXPBar(pdc,rcBar,percent);

}
else//vertical
{
CRect rcBar(rcBounds);
rcBar.InflateRect(-1,-1);
if (m_iFillStyle == cLeft)
DrawBottomVerticalWinXPBar(pdc,rcBar,percent);
else
DrawTopVerticalWinXPBar(pdc,rcBar,percent);

}

}


/////////////////////////////////////////////////////////////////////////////
// CprogCtrl::DrawLeftHorizontalWinXPBar - Drawing function

void CprogCtrl::DrawLeftHorizontalWinXPBar(CDC* pdc, const CRect
&rcProgress,const float percent)
{
BOOL bThemeAvailable = FALSE;
bTheme = m_hTheme.IsAvailable();

if(bThemeAvailable)
{
RECT rcClip;
RECT rcBar;

rcBar.left = rcProgress.left + m_iPixelSize;
rcBar.top = rcProgress.top + m_iPixelSize;
rcBar.right =rcProgress.right - m_iPixelSize;
rcBar.bottom =rcProgress.bottom - m_iPixelSize;


int iWidth = rcBar.right - rcBar.left;
rcClip.left = rcBar.left;
rcClip.top = rcBar.top;
rcClip.right = rcBar.left + iWidth*percent;
rcClip.bottom = rcBar.bottom;

//Draw the background and bar using these rectangles.
//Draw the background and bar using these rectangles.
bThemeAvailable = m_hTheme.Open(GetSafeHwnd(), L"PROGRESS");
m_hTheme.DrawBackground(pdc->GetSafeHdc(),PP_BAR,0, &rcProgress,NULL);
m_hTheme.DrawBackground(pdc->GetSafeHdc(),PP_CHUNK,0, &rcBar,&rcClip);
m_hTheme.Close();
}
}
 
S

Stephen Lebans

Just to clarify, is the rendering issue only with A2000 or is it with all
versions of Access?
I also asked you to verify that you have your A2000 install patched to SR2.
Have you?

I have not developed a control in several years but at a quick glance I will
hazard a guess that your issue lies in the logic used to map the Rectangle's
coordinates to device space. Before I go any further though can you answer
the two questions above please.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
N

Nitheesh

Hi Stephen,

The rendering issue is only found with Access 2000(we tested the control
with all greater versions) and we are using A2000 with SR-1. Installing SR2
will solve this problem?. And whether the issue lies in the logic used to map
the Rectangle's coordinates to device space since it work fine with all other
greater versions of Access?.

please help me to solve this out.

thanks & regards
Nitheesh
 
S

Stephen Lebans

In order for both of our systems to be the same please install the A2K SR2
on your test system.

Did you test all versions of Access(a2K or greater) on the same workstation?
Do you have the same default Printer Driver installed on all test machines?
Have you tried different printer drivers installed locally on the test
machine to ensure it is not a Printer Driver issue?

Is it the save version of Windows that was used to test your control with
the different versions of Access?

I just rechecked and my ActiveX control renders properly on all versions of
Access including A2K. My A2K install is under Win2K.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
S

Stephen Lebans

Once you have installed SR1(a) for A2k please make sure you have Name
Autocorrect turned off.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top