Chinaunix首页 | 论坛 | 博客
  • 博客访问: 486041
  • 博文数量: 105
  • 博客积分: 2922
  • 博客等级: 少校
  • 技术积分: 1113
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-02 16:30
文章分类

全部博文(105)

文章存档

2018年(1)

2016年(2)

2015年(3)

2014年(6)

2013年(21)

2012年(10)

2011年(8)

2010年(7)

2009年(31)

2008年(16)

我的朋友

分类: 数据库开发技术

2013-05-20 23:12:19

1.
string ls_colx
// Get x location of emp_fname column
ls_colx = dw_data.Object.s01_voercode_t.x

// Set the position of the horizontal split scroll point.
dw_data.Object.datawindow.horizontalscrollsplit = ls_colx

2.
// Make sure row/column gets focus.
SetRedraw(FALSE)
this.SetRow (al_row)
this.ScrollToRow (al_row)
this.SetColumn (as_columnname)
this.SetFocus ()
ls_pos = Describe(as_columnname + ".X")
Modify("DataWindow.HorizontalScrollPosition=" + ls_pos)
SetRedraw(TRUE)

3.
You can emulate Excel freeze panes with the datawindow HSplitScroll
property but you need to control the scrolling of each pane to prevent
annoying overlaps.
If you have a window (w_1) with a datawindow (dw_1) containing columns
(c_1, c_2, c_3, etc) do the following:

In the w_1.open event:
// Get the x-coordinate of the start of the third column.
integer li_split_pos
li_hscroll_split = Integer(dw_1.Object.c_3.X)
// Turn on horizontal split scrolling and set the horizontal scroll split
// to the start of the third column.
dw_1.HSplitScroll = TRUE
dw_1.Object.DataWindow.HorizontalScrollSplit = li_hscroll_slit
// Set the starting position of the right pane.
dw_1.Object.DataWindow.HorizontalScrollPosition2 = li_hscroll_slit

// In the dw_1.scrollhorizontal event:
integer li_pos
// Check for split scrolling.
if This.HSplitScroll then
// If the split is all the way left , treat it as if split scrolling
// was not enabled.
li_pos = Integer(This.Object.Datawindow.HorizontalScrollSplit)
if li_pos > 0 then
// Prevent the left pane from scrolling right.
if pane = 1 and scrollpos > Integer(This.Object.Datawindow.HorizontalScrollSplit) then
This.Object.Datawindow.HorizontalScrollPosition = 0

// Prevent the right pane from scrolling to the left of  the split position.
elseif pane = 2 and scrollpos < Integer(This.Object.Datawindow.HorizontalScrollSplit) then
This.Object.Datawindow.HorizontalScrollPosition2 = Integer(This.Object.Datawindow.HorizontalScrollSplit)
end if
end if
end if

4.
ls_max= dw_1.Describe("DataWindow.HorizontalScrollMaximum")
dw_1.modify("datawindow.HorizontalScrollPosition="+ls_max)

5.
//send(handle(dw_1),WM_HSCROLL,SB_RIGHT,0)
send(handle(dw_1),276,7,0)

6.
If you enable the HSplitScroll property of the DataWindow control, you
can then control the initial position of the horizontal "splitter" in
your code, like this:

// Example - Set horizontal split position at 650 PBU's.
dw_1.Object.DataWindow.HorizontalScrollSplit = 650 // Note: Same units
as the DataWindow Object.

Michael's earlier response describes how to keep the horizontal scroll
panes from overlapping (Nicely done, Michael!)

Another alternative exists that does not utilize the horizontal split
scroll feature of the DW, but it also requires a little work on your
part. Use two DataWindow controls and two DataWindow objects and use
ShareData to share the data buffers between the two. In dw_1, display
only the first two columns (your "frozen" columns). In dw_2, display all
of the other columns. Note: In order to shared data buffers, both DW
objects must define the same results set (same # of data columns, same
data type for each column, etc.) For the synchronized vertical scrolling
to work properly, both DW objects must also have same height in all
bands (header, detail, footer, etc.)

Turn on data buffer sharing:

dw_1.SetTransObject( SQLCA)
dw_1.ShareData( dw_2)
dw_1.Retrieve() // For example

In the ScrollVertical event for each DW controls, use code similar to
the following:

In dw_1's ScrollVertical event:

Long ll_OtherVerticalPos

// Prevent endless event loop.
ll_OtherVerticalPos = Long(
dw_2.Object.DataWindow.VerticalScrollPosition)
If currentpos = ll_OtherVerticalPos Then Return 0

// Scroll positions are out of sync. Get them back in sync.
dw_2.Object.DataWindow.VerticalScrollPosition = ll_CurrentPos
Return 0

In dw_2's ScrollVertical event place similar code:

Long ll_OtherVerticalPos

// Prevent endless event loop.
ll_OtherVerticalPos = Long(
dw_1.Object.DataWindow.VerticalScrollPosition)
If currentpos = ll_OtherVerticalPos Then Return 0

// Scroll positions are out of sync. Get them back in sync.
dw_1.Object.DataWindow.VerticalScrollPosition = ll_CurrentPos
Return 0

This will keep the vertical scrolling for both DW's in sync, regardless
of how either DW is scrolled (keyboard or mouse or via the application
code).

A drawback of this technique is the tab sequence from the columns in the
left-side DW to the right-side DW is not the same as it would be using
the horizontal split scroll. However, if the frozen columns are
protected or not modifiable, then the technique described above might
suffice.

阅读(1332) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~