473,382 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

GetScrollInfo doesn't work

I create a utility class, and call

GetScrollInfo(txtHelp, (int)ScrollBarDirection.SB_VERT);

txtHelp is a RichTextBox component instance.

Please tell me why GetScrollInfo doesn't work. Thanks.

-------------------------------------

using System;

using System.Runtime.InteropServices;

namespace Alex.Plan

{

[StructLayout(LayoutKind.Sequential)]

public struct SCROLLINFO

{

public int cbSize;

public uint fMask;

public int nMin;

public int nMax;

public uint nPage;

public int nPos;

public int nTrackPos;

}

public enum ScrollBarDirection

{

SB_HORZ = 0,

SB_VERT = 1,

SB_CTL = 2,

SB_BOTH = 3

}

public enum ScrollInfoMask

{

SIF_RANGE = 0x1,

SIF_PAGE = 0x2,

SIF_POS = 0x4,

SIF_DISABLENOSCROLL = 0x8,

SIF_TRACKPOS = 0x16,

SIF_ALL = SIF_RANGE + SIF_PAGE + SIF_POS + SIF_TRACKPOS

}

/// <summary>

/// Summary description for NativeUtil.

/// </summary>

public class NativeUtil

{

[DllImport("user32.dll")]

private static extern bool GetScrollInfo(IntPtr hwnd, int fnBar,
ref SCROLLINFO ScrollInfo);

public static SCROLLINFO
GetScrollInfo(System.Windows.Forms.RichTextBox richtxt, int fnBar)

{

SCROLLINFO info = new SCROLLINFO();

info.cbSize = Marshal.SizeOf(info);

info.fMask = (int) ScrollInfoMask.SIF_ALL;

GetScrollInfo(richtxt.Handle, fnBar, ref info);

return info;

}

}

}

Regards

Alex


Oct 25 '06 #1
4 9460
"Alex Fu" <Lo********@hotmail.comwrote in message
news:uv****************@TK2MSFTNGP03.phx.gbl...
public enum ScrollInfoMask
{
SIF_RANGE = 0x1,
SIF_PAGE = 0x2,
SIF_POS = 0x4,
SIF_DISABLENOSCROLL = 0x8,
SIF_TRACKPOS = 0x16,
SIF_ALL = SIF_RANGE + SIF_PAGE + SIF_POS + SIF_TRACKPOS
}

[System.Flags]
public enum ScrollInfoMask
{
SIF_RANGE = 0x1,
SIF_PAGE = 0x2,
SIF_POS = 0x4,
SIF_DISABLENOSCROLL = 0x8,
SIF_TRACKPOS = 0x10,
SIF_ALL = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS
}
/claes
Oct 25 '06 #2
public enum ScrollInfoMask
>
{

SIF_RANGE = 0x1,

SIF_PAGE = 0x2,

SIF_POS = 0x4,

SIF_DISABLENOSCROLL = 0x8,

SIF_TRACKPOS = 0x16,

SIF_ALL = SIF_RANGE + SIF_PAGE + SIF_POS + SIF_TRACKPOS

}
You have translated your ScrollInfoMask enum incorrectly to C#. The SIF_TRACKPOS
element should be 0x10 -- not 0x16.
Best Regards,
Dustin Campbell
Developer Express Inc.
Oct 25 '06 #3
Thank you, Mr. Bergefall. The method can work well now. I made two mistakes,
one is 0x16 should be 0x10; the other is RichTextBox.ScrollBars had been set
into NONE by legacy code. This method won’t work well unless the scrollbars
became visible.

Best Regards,

Alex Fu
Oct 26 '06 #4
Thank you, Mr. Campbell. The method can work well now. I made two mistakes,
one is 0x16 should be 0x10; the other is RichTextBox.ScrollBars had been set
into NONE by legacy code. This method won't work well unless the scrollbars
became visible. I add some code to show scrollbars before I call the method;
and hide them after the calling.

Best Regards,

Alex Fu
Oct 26 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
39
by: Mark Johnson | last post by:
It doesn't seem possible. But would the following also seem a violation of the general notions behind css? You have a DIV, say asociated with class, 'topdiv'. Inside of that you have an anchor...
149
by: Christopher Benson-Manica | last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.) strchr() is to strrchr() as strstr() is to strrstr(), but strrstr() isn't part of the standard. Why not? --...
2
by: Rlrcstr | last post by:
Can anyone point me to an example of using the GetScrollInfo API call from VB .NET? I've got it coded based on some stuff I've found, but I always get error 126 (The specified module could not be...
1
by: Matthew Hazlett | last post by:
GetScrollInfo works but I can not get setScrollInfo to wrok, it reports Error 6 (Bad Handle). I use the same handle in GetScrollInfo as SetScrollInfo, any ideas? Const SBS_HORZ = 0 Const...
0
by: Alex Fu | last post by:
I create a utility class, and call GetScrollInfo(txtHelp, (int)ScrollBarDirection.SB_VERT); txtHelp is a RichTextBox component instance.
0
by: Mohit | last post by:
Hi all, I am using GetScrollInfo on webbrowser control of .Net Framework 2.0. I am not getting the scrolling bar info. Following is what I am doing: private static extern int...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
0
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, though i understand how to use the Get/SetScrollInfo(...) API, i could not manage to save and restore the scroll state/position of a ListView in .NET . I call GetSscrollInfo(...) which in...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.