有一个程序A,主窗口中带有一个TPageControl控件,在其上有二个页面,程序运行时,只有一个页面显示出来,另一个页面没有显示,
我另外写了一程序B,在程序B中找到A程序中TPageControl控件的句柄,然后B程序发送一个消息给这个句柄,使A程序中TPageControl控件将其所有页面都显示出来
但不知发送什么消息,我用SPY++查看,也只看到一个页面。如何实现发送消息将另一个程序中的PAGECONTROL隐含的页面显示出来呢?
还请各位大侠指点,谢谢!

解决方案 »

  1.   

    看了一下VCL源代码,其中每一页的TTabSheet显示没有和消息联系起来,楼主要另想办法,或者再研究VCL的源码,我没看出来。其实是在窗体中在插入窗体,设置Parent实现TPageControl的,参考设置显示的VCL源码Page.BringToFront; Page.Visible := True;
    完整源代码:procedure TPageControl.ChangeActivePage(Page: TTabSheet);
    var
      ParentForm: TCustomForm;
    begin
      if FActivePage <> Page then
      begin
        ParentForm := GetParentForm(Self);
        if (ParentForm <> nil) and (FActivePage <> nil) and
          FActivePage.ContainsControl(ParentForm.ActiveControl) then
        begin
          ParentForm.ActiveControl := FActivePage;
          if ParentForm.ActiveControl <> FActivePage then
          begin
            TabIndex := FActivePage.TabIndex;
            Exit;
          end;
        end;
        if Page <> nil then
        begin
          Page.BringToFront;
          Page.Visible := True;
          if (ParentForm <> nil) and (FActivePage <> nil) and
            (ParentForm.ActiveControl = FActivePage) then
            if Page.CanFocus then
              ParentForm.ActiveControl := Page else
              ParentForm.ActiveControl := Self;
        end;
        if FActivePage <> nil then FActivePage.Visible := False;
        FActivePage := Page;
        if (ParentForm <> nil) and (FActivePage <> nil) and
          (ParentForm.ActiveControl = FActivePage) then
          FActivePage.SelectFirst;
      end;
    end;
      

  2.   

    A程序中我只有一个EXE文件,我在B程序获取到了PageControl控件的句柄,
    我想根据句柄来将隐藏的页面显示出来,但不知如何才能实现。
    还请大侠们指点,谢谢!
      

  3.   

    A发送消息到B程序,B对消息进行处理时,可以显示PageControl页面了。
      

  4.   

    這樣啦:
    1、各自定一個消息;
    2、在b程序發送這個消息,只需要知道pagecontrol所在窗的handle就好了;
    2、在a程序處理這個消息,只需要控制tabsheet的tabvisible屬性就可以了,而且你可以通過lparam傳遞標識,來判斷要顯示哪一個或者全部