首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

请问:在ActiveForm和IE ToolBand中把窗体ShowModal后,还能点IE的缺陷

2012-03-23 
请教:在ActiveForm和IE ToolBand中把窗体ShowModal后,还能点IE的缺陷这个问题我在网上搜索了一下,发现有一

请教:在ActiveForm和IE ToolBand中把窗体ShowModal后,还能点IE的缺陷
这个问题我在网上搜索了一下,发现有一段delphi代码:

Delphi(Pascal) code
type  PWindowList = ^TWindowList;  TWindowList = record  Next: PWindowList;  Window: HWnd;  end;  PDisableProcessWindows = ^TDisableProcessWindows;  TDisableProcessWindows = record  ActiveWindow : hWnd;  ProcessId : DWORD;  WindowList: pWindowList;  end;function DoDisableWindow(Window: HWnd; Data: Longint): Bool; stdcall;var  P: PWindowList;  WinProcessId : DWORD;begin  with pDisableProcessWindows(Data)^ do  begin  GetWindowThreadProcessId(Window,@WinProcessId);  if (ProcessId=WinProcessId) and (Window <> ActiveWindow) and  IsWindowVisible(Window) and IsWindowEnabled(Window) then  begin  New(P);  P^.Next := WindowList;  P^.Window := Window;  WindowList := P;  EnableWindow(Window, False);  end;  end;  Result := True;end;function DisableProcessWindows(ActiveWindow: HWnd): Pointer;var  Rec: TDisableProcessWindows;begin  Rec.ActiveWindow := ActiveWindow;  Rec.WindowList := nil;  Rec.ProcessId := GetCurrentProcessId;  try  try  EnumWindows(@DoDisableWindow, integer(@Rec));  Result := Rec.WindowList;  except  EnableTaskWindows(Rec.WindowList);  Result := nil;  raise;  end;  finally  end;end;//写上面的函数,然后把自己需要模态显示的窗口新写一个ShowModalfunction TMyForm.ShowModal: Integer;var  WindowList: Pointer;begin  // 修正IE7下把窗体ShowModal后,还能点IE的缺陷  WindowList := nil;  try  WindowList := DisableProcessWindows(0);  Result := inherited ShowModal;  finally  EnableTaskWindows(WindowList);  end;end;


改成C++后如下:
C/C++ code
BOOL __stdcall DoDisableWindow(HWND Window, int Data){    PWindowList P;    DWORD  WinProcessId;    GetWindowThreadProcessId(Window,&WinProcessId);    if ( ((TDisableProcessWindows *)Data)->ProcessId == WinProcessId &&    Window != ((TDisableProcessWindows *)Data)->ActiveWindow  &&    IsWindowVisible(Window) && IsWindowEnabled(Window)     )    {        P = new TWindowList;        P->Next = ((TDisableProcessWindows *)Data)->WindowList;        P->Window = Window;        ((TDisableProcessWindows *)Data)->WindowList = P;        EnableWindow(Window, false);    }    return true;}void * __fastcall DisableProcessWindows(HWND ActiveWindow){   TDisableProcessWindows Rec;   Rec.ActiveWindow =  ActiveWindow;   Rec.WindowList = NULL;   //Rec.ProcessId = GetCurrentProcessId();   GetWindowThreadProcessId(GetForegroundWindow(), (unsigned long *)&Rec.ProcessId);   void *Result;   try   {       try       {            EnumWindows( (FARPROC)DoDisableWindow, (long)&Rec );            Result = Rec.WindowList;       }       catch (...)       {            EnableTaskWindows(Rec.WindowList);            Result = NULL;       }   }   __finally   {   }   return  Result;}int __fastcall TMyForm::ShowModal(){  void *WindowList;  int Result;  // 修正IE7下把窗体ShowModal后,还能点IE的缺陷  WindowList = NULL;  try  {    WindowList = DisableProcessWindows(0);    Result = ShowModal();  }  __finally  {      EnableTaskWindows(WindowList);  }  return Result;}


但是代码并不起作用,直接导致IE选项卡重置,请问我改的有问题还是其他原因呢?谢谢!

[解决办法]
来看看
[解决办法]
记号留用

热点排行