2013-03-31 3 views
0

굵게, 기울임 꼴로 밑줄 단추를 richtextbox에서 서로 사용하고 싶습니다. 예제를 찾았지만 C#을 사용했습니다. PLS, C++에서의 작업 방법 도움말 : 당신이 C++/CLI로 C 번호의 직접 변환을 원하는 경우에FontStyle 코드 C# to C++

if(e.Button==toolBarButton1) 
{ 
    int fStyle = (int)FontStyle.Bold + (int)FontStyle.Italic; 
    FontStyle f = (FontStyle)fStyle; 
    richTextBox1.SelectionFont = 
     new Font(richTextBox1.Font.Name, richTextBox1.Font.Size, f); 
} 

내 버전은, 내가 원하는 그것을

 if (RichTextBox1->SelectionFont != nullptr) 
    { 
     System::Drawing::Font^ currentFont = RichTextBox1->SelectionFont; 
     System::Drawing::FontStyle newFontStyle; 
     if (RichTextBox1->SelectionFont->Bold == true) 
     { 
     newFontStyle = FontStyle::Regular; 
     } 
     else 
     { 
     newFontStyle = FontStyle::Bold; 
     } 
     RichTextBox1->SelectionFont = gcnew System::Drawing::Font(currentFont->FontFamily,currentFont->Size,newFontStyle); 
+0

비트 또는 연산자 대신 합계 연산을 사용 하시겠습니까? – Machinarius

+0

더 정확하게 말하십시오. Win32? MFC? WinForms C++/CLI? 너 뭐야? 코드가 있습니까? –

+0

WinForms C++. 나는 그것을 더 높게 추가했다. 그래서 선택한 텍스트 스타일을 확인하고 싶습니다. 즉, 선택된 텍스트가 굵게 표시되고 기울임 꼴 버튼이 눌려지면 텍스트가 굵게 표시되고 동시에 기울임 꼴이됩니다. 내 영어로 미안해. – user2227430

답변

0

을 리메이크 바로 사용

if (e->Button == toolBarButton1) 
{ 
    int fStyle = safe_cast<int>(FontStyle::Bold) + safe_cast<int>(FontStyle::Italic); 
    FontStyle ^f = safe_cast<FontStyle^>(fStyle); 
    richTextBox1->SelectionFont = gcnew Font(richTextBox1::Font->Name, richTextBox1::Font::Size, f); 
}