📄 simple.c
字号:
/*
TaskCE - A simple CE Task Manager
TARGET OS: CE 2.x
TARGET FORM FACTOR: PPC, HPC
DESCRIPTION:
A simple Task Manager style application, ideal for PPC, but
also runs well on HPC units.
*/
#include <windows.h>
#include <tchar.h> //if you're using strings of any kind
#include "resource.h" //auto-created header courtesy of MS Dev Studio
BOOL CALLBACK DlgProc (HWND, UINT, WPARAM, LPARAM) ;
//-------------------------------------------------------------------
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int cmdShow)
{
DialogBox ((HANDLE) hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)DlgProc);
return 0 ;
}
//-------------------------------------------------------------------
BOOL CALLBACK DlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
SendMessage(hwnd, WM_USER + 200, 0, 0);
return TRUE;
}
case WM_CTLCOLORDLG:
{
//SetBkColor((HDC)wParam, LTGRAY_BRUSH);
SendMessage(hwnd, WM_USER + 200, 0, 0);
return FALSE;
}
case WM_USER + 200:
{
HWND hWndAWindow;
TCHAR szBuff[MAX_PATH];
HWND hwndCtrl = GetDlgItem (hwnd, IDC_LISTTASKS);
INT iSelfCount; //how many instances of this program are there?
//always clear out list box first!!
SendMessage(hwndCtrl, LB_RESETCONTENT, 0, 0);
hWndAWindow = GetWindow(hwnd, GW_HWNDFIRST);
while (hWndAWindow != 0)
{
if ((hWndAWindow != hwnd) && IsWindowVisible(hWndAWindow) &&
(GetWindow(hWndAWindow, GW_OWNER) == 0) &&
(GetWindowText(hWndAWindow, szBuff, MAX_PATH) != 0) &&
(lstrcmpi (szBuff, TEXT("Desktop")) != 0))
SendMessage(hwndCtrl, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) szBuff);
hWndAWindow = GetWindow(hWndAWindow, GW_HWNDNEXT);
}
return TRUE ;
}
case WM_CLOSE:
case WM_HIBERNATE:
{
EndDialog(hwnd, 0);
return TRUE;
}
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDCANCEL:
case IDOK:
{
EndDialog(hwnd, 0);
return TRUE;
}
case IDC_ENDTASK:
case IDC_SWITCHTO:
{
//first, make sure the window still exists by trying to find it.
int cbCnt;
TCHAR szBuff[MAX_PATH];
HWND hWndAWindow;
cbCnt = (int)SendMessage(GetDlgItem(hwnd, IDC_LISTTASKS), LB_GETCURSEL, 0, 0L);
if ((cbCnt < 0))
{
MessageBox(hwnd, TEXT("You must first select a task."), TEXT("Error: No task"), MB_OK | MB_ICONSTOP);
return TRUE;
}
//SendMessage(hwnd, LB_GETSELITEMS, cbCnt, (LPARAM)(int FAR *)xSel);
SendMessage(GetDlgItem(hwnd, IDC_LISTTASKS),
LB_GETTEXT,
(WPARAM)SendMessage(GetDlgItem(hwnd, IDC_LISTTASKS), LB_GETCURSEL, 0, 0L),
(LPARAM)(LPSTR)szBuff);
if (FindWindow(NULL, szBuff) != NULL) //the window still exists!
{
hWndAWindow = FindWindow(NULL, szBuff);
SetForegroundWindow(hWndAWindow);
if (LOWORD(wParam) == IDC_ENDTASK)
{
SendMessage(hWndAWindow, WM_CLOSE, 0, 0);
}
SendMessage(hwnd, WM_CLOSE, 0, 0);
return TRUE;
}
else //if you didn't find the app, it's time to refresh yourself
SendMessage(hwnd, WM_USER + 200, 0, 0);
break ;
}
}
}
default:
return FALSE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -