最后10分,请帮帮忙,关于窗口遍历

wingfootedtiger 2005-05-27 08:33:01
尝试用热键来隐藏或者复原当前所有可见的程序窗口,隐藏没问题,可是无法复原,各位帮我看看下面的代码,哪里出了问题?

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "LMDCustomComponent"
#pragma link "LMDGlobalHotKey"
#pragma resource "*.dfm"


bool it=true;
char buf[256];

struct WINLIST
{
HANDLE hWnd;
char cWinBuf[256];
};

struct WINLIST ListTemp[256];
int WinCount;

BOOL CALLBACK MyEnumProc(HWND hwnd,LPARAM lParam)
{
GetClassName(hwnd,buf,256);
if ((strcmp(buf,"Shell_TrayWnd")!=0)&&IsWindowVisible(hwnd)&&(strcmp(buf,"Progman")!=0))
{
ListTemp[WinCount].hWnd=hwnd;
strcpy(ListTemp[WinCount].cWinBuf,buf);
ShowWindow(hwnd,SW_HIDE);
WinCount++;
}
return true;
}

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::LMDGlobalHotKey1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (it)
{
WinCount=0;
EnumWindows((FARPROC)MyEnumProc,0);
it=false;
}
else
{
for (int i;i<WinCount;i++)
{
ShowWindow(ListTemp[i].hWnd,SW_SHOW);
}
it=true;
}
}
//---------------------------------------------------------------------------
...全文
30 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wingfootedtiger 2005-05-27
  • 打赏
  • 举报
回复
将SW_SHOW改成SW_RESTORE后也不行,我跟踪了一下,似乎没有将隐藏窗口的hwnd正确的放入数组里去,哪位能看出这里面有什么问题么?
NetSpider9804040 2005-05-27
  • 打赏
  • 举报
回复
学习一下!
halibut 2005-05-27
  • 打赏
  • 举报
回复
void __fastcall TForm1::LMDGlobalHotKey1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (it)
{
WinCount=0;
EnumWindows((FARPROC)MyEnumProc,0);
it=false;
}
else
{
for (int i;i<WinCount;i++)
{
ShowWindow(ListTemp[i].hWnd,SW_RESTORE); <----------------
}
it=true;
}
}

13,825

社区成员

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

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