English 中文(简体)
形式问题——经过一段时间后产生排外现象
原标题:Problem with set visible of form - after some time form generate exeption
  • 时间:2011-04-04 07:56:26
  •  标签:
  • delphi
  • forms

I have problem with my form application created in Delphi 5. In this app I have few buttons which open (set visible property) different forms. This forms as a parent have Panel. Only one function is overridden:

procedure TForm.CreateParams(var Params : TCreateParams);
begin
  inherited CreateParams(Params);
  with Params do begin
    Style := ws_Child; 
    X :=FormMain.panelMain.Left; 
    Y :=FormMain.panelMain.Top;   
    Height :=FormMain.panelMain.Height; 
    Width := FormMain.panelMain.Height; 
    WndParent := FormMain.Handle;
  end
end;

我也能够改变小组的实际形式:


procedure TFormMain.ChangeToForm(newForm: TMainForm);
begin

  if (newForm=nil) or (newForm=lastForm) then EXIT;
  actForm:=newForm;

  actForm.Visible :=true;
  if assigned(lastForm) then lastForm.Visible:=false;
  lastForm:=actForm;
  LabelScreen.Caption:=actForm.Caption;
  newForm.Left := 0;
  newForm.Top := 0;

  newForm.Width := panelMDI.Width;
  newForm.Height := panelMDI.Height;
  newForm.Left := panelMDI.Left;
  newForm.Top := panelMDI.Top;
end;

When I open application everything works fine. Buttons change forms. Everything is ok. But when user don t use this app (don t changes forms etc.) for some period of time. Clicking on the buttons generate exceptions:



Access violation at address 0044D761 in module  rozpoznawanie.exe . Read of address 00000004; EAccessViolation

[...]
00534f2e       jz      loc_534fe9
00534f34 196   mov     eax, [ebp-8]
00534f37       mov     [$54b3a4], eax
00534f3c 197   mov     dl, 1
00534f3e       mov     eax, [$54b3a4]
00534f43     > call    -$9c194 ($498db4)      ; Forms.TCustomForm.SetVisible
00534f48 198   cmp     dword ptr [$54b3a8], 0
00534f4f       jz      loc_534f5d
00534f51       xor     edx, edx
00534f53       mov     eax, [$54b3a8]
00534f58       call    -$9c1a9 ($498db4)      ; Forms.TCustomForm.SetVisible
[...]

I ve looked everywhere and I don t know why it appears. Do you have some ideas?

http://www.ohchr.org。

我发现这个问题可能早些:



00756bc8 vcl70.bpl Controls.TWinControl.HandleNeeded 
00756bd5 vcl70.bpl Controls.TWinControl.GetHandle 
0076e675 vcl70.bpl Forms.TCustomForm.GetMonitor 
0076ecd0 vcl70.bpl Forms.TCustomForm.SetWindowToMonitor 
0076daf1 vcl70.bpl Forms.TCustomForm.SetVisible 

www.un.org/Depts/DGACM/index_french.htm 我读到,如果我们在电脑上安装了不止一个监测器,有时会出现这一问题。 但是,我试图改变对蒙托特人的财产,这并不奏效。

问题回答

I probably found solution for my problem. I have Delphi 5 without Update Pack 1. I do some research and I found that the problem as I said is in Delphi function TCustomForm.GetMonitor On production computer is installed one real monitor and virtual (Radmin application). After installing UP1 problem disapears.
I could also change function by myself:


function TCustomForm.GetMonitor: TMonitor;
var
  HM: HMonitor;
  I: Integer;
begin
  Result := nil;
  HM := MonitorFromWindow(Handle, MONITOR_DEFAULTTONEAREST);
  for I := 0 to Screen.MonitorCount - 1 do
    if Screen.Monitors[I].Handle = HM then
    begin
      Result := Screen.Monitors[I];
      Exit;
    end;

  //if we get here, the Monitors array has changed, so we need to clear and reinitialize it
  for i := 0 to Screen.MonitorCount-1 do
    TMonitor(Screen.FMonitors[i]).Free;
  Screen.FMonitors.Clear;
  EnumDisplayMonitors(0, nil, @EnumMonitorsProc, LongInt(Screen.FMonitors));
  for I := 0 to Screen.MonitorCount - 1 do
    if Screen.Monitors[I].Handle = HM then
    begin
      Result := Screen.Monitors[I];
      Exit;
    end;    
end;

感谢任何评论!

In addition, is:

Height :=FormMain.panelMain.Height; 
Width := FormMain.panelMain.Height; 

A打字? 使用

Height :=FormMain.panelMain.Height; 
Width := FormMain.panelMain.Width;




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签