首页 \ 问答 \ 需要滚动滚动usercontrol(Need to mousewheel scroll a usercontrol)

需要滚动滚动usercontrol(Need to mousewheel scroll a usercontrol)

我有我创建的用户控件。 我在其右侧添加了一个面板和一个垂直滚动条。 我希望能够用鼠标滚轮来滚动它。 问题是,似乎没有任何事件在鼠标轮上发射。 如果我关闭了面板,那么usercontrol会有焦点,它会在表格中的鼠标滚轮上触发。 但是面板上的面板似乎不会触发面板的鼠标滚轮事件或控件内甚至窗体上的用户控件。 最好的解决方案是在用户控件中有一个事件触发器,但我甚至会接受表单上的事件并将其反馈回usercontrol。

如果有问题,我使用vb.net和vs2005。


I have a usercontrol I created. I added a panel and a vertical scrollbar to the right of it. I'd like to be able to scroll it with the mousewheel. The problem is there doesn't seem to be any events that fire on mousewheel. If I take the panel off then the usercontrol has focus and it will fire on mousewheel in the form. But with the panel on it doesn't seem to fire the mousewheel event of the panel, or the usercontrol within the control or even on the form. The best solution would be to have an event fire in the usercontrol but I'd even accept an event on the form and feed it back into the usercontrol.

I'm using vb.net and vs2005 if it matters.


原文:https://stackoverflow.com/questions/612270
更新时间:2022-06-26 19:06

最满意答案

它看起来像你:

  • 在Windows上
  • 试图异步启动外部程序

这是允许您这样做的秘诀:

function async_exec_win($cmd)
{
    $wshShell = new COM('WScript.Shell');
    $wshShell->Run($cmd, 0, false); // NB: the second argument is meaningless
                                    // It just has to be an int <= 10
}

这需要COM类可用于您的PHP实例,您可能需要在php.ini中启用extension=php_com_dotnet.dll (自PHP 5.3.15 / 5.4.5起)以使其可用。

另请注意,这将需要您要执行的文件的完整文件名 ,因为扩展名搜索列表不会在cmd.exe外部使用。 因此,而不是srcds -console ...你需要srcds.exe -console ... - 我个人不喜欢chdir()方法,我宁愿将exe的完整路径传递给函数 -但是如果这样做,则需要确保目录分隔符的操作系统类型正确。 PHP会让你随心所欲地使用任何你喜欢的东西,操作系统也不会那么宽容。

为了完整起见,这里是如何在* nix上做类似的事情。 这实际上比Windows版本更好,因为它还返回创建的进程的PID:

function async_exec_unix($cmd)
{
    return (int) exec($cmd . ' > /dev/null 2>&1 & echo $!');
}

需要注意的事项:必须正确转义您的命令。 这些实现都没有对正在执行的命令执行任何验证,它们只是盲目地运行它。 切勿将用户输入传递给外部程序,而不必将其转移到主机操作系统!


It looks like you are:

  • on Windows
  • trying to launch an external program asynchronously

Here is the secret sauce that will allow you to do so:

function async_exec_win($cmd)
{
    $wshShell = new COM('WScript.Shell');
    $wshShell->Run($cmd, 0, false); // NB: the second argument is meaningless
                                    // It just has to be an int <= 10
}

This requires the COM class to be available to your PHP instance, you may need to enable extension=php_com_dotnet.dll in php.ini (since PHP 5.3.15/5.4.5) in order to make it available.

Also note that this will require a full file name of the file you wish to execute, as the extension search list will not be used outside cmd.exe. So instead of srcds -console ... you'll want srcds.exe -console ... - personally I don't like the chdir() approach, I'd rather pass the full path of the exe into the function instead - but if you do this, you'll need to make sure the directory separators are of the correct type for the operating system. PHP will let you use whatever you like wherever you like, the OS won't be so forgiving.

For completeness, here's how to do a similar thing on *nix. This is actually better than the Windows version as it also returns the PID of the process that was created:

function async_exec_unix($cmd)
{
    return (int) exec($cmd . ' > /dev/null 2>&1 & echo $!');
}

Something to pay attention to: your command must be properly escaped. Neither of these implementations perform any validation on the command being executed, they just run it blindly. Never pass user input to an external program without escaping it as appropriate to the host operating system!

