Click here to Skip to main content
12,455,917 members (49,474 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# Visual-Studio WPF VS2010 , +
Hi,

This new version of SAP Crystal reports have another issue with the focus event.

In some cases, the toolbar buttons are always disabled or in another cases when you minimize and maximize your window the toolbar buttons appear disabled.

You have two workarounds to this situation:

1º: Click on the buttons at the bottom of the viewer (size to fit, slider..), this will activate the toolbar buttons.

2º: insert this code in the window with the Crystal Reports viewer:
protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);
            HwndSource source = PresentationSource.FromVisual(this) as HwndSource;
            source.AddHook(WndProc);
        }
 
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            // Handle messages...

            if (MyReportViewer != null)
            {
                MyReportViewer.Focusable = true;
                MyReportViewer.Focus();
            }
 
            return IntPtr.Zero;
        }

In my case (minimize, maximize), this resolved the problem.

regards
Posted 10-Oct-12 5:28am
Comments
Rajivhost 30-Apr-13 2:19am
   
Hi,
I tried this but not work for me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160826.1 | Last Updated 10 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100