How do I send text to a child window? I want to press a button and it sends the text. I am trying to store all of my CD-keys for my games in a program and then send the text to the boxes in the appropriate areas for each game. I have everything done but I can't figure out how to send the key's to the child windows. Can someone give me an example for starcraft, here are the window names and other things I found with Spy++.

Parent Window:
Caption: Starcraft Setup
Class: BlizzardSetup
Style: 1CCA0000

Child Window:
Caption: Starcraft - CD-Key.
Class: #32770 (Dialog)
Style: 94C800C4

Recommended Answers

All 3 Replies

Define all of your games as classes. Then pass the class to your child window and have the child window read the value of the class and display them. Can't do a code sample for you right now.

Ok, thanks for your help I'll try and do what you said.

Okay I had time to get some code for you.

First you need to create the class Game or whatever you wish to call it. Feel free to add different properties.

class Game
    {
        private string strName;
        public string Name
        {
            get
            {
                return strName;
            }
            set
            {
                strName = value;
            }
        }

        private string strCaption;
        public string Caption
        {
            get
            {
                return strCaption;
            }
            set
            {
                strCaption = value;
            }
        }

        private string strKey;
        public string Key
        {
            get
            {
                return strKey;
            }
            set
            {
                strKey - value;
            }
        }

        private int intCDTrayLocation;
        public int CDTrayLocation
        {
            get
            {
                return intCDTrayLocation;
            }
            set
            {
                intCDTrayLocation = value;
            }
        }


        public Game()
        { }

        public Game(string strName, string strCaption, string strKey, int intCDTrayLocation)
        {
            this.Name = strName;
            this.Caption = strCaption;
            this.Key = strKey;
            this.CDTrayLocation = intCDTrayLocation;
        }
    }

Next you need to create the class and then fill the object with data.

Game clssGame = new Game();

            clssGame.Name = "Starcraft";
            clssGame.Caption = "Cool game also cd need to be cleaned";
            clssGame.Key = "5555-5555-5555-5555";
            clssGame.CDTrayLocation = 22;

After that pass the object Game to the child window. Use some code like this to populate the child window on the load event.

txtbxName.Text = clssGame.Name;
txtbxCaption.Text = clssGame.Caption;

Keep adding different textboxes or whatever control for each property.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.