📄 mainfrm.h
字号:
ctrlTransfers.setSort(l->iSubItem, ExListViewCtrl::SORT_FUNC, true, &sortItem);
break;
}
}
return 0;
}
LRESULT onRowsChanged(UINT /*uMsg*/, WPARAM /* wParam */, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
UpdateLayout();
Invalidate();
return 0;
}
LRESULT onSelected(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
HWND hWnd = (HWND)wParam;
if(::IsIconic(hWnd))
::ShowWindow(hWnd, SW_RESTORE);
MDIActivate(hWnd);
return 0;
}
LRESULT onDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
if(trayIcon) {
updateTray(false);
}
bHandled = FALSE;
return 0;
}
LRESULT onKeyDownTransfers(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) {
NMLVKEYDOWN* kd = (NMLVKEYDOWN*) pnmh;
if(kd->wVKey == VK_DELETE) {
removeSelected();
}
return 0;
}
LRESULT onRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
removeSelected();
return 0;
}
void removeSelected() {
int i = -1;
while( (i = ctrlTransfers.GetNextItem(i, LVNI_SELECTED)) != -1) {
ItemInfo* ii = (ItemInfo*)ctrlTransfers.GetItemData(i);
ConnectionManager::getInstance()->removeConnection(ii->user, ii->type == ItemInfo::TYPE_DOWNLOAD);
}
}
LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
return 0;
}
LRESULT OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
PostMessage(WM_CLOSE);
return 0;
}
LRESULT OnViewStatusBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
BOOL bVisible = !::IsWindowVisible(m_hWndStatusBar);
::ShowWindow(m_hWndStatusBar, bVisible ? SW_SHOWNOACTIVATE : SW_HIDE);
UISetCheck(ID_VIEW_STATUS_BAR, bVisible);
UpdateLayout();
return 0;
}
LRESULT OnWindowCascade(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
MDICascade();
return 0;
}
LRESULT OnWindowTile(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
MDITile();
return 0;
}
LRESULT OnWindowArrangeIcons(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
MDIIconArrange();
return 0;
}
LRESULT onWindowMinimizeAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
HWND tmpWnd = GetWindow(GW_CHILD); //getting client window
tmpWnd = ::GetWindow(tmpWnd, GW_CHILD); //getting first child window
while (tmpWnd!=NULL) {
::CloseWindow(tmpWnd);
tmpWnd = ::GetWindow(tmpWnd, GW_HWNDNEXT);
}
return 0;
}
private:
enum {
COLUMN_FIRST,
COLUMN_USER = COLUMN_FIRST,
COLUMN_STATUS,
COLUMN_TIMELEFT,
COLUMN_SPEED,
COLUMN_FILE,
COLUMN_SIZE,
COLUMN_PATH,
COLUMN_LAST
};
class ItemInfo {
public:
typedef HASH_MAP<ConnectionQueueItem*, ItemInfo*, PointerHash<ConnectionQueueItem> > Map;
typedef Map::iterator MapIter;
enum Status {
STATUS_RUNNING,
STATUS_WAITING
};
enum Types {
TYPE_DOWNLOAD,
TYPE_UPLOAD
};
ItemInfo(const User::Ptr& u, Types t = TYPE_DOWNLOAD, Status s = STATUS_WAITING,
int64_t p = 0, int64_t sz = 0) : user(u), type(t), status(s), pos(p), size(sz), speed(0), timeLeft(0) { };
User::Ptr user;
Types type;
Status status;
int64_t pos;
int64_t size;
int64_t speed;
int64_t timeLeft;
};
class StringListInfo;
friend class StringListInfo;
class StringListInfo {
public:
StringListInfo(LPARAM lp = NULL) : lParam(lp) { };
LPARAM lParam;
string columns[COLUMN_LAST];
};
class DirectoryListInfo {
public:
DirectoryListInfo(LPARAM lp = NULL) : lParam(lp) { };
User::Ptr user;
string file;
LPARAM lParam;
};
CriticalSection cs;
ExListViewCtrl ctrlTransfers;
CStatusBarCtrl ctrlStatus;
FlatTabCtrl ctrlTab;
HttpConnection* c;
string versionInfo;
CImageList images;
CImageList largeImages;
ItemInfo::Map transferItems;
CMenu transferMenu;
UINT trayMessage;
/** Is the tray icon visible? */
bool trayIcon;
/** Was the window maximized when minimizing it? */
bool maximized;
u_int32_t lastMove;
u_int32_t lastUpdate;
bool oldshutdown;
bool closing;
int lastUpload;
static int columnIndexes[];
static int columnSizes[];
int statusSizes[7];
CImageList arrows;
HANDLE stopperThread;
HWND createToolbar();
void buildMenu();
void updateTray(bool add = true);
void autoConnect(const FavoriteHubEntry::List& fl);
void startSocket();
MainFrame(const MainFrame&) { dcassert(0); };
// UploadManagerListener
virtual void onAction(UploadManagerListener::Types type, Upload* aUpload) throw();
virtual void onAction(UploadManagerListener::Types type, const Upload::List& ul) throw();
void onUploadStarting(Upload* aUpload);
void onUploadTick(const Upload::List& aUpload);
void onUploadComplete(Upload* aUpload);
// DownloadManagerListener
virtual void onAction(DownloadManagerListener::Types type, Download* aDownload) throw();
virtual void onAction(DownloadManagerListener::Types type, const Download::List& dl) throw();
virtual void onAction(DownloadManagerListener::Types type, Download* aDownload, const string& aReason) throw();
void onDownloadComplete(Download* aDownload);
void onDownloadFailed(Download* aDownload, const string& aReason);
void onDownloadStarting(Download* aDownload);
void onDownloadTick(const Download::List& aDownload);
// ConnectionManagerListener
virtual void onAction(ConnectionManagerListener::Types type, ConnectionQueueItem* aCqi) throw();
virtual void onAction(ConnectionManagerListener::Types type, ConnectionQueueItem* aCqi, const string& aLine) throw();
void onConnectionAdded(ConnectionQueueItem* aCqi);
void onConnectionConnected(ConnectionQueueItem* /*aCqi*/) { };
void onConnectionFailed(ConnectionQueueItem* aCqi, const string& aReason);
void onConnectionRemoved(ConnectionQueueItem* aCqi);
void onConnectionStatus(ConnectionQueueItem* aCqi);
// TimerManagerListener
virtual void onAction(TimerManagerListener::Types type, u_int32_t aTick) throw();
// HttpConnectionListener
virtual void onAction(HttpConnectionListener::Types type, HttpConnection* conn, string const& /*aLine*/) throw();
virtual void onAction(HttpConnectionListener::Types type, HttpConnection* /*conn*/, const BYTE* buf, int len) throw();
void onHttpComplete(HttpConnection* aConn);
// QueueManagerListener
virtual void onAction(QueueManagerListener::Types type, QueueItem* qi) throw();
};
#endif // !defined(AFX_MAINFRM_H__E73C3806_489F_4918_B986_23DCFBD603D5__INCLUDED_)
/**
* @file
* $Id: MainFrm.h,v 1.19 2003/07/15 14:53:12 arnetheduck Exp $
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -