Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
C#
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
Comments
Rajiv Précieux Mounguengue 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900