Need Help With Translation C#? to VB

S

Scott Gunn

Hello all

I'm trying to use the scrollwindowex api however I have the same problem as
this guy had. There is an answer here in the reply. I just need some help
converting it to VB.Net
Thanks Peter, it works. I have another question for you. What does the
clip rectangle passed on the 5th argument does?

Thanks
Tony


Peter Huang said:
Hi Tony,

I consult the MSDN and find that the RECT structure required by the ?
°ScrollWindowEx¡± API is different from the class ¡°Rectangle¡±. I think
you may declare your ¡°ScrollWindowEx¡± API as follows.
public class win32
{
[DllImport("user32.dll")]
public static extern int ScrollWindowEx(
IntPtr hWnd,
int dx,
int dy,
[MarshalAs(UnmanagedType.Struct)] ref Rectangle prcScroll,
[MarshalAs(UnmanagedType.Struct)] ref Rectangle prcClip,
IntPtr hrgnUpdate,
[MarshalAs(UnmanagedType.Struct)] out Rectangle prcUpdate,
[MarshalAs(UnmanagedType.U4)] int flags);

}
Then you may invoke the API as below.
private void button1_Click(object sender, System.EventArgs e)
{
Rectangle rt = new Rectangle();
Rectangle rtout = new Rectangle(0,0,10,10);
Rectangle rtin = new
Rectangle(20,20,richTextBox1.Width,richTextBox1.He ight);
int rr=win32.ScrollWindowEx(richTextBox1.Handle,0,10,r ef rtin,ref
rt,IntPtr.Zero,out rtout,0);
System.Console.WriteLine(rr.ToString());
}

Hope this will help.

Best regards,
Peter Huang

Regards,

Peter Huang
=============
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Tony" <[email protected]>
Subject: Calling the ScrollWindowEx API
Date: Fri, 4 Jul 2003 08:45:32 +0800
Lines: 21
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.0
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: cm203-168-247-148.hkcable.com.hk 203.168.247.148
Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.languages.csharp:30519
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Hi, I am having problem to scroll only a partion of a window using the
ScrollWindowEx api function. The code is below and any help is pleased.
Thanks in advance.


[DllImport("user32.dll")]
private extern int ScrollWindowEx (IntPtr handle, int dx, int dy, Rectangle
lprcScroll , Rectangle lprcClip, IntPtr hrgnUpdate, out Rectangle
lprcUpdate, int fuScroll);

Rectangle rt;

// This works
ScrollWindowEx(Handle, 0, 30, Rectangle.Empty, Rectangle.Empty, IntPtr.Zero,
out rt, 0);

// This doesn't work
ScrollWindowEx(Handle, 0, 30, new Rectangle(20, 20, ClientSize.Width,
ClientSize.Height), Rectangle.Empty, IntPtr.Zero, out rt, 0);

URL: http://www.pcreview.co.uk/forums/thread-1349023.php

I have the same problem

This works:
ScrollWindowEx(Handle, 0, 30, Rectangle.Empty, Rectangle.Empty, IntPtr.Zero,
Rectangle.Empty, 0)

This doesn't work
ScrollWindowEx(Handle, 0, 30, new Rectangle(20, 20, ClientSize.Width,
ClientSize.Height), Rectangle.Empty, IntPtr.Zero, rectangle.empty, 0)

Many Thanks
Scott
 
G

Guest

