Results 1 to 5 of 5

Thread: problems on data reports[solved]

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    25

    problems on data reports[solved]

    is any way to set my report's page orientation to landscape??
    ------------------------------------------------------------------
    Last edited by sikwate; May 15th, 2005 at 11:37 PM. Reason: solved

  2. #2
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    Re: problems on data reports

    dont think it's possible but i might be wrong. searched this for so long and nothing found that's why i've switched to crystal report

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

    Re: problems on data reports

    Install SP6 and use this before you open the datareport:

    VB Code:
    1. DataReport.Orientation = rptOrientLandScape
    2. DataReport.Show

    Or use this:

    VB Code:
    1. 'Constants used in the DevMode structure
    2. Private Const CCHDEVICENAME = 32
    3. Private Const CCHFORMNAME = 32
    4.  
    5. 'Constants for NT security
    6. Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
    7. Private Const PRINTER_ACCESS_ADMINISTER = &H4
    8. Private Const PRINTER_ACCESS_USE = &H8
    9. Private Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE)
    10.  
    11. 'Constants used to make changes to the values contained in the DevMode
    12. Private Const DM_MODIFY = 8
    13. Private Const DM_IN_BUFFER = DM_MODIFY
    14. Private Const DM_COPY = 2
    15. Private Const DM_OUT_BUFFER = DM_COPY
    16. Private Const DM_DUPLEX = &H1000&
    17. Private Const DMDUP_SIMPLEX = 1
    18. Private Const DMDUP_VERTICAL = 2
    19. Private Const DMDUP_HORIZONTAL = 3
    20. Private Const DM_ORIENTATION = &H1&
    21. Private Const DMPAPER_LEGAL As Long = 5
    22. Private Const DMPAPER_LETTER As Long = 1
    23. Private Const DMORIENT_LANDSCAPE As Long = 2
    24. Private Const DMORIENT_PORTRAIT As Long = 1
    25. 'and so on
    26.  
    27. 'The DevMode structure contains printing parameters.
    28. 'Note that this only represents the PUBLIC portion of the DevMode.
    29. ' The full DevMode also contains a variable length PRIVATE section
    30. ' which varies in length and content between printer drivers.
    31. 'NEVER use this User Defined Type directly with any API call.
    32. ' Always combine it into a FULL DevMode structure and then send the
    33. ' full DevMode to the API call.
    34. Private Type DEVMODE
    35. dmDeviceName As String * CCHDEVICENAME
    36. dmSpecVersion As Integer
    37. dmDriverVersion As Integer
    38. dmSize As Integer
    39. dmDriverExtra As Integer
    40. dmFields As Long
    41. dmOrientation As Integer
    42. dmPaperSize As Integer
    43. dmPaperLength As Integer
    44. dmPaperWidth As Integer
    45. dmScale As Integer
    46. dmCopies As Integer
    47. dmDefaultSource As Integer
    48. dmPrintQuality As Integer
    49. dmColor As Integer
    50. dmDuplex As Integer
    51. dmYResolution As Integer
    52. dmTTOption As Integer
    53. dmCollate As Integer
    54. dmFormName As String * CCHFORMNAME
    55. dmLogPixels As Integer
    56. dmBitsPerPel As Long
    57. dmPelsWidth As Long
    58. dmPelsHeight As Long
    59. dmDisplayFlags As Long
    60. dmDisplayFrequency As Long
    61. dmICMMethod As Long '// Windows 95 only
    62. dmICMIntent As Long ' // Windows 95 only
    63. dmMediaType As Long ' // Windows 95 only
    64. dmDitherType As Long ' // Windows 95 only
    65. dmReserved1 As Long ' // Windows 95 only
    66. dmReserved2 As Long ' // Windows 95 only
    67. End Type
    68.  
    69. Private Type PRINTER_DEFAULTS
    70. 'Note:
    71. ' The definition of Printer_Defaults in the VB5 API viewer is incorrect.
    72. ' Below, pDevMode has been corrected to LONG.
    73. pDatatype As String
    74. pDevMode As Long
    75. DesiredAccess As Long
    76. End Type
    77.  
    78. Public Enum MyPrinterPaperSize
    79. Letter = DMPAPER_LETTER
    80. Legal = DMPAPER_LEGAL
    81.  
    82. End Enum
    83.  
    84. Public Enum MyPrinterOrientation
    85. Portrait = DMORIENT_PORTRAIT
    86. Landscape = DMORIENT_LANDSCAPE
    87.  
    88. End Enum
    89.  
    90. Private InitialPaperSize As Long
    91. Private InitialPaperOrit As Long
    92. Private CallingHwnd As Long
    93.  
    94. '------DECLARATIONS
    95.  
    96. Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long
    97. Private Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, ByVal Command As Long) As Long
    98. Private Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, ByVal cbBuf As Long, pcbNeeded As Long) As Long
    99. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
    100. Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
    101.  
    102. 'The following is an unusual declaration of DocumentProperties:
    103. ' pDevModeOutput and pDevModeInput are usually declared ByRef. They are declared
    104. ' ByVal in this program because we're using a Printer_Info_2 structure.
    105. ' The pi2 structure contains a variable of type LONG which contains the address
    106. ' of the DevMode structure (this is called a pointer). This LONG variable must
    107. ' be passed ByVal.
    108. ' Normally this function is called with a BYTE ARRAY which contains the DevMode
    109. ' structure and the Byte Array is passed ByRef.
    110. Private Declare Function DocumentProperties Lib "winspool.drv" Alias "DocumentPropertiesA" (ByVal hwnd As Long, ByVal hPrinter As Long, ByVal pDeviceName As String, ByVal pDevModeOutput As Any, ByVal pDevModeInput As Any, ByVal fMode As Long) As Long
    111.  
    112.  
    113. '------CODE
    114.  
    115. Public Sub ChangePaperSize(MyHwnd As Long, PaperSize As MyPrinterPaperSize, Optional Orientation As MyPrinterOrientation = 0)
    116. Dim PrinterHandle As Long
    117. Dim PrinterName As String
    118. Dim pd As PRINTER_DEFAULTS
    119. Dim MyDevMode As DEVMODE
    120. Dim Result As Long
    121. Dim Needed As Long
    122. Dim pFullDevMode As Long
    123. Dim pi2_buffer() As Long
    124. CallingHwnd = MyHwnd
    125. PrinterName = Printer.DeviceName
    126. If PrinterName = "" Then
    127. Exit Sub
    128. End If
    129.  
    130. pd.pDatatype = vbNullString
    131. pd.pDevMode = 0&
    132. 'Printer_Access_All is required for NT security
    133. pd.DesiredAccess = PRINTER_ALL_ACCESS
    134.  
    135. Result = OpenPrinter(PrinterName, PrinterHandle, pd)
    136.  
    137. 'The first call to GetPrinter gets the size, in bytes, of the buffer needed.
    138. 'This value is divided by 4 since each element of pi2_buffer is a long.
    139. Result = GetPrinter(PrinterHandle, 2, ByVal 0&, 0, Needed)
    140. ReDim pi2_buffer((Needed \ 4))
    141. Result = GetPrinter(PrinterHandle, 2, pi2_buffer(0), Needed, Needed)
    142.  
    143. 'The seventh element of pi2_buffer is a Pointer to a block of memory
    144. ' which contains the full DevMode (including the PRIVATE portion).
    145. pFullDevMode = pi2_buffer(7)
    146.  
    147. 'Copy the Public portion of FullDevMode into our DevMode structure
    148. Call CopyMemory(MyDevMode, ByVal pFullDevMode, Len(MyDevMode))
    149.  
    150. 'Make desired changes
    151. InitialPaperSize = MyDevMode.dmPaperSize
    152. InitialPaperOrit = MyDevMode.dmOrientation
    153. MyDevMode.dmPaperSize = PaperSize
    154. If Orientation <> 0 Then MyDevMode.dmOrientation = Orientation
    155.  
    156. 'Copy our DevMode structure back into FullDevMode
    157. Call CopyMemory(ByVal pFullDevMode, MyDevMode, Len(MyDevMode))
    158.  
    159. 'Copy our changes to "the PUBLIC portion of the DevMode" into "the PRIVATE portion of the DevMode"
    160. Result = DocumentProperties(MyHwnd, PrinterHandle, PrinterName, ByVal pFullDevMode, ByVal pFullDevMode, DM_IN_BUFFER Or DM_OUT_BUFFER)
    161.  
    162. 'Update the printer's default properties (to verify, go to the Printer folder
    163. ' and check the properties for the printer)
    164. Result = SetPrinter(PrinterHandle, 2, pi2_buffer(0), 0&)
    165.  
    166. Call ClosePrinter(PrinterHandle)
    167. End Sub
    168.  
    169. Public Sub RestorePrinterDefaults()
    170. Dim PrinterHandle As Long
    171. Dim PrinterName As String
    172. Dim pd As PRINTER_DEFAULTS
    173. Dim MyDevMode As DEVMODE
    174. Dim Result As Long
    175. Dim Needed As Long
    176. Dim pFullDevMode As Long
    177. Dim pi2_buffer() As Long
    178.  
    179. PrinterName = Printer.DeviceName
    180. If PrinterName = "" Then
    181. Exit Sub
    182. End If
    183.  
    184. pd.pDatatype = vbNullString
    185. pd.pDevMode = 0&
    186. 'Printer_Access_All is required for NT security
    187. pd.DesiredAccess = PRINTER_ALL_ACCESS
    188.  
    189. Result = OpenPrinter(PrinterName, PrinterHandle, pd)
    190.  
    191. 'The first call to GetPrinter gets the size, in bytes, of the buffer needed.
    192. 'This value is divided by 4 since each element of pi2_buffer is a long.
    193. Result = GetPrinter(PrinterHandle, 2, ByVal 0&, 0, Needed)
    194. ReDim pi2_buffer((Needed \ 4))
    195. Result = GetPrinter(PrinterHandle, 2, pi2_buffer(0), Needed, Needed)
    196.  
    197. 'The seventh element of pi2_buffer is a Pointer to a block of memory
    198. ' which contains the full DevMode (including the PRIVATE portion).
    199. pFullDevMode = pi2_buffer(7)
    200.  
    201. 'Copy the Public portion of FullDevMode into our DevMode structure
    202. Call CopyMemory(MyDevMode, ByVal pFullDevMode, Len(MyDevMode))
    203.  
    204. 'Make desired changes
    205. MyDevMode.dmPaperSize = InitialPaperSize
    206. MyDevMode.dmOrientation = InitialPaperOrit
    207.  
    208. 'Copy our DevMode structure back into FullDevMode
    209. Call CopyMemory(ByVal pFullDevMode, MyDevMode, Len(MyDevMode))
    210.  
    211. 'Copy our changes to "the PUBLIC portion of the DevMode" into "the PRIVATE portion of the DevMode"
    212. Result = DocumentProperties(CallingHwnd, PrinterHandle, PrinterName, ByVal pFullDevMode, ByVal pFullDevMode, DM_IN_BUFFER Or DM_OUT_BUFFER)
    213.  
    214. 'Update the printer's default properties (to verify, go to the Printer folder
    215. ' and check the properties for the printer)
    216. Result = SetPrinter(PrinterHandle, 2, pi2_buffer(0), 0&)
    217.  
    218. Call ClosePrinter(PrinterHandle)
    219. End Sub
    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

  4. #4
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    Re: problems on data reports

    dee-u can the use landscape on design mode?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    25

    Re: problems on data reports

    ty guys

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