sync with trunk r46493
[reactos.git] / dll / win32 / riched20 / context.c
index 161a64a..93d5caa 100644 (file)
 
 void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC)
 {
-  c->nSequence = editor->nSequence++;  
+  c->nSequence = editor->nSequence++;
   c->hDC = hDC;
   c->editor = editor;
   c->pt.x = 0;
   c->pt.y = 0;
   c->hbrMargin = CreateSolidBrush(RGB(224,224,224));
   c->rcView = editor->rcFormat;
-  c->dpi.cx = GetDeviceCaps(hDC, LOGPIXELSX);
-  c->dpi.cy = GetDeviceCaps(hDC, LOGPIXELSY);
+  if (hDC) {
+      c->dpi.cx = GetDeviceCaps(hDC, LOGPIXELSX);
+      c->dpi.cy = GetDeviceCaps(hDC, LOGPIXELSY);
+  } else {
+      c->dpi.cx = c->dpi.cy = 96;
+  }
+  if (editor->nAvailWidth)
+      c->nAvailWidth = ME_twips2pointsX(c, editor->nAvailWidth);
+  else
+      c->nAvailWidth = c->rcView.right - c->rcView.left;
 }
 
-void ME_DestroyContext(ME_Context *c, HWND hWnd)
+void ME_DestroyContext(ME_Context *c)
 {
-  if (hWnd) ReleaseDC(hWnd, c->hDC);
+  if (c->hDC) ITextHost_TxReleaseDC(c->editor->texthost, c->hDC);
   DeleteObject(c->hbrMargin);
 }