HI,All!来继续指导一下做任务栏
我是一菜鸟原来的帖子中想要创建任务栏,已经找到了有CE界面调用任务栏的方法。对于没CE界面的我在做简单的画一个任务栏的操作,
采用如下步骤:
1:设置DLG作为任务栏固定在屏幕底端(已完成)
hDlgTaskBar = CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_TASKDLG), g_hMain, TASKProc);MoveWindow(hDlgTaskBar, 0, cy-20, cx, 20, TRUE);ShowWindow(hDlgTaskBar, SW_SHOW); CheckMenuItem(hMenu, IDM_TOOL_TASKBAR, MF_CHECKED);
//定义了一个简单结构体struct { HWND g_hButton; HMENU ID_Button; TCHAR *Text_Button;} TASKBUTTON[50];//对TASKProc的响应BOOL CALLBACK TASKProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { hDlgTaskBar = hWnd; g_iWndCount = 0; //记录窗口数量 int i; switch (message) { case WM_COMMAND: { wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) case BN_CLICKED: { //?这里的i值如何得到,怎么给szSel赋值 TCHAR * szSel = TASKBUTTON[i].Text_Button; HWND hSel = FindWindow(NULL, szSel); BOOL y = SetForegroundWindow(hSel); ShowWindow(hSel, SW_SHOW); } break; } break; case WM_INITDIALOG: if (GetParent(g_hMain) ==NULL) { //??想要得到当前所有窗口数量和窗口的名称,可是却只得到了一个窗口的名称 WINDOWINFO info; memset(&info, 0, sizeof(WINDOWINFO)); GetWindowAttributes(g_hMain, info); if (_tcscmp(info.szWindowText, _T("")) != NULL) { TASKBUTTON[g_iWndCount].Text_Button = info.szWindowText; g_iWndCount ++; } //设定button大小 int cx = GetSystemMetrics(SM_CXSCREEN) - 1; int cy = GetSystemMetrics(SM_CYSCREEN) - 1; int wide = ((cx - 1) - g_iWndCount * 2) / g_iWndCount; int high = 20 - 1; //创建各个Button for (i = 0 ; i < g_iWndCount; i++) { //??每个Button对应相应的ButtonProc事件 TASKBUTTON[i].g_hButton = CreateWindow( TEXT("button"),TASKBUTTON[i].Text_Button , WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, i*wide + 2 , 1 , wide, high ,hDlgTaskBar, (HMENU)TASKBUTTON[i].ID_Button, g_hInst, NULL); ShowWindow(TASKBUTTON[i].g_hButton, SW_SHOW); } } else { MessageBox(hWnd, _T("There is no programe here!"), _T("MioExplore"), MB_OKCANCEL| MB_ICONWARNING); } break; } return 0;}