
a_jam_sandwich
Avatar/Signature-
Posts
371 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by a_jam_sandwich
-
Just to add the control as it stands is the following Imports System Imports System.Drawing.Printing Imports System.Runtime.InteropServices Imports System.Windows.Forms Public Class printRTF Inherits PrintDocument <StructLayout(LayoutKind.Sequential)> _ Private Structure RECT Public Left As Integer Public Top As Integer Public Right As Integer Public Bottom As Integer End Structure <StructLayout(LayoutKind.Sequential)> _ Private Structure CHARRANGE Public cpMin As Integer Public cpMax As Integer End Structure <StructLayout(LayoutKind.Sequential)> _ Private Structure sFORMATRANGE Public hdc As IntPtr Public hdcTarget As IntPtr Public rc As RECT Public rcPage As RECT Public chrg As CHARRANGE End Structure Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr Private PrintQueuePage As Integer = 0 Private Const WM_USER As Integer = 1024 Private Const EM_FORMATRANGE As Integer = WM_USER + 57 Private Const EM_SETTARGETDEVICE As Integer = WM_USER + 72 Private m_nFirstChar As Integer = 0 Private PrintRichTextBox As RichTextBox Private PrintQueue As ArrayList Public Sub Clear() PrintRichTextBox.Clear() PrintQueue.Clear() m_nFirstChar = 0 End Sub Public Sub New() Me.PrintController = New StandardPrintController() PrintRichTextBox = New RichTextBox() PrintQueue = New ArrayList() PrintRichTextBox.DetectUrls = False End Sub Public Sub LoadRichTextFile(ByVal Filename As String) PrintRichTextBox.LoadFile(Filename) m_nFirstChar = 0 PrintQueue.Add(PrintRichTextBox.Rtf) End Sub Public Sub RichText(ByVal RTB As String) PrintRichTextBox.Rtf = RTB m_nFirstChar = 0 PrintQueue.Add(PrintRichTextBox.Rtf) End Sub Private Function HundredthInchToTwips(ByVal n As Integer) As Integer Return CInt(n * 14.4) End Function Public Function SetTargetDevice(ByVal g As Graphics, ByVal lineLen As Integer) As Boolean Dim res As IntPtr Dim wpar As IntPtr = g.GetHdc() Dim lpar As IntPtr = New IntPtr(HundredthInchToTwips(lineLen)) res = SendMessage(PrintRichTextBox.Handle, EM_SETTARGETDEVICE, wpar, lpar) g.ReleaseHdc(wpar) Return (Not res.ToInt32() = 0) End Function Public Function FormatRange(ByVal e As PrintPageEventArgs, ByVal charFrom As Integer, ByVal charTo As Integer) As Integer Dim cr As CHARRANGE cr.cpMin = charFrom cr.cpMax = charTo Dim rc As RECT rc.Top = HundredthInchToTwips(e.MarginBounds.Top) rc.Bottom = HundredthInchToTwips(e.MarginBounds.Bottom) rc.Left = HundredthInchToTwips(e.MarginBounds.Left) rc.Right = HundredthInchToTwips(e.MarginBounds.Right) Dim rcPage As RECT rcPage.Top = HundredthInchToTwips(e.PageBounds.Top) rcPage.Bottom = HundredthInchToTwips(e.PageBounds.Bottom) rcPage.Left = HundredthInchToTwips(e.PageBounds.Left) rcPage.Right = HundredthInchToTwips(e.PageBounds.Right) Dim hdc As IntPtr = e.Graphics.GetHdc() Dim fr As sFORMATRANGE fr.chrg = cr fr.hdc = hdc fr.hdcTarget = hdc fr.rc = rc fr.rcPage = rcPage Dim res As IntPtr Dim wpar As IntPtr = New IntPtr(1) Dim lpar As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(fr)) Marshal.StructureToPtr(fr, lpar, True) res = SendMessage(PrintRichTextBox.Handle, EM_FORMATRANGE, wpar, lpar) Marshal.FreeCoTaskMem(lpar) e.Graphics.ReleaseHdc(hdc) Return res.ToInt32() End Function Public Function FormatRangeDone() Dim wpar As IntPtr = New IntPtr(0) Dim lpar As IntPtr = New IntPtr(0) SendMessage(PrintRichTextBox.Handle, EM_FORMATRANGE, wpar, lpar) End Function Protected Overrides Sub OnBeginPrint(ByVal e As System.Drawing.Printing.PrintEventArgs) m_nFirstChar = 0 End Sub Protected Overrides Sub OnEndPrint(ByVal e As System.Drawing.Printing.PrintEventArgs) FormatRangeDone() End Sub Protected Overrides Sub OnPrintPage(ByVal e As System.Drawing.Printing.PrintPageEventArgs) If PrintQueue.Count > 0 Then PrintRichTextBox.Rtf = PrintQueue.Item(PrintQueuePage) m_nFirstChar = FormatRange(e, m_nFirstChar, PrintRichTextBox.TextLength) If (m_nFirstChar < PrintRichTextBox.TextLength - 1) Then e.HasMorePages = True ElseIf (PrintQueuePage = (PrintQueue.Count - 1)) Then e.HasMorePages = False PrintQueuePage = 0 m_nFirstChar = 0 Else PrintQueuePage = PrintQueuePage + 1 e.HasMorePages = True m_nFirstChar = 0 End If End If End Sub End Class It works perfectly with XP, 2000 but 98 bring the error as above and printing it vital to the software so any help would be greatly appreciated. Andy
-
I set PrintDocument.PrintController = New System.Drawing.Printing.StandardPrintController() This has not! fixed the problem at all. Anyone have any other ideas? Andy
-
collectbase with a pagelist of Panels
a_jam_sandwich replied to a_jam_sandwich's topic in Windows Forms
Thank you both -
collectbase with a pagelist of Panels
a_jam_sandwich replied to a_jam_sandwich's topic in Windows Forms
So this would also work for indepenant user controls exactly the same as a form? -
collectbase with a pagelist of Panels
a_jam_sandwich replied to a_jam_sandwich's topic in Windows Forms
will that allow me to change panels within the property window? Bear in mind very new to collections etc having a play -
collectbase with a pagelist of Panels
a_jam_sandwich replied to a_jam_sandwich's topic in Windows Forms
ah I see the CollectionBase is the propertys for the Class but the controls are contained within the Usercontro.Controlsl not the CollectionBase Is that right? Cheers -
collectbase with a pagelist of Panels
a_jam_sandwich replied to a_jam_sandwich's topic in Windows Forms
Wow I will now study to under stand Thx very much Andrew -
collectbase with a pagelist of Panels
a_jam_sandwich replied to a_jam_sandwich's topic in Windows Forms
Now im confused any examples? -
collectbase with a pagelist of Panels
a_jam_sandwich replied to a_jam_sandwich's topic in Windows Forms
Just to add I know theres no remove -
collectbase with a pagelist of Panels
a_jam_sandwich replied to a_jam_sandwich's topic in Windows Forms
I dont quite get what you mean the Panels will be container as in normal heres the source Imports System.ComponentModel Imports System.ComponentModel.Design.Serialization Public Class Pagelist Inherits System.Windows.Forms.UserControl Private _pagecollection As New PageCollection() Private _selectedPage As Panel <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _ Public ReadOnly Property Pages() As PageCollection Get Return _pagecollection Invalidate() End Get End Property #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() SetStyle(ControlStyles.AllPaintingInWmPaint, True) SetStyle(ControlStyles.DoubleBuffer, True) _pagecollection = New PageCollection() 'Add any initialization after the InitializeComponent() call End Sub 'UserControl overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() components = New System.ComponentModel.Container() End Sub #End Region End Class Public Class PageCollection Inherits CollectionBase Default Public Property Item(ByVal Index As Integer) As Panel Get Return DirectCast(list.Item(Index), Panel) End Get Set(ByVal Value As Panel) list.Item(Index) = Value End Set End Property Public Function Add(ByVal Item As Panel) As Integer Return List.Add(Item) End Function End Class 'Public Class PageConverter ' Inherits TypeConverter ' Public Overloads Overrides Function CanConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal destinationType As System.Type) As Boolean ' If destinationType Is GetType(InstanceDescriptor) Then ' Return True ' End If ' Return MyBase.CanConvertTo(context, destinationType) ' End Function ' Public Overloads Overrides Function ConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object, ByVal destinationType As System.Type) As Object ' If destinationType Is GetType(InstanceDescriptor) Then ' Dim cat As Panel = DirectCast(value, Panel) ' Dim cl As System.Reflection.ConstructorInfo = GetType(Panel).GetConstructor(System.Type.EmptyTypes) ' Return New InstanceDescriptor(cl, Nothing, False) ' End If ' Return MyBase.ConvertTo(context, culture, value, destinationType) ' End Function 'End Class Cheers Andy -
I have a collectbase with a pagelist of Panels alls great can add remove etc but How do I make the panels visible within the Usercontrol? Andy
-
Dont quite understand what you mean but dll's save to .dll Use dll's created in .NET with .NET Use dll's in VB6 in .NET or VB6 but should really stick with writing new dll's for .NET In reference to file types, .vbproj & .sln are native to .NET and you cannot resave back to VB6 Andy
-
Just added think alike LOL
-
i think PHP is a great language for what it is ive made many complex apps and was very happy with the results in speed and functionality that PHP gives Right ive said it! Andy
-
.vbproj So no conflicts for got to mention the above if for VB.NET projects and .sln are solution files Andy
-
Im trying to create a small program that will add a batch of account to Outlook Express the .reg my program runs and creates if fine no problem. The BIG problem though is the Account is created within a identity in outlook and i first must know what the identity is Anyone know how to get this identity dynamically??? Cheers Andy
-
Thx will look Andy
-
Yes the control is a Notify icon and you can attach a context menu to it with ease Andy
-
In the solution explorer click on the root node the 'Solution <name of solution>' in the propertys window select active configeration and set to release then compile. Andy
-
Im affraid you have to live with it. When in editor and debuging the application will run soo slooowwww.... but once running standalone it is much faster (still nowhere near as fast as VB6) but hey what a second? Andy
-
Im having some right problems at the moment with printing on a Acer laptop with windows 98 The error is as following in short See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at System.Windows.Forms.PrintPreviewControl.CalculatePageInfo() at System.Windows.Forms.Control.InvokeMarshaledCallbacks() I works on all other machines in the Office so I have no idea what it is If anyone can shine some light on it i'd be very greatfull Andy
-
remove it from the connection string Andy
-
DOS as the O\S NO!... Windows command prompt... Yes as above Andy
-
When you create a new project FILE->NEW->PROJECT in the list the is 'Console Application' Andy
-
(C# and ADO.NET) ExecuteNonQuery() problem
a_jam_sandwich replied to gicio's topic in Database / XML / Reporting
If you are getting a return value from the execute the query is being run Check the SQL it return 0 because no records were affected Andy