Derma Menu Help.

I’m trying to make the black box in this picture.

Here’s my code so far.

[LUA]

function Police()

local DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 255, 255 )
DermaPanel:SetTitle( “Testing” )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
DermaPanel:Center( true )
gui.EnableScreenClicker(true)

local DermaButton = vgui.Create( “DButton” )
DermaButton:SetParent( DermaPanel ) – Set parent to our “DermaPanel”
DermaButton:SetText( “Yes, I would like to join the police force!” )
DermaButton:SetPos( 5, 215 )
DermaButton:SetSize( 245, 30 )
DermaButton.DoClick = function ()
DermaPanel:Close(gui.EnableScreenClicker(false))
end

local DermaButton = vgui.Create( “DButton” )
DermaButton:SetParent( DermaPanel )
DermaButton:SetText( “No thanks, I’m fine.” )
DermaButton:SetPos( 5, 185 )
DermaButton:SetSize( 245, 30 )
DermaButton.DoClick = function ()
DermaPanel:Close(gui.EnableScreenClicker(false))

end

end
concommand.Add(“police”, Police)

[/LUA]

I think I need to use
[LUA]
surface.SetDrawColor( 50, 50, 50, 255 )
surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() )
[/LUA]

But when I try to use it it breaks my menu. If someone could give me an example on how to use this that would be great.

From: http://wiki.garrysmod.com/?title=DPanel
[lua]local TestingPanel = vgui.Create( “DPanel”, DermaPanel )
TestingPanel:SetPos( 25, 50 )
TestingPanel:SetSize( 250, 250 )
TestingPanel.Paint = function() – Paint function
surface.SetDrawColor( 50, 50, 50, 255 ) – Set our rect color below us; we do this so you can see items added to this panel
surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) – Draw the rect
end
[/lua]

Make sure you parent the buttons to TestingPanel

Here is an excellent code snippet for changing the background color of a DPanel or similar rectangular objects.

[lua]function panel:Paint()
local col = Color(0,0,255,200)
draw.RoundedBox(0,0,0,self:GetWide(),self:GetTall(),col)
end[/lua]

That will always work for any panel, you just have to change “panel” to the variable name of the panel and “col” to the color your want.

Oh, how I do love objects in Lua.