Browse Source

* in the win16 video unit, don't ever try to update the window, after it has
received a WM_DESTROY message

git-svn-id: trunk@37712 -

nickysn 7 years ago
parent
commit
4cdfe1b025
1 changed files with 31 additions and 25 deletions
  1. 31 25
      packages/rtl-console/src/win16/video.pp

+ 31 - 25
packages/rtl-console/src/win16/video.pp

@@ -102,7 +102,10 @@ begin
     WM_PAINT:
       WindowPaint(hwnd);
     WM_DESTROY:
-      PostQuitMessage(0);
+      begin
+        VideoWindow:=0;
+        PostQuitMessage(0);
+      end;
     else
       MainWndProc:=DefWindowProc(hwnd,msg,wParam,lParam);
   end;
@@ -193,34 +196,37 @@ var
   ch: TVideoCell;
   CharWidth,CharHeight: SmallInt;
 begin
-  dc:=GetDC(VideoWindow);
-  if dc=0 then
+  if VideoWindow<>0 then
   begin
-    MessageBox(0,'GetDC() failed',nil,MB_OK or MB_ICONHAND or MB_TASKMODAL);
-    exit;
-  end;
-  oldfont:=SelectObject(dc,GetStockObject(OEM_FIXED_FONT));
-  GetTextMetrics(dc,FarAddr(Metrics));
-  CharWidth:=Metrics.tmMaxCharWidth;
-  CharHeight:=Metrics.tmHeight+Metrics.tmExternalLeading;
-  oldtextcolor:=GetTextColor(dc);
-  oldbkcolor:=GetBkColor(dc);
-  for y:=0 to ScreenHeight-1 do
-    for x:=0 to ScreenWidth-1 do
+    dc:=GetDC(VideoWindow);
+    if dc=0 then
     begin
-      ch:=videobuf^[y*ScreenWidth+x];
-      if force or (ch<>oldvideobuf^[y*ScreenWidth+x]) then
+      MessageBox(0,'GetDC() failed',nil,MB_OK or MB_ICONHAND or MB_TASKMODAL);
+      exit;
+    end;
+    oldfont:=SelectObject(dc,GetStockObject(OEM_FIXED_FONT));
+    GetTextMetrics(dc,FarAddr(Metrics));
+    CharWidth:=Metrics.tmMaxCharWidth;
+    CharHeight:=Metrics.tmHeight+Metrics.tmExternalLeading;
+    oldtextcolor:=GetTextColor(dc);
+    oldbkcolor:=GetBkColor(dc);
+    for y:=0 to ScreenHeight-1 do
+      for x:=0 to ScreenWidth-1 do
       begin
-        oldvideobuf^[y*ScreenWidth+x]:=videobuf^[y*ScreenWidth+x];
-        SetTextColor(dc,ColorRefs[(ch shr 8) and 15]);
-        SetBkColor(dc,ColorRefs[(ch shr 12) and 15]);
-        TextOut(dc,x*CharWidth,y*CharHeight,FarAddr(ch),1);
+        ch:=videobuf^[y*ScreenWidth+x];
+        if force or (ch<>oldvideobuf^[y*ScreenWidth+x]) then
+        begin
+          oldvideobuf^[y*ScreenWidth+x]:=videobuf^[y*ScreenWidth+x];
+          SetTextColor(dc,ColorRefs[(ch shr 8) and 15]);
+          SetBkColor(dc,ColorRefs[(ch shr 12) and 15]);
+          TextOut(dc,x*CharWidth,y*CharHeight,FarAddr(ch),1);
+        end;
       end;
-    end;
-  SetTextColor(dc,oldtextcolor);
-  SetBkColor(dc,oldbkcolor);
-  SelectObject(dc,oldfont);
-  ReleaseDC(VideoWindow,dc);
+    SetTextColor(dc,oldtextcolor);
+    SetBkColor(dc,oldbkcolor);
+    SelectObject(dc,oldfont);
+    ReleaseDC(VideoWindow,dc);
+  end;
   ProcessMessages;
 end;