function_name
stringlengths
1
80
function
stringlengths
14
10.6k
comment
stringlengths
12
8.02k
normalized_comment
stringlengths
6
6.55k
ShowWindowsNetworkConnectionDialog
bool ShowWindowsNetworkConnectionDialog() { wchar_t exe_name[MAX_SIZE]; void *proc; CombinePathW(exe_name, sizeof(exe_name), MsGetSystem32DirW(), L"control.exe"); proc = Win32RunEx2W(exe_name, L"netconnections", false, NULL); if (proc == NULL) { return false; } Win32CloseProcess(proc); return true; }
/* Show the Windows Network Setup screen*/
Show the Windows Network Setup screen
GetMeiryoFontName
char *GetMeiryoFontName() { if (MsIsWindows7()) { return "Meiryo UI"; } else { if (MsIsVista()) { return "Meiryo"; } else { return "MS UI Gothic"; } } }
/* Get the best Meiryo font name for the current OS*/
Get the best Meiryo font name for the current OS
GetMeiryoFont
HFONT GetMeiryoFont() { return GetMeiryoFontEx(0); }
/* Get the Meiryo font*/
Get the Meiryo font
SetFontMeiryo
void SetFontMeiryo(HWND hWnd, UINT id, UINT font_size) { SetFont(hWnd, id, GetMeiryoFontEx(font_size)); }
/* Set font to Meiryo*/
Set font to Meiryo
SetFontDefault
void SetFontDefault(HWND hWnd, UINT id) { SetFont(hWnd, id, GetDialogDefaultFont()); }
/* Set as the default font*/
Set as the default font
ShowBadProcessWarning
void ShowBadProcessWarning(HWND hWnd, BAD_PROCESS *bad) { wchar_t title[MAX_SIZE]; wchar_t message[8192]; // Validate arguments if (bad == NULL) { return; } UniFormat(title, sizeof(title), _UU("BAD_PROCESS_TITLE"), bad->Title); UniFormat(message, sizeof(message), _UU("BAD_PROCESS_MESSAGE"), bad->Title, bad->Title, bad->Title, bad->Title); OnceMsg(hWnd, title, message, true, ICO_WARNING); }
/* Display the warning messages about bad process*/
Display the warning messages about bad process
CheckBadProcesses
bool CheckBadProcesses(HWND hWnd) { bool ret = true; UINT i; LIST *o; o = MsGetProcessList(); for (i = 0;i < LIST_NUM(o);i++) { MS_PROCESS *p = LIST_DATA(o, i); char exe[MAX_PATH]; BAD_PROCESS *bad; GetFileNameFromFilePath(exe, sizeof(exe), p->ExeFilename); bad = IsBadProcess(exe); if (bad != NULL) { // Display the message because a bad process have been found ret = false; ShowBadProcessWarning(hWnd, bad); } } MsFreeProcessList(o); return ret; }
/* If there is process which is included in incompatible anti-virus software list, show appropriate*/
If there is process which is included in incompatible anti-virus software list, show appropriate
IsBadProcess
BAD_PROCESS *IsBadProcess(char *exe) { UINT i; // Validate arguments if (exe == NULL) { return NULL; } for (i = 0;i < num_bad_processes;i++) { BAD_PROCESS *bad = &bad_processes[i]; if (StrCmpi(bad->ExeName, exe) == 0) { return bad; } } return NULL; }
/* Search whether the specified process name is the appropriate to a bad process*/
Search whether the specified process name is the appropriate to a bad process
OnceMsg
void OnceMsg(HWND hWnd, wchar_t *title, wchar_t *message, bool show_checkbox, UINT icon) { OnceMsgEx(hWnd, title, message, show_checkbox, icon, NULL); }
/* Show a message*/
Show a message
GetOnceMsgHash
UINT GetOnceMsgHash(wchar_t *title, wchar_t *message) { BUF *b; UCHAR hash[SHA1_SIZE]; UINT ret; // Validate arguments if (title == NULL) { title = title_bar; } if (message == NULL) { message = L"message"; } b = NewBuf(); // 2013.5.19: Exclude the title from the hash calculation //WriteBuf(b, title, UniStrSize(title)); WriteBuf(b, message, UniStrSize(message)); Sha1(hash, b->Buf, b->Size); FreeBuf(b); Copy(&ret, hash, sizeof(UINT)); return ret; }
/* Get the message hash*/
Get the message hash
InitVistaWindowTheme
void InitVistaWindowTheme(HWND hWnd) { static HINSTANCE hInstDll = NULL; HRESULT (WINAPI *_SetWindowTheme)(HWND, LPCWSTR, LPCWSTR) = NULL; if (MsIsVista() == false) { return; } if (hInstDll == NULL) { hInstDll = LoadLibraryA("uxtheme.dll"); } if (hInstDll == NULL) { return; } if (_SetWindowTheme == NULL) { _SetWindowTheme = (HRESULT (WINAPI *)(HWND,LPCWSTR,LPCWSTR))GetProcAddress(hInstDll, "SetWindowTheme"); } if (_SetWindowTheme == NULL) { return; } _SetWindowTheme(hWnd, L"explorer", NULL); }
/* Set a theme for Windows Vista*/
Set a theme for Windows Vista
RegistWindowsFirewallAll
void RegistWindowsFirewallAll() { char exedir[MAX_SIZE]; GetExeDir(exedir, sizeof(exedir)); RegistWindowsFirewallAllEx(exedir); }
/* that may be present in the current directory*/
that may be present in the current directory
Win32CnCheckAlreadyExists
bool Win32CnCheckAlreadyExists(bool lock) { char tmp[MAX_SIZE]; HANDLE hMutex; HashInstanceNameLocal(tmp, sizeof(tmp), CLIENT_NOTIFY_SERVICE_INSTANCENAME); hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, tmp); if (hMutex != NULL) { CloseHandle(hMutex); return true; } if (lock == false) { return false; } hMutex = CreateMutex(NULL, FALSE, tmp); if (hMutex == NULL) { CloseHandle(hMutex); return true; } return false; }
/* Check whether the notification service is already running*/
Check whether the notification service is already running
ShowEasterEgg
void ShowEasterEgg(HWND hWnd) { }
/* Show the Easter Egg*/
Show the Easter Egg
FreeKakushi
void FreeKakushi(KAKUSHI *k) { // Validate arguments if (k == NULL) { return; } k->Halt = true; if (k->hWnd != NULL) { PostMessage(k->hWnd, WM_APP + 9821, 0, 0); } WaitThread(k->Thread, INFINITE); ReleaseThread(k->Thread); Free(k); }
/* Release the Kakushi screen */
Release the Kakushi screen
TcpIpDlgUpdate
void TcpIpDlgUpdate(HWND hWnd) { bool ok = true; SetEnable(hWnd, E_RECV, IsChecked(hWnd, R_RECV_ENABLE)); SetEnable(hWnd, S_RECV, IsChecked(hWnd, R_RECV_ENABLE)); SetEnable(hWnd, E_SEND, IsChecked(hWnd, R_SEND_ENABLE)); SetEnable(hWnd, S_SEND, IsChecked(hWnd, R_SEND_ENABLE)); if (IsChecked(hWnd, R_RECV_ENABLE) && GetInt(hWnd, E_RECV) < 1454) { ok = false; } if (IsChecked(hWnd, R_SEND_ENABLE) && GetInt(hWnd, E_SEND) < 1454) { ok = false; } SetEnable(hWnd, IDOK, ok); }
/* Update the dialog*/
Update the dialog
Cpu64DlgProc
UINT Cpu64DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) { switch (msg) { case WM_INITDIALOG: SetIcon(hWnd, 0, ICO_WARNING); DlgFont(hWnd, S_BOLD, 9, true); SetTimer(hWnd, 1, 30 * 1000, NULL); break; case WM_TIMER: switch (wParam) { case 1: KillTimer(hWnd, 1); Command(hWnd, IDOK); break; } break; case WM_COMMAND: switch (wParam) { case IDOK: case IDCANCEL: Close(hWnd); break; } break; case WM_CLOSE: EndDialog(hWnd, 0); break; } return 0; }
/* Warning dialog about 64-bit*/
Warning dialog about 64-bit
ShowCpu64Warning
void ShowCpu64Warning() { Dialog(NULL, D_CPU64_WARNING, Cpu64DlgProc, NULL); }
/* Display a warning dialog about 64-bit*/
Display a warning dialog about 64-bit
GetDialogDefaultFont
HFONT GetDialogDefaultFont() { return GetDialogDefaultFontEx(false); }
/* Get the default font for the dialog box*/
Get the default font for the dialog box
AdjustDialogXY
void AdjustDialogXY(UINT *x, UINT *y, UINT dlgfont_x, UINT dlgfont_y) { if (x != NULL) { *x = (UINT)(((double)*x) * (double)WINUI_DEFAULT_DIALOG_UNIT_X / (double)dlgfont_x); } if (y != NULL) { *y = (UINT)(((double)*y) * (double)WINUI_DEFAULT_DIALOG_UNIT_Y / (double)dlgfont_y); } }
/* Adjust the values of x and y according to the font*/
Adjust the values of x and y according to the font
GetBitmapSize
bool GetBitmapSize(void *bmp, UINT *x, UINT *y) { BITMAP info; // Validate arguments if (bmp == NULL || x == NULL || y == NULL) { return false; } Zero(&info, sizeof(info)); if (GetObject((HANDLE)bmp, sizeof(info), &info) == 0) { return false; } *x = info.bmWidth; *y = info.bmHeight; return true; }
/* Get the size of the bitmap*/
Get the size of the bitmap
NewBitmapList
LIST *NewBitmapList() { LIST *o = NewListFast(NULL); return o; }
/* Initialize the bitmap list*/
Initialize the bitmap list
FreeBitmapList
void FreeBitmapList(LIST *o) { UINT i; // Validate arguments if (o == NULL) { return; } for (i = 0;i < LIST_NUM(o);i++) { HBITMAP *h = LIST_DATA(o, i); DeleteObject(h); } ReleaseList(o); }
/* Release the bitmap list*/
Release the bitmap list
StringDlgInit
void StringDlgInit(HWND hWnd, STRING_DLG *s) { // Validate arguments if (hWnd == NULL || s == NULL) { return; } SetText(hWnd, E_STRING, s->String); SetIcon(hWnd, S_ICON, s->Icon); SetText(hWnd, S_INFO, s->Info); SetText(hWnd, 0, s->Title); FocusEx(hWnd, E_STRING); StringDlgUpdate(hWnd, s); }
/* Initialize the dialog*/
Initialize the dialog
StringDlgUpdate
void StringDlgUpdate(HWND hWnd, STRING_DLG *s) { wchar_t *tmp; bool b = true; // Validate arguments if (hWnd == NULL || s == NULL) { return; } tmp = GetText(hWnd, E_STRING); if (tmp != NULL) { if (s->AllowEmpty == false) { if (UniIsEmptyStr(tmp)) { b = false; } } if (s->AllowUnsafe == false) { if (IsSafeUniStr(tmp) == false) { b = false; } } Free(tmp); } SetEnable(hWnd, IDOK, b); }
/* Update the dialog control*/
Update the dialog control
ShowTextFile
void ShowTextFile(HWND hWnd, char *filename, wchar_t *caption, UINT icon) { BUF *b; wchar_t *str; // Validate arguments if (filename == NULL || caption == NULL) { return; } if (icon == 0) { icon = ICO_NULL; } // Read the text file b = ReadDump(filename); if (b == NULL) { return; } SeekBufToEnd(b); WriteBufChar(b, 0); str = CopyUtfToUni(b->Buf); OnceMsg(hWnd, caption, str, false, icon); FreeBuf(b); Free(str); }
/* Show a text file*/
Show a text file
IpGetFilledNum
UINT IpGetFilledNum(HWND hWnd, UINT id) { UINT ret; DWORD value; // Validate arguments if (hWnd == NULL) { return 0; } ret = SendMsg(hWnd, id, IPM_GETADDRESS, 0, (LPARAM)&value); return ret; }
/* Examine the number of fields that an IP address is entered*/
Examine the number of fields that an IP address is entered
IpIsFilled
bool IpIsFilled(HWND hWnd, UINT id) { UINT ret; DWORD value; // Validate arguments if (hWnd == NULL) { return 0; } ret = SendMsg(hWnd, id, IPM_GETADDRESS, 0, (LPARAM)&value); if (ret != 4) { return false; } else { return true; } }
/* Examine whether an IP address has been entered*/
Examine whether an IP address has been entered
IpGet
UINT IpGet(HWND hWnd, UINT id) { UINT ret; DWORD value; // Validate arguments if (hWnd == NULL) { return 0; } ret = SendMsg(hWnd, id, IPM_GETADDRESS, 0, (LPARAM)&value); if (ret != 4) { return 0; } else { return Endian32((UINT)value); } }
/* Get an IP address*/
Get an IP address
IpSet
void IpSet(HWND hWnd, UINT id, UINT ip) { // Validate arguments if (hWnd == NULL) { return; } SendMsg(hWnd, id, IPM_SETADDRESS, 0, Endian32(ip)); }
/* Set the IP addresses*/
Set the IP addresses
WriteCandidateToReg
void WriteCandidateToReg(UINT root, char *key, LIST *o, char *name) { BUF *b; // Validate arguments if (key == NULL || o == NULL || name == NULL) { return; } b = CandidateToBuf(o); if (b == NULL) { return; } MsRegWriteBin(root, key, name, b->Buf, b->Size); FreeBuf(b); }
/* Write the candidates to the registry*/
Write the candidates to the registry
ReadCandidateFromReg
LIST *ReadCandidateFromReg(UINT root, char *key, char *name) { BUF *b; // Validate arguments if (key == NULL || name == NULL) { return NULL; } b = MsRegReadBin(root, key, name); if (b == NULL) { return NewCandidateList(); } else { LIST *o = BufToCandidate(b); FreeBuf(b); return o; } }
/* Read the candidates from the registry*/
Read the candidates from the registry
RemoteDlgOnOk
void RemoteDlgOnOk(HWND hWnd, WINUI_REMOTE *r) { char *hostname; wchar_t *s; LIST *o; // Validate arguments if (hWnd == NULL || r == NULL) { return; } // Get the entered host name hostname = GetTextA(hWnd, C_HOSTNAME); if (hostname == NULL) { return; } Trim(hostname); // Add a candidate o = r->CandidateList; s = CopyStrToUni(hostname); AddCandidate(o, s, 64); Free(s); // Write the candidates WriteCandidateToReg(REG_CURRENT_USER, r->RegKeyName, o, "RemoteHostCandidate"); FreeCandidateList(o); r->Hostname = hostname; EndDialog(hWnd, true); }
/* Remote connection dialog OK button*/
Remote connection dialog OK button
SearchWindowEnumProc
bool CALLBACK SearchWindowEnumProc(HWND hWnd, LPARAM lParam) { if (hWnd != NULL && lParam != 0) { wchar_t *s = GetText(hWnd, 0); SEARCH_WINDOW_PARAM *p = (SEARCH_WINDOW_PARAM *)lParam; if (s != NULL) { if (UniStrCmpi(p->caption, s) == 0) { p->hWndFound = hWnd; } Free(s); } } return true; }
/* Window Searching procedure*/
Window Searching procedure
SearchWindow
HWND SearchWindow(wchar_t *caption) { SEARCH_WINDOW_PARAM p; // Validate arguments if (caption == NULL) { return NULL; } Zero(&p, sizeof(p)); p.caption = caption; p.hWndFound = NULL; EnumWindows(SearchWindowEnumProc, (LPARAM)&p); return p.hWndFound; }
/* Search for the window*/
Search for the window
AllowFGWindow
void AllowFGWindow(UINT process_id) { if (process_id == 0) { return; } if (OS_IS_WINDOWS_NT(GetOsInfo()->OsType) && GET_KETA(GetOsInfo()->OsType, 100) >= 2) { AllowSetForegroundWindow(process_id); } }
/* Allow for the specified process to become the foreground window*/
Allow for the specified process to become the foreground window
LvRename
void LvRename(HWND hWnd, UINT id, UINT pos) { // Validate arguments if (hWnd == NULL || pos == INFINITE) { return; } ListView_EditLabel(DlgItem(hWnd, id), pos); }
/* Rename the item*/
Rename the item
PrintMenu
void PrintMenu(HWND hWnd, HMENU hMenu) { POINT p; // Validate arguments if (hMenu == NULL || hWnd == NULL) { return; } GetCursorPos(&p); TrackPopupMenu(hMenu, TPM_LEFTALIGN, p.x, p.y, 0, hWnd, NULL); }
/* Show the menu*/
Show the menu
RemoveShortcutKeyStrFromMenu
void RemoveShortcutKeyStrFromMenu(HMENU hMenu) { UINT i, num; // Validate arguments if (hMenu == NULL) { return; } num = GetMenuNum(hMenu); for (i = 0;i < num;i++) { wchar_t *str = GetMenuStr(hMenu, i); if (str != NULL) { UINT j, len; len = UniStrLen(str); for (j = 0;j < len;j++) { if (str[j] == L'\t') { str[j] = 0; } } SetMenuStr(hMenu, i, str); Free(str); } } }
/* Remove a shortcut string from the menu*/
Remove a shortcut string from the menu
GetMenuNum
UINT GetMenuNum(HMENU hMenu) { UINT ret; // Validate arguments if (hMenu == NULL) { return 0; } ret = GetMenuItemCount(hMenu); if (ret == INFINITE) { return 0; } else { return ret; } }
/* Get the number of items in the menu*/
Get the number of items in the menu
SetMenuStr
void SetMenuStr(HMENU hMenu, UINT pos, wchar_t *str) { MENUITEMINFOW info; // Validate arguments if (hMenu == NULL || pos == INFINITE || str == NULL) { return; } if (MsIsNt() == false) { char *s = CopyUniToStr(str); SetMenuStrA(hMenu, pos, s); Free(s); return; } Zero(&info, sizeof(info)); info.cbSize = sizeof(info); info.fMask = MIIM_STRING; info.dwTypeData = str; SetMenuItemInfoW(hMenu, pos, true, &info); }
/* Set the string into the menu*/
Set the string into the menu
GetMenuStr
wchar_t *GetMenuStr(HMENU hMenu, UINT pos) { wchar_t tmp[MAX_SIZE]; // Validate arguments if (hMenu == NULL || pos == INFINITE) { return NULL; } if (MsIsNt() == false) { char *s = GetMenuStrA(hMenu, pos); if (s == NULL) { return NULL; } else { wchar_t *ret = CopyStrToUni(s); Free(s); return ret; } } if (GetMenuStringW(hMenu, pos, tmp, sizeof(tmp), MF_BYPOSITION) == 0) { return NULL; } return UniCopyStr(tmp); }
/* Get a string in the menu*/
Get a string in the menu
SetMenuItemBold
void SetMenuItemBold(HMENU hMenu, UINT pos, bool bold) { MENUITEMINFO info; // Validate arguments if (hMenu == NULL || pos == INFINITE) { return; } Zero(&info, sizeof(info)); info.cbSize = sizeof(info); info.fMask = MIIM_STATE; if (GetMenuItemInfo(hMenu, pos, true, &info) == false) { return; } if (bold) { info.fState |= MFS_DEFAULT; } else { info.fState = info.fState & ~MFS_DEFAULT; } SetMenuItemInfo(hMenu, pos, true, &info); }
/* Bold the menu item*/
Bold the menu item
DeleteMenuItem
void DeleteMenuItem(HMENU hMenu, UINT pos) { // Validate arguments if (hMenu == NULL || pos == INFINITE) { return; } DeleteMenu(hMenu, pos, MF_BYPOSITION); }
/* Remove a menu item*/
Remove a menu item
GetMenuItemPos
UINT GetMenuItemPos(HMENU hMenu, UINT id) { UINT num, i; // Validate arguments if (hMenu == NULL) { return INFINITE; } num = GetMenuItemCount(hMenu); if (num == INFINITE) { return INFINITE; } for (i = 0;i < num;i++) { if (GetMenuItemID(hMenu, i) == id) { return i; } } return INFINITE; }
/* Get the position from the ID in the menu*/
Get the position from the ID in the menu
LoadSubMenu
HMENU LoadSubMenu(UINT menu_id, UINT pos, HMENU *parent_menu) { HMENU h = LoadMenu(hDll, MAKEINTRESOURCE(menu_id)); HMENU ret; if (h == NULL) { return NULL; } ret = GetSubMenu(h, pos); if (parent_menu != NULL) { *parent_menu = h; } return ret; }
/* Get a sub-menu*/
Get a sub-menu
GetUiDll
HINSTANCE GetUiDll() { return hDll; }
/* Get the DLL of the user interface*/
Get the DLL of the user interface
ConnectErrorDlg
bool ConnectErrorDlg(UI_CONNECTERROR_DLG *p) { // Validate arguments if (p == NULL) { return false; } return DialogEx2(NULL, D_CONNECTERROR, ConnectErrorDlgProc, p, true, true); }
/* Show the connection error dialog*/
Show the connection error dialog
CheckCertDlg
void CheckCertDlg(UI_CHECKCERT *p) { // Validate arguments if (p == NULL) { return; } Dialog(NULL, D_CHECKCERT, CheckCertDlgProc, p); }
/* Certificate Check dialog*/
Certificate Check dialog
GetIcon
UINT GetIcon(UINT icon_id) { IMAGELIST_ICON *c, t; t.id = icon_id; c = Search(icon_list, &t); if (c == NULL) { if (icon_id != ICO_NULL) { return GetIcon(ICO_NULL); } else { return INFINITE; } } else { return c->Index; } }
/* Get the image list ID from the icon ID*/
Get the image list ID from the icon ID
LoadIconForImageList
IMAGELIST_ICON *LoadIconForImageList(UINT id) { IMAGELIST_ICON *ret = ZeroMalloc(sizeof(IMAGELIST_ICON)); HICON small_icon, large_icon; ret->id = id; large_icon = LoadLargeIcon(id); if (large_icon == NULL) { large_icon = LoadSmallIcon(id); } small_icon = LoadSmallIcon(id); if (small_icon == NULL) { small_icon = LoadLargeIcon(id); } ret->hSmallImage = small_icon; ret->hLargeImage = large_icon; ret->Index = ImageList_AddIcon(large_image_list, large_icon); ImageList_AddIcon(small_image_list, small_icon); return ret; }
/* Load an icon for the image list*/
Load an icon for the image list
CompareImageListIcon
int CompareImageListIcon(void *p1, void *p2) { IMAGELIST_ICON *c1, *c2; if (p1 == NULL || p2 == NULL) { return 0; } c1 = *(IMAGELIST_ICON **)p1; c2 = *(IMAGELIST_ICON **)p2; if (c1 == NULL || c2 == NULL) { return 0; } if (c1->id > c2->id) { return 1; } else if (c1->id < c2->id) { return -1; } else { return 0; } }
/* Comparison of the image list icons*/
Comparison of the image list icons
InitImageList
void InitImageList() { large_image_list = ImageList_Create(32, 32, ILC_COLOR32 | ILC_MASK, 1, 0); ImageList_SetBkColor(large_image_list, RGB(255, 255, 255)); small_image_list = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 1, 0); ImageList_SetBkColor(small_image_list, RGB(255, 255, 255)); icon_list = NewList(CompareImageListIcon); // Enumeration EnumResourceNames(hDll, RT_GROUP_ICON, EnumResNameProc, 0); }
/* Initialize thr image list*/
Initialize thr image list
EnumResNameProc
BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam) { if (IS_INTRESOURCE(lpszName)) { UINT icon_id = (UINT)lpszName; IMAGELIST_ICON *img = LoadIconForImageList(icon_id); Add(icon_list, img); } return TRUE; }
/* Icon resource enumeration procedure*/
Icon resource enumeration procedure
FreeImageList
void FreeImageList() { UINT i; ImageList_Destroy(large_image_list); ImageList_Destroy(small_image_list); large_image_list = small_image_list = NULL; for (i = 0;i < LIST_NUM(icon_list);i++) { IMAGELIST_ICON *c = LIST_DATA(icon_list, i); Free(c); } ReleaseList(icon_list); icon_list = NULL; }
/* Release the image list*/
Release the image list
LvGetColumnWidth
UINT LvGetColumnWidth(HWND hWnd, UINT id, UINT index) { return (UINT)((double)ListView_GetColumnWidth(DlgItem(hWnd, id), index) / GetTextScalingFactor()); }
/* Get the width of the column of the list view*/
Get the width of the column of the list view
LvInsertColumn
void LvInsertColumn(HWND hWnd, UINT id, UINT index, wchar_t *str, UINT width) { LVCOLUMNW c; // Validate arguments if (hWnd == NULL || str == NULL) { return; } width = (UINT)((double)width * GetTextScalingFactor()); Zero(&c, sizeof(c)); c.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; c.pszText = str; c.iSubItem = index; c.cx = width; SendMsg(hWnd, id, LVM_INSERTCOLUMNW, index, (LPARAM)&c); }
/* Insert the column into the list view*/
Insert the column into the list view
LvReset
void LvReset(HWND hWnd, UINT id) { // Validate arguments if (hWnd == NULL) { return; } ListView_DeleteAllItems(DlgItem(hWnd, id)); }
/* Remove all items from list view*/
Remove all items from list view
LvInitEx
void LvInitEx(HWND hWnd, UINT id, bool no_image) { LvInitEx2(hWnd, id, no_image, false); }
/* Initialize the list view*/
Initialize the list view
LvInsertEnd
void LvInsertEnd(LVB *b, HWND hWnd, UINT id) { LvInsertEndEx(b, hWnd, id, false); }
/* Adding batch complete (high-speed)*/
Adding batch complete (high-speed)
LvGetColumnNum
UINT LvGetColumnNum(HWND hWnd, UINT id) { UINT i; LVCOLUMN c; if (hWnd == NULL) { return 0; } for (i = 0;;i++) { Zero(&c, sizeof(c)); c.mask = LVCF_SUBITEM; if (ListView_GetColumn(DlgItem(hWnd, id), i, &c) == false) { break; } } return i; }
/* Get the number of columns of the list view*/
Get the number of columns of the list view
LvInsertStart
LVB *LvInsertStart() { LVB *b = ZeroMalloc(sizeof(LVB)); b->ItemList = NewListFast(NULL); return b; }
/* Start the item adding batch*/
Start the item adding batch
LvInsert
void LvInsert(HWND hWnd, UINT id, UINT icon, void *param, UINT num_str, ...) { UINT i; va_list va; UINT index = 0; // Validate arguments if (hWnd == NULL) { return; } va_start(va, num_str); for (i = 0;i < num_str;i++) { wchar_t *s = va_arg(va, wchar_t *); if (i == 0) { index = LvInsertItem(hWnd, id, icon, param, s); } else { LvSetItem(hWnd, id, index, i, s); } } va_end(va); }
/* Add items to the list view*/
Add items to the list view
LvAutoSize
void LvAutoSize(HWND hWnd, UINT id) { UINT i; // Validate arguments if (hWnd == NULL) { return; } i = 0; while (true) { if (ListView_SetColumnWidth(DlgItem(hWnd, id), i, LVSCW_AUTOSIZE) == false) { break; } i++; } }
/* Adjust the item size automatically*/
Adjust the item size automatically
LvInsertItem
UINT LvInsertItem(HWND hWnd, UINT id, UINT icon, void *param, wchar_t *str) { return LvInsertItemByImageListId(hWnd, id, GetIcon(icon), param, str); }
/* Add an item*/
Add an item
LvSetItemImageByImageListId
void LvSetItemImageByImageListId(HWND hWnd, UINT id, UINT index, UINT image) { LVITEM t; // Validate arguments if (hWnd == NULL) { return; } Zero(&t, sizeof(t)); t.mask = LVIF_IMAGE; t.iImage = image; t.iItem = index; SendMsg(hWnd, id, LVM_SETITEM, 0, (LPARAM)&t); }
/* Change the image*/
Change the image
LvSetItemParam
void LvSetItemParam(HWND hWnd, UINT id, UINT index, void *param) { LvSetItemParamEx(hWnd, id, index, 0, param); }
/* Set the parameters of the item*/
Set the parameters of the item
LvSetView
void LvSetView(HWND hWnd, UINT id, bool details) { // Validate arguments if (hWnd == NULL) { return; } if (details) { RemoveStyle(hWnd, id, LVS_ICON); SetStyle(hWnd, id, LVS_REPORT); } else { RemoveStyle(hWnd, id, LVS_REPORT); SetStyle(hWnd, id, LVS_ICON); } }
/* Set the view of the list box*/
Set the view of the list box
LvIsSelected
bool LvIsSelected(HWND hWnd, UINT id) { // Validate arguments if (hWnd == NULL) { return false; } if (LvGetSelected(hWnd, id) == INFINITE) { return false; } return true; }
/* Get whether there is currently selected item*/
Get whether there is currently selected item
LvGetFocused
UINT LvGetFocused(HWND hWnd, UINT id) { // Validate arguments if (hWnd == NULL) { return INFINITE; } return ListView_GetNextItem(DlgItem(hWnd, id), -1, LVNI_FOCUSED); }
/* Get the currently selected item*/
Get the currently selected item
LvGetSelectedParam
void *LvGetSelectedParam(HWND hWnd, UINT id) { UINT index; // Validate arguments if (hWnd == NULL) { return NULL; } index = LvGetSelected(hWnd, id); if (index == INFINITE) { return NULL; } return LvGetParam(hWnd, id, index); }
/* Get the parameter of the currently selected item*/
Get the parameter of the currently selected item
LvGetFocusedStr
wchar_t *LvGetFocusedStr(HWND hWnd, UINT id, UINT pos) { UINT i; // Validate arguments if (hWnd == NULL) { return NULL; } i = LvGetFocused(hWnd, id); if (i == INFINITE) { return NULL; } return LvGetStr(hWnd, id, i, pos); }
/* Get a string that is currently selected*/
Get a string that is currently selected
LvGetSelected
UINT LvGetSelected(HWND hWnd, UINT id) { // Validate arguments if (hWnd == NULL) { return INFINITE; } return ListView_GetNextItem(DlgItem(hWnd, id), -1, LVNI_FOCUSED | LVNI_SELECTED); }
/* Get the currently selected item*/
Get the currently selected item
LvGetSelectedStr
wchar_t *LvGetSelectedStr(HWND hWnd, UINT id, UINT pos) { UINT i; // Validate arguments if (hWnd == NULL) { return NULL; } i = LvGetSelected(hWnd, id); if (i == INFINITE) { return NULL; } return LvGetStr(hWnd, id, i, pos); }
/* Get a string that is currently selected*/
Get a string that is currently selected
LvIsMultiMasked
bool LvIsMultiMasked(HWND hWnd, UINT id) { UINT i; // Validate arguments if (hWnd == NULL) { return false; } i = INFINITE; i = LvGetNextMasked(hWnd, id, i); if (i != INFINITE) { if (LvGetNextMasked(hWnd, id, i) != INFINITE) { return true; } } return false; }
/* Get whether two or more items are masked*/
Get whether two or more items are masked
LvIsSingleSelected
bool LvIsSingleSelected(HWND hWnd, UINT id) { return LvIsSelected(hWnd, id) && (LvIsMultiMasked(hWnd, id) == false); }
/* Examine whether just only one item is selected*/
Examine whether just only one item is selected
LvIsMasked
bool LvIsMasked(HWND hWnd, UINT id) { // Validate arguments if (hWnd == NULL) { return false; } if (LvGetNextMasked(hWnd, id, INFINITE) == INFINITE) { return false; } return true; }
/* Get whether there are items that are currently masked*/
Get whether there are items that are currently masked
LvGetNextMasked
UINT LvGetNextMasked(HWND hWnd, UINT id, UINT start) { // Validate arguments if (hWnd == NULL) { return INFINITE; } return ListView_GetNextItem(DlgItem(hWnd, id), start, LVNI_SELECTED); }
/* Get the items that is currently masked*/
Get the items that is currently masked
LvSearchStr
UINT LvSearchStr(HWND hWnd, UINT id, UINT pos, wchar_t *str) { UINT i, num; // Validate arguments if (hWnd == NULL || str == NULL) { return INFINITE; } num = LvNum(hWnd, id); for (i = 0;i < num;i++) { wchar_t *s = LvGetStr(hWnd, id, i, pos); if (s != NULL) { if (UniStrCmpi(s, str) == 0) { Free(s); return i; } else { Free(s); } } } return INFINITE; }
/* Search an item with the specified string*/
Search an item with the specified string
LvSearchParam
UINT LvSearchParam(HWND hWnd, UINT id, void *param) { UINT i, num; // Validate arguments if (hWnd == NULL) { return INFINITE; } num = LvNum(hWnd, id); for (i = 0;i < num;i++) { if (LvGetParam(hWnd, id, i) == param) { return i; } } return INFINITE; }
/* Search for item that have a specified param*/
Search for item that have a specified param
LvNum
UINT LvNum(HWND hWnd, UINT id) { // Validate arguments if (hWnd == NULL) { return 0; } return ListView_GetItemCount(DlgItem(hWnd, id)); }
/* Get the number of items*/
Get the number of items
LvDeleteItem
void LvDeleteItem(HWND hWnd, UINT id, UINT index) { UINT i; // Validate arguments if (hWnd == NULL) { return; } ListView_DeleteItem(DlgItem(hWnd, id), index); i = LvGetSelected(hWnd, id); if (i != INFINITE) { LvSelect(hWnd, id, i); } }
/* Remove an item*/
Remove an item
LvGetParam
void *LvGetParam(HWND hWnd, UINT id, UINT index) { return LvGetParamEx(hWnd, id, index, 0); }
/* Get the data from the item*/
Get the data from the item
LvSetStyle
void LvSetStyle(HWND hWnd, UINT id, UINT style) { // Validate arguments if (hWnd == NULL) { return; } if ((ListView_GetExtendedListViewStyle(DlgItem(hWnd, id)) & style) == 0) { ListView_SetExtendedListViewStyleEx(DlgItem(hWnd, id), style, style); } }
/* Set the style*/
Set the style
LvRemoveStyle
void LvRemoveStyle(HWND hWnd, UINT id, UINT style) { // Validate arguments if (hWnd == NULL) { return; } if ((ListView_GetExtendedListViewStyle(DlgItem(hWnd, id)) & style) != 0) { ListView_SetExtendedListViewStyleEx(DlgItem(hWnd, id), style, 0); } }
/* Remove the style*/
Remove the style
LvSelectAll
void LvSelectAll(HWND hWnd, UINT id) { UINT i, num; // Validate arguments if (hWnd == NULL) { return; } num = LvNum(hWnd, id); for (i = 0;i < num;i++) { ListView_SetItemState(DlgItem(hWnd, id), i, LVIS_SELECTED, LVIS_SELECTED); } }
/* Select all items*/
Select all items
LvSelectByParam
void LvSelectByParam(HWND hWnd, UINT id, void *param) { UINT index; // Validate arguments if (hWnd == NULL || param == NULL) { return; } index = LvSearchParam(hWnd, id, param); if (index == INFINITE) { return; } LvSelect(hWnd, id, index); }
/* Select the item by specifying the parameter*/
Select the item by specifying the parameter
LvSelect
void LvSelect(HWND hWnd, UINT id, UINT index) { // Validate arguments if (hWnd == NULL) { return; } if (index == INFINITE) { UINT i, num; // Deselect all num = LvNum(hWnd, id); for (i = 0;i < num;i++) { ListView_SetItemState(DlgItem(hWnd, id), i, 0, LVIS_SELECTED); } } else { // Select ListView_SetItemState(DlgItem(hWnd, id), index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); ListView_EnsureVisible(DlgItem(hWnd, id), index, true); } }
/* Select an item*/
Select an item
CertDlgUpdate
void CertDlgUpdate(HWND hWnd, CERT_DLG *p) { // Validate arguments if (hWnd == NULL || p == NULL) { return; } if (LvIsSelected(hWnd, L_CERTINFO) == false) { SetText(hWnd, E_DETAIL, L""); } else { UINT i = LvGetSelected(hWnd, L_CERTINFO); wchar_t *tmp = LvGetStr(hWnd, L_CERTINFO, i, 1); SetText(hWnd, E_DETAIL, tmp); Free(tmp); } }
/* Update the display*/
Update the display
CertDlg
void CertDlg(HWND hWnd, X *x, X *issuer_x, bool manager) { CERT_DLG p; // Validate arguments if (x == NULL) { return; } Zero(&p, sizeof(p)); p.x = x; if (CompareX(x, issuer_x) == false) { p.issuer_x = issuer_x; } p.ManagerMode = manager; Dialog(hWnd, D_CERT, CertDlgProc, &p); }
/* Certificate display dialog*/
Certificate display dialog
StatusPrinterWindowThread
void StatusPrinterWindowThread(THREAD *thread, void *param) { STATUS_WINDOW_PARAM *p = (STATUS_WINDOW_PARAM *)param; // Validate arguments if (thread == NULL || param == NULL) { return; } p->Thread = thread; DialogEx2(NULL, D_STATUS, StatusPrinterWindowDlg, p, true, true); Free(p); }
/* Status window control thread*/
Status window control thread
StatusPrinterWindowPrint
void StatusPrinterWindowPrint(STATUS_WINDOW *sw, wchar_t *str) { // Validate arguments if (sw == NULL) { return; } SendMessage(sw->hWnd, WM_APP + 1, 0, (LPARAM)str); }
/* Show a message in the status window*/
Show a message in the status window
StatusPrinterWindowStop
void StatusPrinterWindowStop(STATUS_WINDOW *sw) { // Validate arguments if (sw == NULL) { return; } // Send stop message SendMessage(sw->hWnd, WM_APP + 2, 0, 0); // Wait until the thread terminates WaitThread(sw->Thread, INFINITE); // Release the memory ReleaseThread(sw->Thread); Free(sw); }
/* End and release the status window*/
End and release the status window
StatusPrinterWindowStart
STATUS_WINDOW *StatusPrinterWindowStart(SOCK *s, wchar_t *account_name) { STATUS_WINDOW_PARAM *p; STATUS_WINDOW *sw; THREAD *t; // Validate arguments if (s == NULL || account_name == NULL) { return NULL; } p = ZeroMalloc(sizeof(STATUS_WINDOW_PARAM)); p->Sock = s; UniStrCpy(p->AccountName, sizeof(p->AccountName), account_name); // Create a thread t = NewThread(StatusPrinterWindowThread, p); WaitThreadInit(t); sw = ZeroMalloc(sizeof(STATUS_WINDOW)); sw->hWnd = p->hWnd; sw->Thread = t; return sw; }
/* Initialize the status window*/
Initialize the status window
PasswordDlgProcChange
void PasswordDlgProcChange(HWND hWnd, UI_PASSWORD_DLG *p) { bool b; // Validate arguments if (hWnd == NULL || p == NULL) { return; } b = true; if (IsEmpty(hWnd, E_USERNAME)) { b = false; } SetEnable(hWnd, IDOK, b); p->StartTick = Tick64(); if (p->RetryIntervalSec) { KillTimer(hWnd, 1); Hide(hWnd, P_PROGRESS); Hide(hWnd, S_COUNTDOWN); } }
/* Password input dialog state change*/
Password input dialog state change
CbGetStr
wchar_t *CbGetStr(HWND hWnd, UINT id) { // Validate arguments if (hWnd == NULL) { return NULL; } return GetText(hWnd, id); }
/* Get the string*/
Get the string
CbNum
UINT CbNum(HWND hWnd, UINT id) { // Validate arguments if (hWnd == NULL) { return INFINITE; } return SendMsg(hWnd, id, CB_GETCOUNT, 0, 0); }
/* Get the number of items*/
Get the number of items
CbAddStrA
UINT CbAddStrA(HWND hWnd, UINT id, char *str, UINT data) { wchar_t *tmp; UINT ret; // Validate arguments if (hWnd == NULL || str == NULL) { return INFINITE; } tmp = CopyStrToUni(str); ret = CbAddStr(hWnd, id, tmp, data); Free(tmp); return ret; }
/* Add a string*/
Add a string
CbSelectIndex
void CbSelectIndex(HWND hWnd, UINT id, UINT index) { // Validate arguments if (hWnd == NULL) { return; } SendMsg(hWnd, id, CB_SETCURSEL, index, 0); }
/* Select by specifying the index*/
Select by specifying the index
CbGetData
UINT CbGetData(HWND hWnd, UINT id, UINT index) { // Validate arguments if (hWnd == NULL || index == INFINITE) { return INFINITE; } return SendMsg(hWnd, id, CB_GETITEMDATA, index, 0); }
/* Get the data*/
Get the data