?? senddlg.cpp
字號:
if (strcmp(selectGroup, hostArray[lvi.iItem]->groupName) == 0 && IsSameHost(&hostArray[lvi.iItem]->hostSub, msgMng->GetLocalHost()) != TRUE) {
lvi.stateMask = lvi.state = LVIS_FOCUSED|LVIS_SELECTED;
SendDlgItemMessage(HOST_LIST, LVM_SETITEMSTATE, lvi.iItem, (LPARAM)&lvi);
if (ensure == FALSE) {
ensure = TRUE;
SendDlgItemMessage(HOST_LIST, LVM_ENSUREVISIBLE, lvi.iItem, 0);
SendDlgItemMessage(HOST_LIST, LVM_SETSELECTIONMARK, 0, lvi.iItem);
}
}
else if (ctl_on == FALSE) {
lvi.stateMask = LVIS_SELECTED;
lvi.state = 0;
SendDlgItemMessage(HOST_LIST, LVM_SETITEMSTATE, lvi.iItem, (LPARAM)&lvi);
}
}
}
return TRUE;
}
return FALSE;
}
void TSendDlg::GetOrder(void)
{
int order[MAX_SENDWIDTH], orderCnt=0;
if (SendDlgItemMessage(HOST_LIST, LVM_GETCOLUMNORDERARRAY, maxItems, (LPARAM)order) == FALSE) {
MessageBox(COMCTL_MSGSTR, CANTGETORDER_MSGSTR);
return;
}
for (int cnt=0; cnt < MAX_SENDWIDTH; cnt++) {
if (GetItem(ColumnItems, FullOrder[cnt]))
FullOrder[cnt] = items[order[orderCnt++]];
}
memcpy(cfg->SendOrder, FullOrder, sizeof(FullOrder));
}
/*
WM_SYSCOMMAND CallBack
*/
BOOL TSendDlg::EvSysCommand(WPARAM uCmdType, POINTS pos)
{
switch (uCmdType)
{
case MENU_SAVEPOS:
case MENU_SAVESIZE:
case MENU_SAVECOLUMN:
case MENU_FINDDLG:
case MENU_EDITFONT: case MENU_LISTFONT:
case MENU_DEFAULTFONT:
case MENU_NORMALSIZE:
case MENU_MEMBERDISP:
case MENU_FILEADD:
case MENU_FOLDERADD:
return EvCommand(0, uCmdType, 0);
}
return FALSE;
}
/*
MenuInit Event CallBack
*/
BOOL TSendDlg::EventInitMenu(UINT uMsg, HMENU hMenu, UINT uPos, BOOL fSystemMenu)
{
switch (uMsg)
{
case WM_INITMENU:
{
::ModifyMenu(hMenu, MENU_SAVEPOS, MF_BYCOMMAND|(cfg->SendSavePos ? MF_CHECKED : 0), MENU_SAVEPOS, SAVEPOS_MSGSTR);
}
return TRUE;
}
return FALSE;
}
/*
Color Event CallBack
*/
BOOL TSendDlg::EventCtlColor(UINT uMsg, HDC hDcCtl, HWND hWndCtl, HBRUSH *result)
{
#if 0
COLORREF bkref = 0x0000ff;
COLORREF foreref = 0x00ff00;
COLORREF dlgref = 0xff0000;
COLORREF statref = 0xffff00;
switch (uMsg) {
case WM_CTLCOLORDLG: // dlg 抧
{ static HBRUSH hb; if (hb == NULL) hb = ::CreateSolidBrush(dlgref); *result = hb; }
// SetTextColor(hDcCtl, foreref);
// SetBkColor(hDcCtl, dlgref);
break;
case WM_CTLCOLOREDIT: // edit 抧
{ static HBRUSH hb; if (hb == NULL) hb = ::CreateSolidBrush(bkref); *result = hb; }
SetTextColor(hDcCtl, foreref);
SetBkColor(hDcCtl, bkref);
break;
case WM_CTLCOLORSTATIC: // static control & check box 抧
if (GetDlgItem(SEPARATE_STATIC) == hWndCtl) { static HBRUSH hb; if (hb == NULL) hb = ::CreateSolidBrush(bkref); *result = hb; } else { static HBRUSH hb; if (hb == NULL) hb = ::CreateSolidBrush(dlgref); *result = hb; }
SetTextColor(hDcCtl, statref);
SetBkColor(hDcCtl, dlgref);
break;
}
return TRUE;
#else
return FALSE;
#endif
}
/*
MenuSelect Event CallBack
*/
BOOL TSendDlg::EvMenuSelect(UINT uItem, UINT fuFlag, HMENU hMenu)
{
if (uItem >= MENU_GROUP_START && uItem < MENU_GROUP_START + (UINT)memberCnt)
::GetMenuString(hMenu, uItem, selectGroup, sizeof(selectGroup), MF_BYCOMMAND);
return FALSE;
}
/*
DropFiles Event CallBack
*/
BOOL TSendDlg::EvDropFiles(HDROP hDrop)
{
char buf[MAX_BUF];
int max = ::DragQueryFile(hDrop, ~0UL, 0, 0), cnt;
if (shareInfo == NULL)
shareInfo = shareMng->CreateShare(packetNo);
for (cnt=0; cnt < max; cnt++)
{
if (::DragQueryFile(hDrop, cnt, buf, sizeof(buf)) <= 0)
break;
shareMng->AddFileShare(shareInfo, buf);
}
::DragFinish(hDrop);
if (shareInfo->fileCnt == 0)
return FALSE;
SetFileButton(this, FILE_BUTTON, shareInfo);
EvSize(SIZE_RESTORED, 0, 0);
return TRUE;
}
char *TSendDlg::GetListItemStr(Host *host, int item)
{
switch (items[item]) {
case SW_NICKNAME:
return *host->nickName ? host->nickName : host->hostSub.userName;
case SW_USER:
return host->hostSub.userName;
case SW_ABSENCE:
return (host->hostStatus & IPMSG_ABSENCEOPT) ? "*" : "";
case SW_PRIORITY:
static char buf[4];
if (host->priority == DEFAULT_PRIORITY) buf[0] = '-', buf[1] = 0;
else if (host->priority <= 0) buf[0] = 'X', buf[1] = 0;
else wsprintf(buf, "%d", cfg->PriorityMax - (host->priority - DEFAULT_PRIORITY) / PRIORITY_OFFSET);
return buf;
case SW_GROUP:
return host->groupName;
case SW_HOST:
return host->hostSub.hostName;
case SW_IPADDR:
return inet_ntoa(*(LPIN_ADDR)&host->hostSub.addr);
}
return NULL;
}
/*
Notify Event CallBack
*/
BOOL TSendDlg::EvNotify(UINT ctlID, NMHDR *pNmHdr)
{
if (pNmHdr->code == LVN_COLUMNCLICK) {
NM_LISTVIEW *nmLv = (NM_LISTVIEW *)pNmHdr;
if (sortItem == items[nmLv->iSubItem]) {
if ((sortRev = !sortRev) == FALSE && sortItem == 0)
sortItem = -1;
}
else {
sortItem = items[nmLv->iSubItem];
sortRev = FALSE;
}
DelAllHost();
for (int cnt=0; cnt < hosts->HostCnt(); cnt++)
AddHost(hosts->GetHost(cnt));
return TRUE;
}
if (pNmHdr->code == LVN_GETDISPINFO) {
LV_DISPINFO *dispInfo = (LV_DISPINFO *)pNmHdr;
Host *host = (Host *)dispInfo->item.lParam;
dispInfo->item.pszText = GetListItemStr(host, dispInfo->item.iSubItem);
return TRUE;
}
return FALSE;
}
/*
WM_MOUSEMOVE CallBack
*/
BOOL TSendDlg::EvMouseMove(UINT fwKeys, POINTS pos)
{
if ((fwKeys & MK_LBUTTON) && captureMode)
{
if (lastYPos == (int)pos.y)
return TRUE;
lastYPos = (int)pos.y;
RECT tmpRect;
int min_y = (5 * (item[refresh_item].y + item[refresh_item].cy) - 3 * item[separate_item].y) / 2;
if (pos.y < min_y)
pos.y = min_y;
currentMidYdiff += (int)(short)(pos.y - dividYPos);
EvSize(SIZE_RESTORED, 0, 0);
GetWindowRect(&tmpRect);
MoveWindow(tmpRect.left, tmpRect.top, tmpRect.right - tmpRect.left, tmpRect.bottom - tmpRect.top, TRUE);
dividYPos = (int)pos.y;
return TRUE;
}
return FALSE;
}
BOOL TSendDlg::EventButton(UINT uMsg, int nHitTest, POINTS pos)
{
switch (uMsg)
{
case WM_LBUTTONUP:
if (captureMode)
{
captureMode = FALSE;
::ReleaseCapture();
return TRUE;
}
break;
}
return FALSE;
}
/*
Size 曄峏
*/
BOOL TSendDlg::EvSize(UINT fwSizeType, WORD nWidth, WORD nHeight)
{
if (fwSizeType != SIZE_RESTORED && fwSizeType != SIZE_MAXIMIZED)
return FALSE;
GetWindowRect(&rect);
int xdiff = (rect.right - rect.left) - (orgRect.right - orgRect.left);
int ydiff = (rect.bottom - rect.top) - (orgRect.bottom - orgRect.top);
HDWP hdwp = ::BeginDeferWindowPos(max_senditem);
WINPOS *wpos;
BOOL isFileBtn = shareInfo && shareInfo->fileCnt > 0 ? TRUE : FALSE;
UINT dwFlg = (IsNewShell() ? SWP_SHOWWINDOW : SWP_NOREDRAW) | SWP_NOZORDER;
if (hdwp == NULL)
return FALSE;
// 僒僀僘偑彫偝偔側傞応崌偺挷惍抣偼丄Try and Error(^^;
wpos = &item[host_item];
if ((hdwp = ::DeferWindowPos(hdwp, GetDlgItem(HOST_LIST), NULL, wpos->x, wpos->y, wpos->cx + xdiff, wpos->cy + currentMidYdiff, dwFlg)) == NULL)
return FALSE;
wpos = &item[member_item];
if ((hdwp = ::DeferWindowPos(hdwp, GetDlgItem(MEMBERCNT_TEXT), NULL, wpos->x + xdiff, wpos->y + (currentMidYdiff >= 0 ? 0 : currentMidYdiff / 2), wpos->cx, wpos->cy, dwFlg)) == NULL)
return FALSE;
wpos = &item[refresh_item];
if ((hdwp = ::DeferWindowPos(hdwp, GetDlgItem(REFRESH_BUTTON), NULL, wpos->x + xdiff, wpos->y + (currentMidYdiff >= 0 ? 0 : currentMidYdiff * 2 / 3), wpos->cx, wpos->cy, dwFlg)) == NULL)
return FALSE;
wpos = &item[file_item];
if ((hdwp = ::DeferWindowPos(hdwp, GetDlgItem(FILE_BUTTON), NULL, wpos->x, wpos->y + currentMidYdiff, wpos->cx + xdiff, wpos->cy, isFileBtn ? dwFlg : (SWP_HIDEWINDOW|SWP_NOZORDER))) == NULL)
return FALSE;
wpos = &item[edit_item];
if ((hdwp = ::DeferWindowPos(hdwp, GetDlgItem(SEND_EDIT), NULL, wpos->x, (isFileBtn ? wpos->y : item[file_item].y) + currentMidYdiff, wpos->cx + xdiff, wpos->cy + ydiff - currentMidYdiff + (isFileBtn ? 0 : wpos->y - item[file_item].y), dwFlg)) == NULL)
return FALSE;
wpos = &item[ok_item];
if ((hdwp = ::DeferWindowPos(hdwp, GetDlgItem(IDOK), NULL, wpos->x + (xdiff >= 0 ? xdiff / 2 : xdiff * 6 / 7), wpos->y + ydiff, wpos->cx, wpos->cy, dwFlg)) == NULL)
return FALSE;
wpos = &item[passwd_item];
if ((hdwp = ::DeferWindowPos(hdwp, GetDlgItem(PASSWORD_CHECK), NULL, wpos->x + (xdiff >= 0 ? xdiff / 2 : xdiff), wpos->y + ydiff, wpos->cx, wpos->cy, dwFlg)) == NULL)
return FALSE;
wpos = &item[secret_item];
if ((hdwp = ::DeferWindowPos(hdwp, GetDlgItem(SECRET_CHECK), NULL, wpos->x + (xdiff >= 0 ? xdiff / 2 : xdiff), wpos->y + ydiff, wpos->cx, wpos->cy, dwFlg)) == NULL)
return FALSE;
wpos = &item[separate_item];
if ((hdwp = ::DeferWindowPos(hdwp, GetDlgItem(SEPARATE_STATIC), NULL, wpos->x, wpos->y + currentMidYdiff, wpos->cx + xdiff, wpos->cy, dwFlg)) == NULL)
return FALSE;
EndDeferWindowPos(hdwp);
if (!IsNewShell())
::InvalidateRgn(hWnd, NULL, TRUE);
else if (captureMode)
{
::InvalidateRgn(GetDlgItem(PASSWORD_CHECK), NULL, TRUE);
::InvalidateRgn(GetDlgItem(SECRET_CHECK), NULL, TRUE);
::InvalidateRgn(GetDlgItem(IDOK), NULL, TRUE);
}
return TRUE;
}
/*
嵟戝/嵟彫 Size 愝掕
*/
BOOL TSendDlg::EvGetMinMaxInfo(MINMAXINFO *info)
{
info->ptMinTrackSize.x = (orgRect.right - orgRect.left) * 2 / 3;
info->ptMinTrackSize.y = (item[separate_item].y + item[separate_item].cy + currentMidYdiff) + (shareInfo && shareInfo->fileCnt ? 130 : 95);
info->ptMaxTrackSize.y = 10000; //y曽岦偺惂尷傪奜偡
return TRUE;
}
/*
Context Menu event call back
*/
BOOL TSendDlg::EvContextMenu(HWND childWnd, POINTS pos)
{
PopupContextMenu(pos);
return TRUE;
}
BOOL TSendDlg::EvMeasureItem(UINT ctlID, MEASUREITEMSTRUCT *lpMis)
{
return FALSE;
}
BOOL TSendDlg::EvDrawItem(UINT ctlID, DRAWITEMSTRUCT *lpDis)
{
return FALSE;
}
/*
User掕媊 Event CallBack
*/
BOOL TSendDlg::EventUser(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DELAYSETTEXT:
SetQuoteStr(msg.msgBuf, cfg->QuoteStr);
return TRUE;
case WM_SENDDLG_RESIZE:
if (captureMode != TRUE)
{
POINT pt;
captureMode = TRUE;
::SetCapture(hWnd);
::GetCursorPos(&pt);
::ScreenToClient(hWnd, &pt);
dividYPos = pt.y;
lastYPos = 0;
}
return TRUE;
}
return FALSE;
}
/*
WM_TIMER event call back
憲怣妋擣/嵞憲梡
*/
BOOL TSendDlg::EvTimer(WPARAM _timerID, TIMERPROC proc)
{
if (IsSendFinish())
{
::KillTimer(hWnd, IPMSG_SEND_TIMER);
if (timerID == IPMSG_DUMMY_TIMER) // 嵞擖傛偗
return FALSE;
timerID = IPMSG_DUMMY_TIMER;
::PostMessage(GetMainWnd(), WM_SENDDLG_EXIT, 0, (LPARAM)this);
return TRUE;
}
if (retryCnt++ <= cfg->RetryMax)
{
SendMsgSub();
return TRUE;
}
::KillTimer(hWnd, IPMSG_SEND_TIMER);
char *buf = new char [MAX_UDPBUF];
*buf = 0;
for (int cnt=0; cnt < sendEntryNum; cnt++)
{
if (sendEntry[cnt].Status() != ST_DONE)
{
MakeListString(cfg, sendEntry[cnt].Host(), buf + strlen(buf));
strcat(buf, "\r\n");
}
}
strcat(buf, RETRYSEND_MSGSTR);
int ret = ::MessageBox(hWnd, buf, MSG_STR, MB_RETRYCANCEL|MB_ICONINFORMATION);
delete [] buf;
if (ret == IDRETRY && IsSendFinish() != TRUE)
{
retryCnt = 0;
SendMsgSub();
timerID = IPMSG_SEND_TIMER;
if (::SetTimer(hWnd, IPMSG_SEND_TIMER, cfg->RetryMSec, NULL) == 0)
::PostMessage(GetMainWnd(), WM_SENDDLG_EXIT, 0, (LPARAM)this);
}
else
::PostMessage(GetMainWnd(), WM_SENDDLG_EXIT, 0, (LPARAM)this);
return TRUE;
}
/*
憲怣拞偼丄Show偺visible傪偼偠偔
*/
void TSendDlg::Show(int mode)
{
if (timerID == 0 && hWnd)
TWin::Show(mode);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -