曾经试过用以下方法可以实现,但很麻烦,不可以直接传到想要的框中,必须一个一个轮着,而且是必须一层一层获取句柄。谁还有更好的方法直接点? <br><br>==================================================================================== <br>procedure TForm1.btn1Click(Sender: TObject); <br>begin <br> FH:=FindWindow('tfrmdoccust',Nil); <br> if FH<>0 then <br> lbl1.Caption:='获取窗口句柄成功!' <br> else <br> lbl1.Caption:='获取窗口句柄失败!' <br>end; <br><br>procedure TForm1.btn2Click(Sender: TObject); <br>begin <br> ButH := FindWindowEx(FH,0,'tpagecontrol',nil); <br> if ButH<>0 then <br> lbl1.Caption:='获取tpagecontrol句柄成功!' <br> else <br> lbl1.Caption:='获取tpagecontrol句柄失败!' <br>end; <br><br>procedure TForm1.btn3Click(Sender: TObject); <br>begin <br> But1 := FindWindowEx(ButH,0,'ttabsheet',nil); <br> if But1<>0 then <br> lbl1.Caption:='获取ttabsheet句柄成功!' <br> else <br> lbl1.Caption:='获取ttabsheet句柄失败!' <br>end; <br><br>procedure TForm1.btn4Click(Sender: TObject); <br>begin <br> But2 := FindWindowEx(But1,HWND(0),'tdbedit',nil); <br> if But2<>0 then <br> lbl1.Caption:='获取tdbedit句柄成功!' <br> else <br> lbl1.Caption:='获取tdbedit句柄失败!' <br>end; <br><br>procedure TForm1.btn5Click(Sender: TObject); <br>begin <br> But2:=GetNextWindow(But2,GW_HWNDNEXT); <br> lbl1.Caption:=IntToStr(but2); <br> SendMessage(but2,WM_SETTEXT,0,Integer(pchar(edt1.Text))); <br>end;