我想以编程方式滚动启用AutoScroll的表单。就像人们通常使用# -*- coding: utf-8 -*-
"""Basic Page model."""
from django.db import models
from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel, StreamFieldPanel
from wagtail.core.fields import StreamField
from wagtail.core.models import Page
from your_custom_app.streams import streamfields
class BasicPage(Page):
"""A basic page class."""
template = "templates/pages/basic_page.html"
parent_page_type = ["pages.HomePage", "pages.BasicPage"]
subpage_types = ["pages.BasicPage"]
header = models.CharField(max_length=100)
content = StreamField(
('streamfield_name', streamfields.CustomStreamfield()),
# ... More streams
null=True,
blank=True,
)
# Other additional fields you want on your page.
# Panels are how you lay out your pages in the /admin/
content_panels = [
FieldPanel("title", classname="full title"),
FieldPanel("header"),
# FieldPanel("other_fields"),
StreamFieldPanel("content"),
]
settings_panels = Page.settings_panels + [] # Custom settings panel
promote_panels = Page.promote_panels + [] # Custom promote panel
class Meta:
"""Meta information."""
verbose_name = "Basic Page"
verbose_name_plural = "Basic Pages"
使用javascript一样。
我需要Window.ScrollTo
到窗口客户区域中的特定位置,而不仅仅是按行/页向上或向下或按底部/结束。
edit1:
我已经尝试了所有目前可以找到的技巧, 他们都没有奏效,没有花招去玩:
scroll here
WM_VSCROLL
它在包括面板/窗体的控件上正常工作。
所有控件均响应int sb_param1 = (int)SBCmd.SB_THUMBTRACK + 0x10000 * offset;
IntPtr ptr_sb_param1 = new IntPtr(sb_param1);
SendMessage(panel1.Handle,
(uint)WMScroll.WM_VSCROLL,
// (IntPtr)SBCmd.SB_LINEDOWN,
ptr_sb_param1,
IntPtr.Zero);
命令。SB_XXX
(LOWORD)+ nPos(HIWORD)确实滚动常规控件的内容,例如按预期将文本框中的文本移到预设位置。
但是启用SB_THUMBTRACK
的表单/面板本身都不响应AutoScroll
/ SB_THUMBTRACK
。仅SB_THUMBPOSITION
有效。这对我来说毫无用处。
SB_(LINE*/PAGE*/END/BOTTOM)
Get/SetScrollInfo
SCROLLINFO si = new SCROLLINFO();
si.cbSize = (uint)Marshal.SizeOf(typeof(SCROLLINFO));
si.fMask = (uint)ScrollInfoMask.SIF_ALL;
GetScrollInfo(ptr_hwnd, (int)SBDirection.SB_VERT, ref si);
返回的SetScrollInfo
始终为0,除了其他值都有意义之外。
SCROLLINFO.nTrackPos
SetScrollInfo(ptrhWnd, (int)SBDirection.SB_VERT, ref si, true);
工作正常,
但是只有滚动条移动,窗口/面板工作区是静态的,也许这仅仅是它的全部?
SetScrollInfo
ScrollWindowEx
这似乎没有效果。