[Question] GDI Themes

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

AlphaAnonymous

*Creating A Perfect World
Dank Tier Donator
Nobleman
Aug 9, 2012
153
1,188
1
Hello GuidedHacking Members!

I recently have gotten into making GDI theme coding for VB.Net and C#.

I was wondering if you guys would like the idea of having GDI themes to use for your hacking applications.
 

Helios

Coder
Meme Tier VIP
May 24, 2012
207
1,113
4
I use GDI+ in one of my hacks (CSS hack) and it works very well. Can you show some of your designs?
 

AlphaAnonymous

*Creating A Perfect World
Dank Tier Donator
Nobleman
Aug 9, 2012
153
1,188
1
I use GDI+ in one of my hacks (CSS hack) and it works very well. Can you show some of your designs?
I have not made anything original yet. I have been practicing by replicating other themes.

I do not know if you can tell, but I am not very creative; it is one of the toughest things for me when trying to design a GDI theme.
 

Helios

Coder
Meme Tier VIP
May 24, 2012
207
1,113
4
I have not made anything original yet. I have been practicing by replicating other themes.

I do not know if you can tell, but I am not very creative; it is one of the toughest things for me when trying to design a GDI theme.
Replicating other themes is fine, I also do that a lot, I just change it into what I'd like it to be though. Unless it's perfect. Are you able to create custom controls, like a colorwheel?
 
Last edited:

Obsta

Jr.Hacker
Meme Tier VIP
Jan 27, 2014
394
2,978
17
Can I see some examples of what you mean? This could be pretty interesting, my google search didn't return anything for 'GDI Themes'.
Do you mean just writing a library of custom methods that have a nice looking output? For example a striped line or something?
 

Helios

Coder
Meme Tier VIP
May 24, 2012
207
1,113
4
Can I see some examples of what you mean? This could be pretty interesting, my google search didn't return anything for 'GDI Themes'.
Do you mean just writing a library of custom methods that have a nice looking output? For example a striped line or something?
It's stuff like custom controls, e.g:
Or

With VB & C#, you're able to inherit standard controls like Button, TabControl, Listview and simply change the look of it. It saves a lot of time not having to do the functionality as well.
 
Last edited:

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
It's stuff like custom controls, e.g:
Or
Pretty impressive.
As you are drawing this, if you click on the Form, how do you handle button clicks? Like calculate if your button was pressed from the location of the click?
 

Obsta

Jr.Hacker
Meme Tier VIP
Jan 27, 2014
394
2,978
17
It's stuff like custom controls, e.g:
Or

With VB & C#, you're able to inherit standard controls like Button, TabControl, Listview and simply change the look of it. It saves a lot of time not having to do the functionality as well.
wow, the black and green looks really nice.
 

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
Helios could you tell me what font that is, in your second image ("old theme")?
 

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
I tried to do something myself:



looks like that now. The button changes from dashed to fully lined if you hover it. It does only support Labels, Buttons and Forms so far but I will keep working on this.
Also, the font is in the resources and gets extracted and applied as not everybody has the font installed.


Thanks so far Helios for your help on how to actually achieve this. :)
 

Obsta

Jr.Hacker
Meme Tier VIP
Jan 27, 2014
394
2,978
17
Helios till0sch

How much time did you guys put into writing these? Not including learning it. Definitely going to be going on my to-do list,
this stuff looks great.
 

Helios

Coder
Meme Tier VIP
May 24, 2012
207
1,113
4
I tried to do something myself:



looks like that now. The button changes from dashed to fully lined if you hover it. It does only support Labels, Buttons and Forms so far but I will keep working on this.
Also, the font is in the resources and gets extracted and applied as not everybody has the font installed.


Thanks so far Helios for your help on how to actually achieve this. :)
Looks good man! It's a great start.

Oh stop it you :D But seriously, you actually did all of the research yourself, I basically just confirmed that you found the right thing xD

Helios till0sch

How much time did you guys put into writing these? Not including learning it. Definitely going to be going on my to-do list,
this stuff looks great.
It varies. It really depends on whether you're theming a standard control (functionality is already taken care of), whether you have an idea or not and whether you're happy with the result you get or not. I can have an idea, but not be happy with the result and then sit for quite a long time, making changes, trying different approaches.

