ScrollWindowEx and drawing in C#

  • Thread starter Thread starter Ivonne Riedel
  • Start date Start date
I

Ivonne Riedel

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.
 
Check or post your declararation of Rectangle.

Willy.

| 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.
|
|
 
I used the C# System.Drawing Rectangle.
I did not make any modifications to it.
Do you see this as the mistake?

Thanks

Ivonne.
 
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.


|I used the C# System.Drawing Rectangle.
| I did not make any modifications to it.
| Do you see this as the mistake?
|
| Thanks
|
| Ivonne.
|
Newsbeitrag
| | > Check or post your declararation of Rectangle.
| >
| > Willy.
| >
| > | > | 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.
| > |
| > |
| >
| >
|
|
 

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

Back
Top