Our Instant VB C# to VB.NET converter (www.instantvb.com) produces the
following (assuming I've pasted the C# code correctly):

Public Class win32
<DllImport("user32.dll")> _
Public Shared Function ScrollWindowEx(ByVal hWnd As IntPtr, ByVal dx As
Integer, ByVal dy As Integer, <MarshalAs(UnmanagedType.Struct)> ByRef
prcScroll As Rectangle, <MarshalAs(UnmanagedType.Struct)> ByRef prcClip As
Rectangle, ByVal hrgnUpdate As IntPtr, <System.Runtime.InteropServices.Out()>
(MarshalAs(UnmanagedType.Struct)) ByRef prcUpdate As Rectangle,
<MarshalAs(UnmanagedType.U4)> ByVal flags As Integer) As Integer

End Function
End Class

Private Sub button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim rt As Rectangle = New Rectangle()
Dim rtout As Rectangle = New Rectangle(0,0,10,10)
Dim rtin As Rectangle = New
Rectangle(20,20,richTextBox1.Width,richTextBox1.Height)
Dim rr As
Integer=win32.ScrollWindowEx(richTextBox1.Handle,0,10,rtin,rt,IntPtr.Zero,rtout,0)
System.Console.WriteLine(rr.ToString())
End Sub

David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter

Scott Gunn said:
Hello all

I'm trying to use the scrollwindowex api however I have the same problem as
this guy had. There is an answer here in the reply. I just need some help
converting it to VB.Net
Thanks Peter, it works. I have another question for you. What does the
clip rectangle passed on the 5th argument does?

Thanks
Tony


Peter Huang said:
Hi Tony,

I consult the MSDN and find that the RECT structure required by the ?
°ScrollWindowEx¡± API is different from the class ¡°Rectangle¡±. I think
you may declare your ¡°ScrollWindowEx¡± API as follows.
public class win32
{
[DllImport("user32.dll")]
public static extern int ScrollWindowEx(
IntPtr hWnd,
int dx,
int dy,
[MarshalAs(UnmanagedType.Struct)] ref Rectangle prcScroll,
[MarshalAs(UnmanagedType.Struct)] ref Rectangle prcClip,
IntPtr hrgnUpdate,
[MarshalAs(UnmanagedType.Struct)] out Rectangle prcUpdate,
[MarshalAs(UnmanagedType.U4)] int flags);

}
Then you may invoke the API as below.
private void button1_Click(object sender, System.EventArgs e)
{
Rectangle rt = new Rectangle();
Rectangle rtout = new Rectangle(0,0,10,10);
Rectangle rtin = new
Rectangle(20,20,richTextBox1.Width,richTextBox1.He ight);
int rr=win32.ScrollWindowEx(richTextBox1.Handle,0,10,r ef rtin,ref
rt,IntPtr.Zero,out rtout,0);
System.Console.WriteLine(rr.ToString());
}

Hope this will help.

Best regards,
Peter Huang

Regards,

Peter Huang
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
From: "Tony" <[email protected]>
Subject: Calling the ScrollWindowEx API
Date: Fri, 4 Jul 2003 08:45:32 +0800
Lines: 21
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.0
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: cm203-168-247-148.hkcable.com.hk 203.168.247.148
Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.languages.csharp:30519
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Hi, I am having problem to scroll only a partion of a window using the
ScrollWindowEx api function. The code is below and any help is pleased.
Thanks in advance.


[DllImport("user32.dll")]
private extern int ScrollWindowEx (IntPtr handle, int dx, int dy, Rectangle
lprcScroll , Rectangle lprcClip, IntPtr hrgnUpdate, out Rectangle
lprcUpdate, int fuScroll);

Rectangle rt;

// This works
ScrollWindowEx(Handle, 0, 30, Rectangle.Empty, Rectangle.Empty,
IntPtr.Zero,
out rt, 0);

// This doesn't work
ScrollWindowEx(Handle, 0, 30, new Rectangle(20, 20, ClientSize.Width,
ClientSize.Height), Rectangle.Empty, IntPtr.Zero, out rt, 0);

URL: http://www.pcreview.co.uk/forums/thread-1349023.php

I have the same problem

This works:
ScrollWindowEx(Handle, 0, 30, Rectangle.Empty, Rectangle.Empty, IntPtr.Zero,
Rectangle.Empty, 0)

This doesn't work
ScrollWindowEx(Handle, 0, 30, new Rectangle(20, 20, ClientSize.Width,
ClientSize.Height), Rectangle.Empty, IntPtr.Zero, rectangle.empty, 0)

Many Thanks
Scott
 
S

Scott Gunn

Hello

Excellent, the conversion added some things I didn't however my orignal
problem is still there

I had to change the part:
<System.Runtime.InteropServices.Out()> (MarshalAs(UnmanagedType.Struct))

To (Guessing):
<System.Runtime.InteropServices.Out(), MarshalAs(UnmanagedType.Struct)>

The code as is does nothing though, I also had to change the ByRef to ByVal
and things started to happen.
but still the problem is:

This works:
ScrollWindowEx(Handle, 0, 30, Rectangle.Empty, Rectangle.Empty, IntPtr.Zero,
Rectangle.Empty, 0)

This doesn't work:
ScrollWindowEx(Handle, 0, 30, new Rectangle(20, 20, ClientSize.Width,
ClientSize.Height), Rectangle.Empty, IntPtr.Zero, rectangle.empty, 0)

Thanks for the conversion.
Scott.


David Anton said:
Our Instant VB C# to VB.NET converter (www.instantvb.com) produces the
following (assuming I've pasted the C# code correctly):

Public Class win32
<DllImport("user32.dll")> _
Public Shared Function ScrollWindowEx(ByVal hWnd As IntPtr, ByVal dx As
Integer, ByVal dy As Integer, <MarshalAs(UnmanagedType.Struct)> ByRef
prcScroll As Rectangle, <MarshalAs(UnmanagedType.Struct)> ByRef prcClip As
Rectangle, ByVal hrgnUpdate As IntPtr,
<System.Runtime.InteropServices.Out()>
(MarshalAs(UnmanagedType.Struct)) ByRef prcUpdate As Rectangle,
<MarshalAs(UnmanagedType.U4)> ByVal flags As Integer) As Integer

End Function
End Class

Private Sub button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim rt As Rectangle = New Rectangle()
Dim rtout As Rectangle = New Rectangle(0,0,10,10)
Dim rtin As Rectangle = New
Rectangle(20,20,richTextBox1.Width,richTextBox1.Height)
Dim rr As
Integer=win32.ScrollWindowEx(richTextBox1.Handle,0,10,rtin,rt,IntPtr.Zero,rtout,0)
System.Console.WriteLine(rr.ToString())
End Sub

David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter

Scott Gunn said:
Hello all

I'm trying to use the scrollwindowex api however I have the same problem
as
this guy had. There is an answer here in the reply. I just need some help
converting it to VB.Net
Thanks Peter, it works. I have another question for you. What does the
clip rectangle passed on the 5th argument does?

Thanks
Tony


Hi Tony,

I consult the MSDN and find that the RECT structure required by the ?
°ScrollWindowEx¡± API is different from the class ¡°Rectangle¡±. I
think
you may declare your ¡°ScrollWindowEx¡± API as follows.
public class win32
{
[DllImport("user32.dll")]
public static extern int ScrollWindowEx(
IntPtr hWnd,
int dx,
int dy,
[MarshalAs(UnmanagedType.Struct)] ref Rectangle prcScroll,
[MarshalAs(UnmanagedType.Struct)] ref Rectangle prcClip,
IntPtr hrgnUpdate,
[MarshalAs(UnmanagedType.Struct)] out Rectangle prcUpdate,
[MarshalAs(UnmanagedType.U4)] int flags);

}
Then you may invoke the API as below.
private void button1_Click(object sender, System.EventArgs e)
{
Rectangle rt = new Rectangle();
Rectangle rtout = new Rectangle(0,0,10,10);
Rectangle rtin = new
Rectangle(20,20,richTextBox1.Width,richTextBox1.He ight);
int rr=win32.ScrollWindowEx(richTextBox1.Handle,0,10,r ef rtin,ref
rt,IntPtr.Zero,out rtout,0);
System.Console.WriteLine(rr.ToString());
}

Hope this will help.

Best regards,
Peter Huang

Regards,

Peter Huang
=============
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
From: "Tony" <[email protected]>
Subject: Calling the ScrollWindowEx API
Date: Fri, 4 Jul 2003 08:45:32 +0800
Lines: 21
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.0
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: cm203-168-247-148.hkcable.com.hk 203.168.247.148
Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.languages.csharp:30519
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Hi, I am having problem to scroll only a partion of a window using
the
ScrollWindowEx api function. The code is below and any help is
pleased.
Thanks in advance.


[DllImport("user32.dll")]
private extern int ScrollWindowEx (IntPtr handle, int dx, int dy,
Rectangle
lprcScroll , Rectangle lprcClip, IntPtr hrgnUpdate, out Rectangle
lprcUpdate, int fuScroll);

Rectangle rt;

// This works
ScrollWindowEx(Handle, 0, 30, Rectangle.Empty, Rectangle.Empty,
IntPtr.Zero,
out rt, 0);

// This doesn't work
ScrollWindowEx(Handle, 0, 30, new Rectangle(20, 20, ClientSize.Width,
ClientSize.Height), Rectangle.Empty, IntPtr.Zero, out rt, 0);

URL: http://www.pcreview.co.uk/forums/thread-1349023.php

I have the same problem

This works:
ScrollWindowEx(Handle, 0, 30, Rectangle.Empty, Rectangle.Empty,
IntPtr.Zero,
Rectangle.Empty, 0)

This doesn't work
ScrollWindowEx(Handle, 0, 30, new Rectangle(20, 20, ClientSize.Width,
ClientSize.Height), Rectangle.Empty, IntPtr.Zero, rectangle.empty, 0)

Many Thanks
Scott
 
G

Guest

Thanks for the bug report Scott - the fix will be in today's build.

David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter

Scott Gunn said:
Hello

Excellent, the conversion added some things I didn't however my orignal
problem is still there

I had to change the part:
<System.Runtime.InteropServices.Out()> (MarshalAs(UnmanagedType.Struct))

To (Guessing):
<System.Runtime.InteropServices.Out(), MarshalAs(UnmanagedType.Struct)>

The code as is does nothing though, I also had to change the ByRef to ByVal
and things started to happen.
but still the problem is:

This works:
ScrollWindowEx(Handle, 0, 30, Rectangle.Empty, Rectangle.Empty, IntPtr.Zero,
Rectangle.Empty, 0)

This doesn't work:
ScrollWindowEx(Handle, 0, 30, new Rectangle(20, 20, ClientSize.Width,
ClientSize.Height), Rectangle.Empty, IntPtr.Zero, rectangle.empty, 0)

Thanks for the conversion.
Scott.


David Anton said:
Our Instant VB C# to VB.NET converter (www.instantvb.com) produces the
following (assuming I've pasted the C# code correctly):

Public Class win32
<DllImport("user32.dll")> _
Public Shared Function ScrollWindowEx(ByVal hWnd As IntPtr, ByVal dx As
Integer, ByVal dy As Integer, <MarshalAs(UnmanagedType.Struct)> ByRef
prcScroll As Rectangle, <MarshalAs(UnmanagedType.Struct)> ByRef prcClip As
Rectangle, ByVal hrgnUpdate As IntPtr,
<System.Runtime.InteropServices.Out()>
(MarshalAs(UnmanagedType.Struct)) ByRef prcUpdate As Rectangle,
<MarshalAs(UnmanagedType.U4)> ByVal flags As Integer) As Integer

End Function
End Class

Private Sub button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim rt As Rectangle = New Rectangle()
Dim rtout As Rectangle = New Rectangle(0,0,10,10)
Dim rtin As Rectangle = New
Rectangle(20,20,richTextBox1.Width,richTextBox1.Height)
Dim rr As
Integer=win32.ScrollWindowEx(richTextBox1.Handle,0,10,rtin,rt,IntPtr.Zero,rtout,0)
System.Console.WriteLine(rr.ToString())
End Sub

David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter

Scott Gunn said:
Hello all

I'm trying to use the scrollwindowex api however I have the same problem
as
this guy had. There is an answer here in the reply. I just need some help
converting it to VB.Net

Thanks Peter, it works. I have another question for you. What does the
clip rectangle passed on the 5th argument does?

Thanks
Tony


Hi Tony,

I consult the MSDN and find that the RECT structure required by the ?
°ScrollWindowEx¡± API is different from the class ¡°Rectangle¡±. I
think
you may declare your ¡°ScrollWindowEx¡± API as follows.
public class win32
{
[DllImport("user32.dll")]
public static extern int ScrollWindowEx(
IntPtr hWnd,
int dx,
int dy,
[MarshalAs(UnmanagedType.Struct)] ref Rectangle prcScroll,
[MarshalAs(UnmanagedType.Struct)] ref Rectangle prcClip,
IntPtr hrgnUpdate,
[MarshalAs(UnmanagedType.Struct)] out Rectangle prcUpdate,
[MarshalAs(UnmanagedType.U4)] int flags);

}
Then you may invoke the API as below.
private void button1_Click(object sender, System.EventArgs e)
{
Rectangle rt = new Rectangle();
Rectangle rtout = new Rectangle(0,0,10,10);
Rectangle rtin = new
Rectangle(20,20,richTextBox1.Width,richTextBox1.He ight);
int rr=win32.ScrollWindowEx(richTextBox1.Handle,0,10,r ef rtin,ref
rt,IntPtr.Zero,out rtout,0);
System.Console.WriteLine(rr.ToString());
}

Hope this will help.

Best regards,
Peter Huang

Regards,

Peter Huang
=============
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
From: "Tony" <[email protected]>
Subject: Calling the ScrollWindowEx API
Date: Fri, 4 Jul 2003 08:45:32 +0800
Lines: 21
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.0
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: cm203-168-247-148.hkcable.com.hk 203.168.247.148
Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa09.phx.gbl
microsoft.public.dotnet.languages.csharp:30519
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Hi, I am having problem to scroll only a partion of a window using
the
ScrollWindowEx api function. The code is below and any help is
pleased.
Thanks in advance.


[DllImport("user32.dll")]
private extern int ScrollWindowEx (IntPtr handle, int dx, int dy,
Rectangle
lprcScroll , Rectangle lprcClip, IntPtr hrgnUpdate, out Rectangle
lprcUpdate, int fuScroll);

Rectangle rt;

// This works
ScrollWindowEx(Handle, 0, 30, Rectangle.Empty, Rectangle.Empty,
IntPtr.Zero,
out rt, 0);

// This doesn't work
ScrollWindowEx(Handle, 0, 30, new Rectangle(20, 20, ClientSize.Width,
ClientSize.Height), Rectangle.Empty, IntPtr.Zero, out rt, 0);

URL: http://www.pcreview.co.uk/forums/thread-1349023.php

I have the same problem

This works:
ScrollWindowEx(Handle, 0, 30, Rectangle.Empty, Rectangle.Empty,
IntPtr.Zero,
Rectangle.Empty, 0)

This doesn't work
ScrollWindowEx(Handle, 0, 30, new Rectangle(20, 20, ClientSize.Width,
ClientSize.Height), Rectangle.Empty, IntPtr.Zero, rectangle.empty, 0)

Many Thanks
Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top