Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
messbox can not show until i press the "Alt" on the keyboard,i am confused that,
the detail is:
i run the program in "MainForm",then i open the other form ,when i need the messbox to show,it just can not work ,unless i press the "Alt" key? what's problem?please help,thanks
just paste the messbox code:
C#
//only show when press "Alt"
                MessageBox.Show(str, "the result is:");


in fact,i once met that problem ,and i found that it sometimes apears when i opend the subform with the Mainform ,i search the google , just found the similar problem in MFC ,and what's more ,i wonder this problem is just the messagebox not show on frontform,because i debug that code line and sure it is executed,but not show .
Posted
Updated 15-Jun-12 18:34pm
v3
Comments
Sergey Alexandrovich Kryukov 15-Jun-12 23:44pm    
It should not happen. Showing a message box is very simple, so you must be doing something really weird. How about a (short!) code sample? See "Improve question" above.
--SA
Upniwesh 16-Jun-12 0:09am    
are you using windows application or web application???????????
OriginalGriff 16-Jun-12 0:34am    
The OP wrote:
"yes,the windows application, build in C# 2008"
cyh2260629 16-Jun-12 0:34am    
yes,the windows application, build in C# 2008
Sergey Alexandrovich Kryukov 16-Jun-12 1:28am    
No, this code sample shown nothing. How a about a complete sample? You can write a whole application in one short file (don't use designer, for this purpose) and show it. The problem is somewhere else.
--SA

1 solution

C#
    private void menuBeginClass_Click(object sender, EventArgs e)
    {
    if (strConnect != "")
        {
        /*
    *This program is just something like Pictue Recognition
    */
            ClassMethod cmForm = new ClassMethod();
            cmForm.ShowDialog();
            bool nearChose = cmForm.GetMethod();
            int nearSize = cmForm.GetLength();
            int midPixel = (int)((nearSize - 1) / 2);

            strCommandtext = "select * from Sign";
            myConnect = new OleDbConnection(strConnect);

            DataRow myDataRow = null;
            DataTable mydataTable = new DataTable();
            mydataAdapter = new OleDbDataAdapter(strCommandtext, myConnect);
            mydataAdapter.Fill(mydataTable);
            myDataRow = mydataTable.NewRow();
            myCommBuilder = new OleDbCommandBuilder(mydataAdapter);

            try
            {
                //MessageBox.Show("Connect db sucess");
                myConnect.Open();
                ClassNum = mydataTable.Rows.Count;

                if (ClassNum > 0)
                {
                    for (int i = 0; i < mydataTable.Rows.Count; i++)
                    {
                        strRecord[i] = mydataTable.Rows[i]["ClassName"].ToString ();
                      record[i, 0] = Convert.ToInt32(mydataTable.Rows[i]["ColorR"]);
                      record[i, 1] = Convert.ToInt32(mydataTable.Rows[i]["ColorG"]);
                      record[i, 2] = Convert.ToInt32(mydataTable.Rows[i]["ColorB"]);
                 record[i, 3] =Convert.ToInt32(mydataTable.Rows[i]["redThreshold"]);
              record[i, 4] = Convert.ToInt32(mydataTable.Rows[i]["greenThreshold"]);
               record[i, 5] = Convert.ToInt32(mydataTable.Rows[i]["blueThreshold"]);
                    }
                }

                Bitmap dstBmp = countSign(record,midPixel,nearChose);

                string str = "Classify finish!:" + "\t\n";
                for (int i = 0; i < ClassNum; i++)
                {
                    str += strRecord[i] + ": " + countClass[i].ToString() + "\t\n";
                }
                /*
                 *Here is the problem,only show when press "Alt"
        */
        MessageBox.Show(str,"the result is:");

                saveFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Tif Image|*.tif";
                saveFileDialog1.Title = "Save an Image File";
                saveFileDialog1.ShowDialog();

                // If the file name is not an empty string open it for saving.
                if (saveFileDialog1.FileName != "")
                {
                    string FileName = saveFileDialog1.FileName;
                    switch (saveFileDialog1.FilterIndex)
                    {
                        case 0:
                            dstBmp.Save(FileName, ImageFormat.Jpeg);
                            break;
                        case 1:
                            dstBmp.Save(FileName, ImageFormat.Bmp );
                            break;
                        case 2:
                            dstBmp.Save(FileName, ImageFormat.Tiff) ;
                            break;
                        default :
                            dstBmp.Save(FileName, ImageFormat.Jpeg);
                            break;
                    }
                }

            }
            catch (OleDbException exp)
            {
                MessageBox.Show(exp.ToString());
                Application.Exit();
            }
            finally
            {
                //close connect
                myConnect.Close();
                myConnect.Dispose();
                myCommBuilder.Dispose();

                if (mydataAdapter != null)
                    mydataAdapter.Dispose();
            }
        }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900