Results 1 to 3 of 3

Thread: [RESOLVED] add buttons to toolbar in datareport?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    144

    Resolved [RESOLVED] add buttons to toolbar in datareport?

    I need to export my report to excel. This part is done. My end users want to use the toolbar on the datareport to access the export feature. Can I gain access to the datareport toolbar through some hard to find api or anything?

    Other alternatives are welcomed, but I will tell you that they want to view the report before the export is done. Also, my supervisor is against working in reverse. Closing the datareport to click on another export button is what he considers working backwords. Yes, its odd.

    Throw your ideas at me and this is my first post so welcome me. 4 years programming in vb. Not a .Net fan. No Crystal Reports.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: add buttons to toolbar in datareport?

    Welcome...

    You will need to subclass the datareport in order to capture the button click events (which is beyond me).

    This procedure (found on google) will remove the buttons from the data report toolbar, allowing you to implement your own. Call this routine after you Show the report. The Doevents is necessary as it gives the report time to load.

    DataReport1.Show
    DoEvents 'or use a Timer
    DisableDataReportToolbarButtons DataReport1.Caption

    VB Code:
    1. 'in a module
    2. Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    3. Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4. Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    5. Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    6.  
    7. Private Const GWL_STYLE = (-16)
    8. Private Const GW_CHILD = 5
    9. Private Const GW_HWNDNEXT = 2
    10.  
    11. Public Sub DisableDataReportToolbarButtons(ReportFormCaption As String)
    12.  
    13.     Dim tmpHWnd As Long
    14.     Dim MainHWnd As Long
    15.     Dim ExportHwnd As Long
    16.     Dim PrintHWnd As Long
    17.    
    18.      'Drill down window handle "tree" to the toolbar buttons
    19.     tmpHWnd = FindWindow(vbNullString, ReportFormCaption)
    20.     tmpHWnd = GetWindow(tmpHWnd, GW_CHILD)
    21.     tmpHWnd = GetWindow(tmpHWnd, GW_CHILD)
    22.     tmpHWnd = GetWindow(tmpHWnd, GW_CHILD)
    23.    
    24.     'Get Print and Export buttons' handles
    25.     PrintHWnd = GetWindow(tmpHWnd, GW_CHILD)
    26.     ExportHwnd = GetWindow(PrintHWnd, GW_HWNDNEXT)
    27.    
    28.     'Call API to hide the buttons
    29.     ShowWindow PrintHWnd, 0&
    30.     ShowWindow ExportHwnd, 0&
    31. End Sub

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: add buttons to toolbar in datareport?

    Welcome to VBF!

    Or make it MDI Child and use an MDIForm for the Toolbar.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width