Code:
-- assumption: you've got a frame that you want to hide. it's stored in the variable myFrame.
myFrame.close = CreateFrame("Button",nil,myFrame)
myFrame.close:SetPoint("TOPRIGHT") -- change this to wherever you want it
myFrame.close:SetSize(20,20) -- change to wherever you want it yet again
myFrame.close:SetNormalTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Up") -- change to whatever
myFrame.close:GetNormalTexture():SetTexCoord(0.25,0.75,0.25,0.75) -- the texture file actually has an empty border. we only want the actual icon.
myFrame.close:SetScript("OnClick", function(self) self:GetParent():Hide() end)
Or you can use a template:
Code:
myFrame.close = CreateFrame("Button",nil,myFrame,"UIPanelCloseButton")
myFrame.close:SetPoint("TOPRIGHT")
myFrame.close:SetSize(20,20)