Ejemplo n.º 1
0
//---------------------------------------------------------------------------
void __fastcall TRichEdit20::SetFormat(UnicodeString FontName, int FontSize,
  TFontCharset FontCharset, TFontStyles FontStyles, unsigned int TabSize,
  bool AWordWrap)
{

  if (!FInitialized)
  {
    // for efficiency we should be creating handle here
    assert(!HandleAllocated());
  }

  // setting DefAttributes is noop if we do not have a handle
  // (btw code below would create one anyway)
  HandleNeeded();

  LockWindowUpdate(Handle);

  // setting DefAttributes may take quite time, even if the font attributes
  // do not change, so avoid that if not necessary
  if (!FInitialized ||
      (Font->Name != FontName) ||
      (Font->Size != FontSize) ||
      (Font->Charset != FontCharset) ||
      (Font->Style != FontStyles))
  {
    Font->Name = FontName;
    Font->Size = FontSize;
    Font->Charset = FontCharset;
    Font->Style = FontStyles;
    DefAttributes->Assign(Font);
  }

  if (!FInitialized ||
      (FTabSize != TabSize))
  {
    SetTabSize(TabSize);
    FTabSize = TabSize;
  }

  if (!FInitialized ||
      (FWordWrap != AWordWrap))
  {
    assert(HandleAllocated());
    // Undocumented usage of EM_SETTARGETDEVICE.
    // But note that it is used by MFC in CRichEditView::WrapChanged()
    SendMessage(Handle, EM_SETTARGETDEVICE, 0, (AWordWrap ? 0 : 1));
    FWordWrap = AWordWrap;
  }

  LockWindowUpdate(NULL);

  FInitialized = true;

}
Ejemplo n.º 2
0
//---------------------------------------------------------------------------
HDWP __fastcall TTVPHintWindow::ShowTop(HDWP hdwp)
{
    if(HandleAllocated() && Visible)
    {
        hdwp = DeferWindowPos(hdwp, Handle, HWND_TOPMOST, 0, 0, 0, 0,
                              SWP_NOSENDCHANGING|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREPOSITION|
                              SWP_NOSIZE|WM_SHOWWINDOW);
        Invalidate();
    }
    return hdwp;
}
Ejemplo n.º 3
0
//---------------------------------------------------------------------------
void TLinkLabelEx::AdjustBounds()
{
  if(!ComponentState.Contains(csLoading) && AutoSize)
  {
    if(CheckWin32Version(6) && IsLinkLabelSupported())
    {
      if(HandleAllocated())
      {
        TSize TextSize;
        SendMessage(Handle, LM_GETIDEALSIZE, WordWrap ? Width : MaxInt, reinterpret_cast<LONG>(&TextSize));
        SetBounds(Left, Top, WordWrap ? Width : TextSize.cx, WordWrap ? TextSize.cy : Height);
      }
    }
    else
    {
      HDC DC = GetDC(0);
      try
      {
        HFONT SaveFont = reinterpret_cast<HFONT>(SelectObject(DC, Font->Handle));
        try
        {
          String Parsed = ParseLinks();
          if(FWordWrap)
          {
            TRect Rect(0, 0, Width, Height);
            DrawText(DC, Parsed.c_str(), Parsed.Length(), &Rect, DT_WORDBREAK | DT_NOCLIP | DT_CALCRECT | DT_NOPREFIX);
            Height = Rect.Height();
          }
          else
          {
            TSize TextSize;
            GetTextExtentPoint32(DC, Parsed.c_str(), Parsed.Length(), &TextSize);
            SetBounds(Left, Top, TextSize.cx, TextSize.cy);
          }
        }
        __finally
        {
          SelectObject(DC, SaveFont);
        }
      }
      __finally
      {
        ReleaseDC(0, DC);
      }
    }
  }
}