Take a look at my addon LazyAFK.
Code:
local frame = CreateFrame("Frame")
frame:Hide();
frame:SetHeight(160)
frame:SetWidth(350)
frame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 430, -222)
frame:EnableMouse(true)
frame:SetMovable(true)
frame:SetUserPlaced(true)
frame:SetClampedToScreen(true)
frame:SetScript("OnMouseDown", frame.StartMoving)
frame:SetScript("OnMouseUp", frame.StopMovingOrSizing)
frame:SetBackdrop({
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
tile = true,
tileSize = 32,
edgeSize = 32,
insets = {
left = 11,
right = 12,
top = 12,
bottom = 11
}
});
function button_OnClick()
--Clicking button does stuff in here
end
local button = CreateFrame("Button", "AFKButton", frame, "UIPanelButtonTemplate")
button:SetHeight(45)
button:SetWidth(125)
button:SetPoint("BOTTOM", frame, "BOTTOM", 0, 15)
button:SetText("Click Me!")
button:RegisterForClicks("AnyUp")
button:SetScript("OnClick", button_OnClick)
local close = CreateFrame("Button", "CloseButton", frame, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -8, -8)