triumphost 120 Posting Whiz

I'm trying to clip my Button with the following code but it does not work at all..

#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

#pragma comment(lib, "Gdiplus.lib")

void RegionCloseButton(HWND hwnd)
    CloseRegion = GetDC(hwnd);
    CloseRegionMem = CreateCompatibleDC(CloseRegion);
    Gdiplus::Graphics graphics(CloseRegion);
    Gdiplus::FontFamily fontFamily(L"Courier New");
    Gdiplus::GraphicsPath path;
    Gdiplus::PointF Origin(5, 5);
    path.AddString(L"X", -1, &fontFamily, Gdiplus::FontStyleBold, 15, Origin, NULL);
    Gdiplus::Region StringRegion(&path);

    Gdiplus::Pen pen(Gdiplus::Color(255, 0, 0, 0));
    graphics.DrawPath(&pen, &path);

The following is the .Net equivalent

System::Void Close_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e)
    System::Drawing::Drawing2D::GraphicsPath^ GraphicsPath = gcnew System::Drawing::Drawing2D::GraphicsPath;
    System::String^ stringText = "X";
    FontFamily^ family = gcnew FontFamily("Courier New");
    int fontStyle = (int)FontStyle::Bold;
    float emSize = 15;
    Point origin(5, 5);
    StringFormat^ format = gcnew StringFormat(StringFormat::GenericDefault);
    GraphicsPath->AddString(stringText, family, fontStyle, emSize, origin, format);

    Close->Region = gcnew System::Drawing::Region(GraphicsPath);

    delete Region;
    delete format;
    delete family;

And in the end it looks like (.Net):

I want to do that to the close button in Win32API in my WM_Paint but I cannot get it to clip. It doesn't even draw the X at all.

This is my entire Source Code:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.