博文

目前显示的是 2006的博文

手工通过代码来控制右键菜单的弹出

为什么使用MouseDown事件而不用MouseUp事件呢? 通过实践,我得出MouseUp事件在点击的时候并不总是被触发. procedure TPipeFrame.PipeListViewMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var Pt : TPoint; begin //通过Button参数和Shift参数都可以获取鼠标的左右键信息, //而使用Shift参数应该采用下面的方式 //if (ssRight in Shift) then if Button = mbRight then begin if Assigned(PipeListView.Selected) then begin MenuEditPipe.Enabled := True; MenuDelPipe.Enabled := True; end else begin MenuEditPipe.Enabled := False; MenuDelPipe.Enabled := False; end; //这里应该使用GetCursorPos函数来取得鼠标坐标点,否则会产生坐标点错位的问题. GetCursorPos(Pt); PipeListViewPopupMenu.Popup(Pt.X, Pt.Y); //错位严重 //PipeListViewPopupMenu.Popup(X, Y); //X轴无错位,Y轴有一些错位,估计与隐藏标题栏有关 //PipeListViewPopupMenu.Popup(ClientToScreen(Point(X, Y)).X, ClientToScreen(Point(X, Y)).Y); end; end;

如何控制XML文档的换行和缩进?

NodeIndentStr属性决定子节点的后移位置,缺省值为二个空格,最多可选到八个空格。 我一般使用默认选项,当然我们也可以使用TAB字符。 //xmldoc.NodeIndentStr := #09; xmldoc.Options := [doNodeAutoIndent]; 这个属性只有在选项里设置了doNodeAutoIndent标识为真(True)后才有效,这个标识的缺省状态为非真(False)。

如何加入闪屏画面?

将该段代码放置在dpr文件中,在闪屏窗体上添加定时器,并将初始化的代码全部写在定时器的 函数中,不要将代码写在窗体的Create函数或Show函数中。在函数结尾将定时器置为False。 SplashForm := TSplashForm.Create(Application); SplashForm.Show; SplashForm.Update; 等待闪屏程序结束: while SplashForm.SplashTimer.Enabled do Application.processMessages; Sleep(2000); SplashForm.Hide; Splashform.Free;

错误提示"尚未调用 CoInitialize"的解决方法

这个错误一般会发生在过早调用ADO,XML的时候,需要在你调用的时候加上下面这段代码 : 引用ActiveX单元 Initialization CoInitialize(Nil); Finalization CoUnInitialize;

如何利用脚本文件来控制SQL Agent服务的运行?

如何利用脚本文件来控制SQL Agent服务的运行? 1.在查询分析器理启动或停止SQL Agent服务* {*--启动SQL Agent服务,下面的方法同样可以通过命令行来执行--} use master go xp_cmdshell 'net start SQLSERVERAGENT' {*--停止SQL Agent服务--} use master go xp_cmdshell 'net stop SQLSERVERAGENT' {*--将服务的启动从手工方式改为自动启动方式,关于SCM的用法可以通过命令输入SCM来获取--} exec xp_cmdshell 'scm -action 7 -service SQLSERVERAGENT -svcstarttype 2'

如何避免一个程序的多次运行?

将该段代码放置在dpr文件中,记住要引用Windows单元。 Application.Title := 'Application Name'; //两处'Application Name'要相一致 hMutex:=CreateMutex(nil,false,'Application Name'); if GetLastError = Error_Already_Exists then begin Application.MessageBox('程序已经启动,请检测!','警告',MB_OK); ReleaseMutex(hMutex); Application.FreeOnRelease; end;