Completely custom controls can take quite a bit of time or they could take no time. It really depends.

Glad to hear that! :) If you love designing stuff, you're going to love this.
 

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
Obsta
Concerning the one I created: if you know what you do, this takes like 10 minutes max. when you know what you are wanting to do.
You have to be able to deal with EventHandlers (PaintEventArgs) and draw with Graphics (PaintEventArgs.Graphics), which you can access directly through a control's .Paint() event.

C++:
void PaintControl(object sender, PaintEventArgs e)
        {
            Control s = (Control)sender;
            if (s == null) return;       

            e.Graphics.Clear(this.BackColor);
            switch (s.Name.ToLower())
            {
                case "button1":
                    e.Graphics.Clear(Color.FromArgb(40, 40, 40));
                    if (button1Mouse)
                    {
                        DrawBorder(s, e.Graphics);
                    }
                    else
                    {
                        DrawBorder(s, e.Graphics, 1, true);
                    }
                    break;
                case "label1":
                    e.Graphics.Clear(Color.FromArgb(30, 30, 30));
                    break;
                case "form1":
                    e.Graphics.Clear(Color.FromArgb(30, 30, 30));
                        DrawBorder(s, e.Graphics, 2, true);
                    e.Graphics.DrawLine(Pens.Lime, new Point(0, 50), new Point(s.Width, 50));
                    e.Graphics.DrawLine(Pens.Lime, new Point(0, 51), new Point(s.Width, 51));
                    e.Graphics.DrawImage(global::CustomUI.Properties.Resources.terminal, 10, 10, 30, 30);
                    break;
                case "label2":
                    break;
            }

            e.Graphics.DrawString(s.Text, f, Brushes.Lime, new PointF(
                s.Width / 2 - e.Graphics.MeasureString(s.Text, f).Width / 2,
                s.Height / 2 - e.Graphics.MeasureString(s.Text, f).Height / 2
                ));
}

The icon on the upper left is drawn with Graphics.DrawImage and resources. The Graphics' methods are pretty much speaking for themselves. The DrawBorder is written by myself and supports different thicknesses and dashing:

C++:
 void DrawBorder(Control ctrl, Graphics g, int border = 1, bool dashes = false)
        {
            for (int i = 0; i < border; i++) 
            { 
                if (!dashes)
                {
                    g.DrawRectangle(Pens.Lime, new Rectangle(i, i, ctrl.Width - i * 2 - 1, ctrl.Height - i * 2 - 1));
                }
                else
                {
                    int space = 3;
                    for (int x = 1; x < ctrl.Width +1 / space; x+=3)
                    {
                        g.DrawLine(Pens.Lime, new Point(x * space - space, i), new Point(x * space, i));
                        g.DrawLine(Pens.Lime, new Point(x * space - space, ctrl.Height - i - 1), new Point(x * space, ctrl.Height - i - 1));
                    }
                    for (int y = 1; y < ctrl.Height + 1 / space; y += 3)
                    {
                        g.DrawLine(Pens.Lime, new Point(0 + i, y * space - space), new Point(i, y * space));
                        g.DrawLine(Pens.Lime, new Point(ctrl.Width - i - 1, y * space - space), new Point(ctrl.Width - i - 1, y * space));
                    
                    }
                }
            }
        }
The DrawString combined with MeasureString makes me able to draw the text centered.

If you add a font which might not be installed on the user's system you can do the following after adding the font to the resources:

C++:
FontFamily LoadFontFamily(byte[] buffer)
        {
            var handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
            try
            {
                var ptr = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0);
                using (var pvc = new PrivateFontCollection())
                {
                    pvc.AddMemoryFont(ptr, buffer.Length);
                    return pvc.Families[0];
                }
            }
            finally
            {
                handle.Free();
            }
        }
(taken from here: https://www.gamedev.net/topic/499978-create-a-systemdrawingfont-from-byte-or-stream/)


And do this:
C++:
Font myFont = new Font(LoadFontFamily::CustomUI.Properties.Resources.SegoeUILight), 12f);
You can use the switch because what you can do is:
C++:
Control.Paint += new PaintEventHandler(PaintControl);
for every control you got and then switch it's name. That saves alot of code!

Hope you could get a little bit of an insight. I am new to this myself and trying to make this general with a class right now and still trying things out.
(And yes I did the research myself, but on a thing I never knew existed which is pretty well documented)


