📄 gui.c
字号:
case WM_DESTROY: break; } return (FALSE);}LRESULT CALLBACK FromFileReadDLG(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hWnd; switch (message) { case WM_INITDIALOG: { int fd,len; unsigned char *buffer = '\0', *string = '\0'; EDITSTREAM edit; StreamIO *stream = malloc(sizeof(StreamIO)); unsigned char szText[256]; struct stat sb; HWND hWnd = GetDlgItem(hDlg, IDC_TEXT), hTip; wsprintf(szText, "UnrealIRCd Viewer - %s", (unsigned char *)lParam); SetWindowText(hDlg, szText); lpfnOldWndProc = (FARPROC)SetWindowLong(hWnd, GWL_WNDPROC, (DWORD)RESubClassFunc); if ((fd = open((unsigned char *)lParam, _O_RDONLY|_O_BINARY)) != -1) { fstat(fd,&sb); /* Only allocate the amount we need */ buffer = malloc(sb.st_size+1); buffer[0] = 0; len = read(fd, buffer, sb.st_size); buffer[len] = 0; len = CountRTFSize(buffer)+1; string = malloc(len); bzero(string,len); IRCToRTF(buffer,string); RTFBuf = string; len--; stream->size = &len; stream->buffer = &RTFBuf; edit.dwCookie = (UINT)stream; edit.pfnCallback = SplitIt; SendMessage(hWnd, EM_EXLIMITTEXT, 0, (LPARAM)0x7FFFFFFF); SendMessage(hWnd, EM_STREAMIN, (WPARAM)SF_RTF|SFF_PLAINRTF, (LPARAM)&edit); close(fd); RTFBuf = NULL; free(buffer); free(string); free(stream); } return TRUE; } case WM_COMMAND: { hWnd = GetDlgItem(hDlg, IDC_TEXT); if (LOWORD(wParam) == IDOK) return EndDialog(hDlg, TRUE); if (LOWORD(wParam) == IDM_COPY) { SendMessage(hWnd, WM_COPY, 0, 0); return 0; } if (LOWORD(wParam) == IDM_SELECTALL) { SendMessage(hWnd, EM_SETSEL, 0, -1); return 0; } if (LOWORD(wParam) == IDM_PASTE) { SendMessage(hWnd, WM_PASTE, 0, 0); return 0; } if (LOWORD(wParam) == IDM_CUT) { SendMessage(hWnd, WM_CUT, 0, 0); return 0; } if (LOWORD(wParam) == IDM_UNDO) { SendMessage(hWnd, EM_UNDO, 0, 0); return 0; } if (LOWORD(wParam) == IDM_DELETE) { SendMessage(hWnd, WM_CLEAR, 0, 0); return 0; } break; } case WM_CLOSE: EndDialog(hDlg, TRUE); break; case WM_DESTROY: break; } return FALSE;}LRESULT CALLBACK HelpDLG(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static HFONT hFont; static HCURSOR hCursor; switch (message) { case WM_INITDIALOG: hCursor = LoadCursor(hInst, MAKEINTRESOURCE(CUR_HAND)); hFont = CreateFont(8,0,0,0,0,0,1,0,ANSI_CHARSET,0,0,PROOF_QUALITY,0,"MS Sans Serif"); SendMessage(GetDlgItem(hDlg, IDC_EMAIL), WM_SETFONT, (WPARAM)hFont,TRUE); SendMessage(GetDlgItem(hDlg, IDC_URL), WM_SETFONT, (WPARAM)hFont,TRUE); lpfnOldWndProc = (FARPROC)SetWindowLong(GetDlgItem(hDlg, IDC_EMAIL), GWL_WNDPROC, (DWORD)LinkSubClassFunc); SetWindowLong(GetDlgItem(hDlg, IDC_URL), GWL_WNDPROC, (DWORD)LinkSubClassFunc); return TRUE; case WM_DRAWITEM: { LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; unsigned char text[500]; COLORREF oldtext; RECT focus; GetWindowText(lpdis->hwndItem, text, 500); if (wParam == IDC_URL || IDC_EMAIL) { FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_3DFACE)); oldtext = SetTextColor(lpdis->hDC, RGB(0,0,255)); DrawText(lpdis->hDC, text, strlen(text), &lpdis->rcItem, DT_CENTER|DT_VCENTER); SetTextColor(lpdis->hDC, oldtext); if (lpdis->itemState & ODS_FOCUS) { CopyRect(&focus, &lpdis->rcItem); focus.left += 2; focus.right -= 2; focus.top += 1; focus.bottom -= 1; DrawFocusRect(lpdis->hDC, &focus); } return TRUE; } } case WM_COMMAND: if (LOWORD(wParam) == IDOK) EndDialog(hDlg, TRUE); if (HIWORD(wParam) == BN_DBLCLK) { if (LOWORD(wParam) == IDC_URL) ShellExecute(NULL, "open", "http://www.unrealircd.com", NULL, NULL, SW_MAXIMIZE); else if (LOWORD(wParam) == IDC_EMAIL) ShellExecute(NULL, "open", "mailto:unreal-users@lists.sourceforge.net", NULL, NULL, SW_MAXIMIZE); EndDialog(hDlg, TRUE); return 0; } break; case WM_CLOSE: EndDialog(hDlg, TRUE); break; case WM_DESTROY: DeleteObject(hFont); break; } return FALSE;}LRESULT CALLBACK StatusDLG(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: { hwTreeView = GetDlgItem(hDlg, IDC_TREE); win_map(&me, hwTreeView, 0); SetDlgItemInt(hDlg, IDC_CLIENTS, IRCstats.clients, FALSE); SetDlgItemInt(hDlg, IDC_SERVERS, IRCstats.servers, FALSE); SetDlgItemInt(hDlg, IDC_INVISO, IRCstats.invisible, FALSE); SetDlgItemInt(hDlg, IDC_UNKNOWN, IRCstats.unknown, FALSE); SetDlgItemInt(hDlg, IDC_OPERS, IRCstats.operators, FALSE); SetDlgItemInt(hDlg, IDC_CHANNELS, IRCstats.channels, FALSE); if (IRCstats.clients > IRCstats.global_max) IRCstats.global_max = IRCstats.clients; if (IRCstats.me_clients > IRCstats.me_max) IRCstats.me_max = IRCstats.me_clients; SetDlgItemInt(hDlg, IDC_MAXCLIENTS, IRCstats.global_max, FALSE); SetDlgItemInt(hDlg, IDC_LCLIENTS, IRCstats.me_clients, FALSE); SetDlgItemInt(hDlg, IDC_LSERVERS, IRCstats.me_servers, FALSE); SetDlgItemInt(hDlg, IDC_LMAXCLIENTS, IRCstats.me_max, FALSE); SetTimer(hDlg, 1, 5000, NULL); return TRUE; } case WM_CLOSE: DestroyWindow(hDlg); return TRUE; case WM_TIMER: TreeView_DeleteAllItems(hwTreeView); win_map(&me, hwTreeView, 1); SetDlgItemInt(hDlg, IDC_CLIENTS, IRCstats.clients, FALSE); SetDlgItemInt(hDlg, IDC_SERVERS, IRCstats.servers, FALSE); SetDlgItemInt(hDlg, IDC_INVISO, IRCstats.invisible, FALSE); SetDlgItemInt(hDlg, IDC_INVISO, IRCstats.invisible, FALSE); SetDlgItemInt(hDlg, IDC_UNKNOWN, IRCstats.unknown, FALSE); SetDlgItemInt(hDlg, IDC_OPERS, IRCstats.operators, FALSE); SetDlgItemInt(hDlg, IDC_CHANNELS, IRCstats.channels, FALSE); if (IRCstats.clients > IRCstats.global_max) IRCstats.global_max = IRCstats.clients; if (IRCstats.me_clients > IRCstats.me_max) IRCstats.me_max = IRCstats.me_clients; SetDlgItemInt(hDlg, IDC_MAXCLIENTS, IRCstats.global_max, FALSE); SetDlgItemInt(hDlg, IDC_LCLIENTS, IRCstats.me_clients, FALSE); SetDlgItemInt(hDlg, IDC_LSERVERS, IRCstats.me_servers, FALSE); SetDlgItemInt(hDlg, IDC_LMAXCLIENTS, IRCstats.me_max, FALSE); SetTimer(hDlg, 1, 5000, NULL); return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK) { DestroyWindow(hDlg); return TRUE; } break; } return FALSE;}/* This was made by DrBin but I cleaned it up a bunch to make it work better */HTREEITEM AddItemToTree(HWND hWnd, LPSTR lpszItem, int nLevel, short remap){ TVITEM tvi; TVINSERTSTRUCT tvins; static HTREEITEM hPrev = (HTREEITEM)TVI_FIRST; static HTREEITEM hPrevLev[10] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; HTREEITEM hti; if (remap) { hPrev = (HTREEITEM)TVI_FIRST; memset(hPrevLev, 0, sizeof(HTREEITEM)*10); } tvi.mask = TVIF_TEXT|TVIF_PARAM; tvi.pszText = lpszItem; tvi.cchTextMax = lstrlen(lpszItem); tvi.lParam = (LPARAM)nLevel; tvins.item = tvi; tvins.hInsertAfter = hPrev; if (nLevel == 1) tvins.hParent = TVI_ROOT; else tvins.hParent = hPrevLev[nLevel-1]; hPrev = (HTREEITEM)SendMessage(hWnd, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT) &tvins); hPrevLev[nLevel] = hPrev; TreeView_EnsureVisible(hWnd,hPrev); if (nLevel > 1) { hti = TreeView_GetParent(hWnd, hPrev); tvi.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE; tvi.hItem = hti; TreeView_SetItem(hWnd, &tvi); } return hPrev; }/* * Now used to create list of servers for server list tree view -- David Flynn * Recoded by codemastr to be faster. * I removed the Potvin credit because it no longer uses any original code and I don't * even think Potvin actually made the original code */void win_map(aClient *server, HWND hwTreeView, short remap){ aClient *acptr; Link *lp; AddItemToTree(hwTreeView,server->name,server->hopcount+1, remap); for (lp = Servers; lp; lp = lp->next) { acptr = lp->value.cptr; if (acptr->srvptr != server) continue; win_map(acptr, hwTreeView, 0); }}/* ugly stuff, but hey it works -- codemastr */void win_log(unsigned char *format, ...) { va_list ap; unsigned char buf[2048]; unsigned char *buf2; va_start(ap, format); ircvsprintf(buf, format, ap); if (!IsService) { strcat(buf, "\r\n"); if (errors) { buf2 = MyMalloc(strlen(errors)+strlen(buf)+1); sprintf(buf2, "%s%s",errors,buf); MyFree(errors); errors = NULL; } else { buf2 = MyMalloc(strlen(buf)+1); sprintf(buf2, "%s",buf); } errors = buf2; } else { FILE *fd = fopen("service.log", "a"); if (fd) { fprintf(fd, "%s\n", buf); fclose(fd); }#ifdef _DEBUG else { OutputDebugString(buf); }#endif } va_end(ap);}void win_error() { if (errors && !IsService) DialogBox(hInst, "ConfigError", hwIRCDWnd, (DLGPROC)ConfigErrorDLG);}LRESULT CALLBACK ConfigErrorDLG(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: MessageBeep(MB_ICONEXCLAMATION); SetDlgItemText(hDlg, IDC_CONFIGERROR, errors); MyFree(errors); errors = NULL; return (TRUE); case WM_COMMAND: if (LOWORD(wParam) == IDOK) EndDialog(hDlg, TRUE); break; case WM_CLOSE: EndDialog(hDlg, TRUE); break; case WM_DESTROY: break; } return (FALSE);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -