在compact framwork中add horizontal scroll to listbox遇到的一个Issue...

A0_嘟嘟飞_0A 2007-11-22 06:23:34

我在XdaII(多普达696英文版)中作应用程序开发,其中涉及到为listbox添加水平滚动条。核心代码如下:



const int GWL_STYLE = (-16);

const int LB_SETHORIZONTALEXTENT = 0x0194;

const long WS_HSCROLL = 0x00100000L;

const int SWP_FRAMECHANGED = 0x0020;

const int SWP_NOMOVE = 0x0002;

const int SWP_NOSIZE = 0x0001;

const int SWP_NOZORDER = 0x0004;

const int WM_VSCROLL = 0x0115;

const int SB_BOTTOM = 7;



[DllImport("coredll.dll")]

static extern IntPtr GetCapture();

[DllImport("coredll.dll")]

static extern uint SendMessage(IntPtr hwnd, int msg, int wParam, int lParam);

[DllImport("coredll.dll")]

static extern uint GetWindowLong(IntPtr hwnd, int index);

[DllImport("coredll.dll")]

static extern uint SetWindowLong(IntPtr hwnd, int index,uint dwNewLong);

[DllImport("coredll.dll")]

static extern uint SetWindowPos(IntPtr hwnd, IntPtr hWndInsertAfter,int x,int y,int cx,int cy,uint uFlags);

private void ModifyStyle(uint addStyle, uint removeStyle)

{ // Get current window style

uint windowStyle = GetWindowLong(GetCapture(), GWL_STYLE);

if (addStyle != 0)

{ // Modify style

SetWindowLong(GetCapture(), GWL_STYLE, windowStyle | addStyle);

}

else

{

// Remove style

SetWindowLong(GetCapture(), GWL_STYLE, windowStyle & ~removeStyle);

}

// Let the window know

SetWindowPos(GetCapture(), IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE | SWP_FRAMECHANGED);



}

private void FrmDispatchJob_Load(object sender, System.EventArgs e)

{

this.listBox_Job.Capture=true;

IntPtr handle=GetCapture();

SendMessage(handle, LB_SETHORIZONTALEXTENT, 250,0);

SendMessage(handle, WM_VSCROLL, SB_BOTTOM,0);

ModifyStyle((uint)WS_HSCROLL, 0);

this.listBox_Job.Capture=false;

}

但是莫名的遇见下列行为异常:

Ok, on this screen, it is normal. Without touching anything.




On this screen, I tapped the white part of the scroll bar in GREEN. The text will shift to the right, but the indicator (IN RED) does not move to the right. It stays on the left side.





并且我在.net framework 中也做了相应的测试,行为还是如上异常。

我搜罗,对比了一下,并且发现在vb6.0中用如下所述http://www.freevbcode.com/ShowCode.asp?ID=5362&NoBox=True

实现add horizontal scroll to listbox 结果一切正常。二者之间没有本质的区别呀?为什么我用c#实现出来的add horizontal scroll to listbox 行为会有问题呢?很是不解,所以拿来跟大家一起探讨,还请各位不吝赐教!
...全文
76 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
A0_嘟嘟飞_0A 2007-12-18
  • 打赏
  • 举报
回复
挂了这么久?怎么连个回复的都没有?只好结贴了!
notepad--v3.4 windows Notepad--v3.4.0-plugin-Installer.exe 是win10下面的插件版安装包,会关联右键菜单等。 Notepad--v3.4.0-win10-portable.zip 是绿色免安装版本,解压即用,不会关联右键菜单注册表。 Ndd-quick-v3.3.0-win10-single-portable.zip 是单文件绿色免安装版,只包含皮肤和vc依赖库,不含插件、不含文件对比,主推轻量级、快速反应。适合只需要纯粹、轻快级,文本编辑器的用户。不定期发布。 MacOS 版本 Notepad--v3.4.0-mac_x64_12.3.dmg 是macos 12.x 及以后的版本。 Notepad--v3.4.0-mac_arm64_12.3.dmg 是macos 12.x 及以后 arm64 m1/m2芯片 的版本。第一次安装时,需要在设置偏好里面,放开苹果的安装限制,才能正常识别,请自行放开设置一下。 如果还是有问题,参考帖子:#I8JTJN:macOS Sonoma 14.1.1安装提示已损坏:macOS Sonoma 14.1.1安装提示已损坏 uos com.hmja.notepad_3.4.0.0_amd64.deb 是x64 cpu架构的uos系统对应的ndd版本。 其余系统版本后续会发布。 3.4 修改如下: 1 支持文件标签拖入拖出到新窗口的效果。 2 windows下修改快捷键放开。 3 按行号切分大文件。 4 大文件打开时,在文件夹查找所在目录,macos下可能会崩溃问题。 5 目录右键增加删除文件、文件夹功能。 6 补充深色主题下rust语法高亮; lisp 语法失效问题。 7 linux下信号打开文件,不拿锁,打开文件在消息队列去做。

111,092

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