Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.10.30;
Скачать: CL | DM;

Вниз

При перехвате сообщения WMEraseBkgnd получаю HDC больше Integer   Найти похожие ветки 

 
Valera   (2005-07-19 19:09) [0]

Не могу справиться с этой ошибкой. Использую процедуру
procedure WMEraseBkgnd( var Msg: TWMEraseBkgnd ); message wm_EraseBkgnd; для получения HDC контекста и в дальнейшем использую его в процедуре Control.Parent.Perform( wm_EraseBkgnd, DC, 0 ); Все получается до определенного момента, но когда HDC больше Integer выскакивает ошибка. Подскажите пожалуста как избежать этого.


 
Керк   (2005-07-19 19:43) [1]

Valera   (19.07.05 19:09)
получаю HDC больше Integer


Это как?


 
Fay ©   (2005-07-19 19:44) [2]

HDC = type LongWord;


 
Valera   (2005-07-19 19:52) [3]

Ошибка происходит при передачи HDC процедуре Perform или SendMessage, при подсветки определения процедур указывается, что WParam и LParam соответствуют длинне Integer. В помощи Longint, что в принципе одно и тоже. Как мне обойти тот случай, когда HDC больше Integer, у меня не получается корректно сделать прорисовку компонента.


 
Valera   (2005-07-19 20:06) [4]

сразу прошу извинения за неправильно поставленный вопрос


 
alpet ©   (2005-07-19 21:00) [5]

Valera   (19.07.05 20:06) [4]
Можешь представить значение валидного DC, что у тебя ошибку вызывает?


 
Valera   (2005-07-19 21:30) [6]

Не знаю меняется ли он или нет, отловить трудно потому что ошибка происходит не постоянно. После 10 минут мучений с компонентом HDC получился 3120630617.


 
Valera   (2005-07-20 00:53) [7]

Значения DC всегда разные. Я выкладываю кусок кода, если кто подскажет ошибку буду блогадарен.

procedure TDzTrackBar.WMEraseBkgnd( var Msg: TWMEraseBkgnd );
begin
 if FTransparent then
 begin
   DrawParentImage( Self, Msg.DC, True );
   Msg.Result := 1;
 end
 else
   inherited;
end;

procedure TDzTrackBar.DrawParentImage(Control: TControl; DC: HDC;
 InvalidateParent: Boolean);
var
 SaveIndex: Integer;
 P: TPoint;
begin
 if Control.Parent = nil then
   Exit;
 SaveIndex := SaveDC( DC );
 GetViewportOrgEx( DC, P );

 SetViewportOrgEx( DC, P.X - Control.Left, P.Y - Control.Top, nil );
 IntersectClipRect( DC, 0, 0, Control.Parent.ClientWidth, Control.Parent.ClientHeight );

 if not ( csDesigning in Control.ComponentState ) then
 begin
Ошибка -    Control.Parent.Perform( wm_EraseBkgnd, DC, 0 );
   Control.Parent.Perform( wm_Paint, DC, 0 );
 end
 else
 begin
   // Wrapping the following calls in a try..except is necessary to prevent cascading access violations in the Form
   // Designer (and ultimately the shutting down of the IDE) in the Form Designer under the following specific condition:
   //   1. Control on Form Designer supports Transparency (thus this procedure is called).
   //   2. Control is selected in the Form Designer such that grab handles are visible.
   //   3. User selects File|Close All Files, or Creates a New Application (i.e. Anything that closes the current
   //      project).
   //   4. Cascading access violations are created inside the IDE Form Designer.
   //
   // The same problem also occurs in Delphi 7 under Windows XP if you add a Delphi32.exe.manifest to the Delphi\Bin
   // folder. This will cause controls such as TPanel to appear transparent when on the Form Designer. Repeating the
   // steps above, will result in the cascading access violations as described above.

   try
     Control.Parent.Perform( wm_EraseBkgnd, DC, 0 );
     Control.Parent.Perform( wm_Paint, DC, 0 );
   except
   end;
 end;

 RestoreDC( DC, SaveIndex );

 if InvalidateParent then
 begin
   if not ( Control.Parent is TCustomControl ) and
      not ( Control.Parent is TCustomForm ) and
      not ( csDesigning in Control.ComponentState ) then
   begin
     Control.Parent.Invalidate;
   end;
 end;
end;


 
alpet ©   (2005-07-20 07:58) [8]

Трассировать код VCL Control.Parent.Perform( wm_EraseBkgnd, DC, 0 ); ты пробывал, может ошибка не из-за DC? Очень не похоже чтобы подобное значение могло привести к проблемам.


 
Elifan   (2005-08-26 11:12) [9]

Ребята, та же проблема при использовании TChart (без изменений, все как есть в Delphi 7).
Несколько графиков на форме, тоже раз в 10-20 минут при перерисовке может возникнуть AV или Canvas overflow...
Почему именно возникает, и какая зависимость я так и не смог понять....
Единственно что при дебаге выяснил что ошибка возникает в модуле Controls.pas, при RestoreDC(DC, SaveIndex);
Возможно что это та же проблема!?!
С уважением, Elifan



Страницы: 1 вся ветка

Текущий архив: 2005.10.30;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.05 c
2-1128586322
SQL-nik
2005-10-06 12:12
2005.10.30
Помогите с ADO


14-1128699533
GrayFace
2005-10-07 19:38
2005.10.30
Аберон - что за зверь?


2-1128627955
Молодой
2005-10-06 23:45
2005.10.30
MS Access&D7...... Ошибка - несовместимость типов...


1-1128954325
keal
2005-10-10 18:25
2005.10.30
Выборка с приоритетом


2-1128680067
Os
2005-10-07 14:14
2005.10.30
Базы данных