我看你作的本來就是錯的﹐你這是一個MDI程序﹗所以當能不能直接查找到了﹗ 不過你可以試用FindWindowEx,具體定義如下(vb)﹕ Public Declare Function FindWindowEx Lib "user32" _ Alias "FindWindowExA" (ByVal hWnd1 As Long, _ ByVal hWnd2 As Long, ByVal lpsz1 As String, _ ByVal lpsz2 As String) As Long 其中﹕hWnd1是父窗體句柄﹐hWnd2是父窗體中子窗體句柄 lpsz1是父窗體標題,lpsz2子窗體標題所以你上面的語句應該為﹕FindowEx(frm_carout.hwnd,frm_commit.hwnd,frm_carout.caption,frm_commit.caption)
问题己解决,谢谢大家的支持,谢谢awolfboy的提醒!
pstr_icno:=pchar('入口车辆确认'+card_no); IF Findwindowex(panel5.handle,0,'Tfrm_commit',pstr_icno)>0 then exit; application.CreateForm(tfrm_commit,frm_commit); frm_commit.Caption:=pstr_icno; frm_commit.Parent:=panel5; panel5.Visible:=true; frm_commit.vpi_road_no:=road_no; frm_commit.vps_card_no:=trim(card_no); inc(vgi_willcommit); frm_commit.Show;
不行用spy++看看一样不一样;
不過你可以試用FindWindowEx,具體定義如下(vb)﹕
Public Declare Function FindWindowEx Lib "user32" _
Alias "FindWindowExA" (ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
其中﹕hWnd1是父窗體句柄﹐hWnd2是父窗體中子窗體句柄
lpsz1是父窗體標題,lpsz2子窗體標題所以你上面的語句應該為﹕FindowEx(frm_carout.hwnd,frm_commit.hwnd,frm_carout.caption,frm_commit.caption)
IF Findwindowex(panel5.handle,0,'Tfrm_commit',pstr_icno)>0 then exit;
application.CreateForm(tfrm_commit,frm_commit);
frm_commit.Caption:=pstr_icno;
frm_commit.Parent:=panel5;
panel5.Visible:=true;
frm_commit.vpi_road_no:=road_no;
frm_commit.vps_card_no:=trim(card_no);
inc(vgi_willcommit);
frm_commit.Show;