make your own custom vgui element

hello, i was wondering what would creating my own vgui element like DFrame, would help me?

This should help

You can also take a look at the source for all of the panels, should help clear some stuff up

Ok so I’ll not give you my own implementation of DFrame (RRP_DFrame), so basicaly you want to remake DFrame paint stuff :

local PANEL = {}
function PANEL:Init()
        //Correct GMod DFrame attempt to call a nil value
        self.SizeW = 0
	self.SizeH = 0
function PANEL:Paint()
        surface.SetDrawColor(255,  0, 0, 64)
        surface.DrawRect(0, 0, self.SizeW, self.SizeH)
vgui.Register("MyOwnDFrameClass", PANEL, "DFrame")

There you go.

1- You aren’t seeint self.SizeW or self.SizeH to anything other than 0.
2- Why even bother with that if you can just use the paint hook correctly?

function PANEL:Paint(w,h)
surface.SetDrawColor(255, 0, 0, 64)
surface.DrawRect(0, 0, w, h)

Well on my side self.SizeW/SizeH are equal to window size, otherwise I don’t know how My frame can display… If you need a screen of the Game tell me, I can even make a video for you showing that SizeW and SizeH are indead equal to the size of the window !!

[editline]9th May 2015[/editline]

About the w, h in Paint, well to be honnest, I just saw on GMod dframe.lua, because anyway, the wiki is terribly uninformed about VGui creation, so I remade many VGui elements of GMod because fo 3 reasons :
1- Very bad looking (rendering is horrible not even any transparency effect…).
2- Some people had attemp to index nil values when using default GMod vgui, so I decided to make my own.
3- Many people found that GMod VGui is horrible because there are not even any animation, so I made my own VGui to add animations when opening frames (this is hacky I know, but not found other ways).

I think he meant that self.SizeW and self.SizeH are equal to your screen width and height, so there’s no point setting them to 0 if they already have correct values.

Not even any transparency effect? Why not just do draw.RoundedBox and set the Color()'s last digit to be the alpha amount you want?

Really? There aren’t any animations?