帮助:messbox无法正常显示 [英] Help:messbox can not show normally
问题描述
直到我按下键盘上的"Alt"键,messbox才能显示,我对此感到困惑,
详细信息是:
我在"MainForm"中运行该程序,然后打开另一个窗体,当我需要显示消息框时,它根本无法工作,除非我按"Alt"键?有什么问题?请帮助,谢谢
只需粘贴信息框代码:
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:
//only show when press "Alt"
MessageBox.Show(str, "the result is:");
实际上,我曾经遇到过这个问题,当我用Mainform打开子表单时,我发现它有时会消失,我搜索google,只是在MFC中发现了类似的问题,还有,我想知道这个问题是只是消息框未显示在frontform上,因为我调试了该代码行并确保已执行,但未显示.
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 .
推荐答案
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();
}
}
}
这篇关于帮助:messbox无法正常显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!