|
Alright so here is what I got so far:
Dim WithEvents scrollhandler As MyListener
Private scrolled As Boolean = False
Private maxscroll As Int64
Private Const SB_HORZ As Integer = &H0
Private Const SB_VERT As Integer = &H1
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Public Shared Function GetScrollPos(ByVal hWnd As IntPtr, ByVal nBar As Integer) As Integer
End Function
<DllImport("user32.dll")> _
Private Shared Function SetScrollPos(ByVal hWnd As IntPtr, ByVal nBar As Integer, ByVal nPos As Integer, ByVal bRedraw As Boolean) As Integer
End Function
Public Property HScrollPos() As Integer
Get
Return GetScrollPos(DirectCast(FlowLayoutPanel1.Handle, IntPtr), SB_HORZ)
End Get
Set(ByVal value As Integer)
SetScrollPos(DirectCast(FlowLayoutPanel1.Handle, IntPtr), SB_HORZ, value, True)
End Set
End Property
Public Property VScrollPos() As Integer
Get
Return GetScrollPos(DirectCast(FlowLayoutPanel1.Handle, IntPtr), SB_VERT)
End Get
Set(ByVal value As Integer)
SetScrollPos(DirectCast(FlowLayoutPanel1.Handle, IntPtr), SB_VERT, value, True)
End Set
End Property
Private Sub FlowLayoutPanel1_MouseWheelScroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FlowLayoutPanel1.MouseWheel
scrollhandler_MyScroll(e, e)
End Sub
Private Sub scrollhandler_MyScroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles scrollhandler.MyScroll
If VScrollPos = maxscroll And scrolled Then
MessageBox.Show("you reached the max on the verticle scrollbar!", "yay")
scrolled = False
ElseIf VScrollPos < maxscroll Then
scrolled = True
End If
End Sub
Private Function CalcMaxScroll(ByVal controlhight As Int32, ByVal controlwith As Int32, ByVal itemhight As Int32, ByVal itemwith As Int32, ByVal totalitems As Int32)
Return totalitems - (Math.Floor(controlwith / itemwith) * Math.Floor(controlhight / itemhight))
End Function
Private Class MyListener
Inherits NativeWindow
Public Event MyScroll(ByVal sender As Object, ByVal e As EventArgs)
Const WM_MOUSEACTIVATE = &H21
Const WM_MOUSEMOVE = &H200
Private control As Control
Public Sub New(ByVal control As Control)
AssignHandle(control.Handle)
End Sub
Protected Overrides Sub WndProc(ByRef Messageevent As Message)
Const WM_HSCROLL = &H114
Const WM_VSCROLL = &H115
If Messageevent.Msg = WM_HSCROLL Or Messageevent.Msg = WM_VSCROLL Then
RaiseEvent MyScroll(control, New EventArgs)
End If
MyBase.WndProc(Messageevent)
End Sub
Protected Overrides Sub Finalize()
ReleaseHandle()
MyBase.Finalize()
End Sub
End Class
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
scrollhandler = New MyListener(FlowLayoutPanel1)
maxscroll = CalcMaxScroll(FlowLayoutPanel1.Size.Height, FlowLayoutPanel1.Size.Width, 114, 1075, 19)
End Sub
Source code also attached:
http://www.mediafire.com/?m63ox9sllr887dd[^]
I am pretty sure I am doing everything right... but its just not working with flowlayoutpanel :/
|
|
|
|
|
It seems your making a mistake in providing the arguemnts for your max scroll.
Quote: Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
scrollhandler = New MyListener(FlowLayoutPanel1)
maxscroll = CalcMaxScroll(FlowLayoutPanel1.Size.Height, FlowLayoutPanel1.Size.Width, 114, 1075, 19)
'19 number of tweets
'114 height of tweettimelinecontrol
'1075 width of flowlayoutpanel1
'last number tells the number of items. (read that from a global var)
End Sub
You say that the with of your flowlayoutpanel is 1075. yet you apply it to the formula as the with of your tweettimelinecontrol. quoting you from a previous post:
Quote:
Oh that kinda worked... but how am I ganna calculate the value in a control like this one:
When its normal screen size:
http://foto.pk/images/minx.png[^]
you can see in the screenshot that you got 2 of those controls next to eachoter so it can never be the total size of your flowlayoutpanel. please check the with property of your Tweettimelinecontrol and change the value. while your at it also change the 19 with a flowlayoutpanel.items.count to make sure it are 19.
|
|
|
|
|
private int previousValue;
public void someEventHandler(...) {
int currentValue=...;
if (currentValue==extremeValue && currentValue!=previousValue) doWhatEver();
previousValue=currentValue;
}
|
|
|
|
|
oeh quite nice! might actually try that in the future. but isn't that C#?
|
|
|
|
|
I'd call it pseudo-code around here
|
|
|
|
|
1-0 for you
|
|
|
|
|
isn't previousValue a readonly value?
|
|
|
|
|
did I declare it read-only?
|
|
|
|
|
Seems like I misunderstood the algorithm.
|
|
|
|
|
Hi everyone,
I am currently working on developing some code for transfer file from one pc to another. As I read in lot of article, those work can be done by FTP concept.
I'm using win7 and VB.NET 2010
I've got some simple source code for uploading a file, but I'm experiencing a problem which describe below
System.ArgumentNullException was unhandled
Message=Value cannot be null.
Parameter name: type
ParamName=type
Source=mscorlib
it's refers to:
ITCObject = Activator.CreateInstance(ITC)
Here are the source code:
Imports System.IO
Imports System.Reflection
Imports System.Threading
Public Class Main
Private Sub btnBrowse_Click(ByVal sender As System.Object, e As System.EventArgs) Handles btnBrowse.Click
OpenFileDialog.ShowDialog()
tbFile.Text = OpenFileDialog.FileName
End Sub
Private Sub btnUpload_Click(ByVal sender As System.Object, e As System.EventArgs) Handles btnUpload.Click
Dim thisFile As FileInfo = New FileInfo(tbFile.Text)
Dim ITC As Type
Dim parameter() As Object = New Object(1) {}
Dim ITCObject As Object
ITC = Type.GetTypeFromProgID("InetCtls.Inet")
ITCObject = Activator.CreateInstance(ITC)
parameter(0) = CType(tbRemoteServer.Text, String)
parameter(1) = CType("PUT " + thisFile.FullName + " /" + thisFile.Name, String)
ITC.InvokeMember("execute", BindingFlags.InvokeMethod, Nothing, ITCObject, parameter)
End Sub
End Class
is there anyone could help me to resolve this problem.
Thx,
Phann
|
|
|
|
|
That means:
ITC = Type.GetTypeFromProgID("InetCtls.Inet")
returned null.
But tell us: why do you need Refelection for FTP?
|
|
|
|
|
what do you mean by Bernhard Hiller wrote: Refelection for FTP?
|
|
|
|
|
I'm really not quite sure.. but it came with the source code.. and it has related with "BindingFlags.InvokeMethod".
I'm still having difficulty to figure out the source code and how it works..
|
|
|
|
|
Compare your code with the sample here[^].
Bastard Programmer from Hell
|
|
|
|
|
|
[b]Hello everyone.[/b]
I am trying to create a basic project in vb.net. In this project i have a richtextbox with name editingarea and a button with name button1.
I just want that when the button1 is clicked a font selection dialog box will open where the user can select the font name and size. then set this font for rich text box.
But I am getting some kind of error as "Property name is read only", "Property size is read only", after setting the readonly property to false too.
Here is the code
If SelectFont.ShowDialog = Windows.Forms.DialogResult.OK Then
EditingArea.Font.Name = SelectFont.Font.Name
EditingArea.Font.Size = SelectFont.Font.Size
End If
Can someone help me out.
[b]Thanks[/b]
|
|
|
|
|
Some Properties of a Font cannot be changed after construction. But you can set the "whole" font:
EditingArea.Font = SelectFont.Font
|
|
|
|
|
I want to change all properties of fonts such as name, size, fore-color, back-color, bold, italic as the user wishes.
Can U tell me that how should I go. O can you provide me some code snippet for the same.
Thanks
|
|
|
|
|
Once a Font object is created you cannot change any part of it.
So, the only way to get around this is to create a new Font object and set the Font property of the RichTextBox.
Dim newFont As New Font(fontName, fontSize, fontStyle)
myRichTextBox.Font = newFont
|
|
|
|
|
Student10230 wrote: I want to change all properties of fonts
You're thinking like a user in terms of what you want. You can't set the individual properties of a font, you'll have to create a new object with the properties that you need;
richTextBox1.SelectionFont = new Font(richTextBox1.Font,
richTextBox1.SelectionFont.Style ^ FontStyle.Bold);
It might be working exactly as the user expects as you're not changing a property, but creating a new object with the correct properties. Same goes for the other properties; if they're readonly, you'll probably have to replace the entire object.
Bastard Programmer from Hell
|
|
|
|
|
Tsk Tsk! Posting C# in the VB.NET forum. Talking about dangling a carrot and pulling it away when they bite for it!
|
|
|
|
|
|
Just put "replace brackets and semi-colons by verbose keywords when appropriate" in your sig, and all will be fine.
|
|
|
|
|
Fix'd
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|