怪事!!怪事!!关于API和SQL自定义函数的问题(300分)

  • 主题发起人 主题发起人 WoDing
  • 开始时间 开始时间
W

WoDing

Unregistered / Unconfirmed
GUEST, unregistred user!
SQL自定义函数大致过程:<br> &nbsp; declare @WideStr Nchar(20) ,@SubStr NChar(1)<br> &nbsp; declare @ReturnStr Char(20)<br> &nbsp; declare @i int,@j int<br> &nbsp; Select &nbsp;@WideStr=Cast( '中华人民共和国' as NChar )<br> &nbsp; Select @j=Len(@WideStr)<br> &nbsp; SElect @i=1<br> &nbsp; SElect @ReturnStr=''<br> &nbsp; While @i&lt; @j<br> &nbsp; &nbsp; begin <br> &nbsp; &nbsp; &nbsp; Select @SubStr=Substring(@WideStr,@i,1) <br> &nbsp; &nbsp; &nbsp; Select @ReturnStr=@ReturnStr+@SubStr //函数原来是select @ReturnStr=@ReturnStr+IsNull( FieldName,'') from TableName where Field=@SubStr <br> &nbsp; &nbsp; &nbsp; Select @i=@i+1<br> &nbsp; &nbsp; end<br>select @ReturnStr<br>为什么@ReturnStr的值是空字符串?<br><br>2 一段代码 在button的click中执行正常,在timer的Timer1Timer中执行结果是错误的<br>并且在Timer1Timer中直接调用button1.Click也是错误的<br><br> function EnumChildWindowsProc(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br> &nbsp;var<br> &nbsp; &nbsp;buffer: array[0..255] of Char;<br> &nbsp; &nbsp;R: TRect;<br> &nbsp; &nbsp;s:string;<br> &nbsp;begin<br> &nbsp; &nbsp;Result := True;<br> &nbsp; &nbsp;GetWindowRect(hwnd, R);<br> &nbsp; &nbsp;SendMessage(hwnd, WM_GETTEXT, 1024, Integer(@buffer)); //Text<br> &nbsp; &nbsp;//GetClassName(hwnd,buffer,256);<br> &nbsp; &nbsp;s:= format('绝对:(%-5d,%-5d),相对:(%-5d,%-5d),标签:%-30s',<br> &nbsp; &nbsp; &nbsp;[R.Left,R.Top,R.Left-FWinRect.Left,R.Top-FWinRect.Top,StrPas(buffer)]);<br> &nbsp; &nbsp;form1.Memo1.Lines.Add( s);<br> &nbsp; &nbsp;<br> &nbsp;end;<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> &nbsp;Handle: Integer;<br>begin<br> &nbsp;Handle := FindWindow(nil,PChar(FWinTitle));<br> &nbsp;if not IsWindowVisible(Handle) then<br> &nbsp; &nbsp;exit;<br> &nbsp;memo1.Lines.Clear;<br> &nbsp;if Handle&lt;&gt;0 then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;GetWindowRect(Handle, FWinRect);//<br> &nbsp; &nbsp; &nbsp;EnumChildWindows(Handle,@EnumChildWindowsProc,Integer(@Handle));<br> &nbsp; &nbsp;end;<br> &nbsp;end;
 
第一个问题已经解决 declare @ReturnStr Char(20) 变成 varChar(20)就行了<br>第二个问题:<br>timer 执行的结果<br>绝对:(98 &nbsp; ,162 &nbsp;),相对:(7 &nbsp; &nbsp;,103 &nbsp;),标签:?&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>绝对:(98 &nbsp; ,466 &nbsp;),相对:(7 &nbsp; &nbsp;,407 &nbsp;),标签:?&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>绝对:(103 &nbsp;,474 &nbsp;),相对:(12 &nbsp; ,415 &nbsp;),标签:?&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>绝对:(277 &nbsp;,488 &nbsp;),相对:(186 &nbsp;,429 &nbsp;),标签:?&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>绝对:(194 &nbsp;,488 &nbsp;),相对:(103 &nbsp;,429 &nbsp;),标签:?&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>绝对:(111 &nbsp;,488 &nbsp;),相对:(20 &nbsp; ,429 &nbsp;),标签:?&gt; <br>自己点击按钮后的结果<br>绝对:(98 &nbsp; ,162 &nbsp;),相对:(7 &nbsp; &nbsp;,103 &nbsp;),标签:打印工资 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>绝对:(98 &nbsp; ,466 &nbsp;),相对:(7 &nbsp; &nbsp;,407 &nbsp;),标签: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>绝对:(103 &nbsp;,474 &nbsp;),相对:(12 &nbsp; ,415 &nbsp;),标签: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>绝对:(277 &nbsp;,488 &nbsp;),相对:(186 &nbsp;,429 &nbsp;),标签:简约工资表 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>绝对:(194 &nbsp;,488 &nbsp;),相对:(103 &nbsp;,429 &nbsp;),标签:工资条 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>绝对:(111 &nbsp;,488 &nbsp;),相对:(20 &nbsp; ,429 &nbsp;),标签:工资表
 
timer1.enabled:=False<br>//代码<br>也是错误的结果
 
方法有了:<br><br>procedure TForm1.Timer2Timer(Sender: TObject);<br>begin<br> &nbsp;Timer2.enabled:=False;<br> &nbsp;sendmessage(Button1.Handle,BM_CLICK,0,0);<br> &nbsp;Timer2.enabled:=True;<br>end;<br>可是问题到底错在哪里呢?
 
自己都解决完了[:D]
 
自己都解决完了<br>===<br>有人进来就是好
 
后退
顶部