471,319 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

ScrollWindowEx and drawing in C#

Working on an incremental drawing algorithm I am facing a problem PInvoking
ScrollWindowEx:
The code is as follows...
C#:
[DllImport("user32.dll")]
public static extern int ScrollWindowEx(IntPtr hWnd, int
dx, int dy, IntPtr scrollRect, IntPtr clipRect, IntPtr
hrgn, ref Rectangle updateRect, uint flags);

Rectangle update = new Rectangle();

ScrollWindowEx(
this.Handle,
this.ClientRectangle.X - hScrollBar.Value,
0,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero,
ref update,
0);

C++:

child->ScrollWindowEx(child->fenster_pos.x-pos,0,NULL,NULL,NULL,&update,0);

There is a difference in the values between calling ScrollWindowEx in C++
and through the PInvoke with C#.
The arguments are identical but not the results (update.left, scrolling only
horizontally).
Can anybody identify the problem or my mistake?
Thanks in advance.

Ivonne.
Jan 28 '06 #1
3 4569
Check or post your declararation of Rectangle.

Willy.

"Ivonne Riedel" <iv***********@t-online.de> wrote in message
news:dr*************@news.t-online.com...
| Working on an incremental drawing algorithm I am facing a problem
PInvoking
| ScrollWindowEx:
| The code is as follows...
|
|
| C#:
| [DllImport("user32.dll")]
| public static extern int ScrollWindowEx(IntPtr hWnd, int
| dx, int dy, IntPtr scrollRect, IntPtr clipRect, IntPtr
| hrgn, ref Rectangle updateRect, uint flags);
|
| Rectangle update = new Rectangle();
|
| ScrollWindowEx(
| this.Handle,
| this.ClientRectangle.X - hScrollBar.Value,
| 0,
| IntPtr.Zero,
| IntPtr.Zero,
| IntPtr.Zero,
| ref update,
| 0);
|
| C++:
|
|
child->ScrollWindowEx(child->fenster_pos.x-pos,0,NULL,NULL,NULL,&update,0);
|
| There is a difference in the values between calling ScrollWindowEx in C++
| and through the PInvoke with C#.
| The arguments are identical but not the results (update.left, scrolling
only
| horizontally).
| Can anybody identify the problem or my mistake?
| Thanks in advance.
|
| Ivonne.
|
|
Jan 28 '06 #2
I used the C# System.Drawing Rectangle.
I did not make any modifications to it.
Do you see this as the mistake?

Thanks

Ivonne.

"Willy Denoyette [MVP]" <wi*************@telenet.be> schrieb im Newsbeitrag
news:eK**************@TK2MSFTNGP10.phx.gbl...
Check or post your declararation of Rectangle.

Willy.

"Ivonne Riedel" <iv***********@t-online.de> wrote in message
news:dr*************@news.t-online.com...
| Working on an incremental drawing algorithm I am facing a problem
PInvoking
| ScrollWindowEx:
| The code is as follows...
|
|
| C#:
| [DllImport("user32.dll")]
| public static extern int ScrollWindowEx(IntPtr hWnd, int
| dx, int dy, IntPtr scrollRect, IntPtr clipRect, IntPtr
| hrgn, ref Rectangle updateRect, uint flags);
|
| Rectangle update = new Rectangle();
|
| ScrollWindowEx(
| this.Handle,
| this.ClientRectangle.X - hScrollBar.Value,
| 0,
| IntPtr.Zero,
| IntPtr.Zero,
| IntPtr.Zero,
| ref update,
| 0);
|
| C++:
|
|
child->ScrollWindowEx(child->fenster_pos.x-pos,0,NULL,NULL,NULL,&update,0);
|
| There is a difference in the values between calling ScrollWindowEx in
C++
| and through the PInvoke with C#.
| The arguments are identical but not the results (update.left, scrolling
only
| horizontally).
| Can anybody identify the problem or my mistake?
| Thanks in advance.
|
| Ivonne.
|
|

Jan 28 '06 #3
Yes I do, Rectangle in System.Drawing != Rectangle in User32.
So you need to declare a structure like this:

struct Rect{
public int left;
public int top;
public int right;
public int bottom;
}

Willy.
"Ivonne Riedel" <iv***********@t-online.de> wrote in message
news:dr*************@news.t-online.com...
|I used the C# System.Drawing Rectangle.
| I did not make any modifications to it.
| Do you see this as the mistake?
|
| Thanks
|
| Ivonne.
|
| "Willy Denoyette [MVP]" <wi*************@telenet.be> schrieb im
Newsbeitrag
| news:eK**************@TK2MSFTNGP10.phx.gbl...
| > Check or post your declararation of Rectangle.
| >
| > Willy.
| >
| > "Ivonne Riedel" <iv***********@t-online.de> wrote in message
| > news:dr*************@news.t-online.com...
| > | Working on an incremental drawing algorithm I am facing a problem
| > PInvoking
| > | ScrollWindowEx:
| > | The code is as follows...
| > |
| > |
| > | C#:
| > | [DllImport("user32.dll")]
| > | public static extern int ScrollWindowEx(IntPtr hWnd, int
| > | dx, int dy, IntPtr scrollRect, IntPtr clipRect, IntPtr
| > | hrgn, ref Rectangle updateRect, uint flags);
| > |
| > | Rectangle update = new Rectangle();
| > |
| > | ScrollWindowEx(
| > | this.Handle,
| > | this.ClientRectangle.X - hScrollBar.Value,
| > | 0,
| > | IntPtr.Zero,
| > | IntPtr.Zero,
| > | IntPtr.Zero,
| > | ref update,
| > | 0);
| > |
| > | C++:
| > |
| > |
| >
child->ScrollWindowEx(child->fenster_pos.x-pos,0,NULL,NULL,NULL,&update,0);
| > |
| > | There is a difference in the values between calling ScrollWindowEx in
| > C++
| > | and through the PInvoke with C#.
| > | The arguments are identical but not the results (update.left,
scrolling
| > only
| > | horizontally).
| > | Can anybody identify the problem or my mistake?
| > | Thanks in advance.
| > |
| > | Ivonne.
| > |
| > |
| >
| >
|
|
Jan 28 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Tony Liu | last post: by
2 posts views Thread by Champika Nirosh | last post: by
reply views Thread by Scott Gunn | last post: by
2 posts views Thread by ThatsIT.net.au | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.