티스토리 뷰

목차

    반응형

    C# MFC 차이 비교 - part2 (소스 차이 비교)


    C# MFC 차이 비교 A

    1. MFC - abs


    1
    2
    3
    4
    5
    int n = ...;
    int a = abs(n);
     
    int n = -2147483648// 아래처럼 변환
    UINT u = abs(n);
    cs


    C# - Math.Abs


    1
    2
    3
    4
    5
    6
    int n = ...;
    int a = Math.Abs(n);
     
    int n = -2147483648// 아래처럼 변환
    uint u = Math.Abs(n);
    uint u = unchecked(n < 0 ? -n : n);
    cs

    MFC - AfxMessageBox


    1
    UINT n = AfxMessageBox(body, flags);
    cs


    C# - MessageBox.Show


    1
    DialogResult n = MessageBox.Show(body, caption, flags, icon);
    cs


    3. MFC - atoi


    1
    2
    3
    CString s;
    int n = atoi(s);
    long n = atoi(s);
    cs


    C# - Parse


    1
    2
    3
    String s
    int n = int.Parse(s)
    long n = long.Parse(s)
    cs


    c# mfc 비교 소스


    C# MFC 차이 비교 C

    1. MFC - CDC 또는 CClientDC   


    1
    2
    CClientDC dc(&c_Ctl)
    Graphics g = c_Ctl.CreateGraphics();
    cs


    C# - Graphics


    2. MFC - COLORREF


    1
    COLORREF r = RGB(25500);
    cs


    C# - Color


    1
    2
    3
    Color c = Color.FromArgb(25500);
    또는
    Color c = Color.Red;
    cs

    3. MFC - CString


    1
    2
    CString::Find(CString s)   |   String.IndexOf(String s)
    CString::Format   |   Format
    cs


    C# - String


    1
    2
    CString s;
    s.Format(fmt, val...) 동일
    cs


    C# MFC 차이 비교 E

    1. MFC - .Ellipse


    1
    2
    3
    4
    5
    CClientDC dc(&wnd);
    CRect r;
    CPen pen(PS_SOLID, n, RGB(0,0,0));
    dc.SelectObject(&pen);
    dc.Ellipse(&r);
    cs


    C# - .DrawEllipse


    1
    2
    3
    4
    Graphics g = wnd.CreateGraphics();
    Rectangle r;
    Pen pen = new Pen(Color.Black, n);
    g.DrawEllipse(pen, r);
    cs


    c# mfc 비교 소스


    C# MFC 차이 비교 G

    1. MFC - GetBValue


    1
    2
    COLORREF c = ...;
    int b = GetBValue(c);
    cs


    C# - .B


    1
    2
    Color c = ...;
    int b = c.B;
    cs


    2. MFC - .GetClientRect()


    1
    2
    3
    CRect r;
    wnd.GetClientRect(&r);
    Rectangle r = wnd.ClientRectangle;
    cs


    C# - .ClientRectangle (property)

    3. MFC - GetDC


    1
    2
    CDC * dc = wnd.GetDC();
    Graphics g = wnd.CreateGraphics();
    cs


    C# - Graphics


    4. MFC - GetFont


    1
    2
    CFont * f = wnd.GetFont();
    Font f = wnd.Font;
    cs


    C# - .Font


    5. MFC - GetGValue


    1
    2
    COLORREF c = ...;
    int g = GetGValue(c);
    cs


    C# - .G


    1
    2
    Color c = ...;
    int g = c.G;
    cs


    마이크로소프트 c# mfc 차이 비교


    6. GetModuleFileName


    1
    2
    TCHAR name[MAX_PATH];
    GetModuleFileName(NULL, name, MAX_PATH);
    cs


    C# - System.Windows.Forms.Application.ExecutablePath


    1
    2
    String name = System.Windows.Forms.
    Application.ExecutablePath;
    cs


    7. GetRValue


    1
    2
    COLORREF c = ...;
    int r = GetRValue(c);
    cs


    .R


    1
    2
    Color c = ...;
    int r = c.R;
    cs


    8. GetSysColor (C# - Color.FromKnownColor(KnownColor.colorname))


    좌측 MFC, 우측 C#


    COLORREF c = ::GetSysColor(COLOR_WINDOW)

     Color.KnownColor.Window

     COLOR_3DDKSHADOW

     Color.KnownColor.ControlDarkDark (?)

     COLOR_3DFACE

     Color.KnownColor.Control (?)

     COLOR_3DHIGHLIGHT

     Color.KnownColor.ControlLight (?)

     COLOR_3DHILIGHT

     Color.KnownColor.ControlLight (?)

     COLOR_3DLIGHT

     Color.KnownColor.?

     COLOR_ACTIVEBORDER

     Color.KnownColor.ActiveBorder

     COLOR_ACTIVECAPTION

     Color.KnownColor.ActiveCaption

     COLOR_APPWORKSPACE

     Color.KnownColor.AppWorkspace

     COLOR_BACKGROUND

     Color.KnownColor.Desktop

     COLOR_BTNFACE

     Color.KnownColor.Control (?)

     COLOR_BTNHIGHLIGHT

     Color.KnownColor.ControlLight (?)

     COLOR_BTNHILIGHT

     Color.KnownColor.ControlLight (?)

     COLOR_BTNSHADOW

     Color.KnownColor.ControlDark (?)

     COLOR_BTNTEXT

     Color.KnownColor.ControlText

     COLOR_CAPTIONTEXT

     

     COLOR_DESKTOP

     Color.KnownColor.Desktop

     COLOR_GRADIENTACTIVECAPTION

     

     COLOR_GRADIENTINACTIVECAPTION

     

     COLOR_GRAYTEXT

     Color.KnownColor.GrayText

     COLOR_HIGHLIGHT Color.KnownColor.Highlight
     COLOR_HIGHLIGHTTEXT Color.KnownColor.HighlightText
     COLOR_HOTLIGHT Color.KnownColor.HotTrack (?)
     COLOR_INACTIVEBORDER Color.KnownColor.InactiveBorder
     COLOR_INACTIVECAPTION Color.KnownColor.InactiveCaption
     COLOR_INACTIVECAPTIONTEXT Color.KnownColor.InactiveCaptionText
     COLOR_INFOBK 
     COLOR_INFOTEXT Color.KnownColor.InfoText
     COLOR_MENU Color.KnownColor.Menu
     COLOR_MENUTEXT Color.KnownColor.MenuText
     COLOR_SCROLLBAR Color.KnownColor.ScrollBar
     COLOR_WINDOW Color.KnownColor.Window
     COLOR_WINDOWFRAME Color.KnownColor.WindowFrame
     COLOR_WINDOWTEXT Color.KnownColor.WindowText


    9. GetTextExtent


    1
    2
    3
    4
    CClientDC dc(&wnd);
    CSize sz;
    CString s = ...;
    sz = dc.GetTextExtent(s);
    cs

    C# - MeasureString


    1
    2
    3
    4
    Graphics g = wnd.CreateGraphics();
    SizeF sz;
    String s = ...;
    sz = g.MeasureString(wnd.Font, s);
    cs


    10. GWL_DLGRESULT


    1
    2
    3
    4
    5
    6
    7
    void CMyDialog::OK()
    {
        DWORD result = ...;
         SetWindowLong((HWND)this, GWL_DLGRESULT, result);
           
           CDialog::OnOK();
    }
    cs


    Closing event, DialogResult property


    1
    2
    3
    4
    5
    private void OnClosing(Object sender, System.ComponentModel.CancelEventArgs e)
    {
        Object result = ...;
        e.DialogResult = result;
    }
    cs


    C# MFC 차이 비교 I (ai)

    1. .InvalidateRect


    1
    2
    CRect r;
    wnd.InvalidateRect(&r)
    cs


    .Invalidate();


    1
    2
    Rectangle r;
    wnd.Invalidate(r);
    cs


    C# MFC 차이 비교 L

    1. LineTo


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    CClientDC dc(&wnd);
    dc.SelectObject(&pen);
    dc.MoveTo( x0, y0);
    dc.LineTo( x1, y1);
     
    CClientDC dc(&wnd);
    dc.SelectObject(&pen);
    CPoint p0(x0, y0);
    CPoint p1(x1, y1);
    dc.MoveTo( p0 );
    dc.LineTo( p1 );
    cs


    DrawLine(2쌍씩)


    1
    2
    3
    4
    5
    6
    7
    Graphics g = wnd.CreateGraphics();
    g.DrawLine(pen, x0, y0, x1, y1);
     
    Graphics g = wnd.CreateGraphics();
    Point p0 = new Point(x0, y0);
    Point p1 = new Point(x1, y1);
    g.DrawLine(pen, p0, p1);
    cs


    << 다음 글로 이어집니다. >>

    C# MFC 비교 테이블 [링크]


    C# MFC 차이 비교 - part2 (소스 차이 비교)

    반응형