如果按下鼠标按钮并显示一个窗口,则释放鼠标按钮时窗口将接收MouseUp事件.
一旦显示窗口,是否可以检测是否已按下鼠标按钮?
我在Visual Studio 2005中有以下代码.
Dim OutFile As System.IO.StreamWriter
Try
OutFile = New System.IO.StreamWriter(Filename)
// Do stuff with OutFile
Catch Ex As Exception
// Handle Exception
Finally
If OutFile IsNot Nothing Then OutFile.Close()
End Try
Run Code Online (Sandbox Code Playgroud)
但VS2005提出警告"If OutFile IsNot .."这一行
变量'OutFile'在被赋值之前使用.在运行时可能会导致空引用异常.
有没有办法通过巧妙地改变代码来消除这个警告,或者只是有更好的方法来做我正在尝试做的事情?
谢谢
抢
我正在编写一些针对两个非常相似的硬件版本的软件,直到我使用API来初始化硬件,我才知道我会找回哪种类型.
因为硬件非常相似,我计划有一个父类(TParent),它有一些抽象方法(对于硬件不同的地方),然后是两个子类(TChildA,TChildB),它们以硬件相关的方式实现这些方法.
所以我首先实例化一个TParent的对象检查它是什么样的,然后把它投射到正确的孩子.
但是,当我这样做并调用在子类中完全实现的抽象方法之一时,我得到一个EAbstractError.
例如:
myHardware:=TParent.Create();
if myHardware.TypeA then
myHardware:=TChildA(myHardware)
else
myHardware:=TChildB(myHardware);
myHardware.SomeMehtod();
Run Code Online (Sandbox Code Playgroud)
我假设我不能将父类强制转换为子类,并且还有一种更好的方法可以做到这一点.有什么指针吗?
就像标题所说,我想知道C-define-function-call中的" (int(*)()) "是什么意思?
例如,它看起来类似于:
#define Bla(x) (Char *) read((char *(*)()) Blub, (char **) x)
Run Code Online (Sandbox Code Playgroud)
或这个
#define XXX(nx, id) PEM_ASN1_write_bio((int (*)()) id, (char *) nx)
Run Code Online (Sandbox Code Playgroud)
先感谢您!
我的脚本由随机生成参数的程序调用,例如
input=12 output=14 destinationroute=10.0.0.0
Run Code Online (Sandbox Code Playgroud)
然后使用生成的参数调用我的脚本:
./getroute.sh input=12 output=14 destinationroute=10.0.0.0
Run Code Online (Sandbox Code Playgroud)
脚本里面是这样的:
#!/bin/bash
input=$1
output=$2
destinationroute=$3
...
Run Code Online (Sandbox Code Playgroud)
该程序总是以随机顺序调用参数(例如,输入=12 输出=14 或输出=14 输入=12),并且我无法更改程序。
有什么方法可以识别正确的参数并将它们放在适当的位置。