none
请教在winform中如何通过gdi+实现文本编辑器

全部回复

  • Hi,

    感谢你在MSDN论坛发帖。

    下面的代码就是使用GDI+,在文本编辑器中显示字。 希望对你有所帮助。

    WCHAR string[] = 
       L"Draw text in a rectangle by passing a RectF to the DrawString method.";
                           
    FontFamily   fontFamily(L"Arial");
    Font         font(&fontFamily, 12, FontStyleBold, UnitPoint);
    RectF        rectF(30.0f, 10.0f, 100.0f, 122.0f);
    SolidBrush   solidBrush(Color(255, 0, 0, 255));
    
    graphics.DrawString(string, -1, &font, rectF, NULL, &solidBrush);
    
    Pen pen(Color(255, 0, 0, 0));
    graphics.DrawRectangle(&pen, rectF);
    			

    Best Regards,

    Hart

     

    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2017年4月5日 7:07
    版主
  • 可以参考下winform的TextBox或RichTextBox的源代码(用ILSpy反编译),看他们是如何实现的。


    专注于.NET ERP/CRM开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms

    2017年4月6日 0:25