菜鸟问大虾:为何我的show 与hide时灵时不灵?(祥见下)

SearchAlone 2000-09-01 09:56:00
I have defined two function to restore and hide my main form,and the form is located at the tray area,when I right click on the icon of it,it pops up a menu include "hide" and "show" just like that:

void __fastcall TForm1::Show1Click(TObject *Sender)
{ ::SendMessage(Form1->Handle,WM_SYSCOMMAND,SC_RESTORE,0);
}
void __fastcall TForm1::Hide1Click(TObject *Sender)
{::SendMessage(Form1->Handle,WM_SYSCOMMAND,SC_MINIMIZE,0);
}
the first time you run it ,the "show" and "hide" take effect,but when you repeat doing so,the form keep unchange in the desktop!
I wish I can get your help,give you my best thanks!!!
...全文
115 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
billlu 2000-09-05
  • 打赏
  • 举报
回复
正确的方法是:
void __fastcall TMainForm::RestoreClick(TObject *Sender)
{
SendMessage(Application->Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
}
void __fastcall TMainForm::MinClick(TObject *Sender)
{
SendMessage(Application->Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
}
我以前犯过和你一样的错误。
FengSC 2000-09-03
  • 打赏
  • 举报
回复
你用Form1->Handle可能不对,因为Form1和TForm1是完全不一样的东西。你可以把
Form1->Handle改成 Handle试一试。
SearchAlone 2000-09-03
  • 打赏
  • 举报
回复
Thank hhzh426's reply,I know that method,I just want to know what's wrong with my code?I hope I can do it in WinApi.Thank you all the same!!
hhzh426 2000-09-03
  • 打赏
  • 举报
回复
show1click(tobject *sender)
{
form1->visible=true;
}
hide1click(tobject *sender)
{
form1->visible=false;
}

13,822

社区成员

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

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