为什么程序有时候没有反应?

ravehe 2005-10-26 08:32:49
写了个多显示器应用程序,窗口的配置信息写在INI文件中,程序可以进行窗口显示位置的设置,但是不知道为什么在设置的时候,程序经常没有反应,好像死掉一样。。。。。。
代码如下:







void TForm1::MultiMonitor(HWND Handle,String DClass,int Value,int Top,int Left,String opertype)
{
String Filename;
int Index,Top1,Left1,MoniCount;
int result;
Filename=ExtractFileDir(Application->ExeName)+"\\MultiMonitor.ini";
TIniFile *ini = new TIniFile(Filename);
//显示器数目
MoniCount=Screen->MonitorCount;
//保存窗口设置信息
if(opertype=="W")
{
if((Value>0)&&(Value<=MoniCount))
{
Left1 = Left - Monitor->Left;//本窗口调用此行没有问题,其他窗口调用出现地址错
Top1 = Top - Monitor->Top;//错误同上

Left1 = Left + Screen->Monitors[Value - 1]->Left;
Top1 = Top + Screen->Monitors[Value - 1]->Top;
try
{
ini->WriteString(DClass,"MonitorIndex",Value);
ini->WriteString(DClass,"Top",Top1);
ini->WriteString(DClass,"Left",Left1);
Application->MessageBoxA("ok","success" MB_OK);
SetWindowPos(Handle,HWND_TOPMOST,Top1,Left1,0,0,SWP_NOSIZE);

}
catch(...)
{
Application->MessageBoxA("error!","fail",MB_OK+16);
}
}
delete ini;
}
...全文
184 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ravehe 2005-11-07
  • 打赏
  • 举报
回复
顶,看来还是靠自己才那解决问题
caizhen2000_82 2005-10-28
  • 打赏
  • 举报
回复
Application->MessageBoxA("ok","success" MB_OK);少一个逗号。
ravehe 2005-10-27
  • 打赏
  • 举报
回复
原来是 Application->MessageBoxA作怪,好奇怪,MessageBoxA 窗口明明已经弹出,但是却不知道显示在哪里,所以造成程序假死而没有反应的现象,请问该如何解决呢?
ravehe 2005-10-27
  • 打赏
  • 举报
回复
ravehe 2005-10-26
  • 打赏
  • 举报
回复
如果写成单独的一个类进行调用的话,Monitor有有没有办法使用,不知道怎么处理好

13,871

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