473,574 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("user 32.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.ClientRect angle.X - hScrollBar.Valu e,
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 4811
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("user 32.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.ClientRect angle.X - hScrollBar.Valu e,
| 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******** ******@TK2MSFTN GP10.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("user 32.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.ClientRect angle.X - hScrollBar.Valu e,
| 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******** ******@TK2MSFTN GP10.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("user 32.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.ClientRect angle.X - hScrollBar.Valu e,
| > | 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2385
by: Tony Liu | last post by:
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. private extern int ScrollWindowEx (IntPtr handle, int dx, int dy, Rectangle lprcScroll , Rectangle lprcClip, IntPtr hrgnUpdate, out Rectangle lprcUpdate, int fuScroll);
2
12309
by: Champika Nirosh | last post by:
Hi, I want to create drawing board application that can draw Line, rectagle, circle and free hand drawing. Each drawing need to be transparent, moveable (draggable), have bring to front and send to back feature etc. How can I do this .. where should I start?
1
3220
by: Hadar | last post by:
Hi, I'm getting "object is currently in use elsewhere" when I use System.Drawing.Graphics.MesureString. This is what I do: My controls use a utility class the helps it to mesure strings. To get the best performance for the utility class, its members, as well as the System.Drawing.Graphics object, are static:
3
2680
by: Scott Gunn | last post by:
I have looked all over the net for an example on how to use this function but got no joy, lots of jargon explaining the function but no examples. In VB.Net the hwnd has gone there was one in vb6 - I tried using Handle but nothing happens Can anyone shed some light on how to use this function or give an example? Many Thanks TBS
0
1167
by: Scott Gunn | last post by:
Hello I'm trying to scroll a region of graphics, the best way I can see is to use the ScrollWindowEx API because it is designed for doing this However it doesn't work correctly, Why? Here is my code: Public Class Win32
5
3356
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However, when I did this I got the following error: 'System.Drawing.Image.Image()' is inaccessible due to its protection level Looking at other online...
0
2332
by: evan | last post by:
Hi, Is anyone able to give me an example on how to scroll the contents of a ListBox without forcing the user to click on the scroll up/down internal buttons? ============================== I am wanting to draw my own non-client area (including the scrollbar). I have had the following ideas but each idea has failed:
1
3950
by: YouPoP | last post by:
I am doing an app (C# 2.0) where you can draw in a panel with your mouse in "real time". I actually have 2 problems; 1- it does not really is "real time", if your mouse move fast or very fast the line is added after a very small delay. 2-Because I use AddLine(), it adds very short lines from one point to another and it does not give a very good...
2
2315
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no response object but how do I write it to screen? Dim objBitmap As New System.Drawing.Bitmap(400, 440) Dim objGraphics As System.Drawing.Graphics...
0
7814
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7736
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8067
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7826
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8107
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5307
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3748
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2252
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.