EDIT: I just noticed that you asked how long it'd take to code this and not how. :facepalm:
 
Last edited:

Helios

Coder
Meme Tier VIP
May 24, 2012
207
1,113
4
till0sch

It's good that you're looking into classes, it's a much prettier way of doing this stuff. I'm not sure if you're aware of this or not, but you didn't have to create your own border function, one already exists, and using that in conjunction with a pen, you could have dashed lines. You should definitely also have a look at the Graphics class and the classes around it (Pen, Brush, GraphicsPath, etc.).

An example of a class (this should somewhat look like your form):
C#:
Class CustomForm
    Inherits ContainerControl

#Region "Form movement"
    Private Const WM_NCLBUTTONDOWN As Integer = &HA1
    Private Const HTCAPTION As Integer = 2

    <DllImport("user32.dll")> _
    Public Shared Function ReleaseCapture() As Boolean
    End Function

    <DllImport("user32.dll")> _
    Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    End Function
#End Region

    Protected Overrides Sub OnCreateControl()
        MyBase.OnCreateControl()

        ParentForm.FormBorderStyle = FormBorderStyle.None 'We want to remove the border from the form so that we can have the look of a custom form.
        Dock = DockStyle.Fill 'Again fill the whole form to get the right look.

        DoubleBuffered = True 'Remember to enable doublebuffering
    End Sub

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaint(e)

        'You can also change the quality of the graphics object. Have a look at e.g. G.SmoothingMode
        Dim G As Graphics = e.Graphics

        'Background color
        G.Clear(Color.FromArgb(30, 30, 30))

        'Header line
        G.FillRectangle(Brushes.Lime, New Rectangle(0, 44, Width, 3))
        G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(200, 0, 0, 0))), New Rectangle(0, 44, Width, 3))

        'Border
        Dim NewPen As New Pen(Brushes.Lime, 3)
        NewPen.DashPattern = New Single() {2, 2, 2, 2}
        G.DrawRectangle(NewPen, New Rectangle(0, 0, Width - 1, Height - 1))
    End Sub

    Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
        MyBase.OnMouseDown(e)

        'Add logic to make it only work in specific areas.
        ReleaseCapture()
        SendMessage(ParentForm.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0)
    End Sub
End Class
 
Last edited:

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
It's good that you're looking into classes, it's a much prettier way of doing this stuff.
That's what I did so far:




Supports checkboxes buttons and labels so far. All in a class, an extended control class which has some additional properties and you have to just add your controls to and it does everything pretty much.

This is all I'm doing for the button design

C++:
UICtrl = new Theme.UIControl();
UICtrl.originalControl = button1;
UICtrl.controlType = Theme.ControlTypes.BUTTON;
UICtrl.borderType = Theme.LineTypes.DASHED;
UICtrl.borderThickness = 1;
UICtrl.backColor = controlBackground;
UICtrl.dashHover = true;

UICtrl.Init(t, font1);
 

Helios

Coder
Meme Tier VIP
May 24, 2012
207
1,113
4
till0sch

You're probably just fooling around trying stuff out, learning GDI+, but I still feel like I should mention, just in case, that this is not the optimal or usual way one would do things.

With GDI+ and Windows forms, one usually separates the theme code and program specific code. It's done by creating a class which inherits a control class, like TabControl or "Control", and simply overriding needed events in the class. This mean that no extra code is required and won't clutter anything. One can then drag and drop the control from the toolbar onto the form and then obviously also view the theme design-time, and not only run-time. It just makes for easier readable & maintainable code.
 

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
till0sch

You're probably just fooling around trying stuff out, learning GDI+, but I still feel like I should mention, just in case, that this is not the optimal or usual way one would do things.

With GDI+ and Windows forms, one usually separates the theme code and program specific code. It's done by creating a class which inherits a control class, like TabControl or "Control", and simply overriding needed events in the class. This mean that no extra code is required and won't clutter anything. One can then drag and drop the control from the toolbar onto the form and then obviously also view the theme design-time, and not only run-time. It just makes for easier readable & maintainable code.
Glad you mention that, I had a paint handler for all types of controls and used a switch..

Other that that, though how could I then make these hover things if I can't store anything. Or could I just define a variable in the overriding class?:)
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods