Jump to content

Program getting trapped in WndProc override.

- - - - -

  • Please log in to reply
2 replies to this topic

#1
reed

reed

    Newbie

  • Members
  • PipPip
  • 15 posts
I have a method that looks like this:

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

        {

            string clubname = "", clublocation = "", contactname = "", contactaddress = "", contactlocation = "";

            Club tempclub = new Club(Convert.ToInt32(comboBox1.SelectedText)); //A custom object Club(int somenum)

            tempclub.GetClubInfo(ref clubname, ref clublocation, ref contactname, ref contactaddress, ref contactlocation); //Reads the row where the first column == comboBox1.SelectedText

            ClubNameTextBox.Text = clubname;

            ClubLocationTextbox.Text = clublocation;

            ContactNameTextBox.Text = contactname;

            ContactAddressTextBox.Text = contactaddress;

            ContactLocationTextBox.Text = contactlocation;

        }


    }


The program gets to the line where I declare a Club object, then inexplicably jumps to:

    class TablessControl : TabControl

    {

        protected override void WndProc(ref Message m)

        {

            // Hide tabs by trapping the TCM_ADJUSTRECT message

            if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1;

            else base.WndProc(ref m);

        }

    }

Which I used to hide the tabs on a TabControl (DIY 'Wizard' style window).

It just keeps running the Wndproc method over and over (and over) again in an infinite loop. The program does not lock up, it simply skips the rest of my SelectedIndexChanged event.

The combo box is populated with a list of numbers from a database. When the Club object is created, it populates it's private variables with the rest of the info from that record(row). The GetClubInfo() method is supposed to set the strings to the values stored in the Club object. Only...it doesn't get to that line; i set a break on it, and it never broke. I set a break on the declaration of Club, and it stepped into WndProc.

Any ideas as to why this would happen?

#2
reed

reed

    Newbie

  • Members
  • PipPip
  • 15 posts

reed said:

I have a method that looks like this:

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

        {

            string clubname = "", clublocation = "", contactname = "", contactaddress = "", contactlocation = "";

            Club tempclub = new Club(Convert.ToInt32(comboBox1.SelectedText)); //A custom object Club(int somenum)

            tempclub.GetClubInfo(ref clubname, ref clublocation, ref contactname, ref contactaddress, ref contactlocation); //Reads the row where the first column == comboBox1.SelectedText

            ClubNameTextBox.Text = clubname;

            ClubLocationTextbox.Text = clublocation;

            ContactNameTextBox.Text = contactname;

            ContactAddressTextBox.Text = contactaddress;

            ContactLocationTextBox.Text = contactlocation;

        }


    }


The program gets to the line where I declare a Club object, then inexplicably jumps to:

    class TablessControl : TabControl

    {

        protected override void WndProc(ref Message m)

        {

            // Hide tabs by trapping the TCM_ADJUSTRECT message

            if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1;

            else base.WndProc(ref m);

        }

    }

Which I used to hide the tabs on a TabControl (DIY 'Wizard' style window).

It just keeps running the Wndproc method over and over (and over) again in an infinite loop. The program does not lock up, it simply skips the rest of my SelectedIndexChanged event.

The combo box is populated with a list of numbers from a database. When the Club object is created, it populates it's private variables with the rest of the info from that record(row). The GetClubInfo() method is supposed to set the strings to the values stored in the Club object. Only...it doesn't get to that line; i set a break on it, and it never broke. I set a break on the declaration of Club, and it stepped into WndProc.

Any ideas as to why this would happen?


I've done some more testing this morning and it turns out that it gets all the way to:

            command = new OleDbCommand(mycommand, myconnection);

            OleDbDataReader tempread = command.ExecuteReader(); //This line is where it happens

Which is inside the Club.GetClubInfo() method.


It looks like the ExecuteReader() method is jumping me into the WndProc override. The WndProc spins a couple times, then stops and the program waits for me to change the value of the combo box again.

#3
reed

reed

    Newbie

  • Members
  • PipPip
  • 15 posts
Nevermind. I fixed it. It was a datatype mismatch in my SQL statement that didn't throw an exception until I put the code in a different thread. Weird.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users