Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C# Programming › Creating New Objects DLL Need Help

Creating New Objects DLL Need Help

Posts 1–7 of 7 · Page 1 of 1
SeptFicelle
SeptFicelle
Creating New Objects DLL Need Help
I'm creating a DLL that will create 4 objects and place them on a form using custom made methods. The logic I've put into this should work, but it's not. I don't understand why. In a blank DLL I need a method called Create(int x, int y) that will assign the location for all 4 objects. The objects are arranged in a 4 square style pattern so simple location math is required. My problem is creating the objects and placing them on the form in the user's project. My pseudo code is:

[code]// Had to add most of these manually.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ClassLibraryExample
{
public class Class1
{
private int x;
private int y;

public void Create(int x, int y)
{
object1.Location = new Point(x, y);
object2.Location = new Point(x + 10 + object.Width, y);
object3.Location = new Point(x + 10 + object.Width, y + 10 + object.Height);
object4.Location = new Point(x, y + 10 + object.Height);
}
}
}[code]

The idea is to make all 4 objects into a single object. Implementation into a forms application would be like:

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClassLibraryExample;

namespace FormExample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Class1.Create(50, 50);
        }
    }
}
That's pretty much all I have to go on. C# and .NET are easy to convert back and forth (except for a few minor classes and methods). Much thanks to whoever helps.
#1 · 15y ago
B1ackAnge1
B1ackAnge1
I'm assuming you're not posting half your code or something?
Object 1-4 are never initialized in the code you post.
Also if you want to add controls to a form, you add them to the Controls collection ON the form

Code:
//someX,someY,someWidth & someHeight have  values set somewhere

public void AddButtonToForm(Form someForm)
{
      Button b = new Button();
      b.Text = "Do Something";
      b.Location = new Point(someX,someY); 
      b.Size = new Size(someWidth,someHeight);
      b.Click += new System.EventHandler(this.someButton_Click); 
      
      someForm.Controls.Add(b);
}

private void someButton_Click(object sender, EventArgs e)
{
     //Do Something here
}

Of course if you want to do it 'properly' you'd also suspend the layout on the form before adding the button and resume it afterwards
#2 · edited 15y ago · 15y ago
SeptFicelle
SeptFicelle
THANK YOUUUUUUUUUUUUUUUUUUUUU It was form.Controls.Add(controlName); WOOOOOO Thank you so much... Here is the result.

// DLL Code
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Windows.Forms;
using System.Drawing;

namespace agUltimate2011
{
    public class agNet
    {
        
    }

    public class agSpecial
    {
        public void Windmill(Form formToAddWindmillTo, int x, int y)
        {
            Button button1 = new System.Windows.Forms.Button();
            Button button2 = new System.Windows.Forms.Button();
            Button button3 = new System.Windows.Forms.Button();
            Button button4 = new System.Windows.Forms.Button();

            button1.Location = new System.Drawing.Point(x, y);
            button1.Name = "windmill1";
            button1.Size = new System.Drawing.Size(75, 23);
            button1.TabIndex = 0;
            button1.Text = "Create New";
            button1.UseVisualStyleBackColor = true;
            button1.Click += new System.EventHandler(click1);

            button2.Location = new System.Drawing.Point(x + 10 + button2.Width, y);
            button2.Name = "windmill2";
            button2.Size = new System.Drawing.Size(75, 23);
            button2.TabIndex = 0;
            button2.Text = "Create New";
            button2.UseVisualStyleBackColor = true;
            button2.Click += new System.EventHandler(click2);

            button3.Location = new System.Drawing.Point(x + 10 + button2.Width, y + 10 + button2.Height);
            button3.Name = "windmill3";
            button3.Size = new System.Drawing.Size(75, 23);
            button3.TabIndex = 0;
            button3.Text = "Create New";
            button3.UseVisualStyleBackColor = true;
            button3.Click += new System.EventHandler(click3);

            button4.Location = new System.Drawing.Point(x, y + 10 + button1.Height);
            button4.Name = "windmill4";
            button4.Size = new System.Drawing.Size(75, 23);
            button4.TabIndex = 0;
            button4.Text = "Create New";
            button4.UseVisualStyleBackColor = true;
            button4.Click += new System.EventHandler(click4);

            formToAddWindmillTo.Controls.Add(button1);
            formToAddWindmillTo.Controls.Add(button2);
            formToAddWindmillTo.Controls.Add(button3);
            formToAddWindmillTo.Controls.Add(button4);
        }

        private void click1(object sender, EventArgs e)
        {
            MessageBox.Show("You clicked Button 1");
        }

        private void click2(object sender, EventArgs e)
        {
            MessageBox.Show("You clicked Button 2");
        }

        private void click3(object sender, EventArgs e)
        {
            MessageBox.Show("You clicked Button 3");
        }

        private void click4(object sender, EventArgs e)
        {
            MessageBox.Show("You clicked Button 4");
        }
    }
}
// Form code
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using agUltimate2011;

namespace TestForm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            agSpecial agSpecial = new agSpecial();
            agSpecial.Windmill(this, 20, 20);
        }
    }
}
WOOOOOOOOOOOOOOO Thank you so much!!!!!
#3 · edited 15y ago · 15y ago
Imported
Imported
What the hell? I swear I posted here...
#4 · 15y ago
SeptFicelle
SeptFicelle
Quote Originally Posted by Imported View Post
What the hell? I swear I posted here...
The first time I posted this it was in the wrong section; I re-posted in the correct section before they moved the original. So there are two.
#5 · 15y ago
Jason
Jason
Quote Originally Posted by SeptFicelle View Post
The first time I posted this it was in the wrong section; I re-posted in the correct section before they moved the original. So there are two.
Ahhh okay. Well, looks like BA has it all under control
#6 · 15y ago
SeptFicelle
SeptFicelle
Quote Originally Posted by Chooka View Post


Ahhh okay. Well, looks like BA has it all under control
I tried to play the piano in your quote with my mouse. Sadface because it didn't make any noise. LOLOL
#7 · 15y ago
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Tags for this Thread

None