相关问答

更多
  • 首先:你是否证实/ usr / bin / php是PHP的正确路径? Php不喜欢这样跑。 与stdin有关。 尝试nohup: exec("nohup /usr/bin/php -f /path/to/beta.php > logfile.txt 2> errorfile.txt &"); 使用-f其他任何看起来像标志的东西都会转到PHP,所以如果你想将“-x”选项传递给你的脚本,那么你必须 /usr/bin/php -f /path/to/beta.php -- -x 如果没有,文件名前的选项 ...
  • 你有一套旧的开发工具。 gcc将其版本报告为4.0.1。 这可能是从旧版本的操作系统迁移中遗留下来的。 如果您安装了Xcode 4.3.x,则需要启动它,进入其首选项,选择“下载”选项卡,然后单击“命令行工具”包旁边的“安装”。 You have an old set of developer tools. gcc is reporting its version as 4.0.1. This may be left over from migrating from an older version of ...
  • 此链接提供了此问题的答案 configure:error:C编译器在安装Ruby 1.9.3时无法创建可执行文件 干 sudo apt-get install clang 接着 ./configure --with-apxs=/opt/lampp/bin/apxs --with-php-config=/opt/lampp/bin/php-config --with-pdo-odbc=ibm-db2,/opt/ibm/db2/V9.7/ --with-gcc=clang 完美的工作! The answer ...
  • exec()命令不直接计入PHP,因为该过程是单独执行的,而不是从PHP进程内部执行的。 话虽如此,如果您使用任何输出变量与命令,他们将计入限制。 因此,如果您有一个产生大量详细日志记录的文件,并且您正在捕获该日志记录,那么它将计入内存限制。 The exec() command does not directly count towards the PHP since the process is executed separately not from within the PHP Process. H ...
  • 试试这样: desktop extendedDesktop My executable is a wrapped perl file that runs a CHDK hacked camera. Needed to add the ptpcam.exe as an included file even though that isn't the executable I am targeting
  • 请试试这个 It will work only in Internet Explorer and ActiveX control should be enabled in the browser code: function openapp(){ var obj=new ActiveXObject("WScript.Shell"); obj.Run("file_exe_path",1,true); }
  • 它看起来像你: 在Windows上 试图异步启动外部程序 这是允许您这样做的秘诀: function async_exec_win($cmd) { $wshShell = new COM('WScript.Shell'); $wshShell->Run($cmd, 0, false); // NB: the second argument is meaningless // It just has to be an in ...
  • 我假设exec1和exec2都是MPI应用程序? 理论上它应该可行,但LSF可能会做些奇怪的事情,并且在exec1实际退出之前exec1的mpirun正在退出。 你可以尝试: mpirun $OPT exec1 && mpirun $OPT exec2 因此,在执行exec2之前,mpirun $ OPT exec1必须退出并返回代码0。 但是,像这样从相同脚本运行两个MPI作业可能不是一个好主意,因为例如MPI环境变量设置可能会引入冲突。 你应该真正做的是使用作业链,这样exec2在exec1之后运行 ...
  • 你只需要. 当你在没有提供路径名的情况下运行程序时。 如果程序名称不包含/ ,则shell在$PATH搜索程序。 通过输入./run ,它会告诉它查看当前目录而不是搜索它。 由于您通过预先添加__DIR__来提供程序的完整路径,因此它不会搜索该程序。 没有必要插入. 在这种情况下,在程序名称之前,它导致文件名不正确。 它正在补充. 到__DIR__的最后一个目录,该目录不存在。 You only need the . when you're running a program without providi ...
  • 查询中的输出没有用,你只是运行应用程序而windbg显示它加载的所有模块,它不会产生任何信息到手头的问题你可能需要设置至少一个断点让windbg中断并转储堆栈来分析执行的道路 。重新开始 当windbg中断时,在发出g之前设置一个bp,当断点被击中时,使用kb转储堆栈回溯 bp ntdll!ntTerminateProcess BL G KB 编辑帖子以粘贴新输出 导致终止的功能似乎是00007ff6`800f9e78 您可能需要分析此功能 ub (unassemble backward ) ub 0000 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。