AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 01.07.2009, 13:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,617 / 848 (80) +++++++
Регистрация: 28.10.2006
axaptapedia: FormTreeControl AutoScrolling when draging over top and bottom
Источник: http://www.axaptapedia.com/FormTreeC...top_and_bottom
==============

Summary:

Been working with trees, looking for common behaviors but not implemented in standard AX FormTreeControl...I encountered the same situation, so I decided to add this behavior to the tree in my form:

What's this doing ?

When using a FormTreeControl that contains scrollbars (vertical scrollbars in this example), you might need to drag'n drop a tree node to another tree node that is currently hidden, and you'll need to scroll while drag'n dropping.

Basically, when the mouse comes close to the top or the bottom of the tree, you want to have your tree automatically scrolling to have the same behavior that you would find in Windows Explorer...

You need 2 different algorithms to do this:
#Scroll Up or Down algorithm,
#Timer Algorithm to enable moving even when the mouse is not moving (ie dragOver not called but still expecting the tree do scroll),

You can find attached to this page a simple XPO for this example.

First algorithm looks like the following
void doAutoScroll(int upDown)
{
#WinApi
;
element.scrollWindow(tree.hWnd(), 0, (-#IconHeight) * upDown);
winAPI::sendMessage(tree.hWnd(), #WM_VSCROLL, upDown == -1 ? 0 : 1, '');
winApi::invalidateRect(tree.hWnd());
}


You'll need the scrollWindow method. For this example, I put it into the form, but I believe that it's best place would be in the WinApi Class:
int scrollWindow( int hwnd,
int XAmount,
int YAmount)
{
DLL _winApiDLL = new DLL('USER32');
DLLFunction _scrollWindow = new DLLFunction(_winApiDLL, 'ScrollWindow');

_scrollWindow.returns(ExtTypes::DWord);
_scrollWindow.arg(ExtTypes::DWord,
ExtTypes::DWord,
ExtTypes::DWord,
ExtTypes::DWord,
ExtTypes::DWord);

return _scrollWindow.call(hwnd, XAmount, YAmount, 0,0);
}
Note that if you put this method in the WinApi class, you probably would specify that this method is static

Finally, you need to setup timeouts so that these methods are called accurately, matching the common behavior of GUI trees (see Download)
To set the timers, use a method like this:
void AutoScroll(int x, int y)
{
#define.SBPosMin(1)
#define.SBPosMax(2)
#define.SBPosPageSize(3)
#define.SBPosPosition(4)
int scrollPos;
#WinApi
int height = tree.heightValue();
container scrollInfo;
;
this.endTimerScroll();
scrollPos = WinApi::getScrollPos(tree.hWnd(), #SB_VERT);
if (y < 2 * #IconHeight && scrollPos > 0)//bottom of first displayed line in tree
timerScroll = this.setTimeOut(#TimerScrollUp, #TimerScrollTime, false);
else if (y > height - (2 * #IconHeight))//top of last displayed line in tree
{
scrollInfo = winApi::getScrollInfo(tree.hWnd(), #SB_VERT);
if (conPeek(scrollInfo, #SBPosMax) > conPeek(scrollInfo, #SBPosPageSize) + conPeek(scrollInfo, #SBPosPosition))//only if not at the bottom already
timerScroll = this.setTimeOut(#TimerScrollDown, #TimerScrollTime, false);
}
}
void TimerScrollUp()
{
;
this.doAutoScroll(-1);
timerScroll = this.setTimeOut(#TimerScrollUp, #TimerScrollTime, false);
}
void TimerScrollDown()
{
;
this.doAutoScroll(1);
timerScroll = this.setTimeOut(#TimerScrollDown, #TimerScrollTime, false);
}


== Constants ==

#define.TimerScrollUp("TimerScrollUp")
#define.TimerScrollDown("TimerScrollDown")
#define.TimerScrollTime(150)
#define.IconHeight(16)

== Download ==

'''DEV_FormTreeControl_AutoScroll version 1.0 - [http://www.axaptapedia.com/images/a/...nDragOver.xpo]'''
This version is compatible with Dynamics AX 2009, but it suppose it should work with previous versions as well
[[Category:Form development]]


Источник: http://www.axaptapedia.com/FormTreeC...top_and_bottom
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
AX 2009 Technical Journal: Staying on top of things - AX 2009 hot fixes Blog bot DAX Blogs 0 30.04.2009 20:05
Tab control+bottom in XP IPv6 DAX: Программирование 2 11.10.2006 10:14

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 02:29.