Value CreateFixture(b2Body &body, b2Shape &shape) { auto fixture = body.CreateFixture(&shape, 1.0f); auto r = new Renderable("color"); fixture->SetUserData(r); return Value((int)fixtures->Add(fixture)); }
void Window::InstallWndProc() { assert(prev_wndproc == NULL); SetUserData(this); prev_wndproc = SetWndProc(WndProc); }
CBaseCtrl::CBaseCtrl(HWND hDlg, WORD idCtrl, LPCSTR pszModule, LPCSTR pszSetting) { ZeroMemory(this, sizeof(*this)); _cbSize = sizeof(CBaseCtrl); _hwnd = GetDlgItem(hDlg, idCtrl); if (!IsWindow(_hwnd)) throw; _idCtrl = idCtrl; _pszModule = pszModule; _pszSetting = pszSetting; SetUserData(_hwnd, this); }
void CSocketServer::Socket::Attach( SOCKET theSocket ) { if ( INVALID_SOCKET != m_socket ) { throw CException( _T("CSocketServer::Socket::Attach()"), _T("Socket already attached") ); } m_socket = theSocket; SetUserData( 0 ); }
BrentsMethod<Real>::BrentsMethod (Function function, int maxIterations, Real negFTolerance, Real posFTolerance, Real stepXTolerance, Real convXTolerance, void* userData) { SetFunction(function); SetMaxIterations(maxIterations); SetNegFTolerance(negFTolerance); SetPosFTolerance(posFTolerance); SetStepXTolerance(stepXTolerance); SetConvXTolerance(convXTolerance); SetUserData(userData); }
CCtrlList::~CCtrlList() { INT_PTR i; SetUserData(_hOwnerDlg, NULL); // delete data for (i = 0 ; i < count; i++) { delete (*this)[i]; } // delete the list LIST<CBaseCtrl>::destroy(); }
BeliefCollisionCheckerPtr BeliefCollisionChecker::GetOrCreate(OR::EnvironmentBase& env) { UserDataPtr ud = GetUserData(env, "trajopt_cc"); if (!ud) { LOG_INFO("creating bullet belief collision checker for environment"); BeliefCollisionCheckerPtr checker(new BeliefCollisionChecker(env.shared_from_this())); ud = checker; SetUserData(env, "trajopt_cc", ud); } else { LOG_DEBUG("already have a belief collision checker for this environment"); } return boost::dynamic_pointer_cast<BeliefCollisionChecker>(ud); }
// ReportResult is completely optional. Its purpose is to allow a credential to customize the string // and the icon displayed in the case of a logon failure. For example, we have chosen to // customize the error shown in the case of bad username/password and in the case of the account // being disabled. HRESULT CardUnlockCredential::ReportResult( NTSTATUS ntsStatus, NTSTATUS ntsSubstatus, PWSTR* ppwszOptionalStatusText, CREDENTIAL_PROVIDER_STATUS_ICON* pcpsiOptionalStatusIcon ) { *ppwszOptionalStatusText = NULL; *pcpsiOptionalStatusIcon = CPSI_NONE; DWORD dwStatusInfo = (DWORD)-1; // Look for a match on status and substatus. for (DWORD i = 0; i < ARRAYSIZE(s_rgLogonStatusInfo); i++) { if (s_rgLogonStatusInfo[i].ntsStatus == ntsStatus && s_rgLogonStatusInfo[i].ntsSubstatus == ntsSubstatus) { dwStatusInfo = i; break; } } if ((DWORD)-1 != dwStatusInfo) { if (SUCCEEDED(SHStrDupW(s_rgLogonStatusInfo[dwStatusInfo].pwzMessage, ppwszOptionalStatusText))) { *pcpsiOptionalStatusIcon = s_rgLogonStatusInfo[dwStatusInfo].cpsi; } } // If we failed the logon, try to erase the password field. if (!SUCCEEDED(HRESULT_FROM_NT(ntsStatus))) { if (_pCredProvCredentialEvents) { _pCredProvCredentialEvents->SetFieldString(this, SFI_PASSWORD, L""); } // clear credentials SetUserData(L"", L""); // disconnect listener if login failed if (_rfidListener) _rfidListener->Disconnect(); } // Since NULL is a valid value for *ppwszOptionalStatusText and *pcpsiOptionalStatusIcon // this function can't fail. return S_OK; }
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam) { auto pi = reinterpret_cast<ProcInfo*>(lParam); auto ProcList=pi->procList; if (IsWindowVisible(hwnd) || (IsIconic(hwnd) && !(GetWindowLongPtr(hwnd,GWL_STYLE) & WS_DISABLED))) { DWORD ProcID; GetWindowThreadProcessId(hwnd,&ProcID); string strTitle; int LenTitle=GetWindowTextLength(hwnd); if (LenTitle) { if (pi->bShowImage) { HANDLE hProc = OpenProcess(Imports().QueryFullProcessImageNameW? PROCESS_QUERY_LIMITED_INFORMATION : PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, false, ProcID); if (hProc) { os::GetModuleFileNameEx(hProc, nullptr, strTitle); CloseHandle(hProc); } } else { wchar_t_ptr Title(LenTitle + 1); if (Title) { if ((LenTitle=GetWindowText(hwnd, Title.get(), LenTitle+1))) Title[LenTitle]=0; else Title[0]=0; strTitle=Title.get(); } } } if (!strTitle.empty()) { ProcList->SetUserData(&hwnd,sizeof(hwnd),ProcList->AddItem(FormatString()<<fmt::MinWidth(PID_LENGTH)<<ProcID<< L' ' << BoxSymbols[BS_V1]<< L' ' << strTitle)); } } return TRUE; }
Node* Llama::getNode(){ if(m_node==NULL) { m_sprite = Sprite::createWithSpriteFrameName("fuego1.png"); m_sprite->setPosition(x,y); m_sprite->retain(); Action *move = RepeatForever::create(Animate::create(m_anim)); m_sprite->runAction(move); m_node = m_sprite; m_node->setAnchorPoint(Vec2(0.5, 0.25)); m_node->setLocalZOrder(0); mCB=new CombinedData(this, CombinedDataType::TCDObjetoLetal); b2World *world = Mundo::getActual()->getPhysicsWorld(); b2BodyDef bodyDef; bodyDef.type = b2BodyType::b2_staticBody; double widthptm=m_sprite->getContentSize().width/PTM_RATIO; double heightptm=m_sprite->getContentSize().height/PTM_RATIO; b2PolygonShape shapeBoundingBox; shapeBoundingBox.SetAsBox(widthptm*0.35f, heightptm*0.3f); m_body = world->CreateBody(&bodyDef); auto fixture = m_body->CreateFixture(&shapeBoundingBox, 1.0); fixture->SetSensor(true); fixture->SetUserData(mCB); setTransform(cocos2d::Vec2(75+x+m_sprite->getContentSize().width/2,y+(0.75)*m_sprite->getContentSize().height), 0); } return m_node; }
BipedDef::BipedDef() { SetMotorTorque(3.0f); SetMotorSpeed(0.0f); SetDensity(0.0015f); SetRestitution(0.0f); SetLinearDamping(0.0f); SetAngularDamping(0.0f); SetGroupIndex(--count); SetUserData(); EnableMotor(); EnableLimit(); DefaultVertices(); DefaultPositions(); DefaultJoints(); LFootPoly.friction = RFootPoly.friction = 0.85f; }
/** * name: BeginLabelEdit * class: CPsTree * desc: begins the labeledit mode * param: hItem - handle of the treeitm whose label to edit * return: 0 **/ int CPsTree::BeginLabelEdit(HTREEITEM hItem) { CPsTreeItem* pti; // tree is readonly if (db_get_b(NULL, MODNAME, SET_PROPSHEET_READONLYLABEL, 0)) return 0; // get item text if (!hItem && !(hItem = TreeView_GetSelection(_hWndTree))) return 0; if (pti = FindItemByHandle(hItem)) { RECT rc, rcTree; // create the edit control GetClientRect(_hWndTree, &rcTree); TreeView_GetItemRect(_hWndTree, hItem, &rc, TRUE); _hLabelEdit = CreateWindowEx(WS_EX_NOPARENTNOTIFY|WS_EX_CLIENTEDGE, _T( "EDIT" ), pti->Label(), WS_VISIBLE|ES_AUTOHSCROLL|WS_CHILD, rc.left, rc.top, rcTree.right - rc.left, rc.bottom - rc.top, _hWndTree, NULL, ghInst, NULL ); if (_hLabelEdit) { _hDragItem = hItem; SetUserData(_hLabelEdit, this); mir_subclassWindow(_hLabelEdit, TPropsheetTree_LabelEditProc); SendMessage(_hLabelEdit, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0 ); Edit_SetSel(_hLabelEdit, 0, -1); Edit_LimitText(_hLabelEdit, MAX_TINAME); SetFocus(_hLabelEdit); return 0; } } return 1; }
b2Body* Map::obstacle::createBody (Game* game) { auto world = game->world(); b2BodyDef def; def.position = { 0, 0 }; def.type = b2_staticBody; b2PolygonShape shape; b2Vec2 points[MaxVertices]; for (int i = 0; i < numVertices; i++) points[i] = to_b2(vertices[i]); shape.Set(points, numVertices); body = world->CreateBody(&def); auto fix = body->CreateFixture(&shape, 0); fix->SetUserData(Game::UserData_Wall); return body; }
BaseADMList::~BaseADMList() { if (sADMList) { SetUserData(NULL); /* Don't touch these. If this list class object is deleted in the plug-in before associated ADMList object is deleted in ADM, we'll need these procs still set on that side of ADM to make sure any entry data on this side is cleaned up. sADMList->SetUserData(fList, NULL); sADMList->SetDrawProc(fList, NULL); sADMList->SetNotifyProc(fList, NULL); sADMList->SetDestroyProc(fList, NULL); */ } // fList = NULL; }
/** * name: CPsTree * class: CPsTree * desc: constructor * param: none * return: none **/ BYTE CPsTree::Create(HWND hWndTree, CPsHdr* pPsh) { BYTE rc; if (hWndTree && pPsh->_hImages && pPsh->_pPages && pPsh->_numPages) { _hWndTree = hWndTree; _hImages = pPsh->_hImages; _pItems = pPsh->_pPages; _numItems = pPsh->_numPages; _dwFlags = pPsh->_dwFlags; TreeView_SetImageList(_hWndTree, _hImages, TVSIL_NORMAL); TreeView_SetItemHeight(_hWndTree, TreeView_GetItemHeight(_hWndTree) + 4); SetUserData(_hWndTree, this); rc = TRUE; } else { rc = FALSE; } return rc; }
void BaseScene::addEdge(Vec2 startpoint, Vec2 endpoint){ startpoint = startpoint / RTM_RATIO; endpoint = endpoint / RTM_RATIO; Vec2 middlepoint = (startpoint + endpoint) / 2; b2BodyDef bodydef; bodydef.position.Set(middlepoint.x, middlepoint.y); auto ground = world->CreateBody(&bodydef); b2EdgeShape shape; shape.Set(b2Vec2(startpoint.x - middlepoint.x, startpoint.y - middlepoint.y), b2Vec2(endpoint.x - middlepoint.x, endpoint.y - middlepoint.y)); b2FixtureDef fixtureDef; fixtureDef.shape = &shape; b2Filter filter; filter.categoryBits = 0x0001; filter.maskBits = 0xffff; fixtureDef.filter = filter; ground->CreateFixture(&fixtureDef); MyUserData* mytype = new MyUserData(); mytype->bd_type = bd_ground; ground->SetUserData(mytype); }
dndTableShape::dndTableShape(Table* tab):wxSFShapeBase() { SetUserData(tab); }
/** * name: ListSubclassProc * desc: procedure to catch messages for a listview control, to handle tooltips * param: hwnd - handle to the listview control's window * msg - message sent to the control * wParam - message specific parameter * lParam - message specific parameter * return: message specific **/ static INT_PTR CALLBACK ProfileList_SubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { LPLISTCTRL pList; switch (msg) { case WM_KEYDOWN: { INT nCurSel, newSel; LVITEM lvi; switch (wParam) { case VK_F2: nCurSel = ListView_GetSelectionMark(hwnd); if (nCurSel == -1) break; ProfileList_BeginLabelEdit(hwnd, nCurSel, 0); return 0; case VK_F3: nCurSel = ListView_GetSelectionMark(hwnd); if (nCurSel == -1) break; ProfileList_BeginLabelEdit(hwnd, nCurSel, 1); return 0; case VK_UP: case VK_DOWN: lvi.iItem = nCurSel = ListView_GetSelectionMark(hwnd); lvi.iSubItem = 0; // find next valid item to select lvi.mask = LVIF_PARAM; do { if (wParam == VK_UP) lvi.iItem--; else lvi.iItem++; if (lvi.iItem == -1 || !ListView_GetItem(hwnd, &lvi)) { return 0; } } while (!lvi.lParam); ListView_EnsureVisible(hwnd, lvi.iItem, FALSE); newSel = lvi.iItem; lvi.iItem = nCurSel; lvi.mask = LVIF_STATE; lvi.stateMask = LVIS_FOCUSED|LVIS_SELECTED; lvi.state = 0; ListView_SetItem(hwnd, &lvi); lvi.iItem = newSel; lvi.state = LVIS_FOCUSED|LVIS_SELECTED; ListView_SetItem(hwnd, &lvi); ListView_SetSelectionMark(hwnd, lvi.iItem); return 0; } break; } case WM_MOUSEMOVE: if (PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd))) { HDC hDC; RECT rchWnd, rcItem; SIZE textSize; LVHITTESTINFO hi; TOOLINFO ti; BOOLEAN bReposition; LPLCITEM pItem; hi.pt.x = GET_X_LPARAM(lParam); hi.pt.y = GET_Y_LPARAM(lParam); ListView_SubItemHitTest(hwnd, &hi); // show tip only if pointer is over an item if (pList->iHotItem != hi.iItem || pList->iHotSubItem != hi.iSubItem) { bReposition = pList->iHotItem != -1 || pList->iHotSubItem != -1; pList->iHotItem = hi.iItem; pList->iHotSubItem = hi.iSubItem; if ((hi.flags & LVHT_ONITEMLABEL) && PtrIsValid(pItem = ProfileList_GetItemData(hwnd, hi.iItem))) { GetWindowRect(hwnd, &rchWnd); ListView_GetSubItemRect(hwnd, hi.iItem, hi.iSubItem, LVIR_BOUNDS, &rcItem); // calculate size of text on the screen if ((hDC = GetDC(GetParent(hwnd)))) { SelectObject(hDC, (HFONT)SendMessage(GetParent(hwnd), WM_GETFONT, NULL, NULL)); GetTextExtentPoint32(hDC, pItem->pszText[hi.iSubItem], lstrlen(pItem->pszText[hi.iSubItem]), &textSize); ReleaseDC(GetParent(hwnd), hDC); } // show tip only for text that is larger than te listview can display if (textSize.cx > rchWnd.right - rchWnd.left || textSize.cx > rcItem.right - rcItem.left) { ZeroMemory(&ti, sizeof(TOOLINFO)); ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS|TTF_TRANSPARENT; ti.hinst = ghInst; ti.hwnd = hwnd; ti.uId = (UINT_PTR)hwnd; ti.lpszText = pItem->pszText[hi.iSubItem]; ti.rect = rcItem; SendMessage(pList->hTip, TTM_SETMAXTIPWIDTH, 0, 300); SendMessage(pList->hTip, TTM_SETTOOLINFO, NULL, (LPARAM)&ti); if (pList->iHotSubItem > 0) { SendMessage(pList->hTip, TTM_SETTITLE, 1, (LPARAM) ((pItem->idstrList && pItem->iListItem > 0 && pItem->iListItem < pItem->idstrListCount) ? pItem->idstrList[pItem->iListItem].ptszTranslated : (pItem->pszText[0] && *pItem->pszText[0]) ? pItem->pszText[0] : TranslateT("<empty>")) ); InvalidateRect(pList->hTip, NULL, TRUE); } else SendMessage(pList->hTip, TTM_SETTITLE, 0, (LPARAM)""); SendMessage(pList->hTip, TTM_ACTIVATE, TRUE, (LPARAM)&ti); pList->ptTip.x = rchWnd.left + GET_X_LPARAM(lParam) - 16; pList->ptTip.y = rchWnd.top + rcItem.top; // no TTN_SHOW is called if bReposition is TRUE, so repose here! if (bReposition) { RECT rcTip; GetClientRect(pList->hTip, &rcTip); SetWindowPos(pList->hTip, hwnd, pList->ptTip.x, pList->ptTip.y - rcTip.bottom, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE); } pList->wFlags |= LIF_TIPVISIBLE; return 0; } } if (pList->wFlags & LIF_TIPVISIBLE) { SendMessage(pList->hTip, TTM_ACTIVATE, FALSE, (LPARAM)&ti); pList->wFlags &= ~LIF_TIPVISIBLE; } } } return 0; // begin label edit case WM_LBUTTONDBLCLK: { LVHITTESTINFO hi; hi.pt.x = GET_X_LPARAM(lParam); hi.pt.y = GET_Y_LPARAM(lParam); if (ListView_SubItemHitTest(hwnd, &hi)) { ProfileList_BeginLabelEdit(hwnd, hi.iItem, hi.iSubItem); } return TRUE; } case WM_NOTIFY: if (!PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd))) break; // ensure position of tooltip is on the topline of the item if (((LPNMHDR)lParam)->hwndFrom == pList->hTip) { RECT rcTip; GetClientRect(pList->hTip, &rcTip); switch (((LPNMHDR)lParam)->code) { case TTN_SHOW: SetWindowPos(pList->hTip, hwnd, pList->ptTip.x, pList->ptTip.y - rcTip.bottom, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE); return TRUE; } } break; case WM_COMMAND: { switch (LOWORD(wParam)) { // show dropdown menu for category list case BTN_EDIT: { INT i; TCHAR szEdit[MAX_PATH]; if (!PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd))) break; GetWindowText(pList->labelEdit.hEdit, szEdit, MAX_PATH); // need to create the dropdown list? if (pList->labelEdit.dropDown.hDrop == NULL) { const INT listHeight = 120; RECT rc, rcList; INT add; // dropdown rect GetClientRect(pList->hList, &rcList); rc.left = pList->labelEdit.rcCombo.left; rc.right = pList->labelEdit.rcCombo.right + pList->labelEdit.rcCombo.bottom - pList->labelEdit.rcCombo.top; if (rcList.bottom < pList->labelEdit.rcCombo.bottom + listHeight) { rc.bottom = pList->labelEdit.rcCombo.bottom - 7; // don't ask me why! rc.top = rc.bottom - listHeight; } else { rc.top = pList->labelEdit.rcCombo.bottom; rc.bottom = rc.top + listHeight; } pList->labelEdit.dropDown.hDrop = CreateWindowEx(0, _T("LISTBOX"), NULL, WS_CHILD|WS_BORDER|WS_VSCROLL|LBS_COMBOBOX|LBS_HASSTRINGS, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hwnd, NULL, ghInst, NULL); if (!pList->labelEdit.dropDown.hDrop) return FALSE; SetUserData(pList->labelEdit.dropDown.hDrop, pList); OldDropdownProc = (WNDPROC)SetWindowLongPtr(pList->labelEdit.dropDown.hDrop, GWLP_WNDPROC, (LONG_PTR)ProfileList_DropdownProc); SetWindowLongPtr(pList->labelEdit.dropDown.hDrop, GWLP_ID, LIST_DROPDOWN); SendMessage(pList->labelEdit.dropDown.hDrop, WM_SETFONT, (WPARAM)SendMessage(GetParent(pList->hList), WM_GETFONT, 0, 0), 0); // add items for (i = 0; i < pList->labelEdit.pItem->idstrListCount; i++) { add = ListBox_AddString(pList->labelEdit.dropDown.hDrop, pList->labelEdit.pItem->idstrList[i].ptszTranslated); ListBox_SetItemData(pList->labelEdit.dropDown.hDrop, add, pList->labelEdit.pItem->idstrList + i); if (!_tcscmp(szEdit, pList->labelEdit.pItem->idstrList[i].ptszTranslated)) ListBox_SetCurSel(pList->labelEdit.dropDown.hDrop, add); } } else { LPIDSTRLIST lpidList; i = 0; while (PtrIsValid(lpidList = (LPIDSTRLIST)ListBox_GetItemData(pList->labelEdit.dropDown.hDrop, i))) { if (!_tcscmp(szEdit, lpidList->ptszTranslated)) { ListBox_SetCurSel(pList->labelEdit.dropDown.hDrop, i); break; } i++; } if (i == pList->labelEdit.pItem->idstrListCount) ListBox_SetCurSel(pList->labelEdit.dropDown.hDrop, -1); } if (IsWindowVisible(pList->labelEdit.dropDown.hDrop)) { SetFocus(pList->labelEdit.hEdit); } else { ShowWindow(pList->labelEdit.dropDown.hDrop, SW_SHOW); //SetFocus(pList->labelEdit.dropDown.hDrop); } break; } } break; } case WM_MOUSEWHEEL: case WM_VSCROLL: case WM_HSCROLL: { if (PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd))) ProfileList_EndLabelEdit(pList, FALSE); break; } case WM_KILLFOCUS: { HWND hwndFocus = GetFocus(); if (PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd)) && pList->labelEdit.hEdit != hwndFocus && pList->labelEdit.dropDown.hDrop != hwndFocus && pList->labelEdit.hBtn != hwndFocus) ProfileList_EndLabelEdit(pList, FALSE); break; } case WM_DESTROY: if (PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd))) { HFONT hFont; ProfileList_EndLabelEdit(pList, FALSE); ProfileList_Clear(hwnd); if (PtrIsValid(hFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0)) && hFont != pList->hFont) DeleteObject(hFont); DestroyWindow(pList->hTip); mir_free(pList); } break; } return CallWindowProc(OldListViewProc, hwnd, msg, wParam, lParam); }
dndTableShape::dndTableShape(xsSerializable* pData):wxSFShapeBase() { SetUserData(pData); }
/** * name: DlgProcPspAbout() * desc: dialog procedure * * return: 0 or 1 **/ INT_PTR CALLBACK PSPProcContactProfile(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { HWND hList = GetDlgItem(hDlg, LIST_PROFILE); LPLISTCTRL pList; switch (uMsg) { case WM_INITDIALOG: { LVCOLUMN lvc; RECT rc; LOGFONT lf; HFONT hFont; TOOLINFO ti; if (!hList || !(pList = (LPLISTCTRL)mir_alloc(sizeof(LISTCTRL)))) return FALSE; ZeroMemory(pList, sizeof(LISTCTRL)); TranslateDialogDefault(hDlg); Ctrl_InitTextColours(); // init info structure pList->hList = hList; pList->nType = CTRL_LIST_PROFILE; ZeroMemory(&pList->labelEdit, sizeof(pList->labelEdit)); SetUserData(hList, pList); // set new window procedure OldListViewProc = (WNDPROC)SetWindowLongPtr(hList, GWLP_WNDPROC, (LONG_PTR)&ProfileList_SubclassProc); // remove static edge in aero mode if (IsAeroMode()) SetWindowLongPtr(hList, GWL_EXSTYLE, GetWindowLongPtr(hList, GWL_EXSTYLE)&~WS_EX_STATICEDGE); // insert columns into the listboxes ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT); PSGetBoldFont(hDlg, hFont); SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hFont, 0); // set listfont pList->hFont = (HFONT)SendMessage(hList, WM_GETFONT, 0, 0); pList->wFlags |= LVF_EDITLABEL; GetObject(pList->hFont, sizeof(lf), &lf); lf.lfHeight -= 6; hFont = CreateFontIndirect(&lf); SendMessage(hList, WM_SETFONT, (WPARAM)hFont, 0); GetClientRect(hList, &rc); rc.right -= GetSystemMetrics(SM_CXVSCROLL); // initiate the tooltips pList->hTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP|TTS_BALLOON|TTS_NOPREFIX|TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hList, NULL, ghInst, NULL); if (pList->hTip) { SetWindowPos(pList->hTip, HWND_TOPMOST, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); ZeroMemory(&ti, sizeof(TOOLINFO)); ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS|TTF_TRANSPARENT; ti.hinst = ghInst; ti.hwnd = hList; ti.uId = (UINT_PTR)hList; SendMessage(pList->hTip, TTM_ADDTOOL, NULL, (LPARAM)&ti); SendMessage(pList->hTip, TTM_ACTIVATE, FALSE, (LPARAM)&ti); } // insert columns into the listboxes lvc.mask = LVCF_WIDTH; lvc.cx = rc.right / 8 * 3; ListView_InsertColumn(hList, 0, &lvc); lvc.cx = rc.right / 8 * 5; ListView_InsertColumn(hList, 1, &lvc); return TRUE; } case WM_CTLCOLORSTATIC: case WM_CTLCOLORDLG: if (IsAeroMode()) return (INT_PTR)GetStockBrush(WHITE_BRUSH); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case 0: { HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam; LPCSTR pszProto; if (!PtrIsValid(pList = (LPLISTCTRL)GetUserData(hList))) break; switch (((LPNMHDR)lParam)->code) { // some account data may have changed so reread database case PSN_INFOCHANGED: { BYTE msgResult = 0; LPIDSTRLIST idList; UINT nList; BYTE i; INT iItem = 0, iGrp = 0, numProtoItems, numUserItems; if (!(pList->wFlags & CTRLF_CHANGED) && PSGetBaseProto(hDlg, pszProto) && *pszProto != 0) { ProfileList_Clear(hList); // insert the past information for (i = 0; i < 3; i++) { pFmt[i].GetList((WPARAM)&nList, (LPARAM)&idList); if ((numProtoItems = ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hContact, pszProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASPROTO)) < 0) return FALSE; // scan all basic protocols for the subcontacts if (DB::Module::IsMetaAndScan(pszProto)) { INT iDefault = CallService(MS_MC_GETDEFAULTCONTACTNUM, (WPARAM)hContact, NULL); HANDLE hSubContact, hDefContact; LPCSTR pszSubBaseProto; INT j, numSubs; if ((hDefContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hContact, iDefault)) && (pszSubBaseProto = DB::Contact::Proto(hDefContact))) { if ((numProtoItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hDefContact, pszSubBaseProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA|CTRLF_HASPROTO)) < 0) return FALSE; // copy the missing settings from the other subcontacts numSubs = CallService(MS_MC_GETNUMCONTACTS, (WPARAM)hContact, NULL); for (j = 0; j < numSubs; j++) { if (j == iDefault) continue; if (!(hSubContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hContact, j))) continue; if (!(pszSubBaseProto = DB::Contact::Proto(hSubContact))) continue; if ((numProtoItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hSubContact, pszSubBaseProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA|CTRLF_HASPROTO)) < 0) return FALSE; //if ((numUserItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hSubContact, USERINFO, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA|CTRLF_HASPROTO)) < 0) // return FALSE; } } } if ((numUserItems = ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hContact, USERINFO, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASCUSTOM)) < 0) return FALSE; if (numUserItems || numProtoItems) { msgResult = PSP_CHANGED; ProfileList_AddGroup(hList, pFmt[i].szGroup, iGrp); iGrp = ++iItem; } } } SetWindowLongPtr(hDlg, DWLP_MSGRESULT, msgResult); break; } // user swiches to another propertysheetpage case PSN_KILLACTIVE: ProfileList_EndLabelEdit(hList, TRUE); break; // user selected to apply settings to the database case PSN_APPLY: if (pList->wFlags & CTRLF_CHANGED) { BYTE iFmt = -1; INT iItem; LVITEM lvi; TCHAR szGroup[MAX_PATH]; CHAR pszSetting[MAXSETTING]; LPLCITEM pItem; LPSTR pszModule = USERINFO; if (!hContact) PSGetBaseProto(hDlg, pszModule); *szGroup = 0; lvi.mask = LVIF_TEXT|LVIF_PARAM; lvi.pszText = szGroup; lvi.cchTextMax = MAX_PATH; for (iItem = lvi.iItem = lvi.iSubItem = 0; ListView_GetItem(hList, &lvi); lvi.iItem++) { if (!PtrIsValid(pItem = (LPLCITEM)lvi.lParam)) { // delete reluctant items if (iFmt >= 0 && iFmt < SIZEOF(pFmt)) { DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szCatFmt, iItem); DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szValFmt, iItem); } // find information about the group for (iFmt = 0; iFmt < SIZEOF(pFmt); iFmt++) { if (!_tcscmp(szGroup, pFmt[iFmt].szGroup)) { break; } } // indicate, no group was found. should not happen!! if (iFmt == SIZEOF(pFmt)) { *szGroup = 0; iFmt = -1; } iItem = 0; } else if (iFmt >= 0 && iFmt < SIZEOF(pFmt)) { // save value if (!pItem->pszText[1] || !*pItem->pszText[1]) continue; if (!(pItem->wFlags & (CTRLF_HASPROTO|CTRLF_HASMETA))) { mir_snprintf(pszSetting, MAXSETTING, pFmt[iFmt].szValFmt, iItem); DB::Setting::WriteTString(hContact, pszModule, pszSetting, pItem->pszText[1]); // save category mir_snprintf(pszSetting, MAXSETTING, pFmt[iFmt].szCatFmt, iItem); if (pItem->idstrList && pItem->iListItem > 0 && pItem->iListItem < pItem->idstrListCount) DB::Setting::WriteAString(hContact, pszModule, pszSetting, (LPSTR)pItem->idstrList[pItem->iListItem].pszText); else if (pItem->pszText[0] && *pItem->pszText[0]) DB::Setting::WriteTString(hContact, pszModule, pszSetting, (LPTSTR)pItem->pszText[0]); else DB::Setting::Delete(hContact, pszModule, pszSetting); // redraw the item if required if (pItem->wFlags & CTRLF_CHANGED) { pItem->wFlags &= ~CTRLF_CHANGED; ListView_RedrawItems(hList, lvi.iItem, lvi.iItem); } iItem++; } } } // delete reluctant items if (iFmt >= 0 && iFmt < SIZEOF(pFmt)) { DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szCatFmt, iItem); DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szValFmt, iItem); } pList->wFlags &= ~CTRLF_CHANGED; } break; } break; } // // handle notification messages from the list control // case LIST_PROFILE: { LPLISTCTRL pList = (LPLISTCTRL)GetUserData(((LPNMHDR)lParam)->hwndFrom); switch (((LPNMHDR)lParam)->code) { case NM_RCLICK: { HMENU hMenu = CreatePopupMenu(); MENUITEMINFO mii; HANDLE hContact; LVHITTESTINFO hi; LPLCITEM pItem; POINT pt; if (!hMenu) return 1; PSGetContact(hDlg, hContact); GetCursorPos(&pt); hi.pt = pt; ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hi.pt); ListView_SubItemHitTest(((LPNMHDR)lParam)->hwndFrom, &hi); pItem = ProfileList_GetItemData(((LPNMHDR)lParam)->hwndFrom, hi.iItem); // insert menuitems ZeroMemory(&mii, sizeof(MENUITEMINFO)); mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_ID|MIIM_STRING; // insert "Add" Menuitem mii.wID = BTN_ADD_intEREST; mii.dwTypeData = TranslateT("Add Interest"); InsertMenuItem(hMenu, 0, TRUE, &mii); mii.wID = BTN_ADD_AFFLIATION; mii.dwTypeData = TranslateT("Add Affliation"); InsertMenuItem(hMenu, 1, TRUE, &mii); mii.wID = BTN_ADD_PAST; mii.dwTypeData = TranslateT("Add Past"); InsertMenuItem(hMenu, 2, TRUE, &mii); if (hi.iItem != -1 && PtrIsValid(pItem) && !(hContact && (pItem->wFlags & CTRLF_HASPROTO))) { // insert separator mii.fMask = MIIM_FTYPE; mii.fType = MFT_SEPARATOR; InsertMenuItem(hMenu, 3, TRUE, &mii); // insert "Delete" Menuitem mii.fMask = MIIM_ID|MIIM_STRING; mii.wID = BTN_EDIT_CAT; mii.dwTypeData = TranslateT("Edit Category"); InsertMenuItem(hMenu, 4, TRUE, &mii); mii.wID = BTN_EDIT_VAL; mii.dwTypeData = TranslateT("Edit Value"); InsertMenuItem(hMenu, 5, TRUE, &mii); mii.fMask = MIIM_FTYPE; mii.fType = MFT_SEPARATOR; InsertMenuItem(hMenu, 6, TRUE, &mii); // insert "Delete" Menuitem mii.fMask = MIIM_ID|MIIM_STRING; mii.wID = BTN_DEL; mii.dwTypeData = TranslateT("Delete"); InsertMenuItem(hMenu, 7, TRUE, &mii); } TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hDlg, 0); DestroyMenu(hMenu); return 0; } /*case LVN_BEGINSCROLL: SetFocus(((LPNMHDR)lParam)->hwndFrom); break; */ case LVN_GETDISPINFO: if (pList->labelEdit.iTopIndex != ListView_GetTopIndex(hList)) ProfileList_EndLabelEdit(((LPNMHDR)lParam)->hwndFrom, FALSE); break; case NM_CUSTOMDRAW: { LPNMLVCUSTOMDRAW cd = (LPNMLVCUSTOMDRAW)lParam; LPLCITEM pItem = (LPLCITEM)cd->nmcd.lItemlParam; RECT rc; switch (cd->nmcd.dwDrawStage) { case CDDS_PREPAINT: SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW); return TRUE; case CDDS_ITEMPREPAINT: ListView_GetItemRect(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, &rc, LVIR_BOUNDS); if (!PtrIsValid(pItem)) { HFONT hBold, hFont; TCHAR szText[MAX_PATH]; PSGetBoldFont(hDlg, hBold); hFont = (HFONT)SelectObject(cd->nmcd.hdc, hBold); SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_3DSHADOW)); ProfileList_GetItemText(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, 0, szText, MAX_PATH); rc.left += 6; DrawText(cd->nmcd.hdc, TranslateTS(szText), -1, &rc, DT_NOCLIP|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER); rc.bottom -= 2; rc.top = rc.bottom - 1; rc.left -= 6; DrawEdge(cd->nmcd.hdc, &rc, BDR_SUNKENOUTER, BF_RECT); SelectObject(cd->nmcd.hdc, hFont); SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT); return TRUE; } // draw selected item if ((cd->nmcd.uItemState & CDIS_SELECTED) || (pList->labelEdit.iItem == cd->nmcd.dwItemSpec)) { SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); FillRect(cd->nmcd.hdc, &rc, GetSysColorBrush(COLOR_HIGHLIGHT)); } // draw background of unselected item else { SetTextColor(cd->nmcd.hdc, (pItem->wFlags & CTRLF_CHANGED) ? clrChanged : (pItem->wFlags & CTRLF_HASMETA) ? clrMeta : ((pItem->wFlags & (CTRLF_HASCUSTOM)) && (pItem->wFlags & CTRLF_HASPROTO)) ? clrBoth : (pItem->wFlags & CTRLF_HASCUSTOM) ? clrCustom : clrNormal); FillRect(cd->nmcd.hdc, &rc, GetSysColorBrush(COLOR_WINDOW)); } SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_NEWFONT|CDRF_NOTIFYSUBITEMDRAW); return TRUE; case CDDS_SUBITEM|CDDS_ITEMPREPAINT: { HFONT hoFont = (HFONT)SelectObject(cd->nmcd.hdc, pList->hFont); ListView_GetSubItemRect(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, cd->iSubItem, LVIR_BOUNDS, &rc); if (cd->iSubItem == 0) { RECT rc2; ListView_GetSubItemRect(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, 1, LVIR_BOUNDS, &rc2); rc.right = rc2.left; } rc.left += 3; DrawText(cd->nmcd.hdc, pItem->pszText[cd->iSubItem] ? pItem->pszText[cd->iSubItem] : (cd->iSubItem == 0 && pItem->idstrList && pItem->iListItem > 0 && pItem->iListItem < pItem->idstrListCount) ? pItem->idstrList[pItem->iListItem].ptszTranslated : TranslateT("<empty>"), -1, &rc, DT_END_ELLIPSIS|DT_NOCLIP|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER); SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT); return TRUE; } } /* switch (cd->nmcd.dwDrawStage) */ break; } /* case NM_CUSTOMDRAW: */ } /* (((LPNMHDR)lParam)->code) */ break; } } break; /* case WM_NOTIFY: */ case WM_COMMAND: { switch (LOWORD(wParam)) { case BTN_ADD_intEREST: return ProfileList_AddNewItem(hDlg, (LPLISTCTRL)GetUserData(hList), &pFmt[2]); case BTN_ADD_AFFLIATION: return ProfileList_AddNewItem(hDlg, (LPLISTCTRL)GetUserData(hList), &pFmt[1]); case BTN_ADD_PAST: return ProfileList_AddNewItem(hDlg, (LPLISTCTRL)GetUserData(hList), &pFmt[0]); case BTN_EDIT_CAT: ProfileList_BeginLabelEdit(hList, ListView_GetSelectionMark(hList), 0); break; case BTN_EDIT_VAL: ProfileList_BeginLabelEdit(hList, ListView_GetSelectionMark(hList), 1); break; case BTN_DEL: if (IDYES == MsgBox(hDlg, MB_YESNO|MB_ICON_QUESTION, LPGENT("Question"), LPGENT("Delete an entry"), LPGENT("Do you really want to delete this entry?"))) { INT iItem = ListView_GetSelectionMark(hList); LPLISTCTRL pList = (LPLISTCTRL)GetUserData(hList); ProfileList_DeleteItem(hList, iItem); if (PtrIsValid(pList)) pList->wFlags |= CTRLF_CHANGED; SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL); // check if to delete any devider if (!ProfileList_GetItemData(hList, iItem--) && !ProfileList_GetItemData(hList, iItem)) ListView_DeleteItem(hList, iItem); } break; } break; } } return FALSE; }
/** * name: ProfileList_BeginLabelEdit * desc: create an edit control to edit the label of the selected item * param: pList - handle to listview control's info structure * iItem - item index * iSubItem - subitem (column) index * return: handle to the edit control **/ static HWND ProfileList_BeginLabelEdit(LPLISTCTRL pList, INT iItem, INT iSubItem) { LVITEM lvi; LPLCITEM pItem; HANDLE hContact; RECT rcList; if (!PtrIsValid(pList)) return NULL; if (pList->labelEdit.hEdit) ProfileList_EndLabelEdit(pList, FALSE); lvi.mask = LVIF_PARAM|LVIF_STATE; lvi.stateMask = 0xFFFFFFFF; lvi.iItem = iItem; lvi.iSubItem = iSubItem; if (!ListView_GetItem(pList->hList, &lvi)) return NULL; pItem = (LPLCITEM)lvi.lParam; PSGetContact(GetParent(pList->hList), hContact); // do not edit deviders or protocol based contact information if (!(lvi.state & LVIS_SELECTED) || !PtrIsValid(pItem) || (hContact && (pItem->wFlags & CTRLF_HASPROTO))) return NULL; ListView_EnsureVisible(pList->hList, iItem, FALSE); ListView_GetSubItemRect(pList->hList, iItem, iSubItem, LVIR_BOUNDS, &pList->labelEdit.rcCombo); if (lvi.iSubItem == 0) { RECT rc2; ListView_GetSubItemRect(pList->hList, iItem, 1, LVIR_BOUNDS, &rc2); pList->labelEdit.rcCombo.right = rc2.left; } GetClientRect(pList->hList, &rcList); pList->labelEdit.rcCombo.right = min(pList->labelEdit.rcCombo.right, rcList.right); pList->labelEdit.rcCombo.left = max(pList->labelEdit.rcCombo.left, rcList.left); InflateRect(&pList->labelEdit.rcCombo, -1, -1); // create the button control for the combobox if (!iSubItem && pItem->idstrList) { pList->labelEdit.hBtn = CreateWindowEx(WS_EX_NOPARENTNOTIFY, UINFOBUTTONCLASS, NULL, WS_VISIBLE|WS_CHILD|MBS_DOWNARROW, pList->labelEdit.rcCombo.right - (pList->labelEdit.rcCombo.bottom - pList->labelEdit.rcCombo.top), pList->labelEdit.rcCombo.top, pList->labelEdit.rcCombo.bottom - pList->labelEdit.rcCombo.top, pList->labelEdit.rcCombo.bottom - pList->labelEdit.rcCombo.top, pList->hList, NULL, ghInst, NULL); if (pList->labelEdit.hBtn) { SetWindowLongPtr(pList->labelEdit.hBtn, GWLP_ID, BTN_EDIT); pList->labelEdit.rcCombo.right -= pList->labelEdit.rcCombo.bottom - pList->labelEdit.rcCombo.top; } } else { pList->labelEdit.rcCombo.bottom = 3 * pList->labelEdit.rcCombo.bottom - 2 * pList->labelEdit.rcCombo.top; if (rcList.bottom < pList->labelEdit.rcCombo.bottom) { OffsetRect(&pList->labelEdit.rcCombo, 0, rcList.bottom - pList->labelEdit.rcCombo.bottom - 2); } } // create the edit control pList->labelEdit.hEdit = CreateWindowEx(WS_EX_NOPARENTNOTIFY|WS_EX_CLIENTEDGE, _T("EDIT"), (!iSubItem && pItem->idstrList && pItem->iListItem > 0 && pItem->iListItem < pItem->idstrListCount) ? pItem->idstrList[pItem->iListItem].ptszTranslated : (iSubItem >= 0 && iSubItem < 2 && pItem->pszText[iSubItem] && *pItem->pszText[iSubItem]) ? pItem->pszText[iSubItem] : _T(""), WS_VISIBLE|WS_CHILD|(iSubItem ? (WS_VSCROLL|ES_MULTILINE|ES_AUTOVSCROLL) : ES_AUTOHSCROLL), pList->labelEdit.rcCombo.left, pList->labelEdit.rcCombo.top, pList->labelEdit.rcCombo.right - pList->labelEdit.rcCombo.left, pList->labelEdit.rcCombo.bottom - pList->labelEdit.rcCombo.top, pList->hList, NULL, ghInst, NULL); if (!pList->labelEdit.hEdit) return NULL; SendMessage(pList->labelEdit.hEdit, WM_SETFONT, (WPARAM)(pList->hFont), 0); SendMessage(pList->labelEdit.hEdit, EM_SETSEL, 0, (LPARAM)-1); SetUserData(pList->labelEdit.hEdit, pList); pList->labelEdit.dropDown.iItem = pItem->iListItem; pList->labelEdit.iItem = iItem; pList->labelEdit.iSubItem = iSubItem; pList->labelEdit.iTopIndex = ListView_GetTopIndex(pList->hList); pList->labelEdit.pItem = pItem; SetFocus(pList->labelEdit.hEdit); OldEditProc = (WNDPROC)SetWindowLongPtr(pList->labelEdit.hEdit, GWLP_WNDPROC, (LONG_PTR)ProfileList_LabelEditProc); return pList->labelEdit.hEdit; }
bool ListenSessionTcp::Run( std::string& host, const int port, rnSocketIOHandler* func, size_t receive_buffer_size, size_t send_buffer_size ) { std::ostringstream oss; oss << port; std::string port_string = oss.str(); boost::asio::ip::tcp::resolver resolver( io_service_ ); boost::asio::ip::tcp::resolver::query query( host, port_string ); boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve( query ); boost::system::error_code error; acceptor_.open( endpoint.protocol(), error ); if( error ) { LOG_ERROR( "bnf - acceptor_.open error. error[%s] / host[%s] / port[%d]", error.message().c_str(), host.c_str(), port); return false; } acceptor_.set_option( boost::asio::ip::tcp::acceptor::reuse_address( true ), error ); if( error ) { LOG_ERROR( "bnf - acceptor_.set_option error. error[%s] / host[%s] / port[%d]", error.message().c_str(), host.c_str(), port); return false; } acceptor_.bind( endpoint, error ); if( error ) { LOG_ERROR( "bnf - acceptor_.bind error. error[%s] / host[%s] / port[%d]", error.message().c_str(), host.c_str(), port); return false; } acceptor_.listen( boost::asio::socket_base::max_connections, error ); if( error ) { LOG_ERROR( "bnf - acceptor_.listen error. error[%s] / host[%s] / port[%d]", error.message().c_str(), host.c_str(), port); return false; } closeOnExecOn(); SetUserData(func); session_handle shandle; if( bnf::instance()->tcp_session_seq_.pop(shandle) == false ) { bnf::instance()->growSessionBuffer(); LOG_INFO("session buffer growing."); } rnSocketIOServiceTcp* pSession = bnf::instance()->tcp_session_buf_[shandle]; pSession->Open( shandle, handle_, read_wait_time_sec_, write_wait_time_sec_ ); acceptor_.async_accept( pSession->Socket(), boost::bind( &ListenSessionTcp::HandleAccept, this, pSession, boost::asio::placeholders::error ) ); LOG_INFO( "bnf - open listen socket. ip: %s, port: %d, fd: %d, handle: %X", host.c_str(), port, acceptor_.native(), GetHandle() ); return true; }
/** * Dialog procedure for the anniversary add/edit dialog * * @param hDlg - handle to the dialog window * @param uMsg - the message to handle * @param wParam - parameter * @param lParam - parameter * * @return different values **/ static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { MAnnivDate *pDlgEditAnniv = (MAnnivDate *)GetUserData(hDlg); switch (uMsg) { case WM_INITDIALOG: pDlgEditAnniv = (MAnnivDate *)lParam; if (!PtrIsValid(pDlgEditAnniv)) break; SetUserData(hDlg, lParam); // set icons if (db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1)) { SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_OK)); SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_CANCEL)); } SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)IcoLib_GetIcon(ICO_DLG_ANNIVERSARY, TRUE)); // translate controls SendDlgItemMessage(hDlg, IDOK, BUTTONTRANSLATE, NULL, NULL); SendDlgItemMessage(hDlg, IDCANCEL, BUTTONTRANSLATE, NULL, NULL); TranslateDialogDefault(hDlg); // init controls EnableWindow(GetDlgItem(hDlg, EDIT_CATEGORY), pDlgEditAnniv->Id() != ANID_BIRTHDAY); SetDlgItemText(hDlg, EDIT_CATEGORY, pDlgEditAnniv->Description()); return TRUE; case WM_CTLCOLORSTATIC: SetBkColor((HDC)wParam, RGB(255, 255, 255)); return (INT_PTR)GetStockObject(WHITE_BRUSH); case WM_COMMAND: switch (LOWORD(wParam)) { case EDIT_CATEGORY: if (HIWORD(wParam) == EN_UPDATE) EnableWindow(GetDlgItem(hDlg, IDOK), GetWindowTextLength((HWND)lParam) > 0); break; case IDOK: { // read new description HWND hEdit = GetDlgItem(hDlg, EDIT_CATEGORY); int len = Edit_GetTextLength(hEdit); LPTSTR pszText; if (len == 0 || (pszText = (LPTSTR)_alloca((len + 1) * sizeof(TCHAR))) == NULL || !Edit_GetText(hEdit, pszText, len + 1)) { MsgErr(hDlg, LPGENT("Please enter a valid description first!")); break; } if (mir_tstrcmpi(pszText, pDlgEditAnniv->Description())) { pDlgEditAnniv->Description(pszText); pDlgEditAnniv->SetFlags(MAnnivDate::MADF_HASCUSTOM | MAnnivDate::MADF_CHANGED); } } // fall through case IDCANCEL: return EndDialog(hDlg, LOWORD(wParam)); } } return FALSE; }
/** * name: DlgProc_EditPhone() * desc: dialog procedure * * return: 0 or 1 **/ INT_PTR CALLBACK DlgProc_Phone(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { LPCBEXITEM cbi = (LPCBEXITEM)GetUserData(hDlg); static int noRecursion = 0; switch (msg) { case WM_INITDIALOG: { UINT i, item, countryCount; LPIDSTRLIST pCountries; HWND hCombo = GetDlgItem(hDlg, EDIT_COUNTRY); cbi = (LPCBEXITEM)lParam; if (!cbi) return FALSE; SetUserData(hDlg, lParam); SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)IcoLib_GetIcon(ICO_DLG_PHONE, TRUE)); if (db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1)) { SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_OK)); SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_CANCEL)); } // translate Userinfo buttons { TCHAR szButton[MAX_PATH]; HWND hBtn; hBtn = GetDlgItem(hDlg, IDOK); GetWindowText(hBtn, szButton, _countof(szButton)); SetWindowText(hBtn, TranslateTS(szButton)); hBtn = GetDlgItem(hDlg, IDCANCEL); GetWindowText(hBtn, szButton, _countof(szButton)); SetWindowText(hBtn, TranslateTS(szButton)); } if (*cbi->pszVal) SetWindowText(hDlg, LPGENT("Edit phone number")); if (cbi->wFlags & CBEXIF_SMS) CheckDlgButton(hDlg, CHECK_SMS, BST_CHECKED); TranslateDialogDefault(hDlg); EnableWindow(GetDlgItem(hDlg, IDOK), *cbi->pszVal); SendDlgItemMessage(hDlg, EDIT_AREA, EM_LIMITTEXT, 31, 0); SendDlgItemMessage(hDlg, EDIT_NUMBER, EM_LIMITTEXT, 63, 0); SendDlgItemMessage(hDlg, EDIT_CATEGORY, EM_LIMITTEXT, cbi->ccCat - 1, 0); SendDlgItemMessage(hDlg, EDIT_PHONE, EM_LIMITTEXT, cbi->ccVal - 1, 0); GetCountryList(&countryCount, &pCountries); for (i = 0; i < countryCount; i++) { if (pCountries[i].nID == 0 || pCountries[i].nID == 0xFFFF) continue; item = SendMessage(hCombo, CB_ADDSTRING, NULL, (LPARAM)pCountries[i].ptszTranslated); SendMessage(hCombo, CB_SETITEMDATA, item, pCountries[i].nID); } SetDlgItemText(hDlg, EDIT_PHONE, cbi->pszVal); SetDlgItemText(hDlg, EDIT_CATEGORY, cbi->pszCat); EnableWindow(GetDlgItem(hDlg, EDIT_CATEGORY), !(cbi->wFlags & CBEXIF_CATREADONLY)); } return TRUE; case WM_CTLCOLORSTATIC: SetBkColor((HDC)wParam, RGB(255, 255, 255)); return (INT_PTR)GetStockObject(WHITE_BRUSH); case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: if (HIWORD(wParam) == BN_CLICKED) { TCHAR szText[MAXDATASIZE]; int errorPos; if (!GetDlgItemText(hDlg, EDIT_PHONE, szText, _countof(szText)) || !CheckPhoneSyntax(szText, cbi->pszVal, cbi->ccVal, errorPos) || errorPos > -1) { MsgErr(hDlg, TranslateT("The phone number should start with a + and consist of\nnumbers, spaces, brackets and hyphens only.")); break; } // save category string GetDlgItemText(hDlg, EDIT_CATEGORY, cbi->pszCat, cbi->ccCat); // save SMS flag if ((int)IsDlgButtonChecked(hDlg, CHECK_SMS) != ((cbi->wFlags & CBEXIF_SMS) == CBEXIF_SMS)) cbi->wFlags ^= CBEXIF_SMS; } //fall through case IDCANCEL: if (HIWORD(wParam) == BN_CLICKED) EndDialog(hDlg, wParam); break; case EDIT_COUNTRY: if (HIWORD(wParam) != CBN_SELCHANGE) break; case EDIT_AREA: case EDIT_NUMBER: if (LOWORD(wParam) != EDIT_COUNTRY && HIWORD(wParam) != EN_CHANGE) break; if (noRecursion) break; EnableWindow(GetDlgItem(hDlg, IDOK), TRUE); { TCHAR szPhone[MAXDATASIZE], szArea[32], szData[64]; int nCurSel = SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_GETCURSEL, 0, 0); UINT nCountry = (nCurSel != CB_ERR) ? SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_GETITEMDATA, nCurSel, 0) : 0; GetDlgItemText(hDlg, EDIT_AREA, szArea, _countof(szArea)); GetDlgItemText(hDlg, EDIT_NUMBER, szData, _countof(szData)); mir_sntprintf(szPhone, _T("+%u (%s) %s"), nCountry, szArea, szData); noRecursion = 1; SetDlgItemText(hDlg, EDIT_PHONE, szPhone); noRecursion = 0; } break; case EDIT_PHONE: if (HIWORD(wParam) != EN_UPDATE) break; if (noRecursion) break; noRecursion = 1; { TCHAR szText[MAXDATASIZE], *pText = 0, *pArea, *pNumber; bool isValid = true; GetDlgItemText(hDlg, EDIT_PHONE, szText, _countof(szText)); if (szText[0] != '+') isValid = false; if (isValid) { int country = _tcstol(szText + 1, &pText, 10); if (pText - szText > 4) isValid = false; else { int i; for (i = SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_GETCOUNT, 0, 0) - 1; i >= 0; i--) { if (country == SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_GETITEMDATA, i, 0)) { SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_SETCURSEL, i, 0); break; } } if (i < 0) isValid = false; } } if (isValid) { pArea = pText + _tcscspn(pText, _T("0123456789")); pText = pArea + _tcsspn(pArea, _T("0123456789")); if (*pText) { *pText = '\0'; pNumber = pText + 1 + _tcscspn(pText + 1, _T("0123456789")); SetDlgItemText(hDlg, EDIT_NUMBER, pNumber); } SetDlgItemText(hDlg, EDIT_AREA, pArea); } if (!isValid) { SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_SETCURSEL, -1, 0); SetDlgItemText(hDlg, EDIT_AREA, _T("")); SetDlgItemText(hDlg, EDIT_NUMBER, _T("")); } } noRecursion = 0; EnableWindow(GetDlgItem(hDlg, IDOK), GetWindowTextLength(GetDlgItem(hDlg, EDIT_PHONE))); break; } break; } return FALSE; }
/** * name: DlgProc_EditEMail() * desc: dialog procedure * * return: 0 or 1 **/ static INT_PTR CALLBACK DlgProc_EMail(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { LPCBEXITEM cbi = (LPCBEXITEM)GetUserData(hDlg); switch (msg) { case WM_INITDIALOG: cbi = (LPCBEXITEM)lParam; if (!cbi) return FALSE; SetUserData(hDlg, lParam); SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)IcoLib_GetIcon(ICO_DLG_EMAIL, TRUE)); if (db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1)) { SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_OK)); SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_CANCEL)); } if (*cbi->pszVal) SetWindowText(hDlg, LPGENT("Edit e-mail")); TranslateDialogDefault(hDlg); SendDlgItemMessage(hDlg, EDIT_CATEGORY, EM_LIMITTEXT, cbi->ccCat - 1, 0); SendDlgItemMessage(hDlg, EDIT_EMAIL, EM_LIMITTEXT, cbi->ccVal - 1, 0); SetDlgItemText(hDlg, EDIT_CATEGORY, cbi->pszCat); SetDlgItemText(hDlg, EDIT_EMAIL, cbi->pszVal); EnableWindow(GetDlgItem(hDlg, EDIT_CATEGORY), !(cbi->wFlags & CBEXIF_CATREADONLY)); EnableWindow(GetDlgItem(hDlg, IDOK), *cbi->pszVal); // translate Userinfo buttons { TCHAR szButton[MAX_PATH]; HWND hBtn = GetDlgItem(hDlg, IDOK); GetWindowText(hBtn, szButton, _countof(szButton)); SetWindowText(hBtn, TranslateTS(szButton)); hBtn = GetDlgItem(hDlg, IDCANCEL); GetWindowText(hBtn, szButton, _countof(szButton)); SetWindowText(hBtn, TranslateTS(szButton)); } return TRUE; case WM_CTLCOLORSTATIC: SetBkColor((HDC)wParam, RGB(255, 255, 255)); return (INT_PTR)GetStockObject(WHITE_BRUSH); case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: { if (HIWORD(wParam) == BN_CLICKED) { if (cbi->pszVal && cbi->ccVal > 0) GetDlgItemText(hDlg, EDIT_EMAIL, cbi->pszVal, cbi->ccVal); if (cbi->pszCat && cbi->ccCat > 0) GetDlgItemText(hDlg, EDIT_CATEGORY, cbi->pszCat, cbi->ccCat); } break; } case IDCANCEL: { if (HIWORD(wParam) == BN_CLICKED) EndDialog(hDlg, LOWORD(wParam)); break; } case EDIT_EMAIL: if (HIWORD(wParam) == EN_UPDATE) { TCHAR szText[MAXDATASIZE]; LPTSTR pszAdd, pszDot; if (PtrIsValid(cbi)) { GetWindowText((HWND)lParam, szText, _countof(szText)); EnableWindow(GetDlgItem(hDlg, IDOK), ((pszAdd = _tcschr(szText, '@')) && *(pszAdd + 1) != '.' && (pszDot = _tcschr(pszAdd, '.')) && *(pszDot + 1) && mir_tstrcmp(szText, cbi->pszVal))); } } break; } break; } return FALSE; }
static boolean CSettings_Dialog_HandleEvent(void *po, AEEEvent evt, uint16 wParam, uint32 dwParam) { CSettings* pMe = (CSettings*) po; user *pUser=NULL; AECHAR *rangetext=NULL; char* charrangetext=NULL; unsigned long time=0; if(evt == EVT_WDG_GETPROPERTY && wParam == FID_PREFRECT) { //catch FID_PREFRECT and set preferred extent of menu AEERect rc; ISHELL_GetDeviceInfo(pMe->pIShell, &pMe->DeviceInfo); if(pMe->isRoomimgDialog==1){ pMe->isRoomimgDialog=0; rc.x = pMe->DeviceInfo.cxScreen/10; rc.y = pMe->DeviceInfo.cyScreen/2; rc.dx = pMe->DeviceInfo.cxScreen*5/6; rc.dy = pMe->DeviceInfo.cyScreen-pMe->DeviceInfo.cyScreen*3/5; *(AEERect*) dwParam = rc; }else{ rc.x = 0; rc.y = pMe->DeviceInfo.cyScreen/4; rc.dx = pMe->DeviceInfo.cxScreen; rc.dy = pMe->DeviceInfo.cyScreen-pMe->DeviceInfo.cyScreen*19/56; *(AEERect*) dwParam = rc; } return TRUE; } if(evt == EVT_KEY && (wParam == AVK_CLR || wParam == AVK_SOFT2)) { IROOTFORM_PopForm(pMe->rootForm); deleteDialog(pMe); deleteShdulerForm(pMe); if(pMe->dialog) { IDIALOG_Release(pMe->dialog); pMe->dialog=NULL; } return TRUE; } if(evt == EVT_KEY && wParam == AVK_SOFT1) { if ( GetUserData(pMe->pIShell, &pUser)) { if(pMe->dialogEvent==1) { STRCPY(pUser->roomingState,"ON"); }if(pMe->dialogEvent==2) { STRCPY(pUser->roomingState,"OFF"); } if(pMe->dialogEvent==3) { IWIDGET_GetTextWidgetText(pMe->rangeCreateTextWidget,&rangetext); charrangetext=MALLOC(30); WSTRTOSTR(rangetext,charrangetext,30); if(IVALUEMODEL_GetBool(pMe->valueModel3)) { STRCPY(pUser->sheduler,"h"); if(STRTOUL(charrangetext, NULL, 10)>1000) time=500*3600000; else time = STRTOUL(charrangetext, NULL, 10)*3600000; } if(IVALUEMODEL_GetBool(pMe->valueModel4)) { STRCPY(pUser->sheduler,"m"); time = STRTOUL(charrangetext, NULL, 10)*60000; } if(IVALUEMODEL_GetBool(pMe->valueModel5)) { STRCPY(pUser->sheduler,"s"); time = STRTOUL(charrangetext, NULL, 10)*1000; } pUser->shedulePeriod=time; } SetUserData(pMe->pIShell, pUser); pMe->dialogEvent=0; FREEIF(charrangetext); FREEIF(pUser); } IROOTFORM_PopForm(pMe->rootForm); deleteDialog(pMe); deleteShdulerForm(pMe); if(pMe->dialog) { IDIALOG_Release(pMe->dialog); pMe->dialog=NULL; } return TRUE; } //the default form handler is swapped with the AppForm handler // calling this allows the default form handler to handle the event return HANDLERDESC_Call(&pMe->dlgHandler, evt, wParam, dwParam); }
/** * This static method is the window procedure for the dialog. * * @param hDlg - handle of the dialog window * @param uMsg - message to handle * @param wParam - message dependend parameter * @param lParam - message dependend parameter * * @return depends on message **/ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { CAnnivList *pDlg = (CAnnivList *)GetUserData(hDlg); switch (uMsg) { case WM_INITDIALOG: { HWND hCtrl; HICON hIcon; RECT rc; // link the class to the window handle pDlg = (CAnnivList *)lParam; if (!pDlg) break; SetUserData(hDlg, lParam); pDlg->_hDlg = hDlg; // init pointer listview control pDlg->_hList = GetDlgItem(hDlg, EDIT_ANNIVERSARY_DATE); if (!pDlg->_hList) break; // set icons hIcon = IcoLib_GetIcon(ICO_DLG_ANNIVERSARY); SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)hIcon); SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); // insert columns into the listboxes ListView_SetExtendedListViewStyle(pDlg->_hList, LVS_EX_FULLROWSELECT); // add columns if (pDlg->AddColumn(CAnnivList::COLUMN_ETA, LPGENT("ETA"), 40) || pDlg->AddColumn(CAnnivList::COLUMN_CONTACT, LPGENT("Contact"), 160) || pDlg->AddColumn(CAnnivList::COLUMN_PROTO, LPGENT("Proto"), 50) || pDlg->AddColumn(CAnnivList::COLUMN_AGE, LPGENT("Age/Nr."), 40) || pDlg->AddColumn(CAnnivList::COLUMN_DESC, LPGENT("Anniversary"), 100) || pDlg->AddColumn(CAnnivList::COLUMN_DATE, LPGENT("Date"), 80)) break; TranslateDialogDefault(hDlg); // save minimal size GetWindowRect(hDlg, &rc); pDlg->_sizeMin.cx = rc.right - rc.left; pDlg->_sizeMin.cy = rc.bottom - rc.top; // restore position and size Utils_RestoreWindowPosition(hDlg, NULL, MODNAME, "AnnivDlg_"); //save win pos GetWindowRect(hDlg, &pDlg->_rcWin); // add filter strings if (hCtrl = GetDlgItem(hDlg, COMBO_VIEW)) { ComboBox_AddString(hCtrl, TranslateT("All contacts")); ComboBox_AddString(hCtrl, TranslateT("Birthdays only")); ComboBox_AddString(hCtrl, TranslateT("Anniversaries only")); ComboBox_AddString(hCtrl, TranslateT("Disabled reminder")); ComboBox_SetCurSel(hCtrl, pDlg->_filter.bFilterIndex); } // init reminder groups pDlg->_bRemindEnable = db_get_b(NULL, MODNAME, SET_REMIND_ENABLED, DEFVAL_REMIND_ENABLED) != REMIND_OFF; if (hCtrl = GetDlgItem(hDlg, CHECK_REMIND)) { Button_SetCheck(hCtrl, pDlg->_bRemindEnable ? BST_INDETERMINATE : BST_UNCHECKED); EnableWindow(hCtrl, pDlg->_bRemindEnable); } CheckDlgButton(hDlg, CHECK_POPUP, db_get_b(NULL, MODNAME, SET_ANNIVLIST_POPUP, FALSE) ? BST_CHECKED : BST_UNCHECKED); // set number of days to show contact in advance SetDlgItemInt(hDlg, EDIT_DAYS, pDlg->_filter.wDaysBefore, FALSE); if (hCtrl = GetDlgItem(hDlg, CHECK_DAYS)) { Button_SetCheck(hCtrl, db_get_b(NULL, MODNAME, SET_ANNIVLIST_FILTER_DAYSENABLED, FALSE)); DlgProc(hDlg, WM_COMMAND, MAKEWPARAM(CHECK_DAYS, BN_CLICKED), (LPARAM)hCtrl); } pDlg->_wmINIT = false; } return TRUE; // set propertysheet page's background white in aero mode case WM_CTLCOLORSTATIC: case WM_CTLCOLORDLG: if (IsAeroMode()) return (INT_PTR)GetStockBrush(WHITE_BRUSH); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case EDIT_ANNIVERSARY_DATE: switch (((LPNMHDR)lParam)->code) { // handle changed selection case LVN_ITEMCHANGED: { CItemData *pid; HWND hCheck; pDlg->_curSel = ((LPNMLISTVIEW)lParam)->iItem; pid = pDlg->ItemData(pDlg->_curSel); if (pid && pDlg->_bRemindEnable && (hCheck = GetDlgItem(hDlg, CHECK_REMIND))) { SetDlgItemInt(hDlg, EDIT_REMIND, pid->_wDaysBefore, FALSE); Button_SetCheck(hCheck, pid->_wReminderState); DlgProc(hDlg, WM_COMMAND, MAKEWPARAM(CHECK_REMIND, BN_CLICKED), (LPARAM)hCheck); } } break; // resort the list case LVN_COLUMNCLICK: { LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam; if (pDlg->_sortHeader == pnmv->iSubItem) pDlg->_sortOrder *= -1; else { pDlg->_sortOrder = 1; pDlg->_sortHeader = pnmv->iSubItem; } ListView_SortItemsEx(pDlg->_hList, (CMPPROC)cmpProc, pDlg); } break; // show contact menu case NM_RCLICK: { CItemData *pid = pDlg->ItemData(pDlg->_curSel); if (pid) { HMENU hPopup = Menu_BuildContactMenu(pid->_hContact); if (hPopup) { POINT pt; GetCursorPos(&pt); TrackPopupMenu(hPopup, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hDlg, NULL); DestroyMenu(hPopup); } } } break; // handle double click on contact: show message dialog case NM_DBLCLK: { CItemData *pid = pDlg->ItemData(((LPNMITEMACTIVATE)lParam)->iItem); if (pid) CallService(MS_MSG_SENDMESSAGE,(WPARAM)pid->_hContact, NULL); } } } break; case WM_COMMAND: if (PtrIsValid(pDlg)) { CItemData* pid = pDlg->ItemData(pDlg->_curSel); // process contact menu command if (pid && CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)pid->_hContact)) break; switch (LOWORD(wParam)) { // enable/disable reminder checkbox is clicked case CHECK_REMIND: if (pDlg->_bRemindEnable && HIWORD(wParam) == BN_CLICKED) { BYTE checkState = Button_GetCheck((HWND)lParam); EnableWindow(GetDlgItem(hDlg, EDIT_REMIND), checkState == BST_CHECKED); EnableWindow(GetDlgItem(hDlg, SPIN_REMIND), checkState == BST_CHECKED); if (pid && pid->_wReminderState != checkState) pid->_wReminderState = checkState; } break; // number of days to remind in advance is edited case EDIT_REMIND: if (pid && pDlg->_bRemindEnable && HIWORD(wParam) == EN_CHANGE) { WORD wDaysBefore = GetDlgItemInt(hDlg, LOWORD(wParam), NULL, FALSE); if (pid->_wReminderState == BST_CHECKED && pid->_wDaysBefore != wDaysBefore) { pid->_wDaysBefore = wDaysBefore; } } break; // the filter to display only contacts which have an anniversary in a certain // period of time is enabled/disabled case CHECK_DAYS: if (HIWORD(wParam) == BN_CLICKED) { BYTE isChecked = Button_GetCheck((HWND)lParam); EnableWindow(GetDlgItem(hDlg, EDIT_DAYS), isChecked); EnableWindow(GetDlgItem(hDlg, TXT_DAYS), isChecked); pDlg->_filter.wDaysBefore = isChecked ? GetDlgItemInt(hDlg, EDIT_DAYS, NULL, FALSE) : (WORD)-1; pDlg->RebuildList(); } break; // the number of days a contact must have an anniversary in advance to be displayed is edited case EDIT_DAYS: if (HIWORD(wParam) == EN_CHANGE) { WORD wNewDays = GetDlgItemInt(hDlg, LOWORD(wParam), NULL, FALSE); if (wNewDays != pDlg->_filter.wDaysBefore) { pDlg->_filter.wDaysBefore = wNewDays; pDlg->RebuildList(); } } break; // the filter selection of the filter combobox has changed case COMBO_VIEW: if (HIWORD(wParam) == CBN_SELCHANGE) { pDlg->_filter.bFilterIndex = ComboBox_GetCurSel((HWND)lParam); pDlg->RebuildList(); } } } break; case WM_DRAWITEM: return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam); case WM_MEASUREITEM: return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam); case WM_WINDOWPOSCHANGING: if (PtrIsValid(pDlg)) { WINDOWPOS *wndPos = (WINDOWPOS *)lParam; if (!pDlg->_wmINIT && (wndPos->cx != 0 || wndPos->cy != 0)) { //win pos change if ((wndPos->cx == pDlg->_rcWin.right - pDlg->_rcWin.left) && (wndPos->cy == pDlg->_rcWin.bottom - pDlg->_rcWin.top)) //win pos change (store new pos) GetWindowRect(hDlg, &pDlg->_rcWin); //win size change else { // l change if ((wndPos->cx < pDlg->_sizeMin.cx) && (wndPos->x > pDlg->_rcWin.left)) { wndPos->x = wndPos->x + wndPos->cx - pDlg->_sizeMin.cx; wndPos->cx = pDlg->_sizeMin.cx; } // r change else if (wndPos->cx < pDlg->_sizeMin.cx) wndPos->cx = pDlg->_sizeMin.cx; // t change if ((wndPos->cy < pDlg->_sizeMin.cy) && (wndPos->y > pDlg->_rcWin.top)) { wndPos->y = wndPos->y + wndPos->cy - pDlg->_sizeMin.cy; wndPos->cy = pDlg->_sizeMin.cy; } // b change else if (wndPos->cy < pDlg->_sizeMin.cy) wndPos->cy = pDlg->_sizeMin.cy; pDlg->_rcWin.left = wndPos->x; pDlg->_rcWin.right = wndPos->x + wndPos->cx; pDlg->_rcWin.top = wndPos->y; pDlg->_rcWin.bottom = wndPos->y + wndPos->cy; } } CAnchor anchor(wndPos, pDlg->_sizeMin); int anchorPos = CAnchor::ANCHOR_LEFT | CAnchor::ANCHOR_RIGHT | CAnchor::ANCHOR_TOP; anchor.MoveCtrl(IDC_HEADERBAR, anchorPos); anchor.MoveCtrl(GROUP_STATS, anchorPos); // birthday list anchor.MoveCtrl(EDIT_ANNIVERSARY_DATE, CAnchor::ANCHOR_ALL); anchorPos = CAnchor::ANCHOR_RIGHT | CAnchor::ANCHOR_BOTTOM; // filter group anchor.MoveCtrl(GROUP_FILTER, anchorPos); anchor.MoveCtrl(COMBO_VIEW, anchorPos); anchor.MoveCtrl(CHECK_DAYS, anchorPos); anchor.MoveCtrl(EDIT_DAYS, anchorPos); anchor.MoveCtrl(TXT_DAYS, anchorPos); // filter group anchor.MoveCtrl(GROUP_REMINDER, anchorPos); anchor.MoveCtrl(CHECK_REMIND, anchorPos); anchor.MoveCtrl(EDIT_REMIND, anchorPos); anchor.MoveCtrl(SPIN_REMIND, anchorPos); anchor.MoveCtrl(TXT_REMIND6, anchorPos); anchor.MoveCtrl(CHECK_POPUP, anchorPos); } break; // This message is sent if eighter the user clicked on the close button or // Miranda fires the ME_SYSTEM_SHUTDOWN event. case WM_CLOSE: DestroyWindow(hDlg); break; // If the anniversary list is destroyed somehow, the data class must be deleted, too. case WM_DESTROY: if (PtrIsValid(pDlg)) { SetUserData(hDlg, NULL); delete pDlg; } break; } return FALSE; }
CCtrlList::CCtrlList(HWND hOwnerDlg) : LIST<CBaseCtrl>(10, (FTSortFunc) CCtrlList::sortFunc) { _hOwnerDlg = hOwnerDlg; SetUserData(_hOwnerDlg, this); }
CBaseCtrl::~CBaseCtrl() { SetUserData(_hwnd, NULL); MIR_FREE(_pszValue); }
void CControlUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { // ÊÇ·ñÑùʽ±í if(m_pManager != NULL) { LPCTSTR pStyle = m_pManager->GetStyle(pstrValue); if( pStyle != NULL) { ApplyAttributeList(pStyle); return; } } if( _tcsicmp(pstrName, _T("pos")) == 0 ) { RECT rcPos = { 0 }; LPTSTR pstr = NULL; rcPos.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcPos.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPos.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPos.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SIZE szXY = {rcPos.left >= 0 ? rcPos.left : rcPos.right, rcPos.top >= 0 ? rcPos.top : rcPos.bottom}; SetFixedXY(szXY); SetFixedWidth(rcPos.right - rcPos.left); SetFixedHeight(rcPos.bottom - rcPos.top); } else if( _tcsicmp(pstrName, _T("float")) == 0 ) { CDuiString nValue = pstrValue; // ¶¯Ì¬¼ÆËãÏà¶Ô±ÈÀý if(nValue.Find(',') < 0) { SetFloat(_tcsicmp(pstrValue, _T("true")) == 0); } else { TPercentInfo piFloatPercent = { 0 }; LPTSTR pstr = NULL; piFloatPercent.left = _tcstod(pstrValue, &pstr); ASSERT(pstr); piFloatPercent.top = _tcstod(pstr + 1, &pstr); ASSERT(pstr); piFloatPercent.right = _tcstod(pstr + 1, &pstr); ASSERT(pstr); piFloatPercent.bottom = _tcstod(pstr + 1, &pstr); ASSERT(pstr); SetFloatPercent(piFloatPercent); SetFloat(true); } } else if( _tcsicmp(pstrName, _T("padding")) == 0 ) { RECT rcPadding = { 0 }; LPTSTR pstr = NULL; rcPadding.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcPadding.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPadding.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetPadding(rcPadding); } else if( _tcsicmp(pstrName, _T("bkcolor")) == 0 || _tcsicmp(pstrName, _T("bkcolor1")) == 0 ) { while( *pstrValue > _T('\0') && *pstrValue <= _T(' ') ) pstrValue = ::CharNext(pstrValue); if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetBkColor(clrColor); } else if( _tcsicmp(pstrName, _T("bkcolor2")) == 0 ) { while( *pstrValue > _T('\0') && *pstrValue <= _T(' ') ) pstrValue = ::CharNext(pstrValue); if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetBkColor2(clrColor); } else if( _tcsicmp(pstrName, _T("bkcolor3")) == 0 ) { while( *pstrValue > _T('\0') && *pstrValue <= _T(' ') ) pstrValue = ::CharNext(pstrValue); if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetBkColor3(clrColor); } else if( _tcsicmp(pstrName, _T("forecolor")) == 0 ) { while( *pstrValue > _T('\0') && *pstrValue <= _T(' ') ) pstrValue = ::CharNext(pstrValue); if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetForeColor(clrColor); } else if( _tcsicmp(pstrName, _T("bordercolor")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetBorderColor(clrColor); } else if( _tcsicmp(pstrName, _T("focusbordercolor")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetFocusBorderColor(clrColor); } else if( _tcsicmp(pstrName, _T("colorhsl")) == 0 ) SetColorHSL(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("bordersize")) == 0 ) { CDuiString nValue = pstrValue; if(nValue.Find(',') < 0) { SetBorderSize(_ttoi(pstrValue)); RECT rcPadding = {0}; SetBorderSize(rcPadding); } else { RECT rcPadding = { 0 }; LPTSTR pstr = NULL; rcPadding.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcPadding.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPadding.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetBorderSize(rcPadding); } } else if( _tcsicmp(pstrName, _T("leftbordersize")) == 0 ) SetLeftBorderSize(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("topbordersize")) == 0 ) SetTopBorderSize(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("rightbordersize")) == 0 ) SetRightBorderSize(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("bottombordersize")) == 0 ) SetBottomBorderSize(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("borderstyle")) == 0 ) SetBorderStyle(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("borderround")) == 0 ) { SIZE cxyRound = { 0 }; LPTSTR pstr = NULL; cxyRound.cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); cxyRound.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetBorderRound(cxyRound); } else if( _tcsicmp(pstrName, _T("bkimage")) == 0 ) SetBkImage(pstrValue); else if( _tcsicmp(pstrName, _T("foreimage")) == 0 ) SetForeImage(pstrValue); else if( _tcsicmp(pstrName, _T("width")) == 0 ) SetFixedWidth(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("height")) == 0 ) SetFixedHeight(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("minwidth")) == 0 ) SetMinWidth(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("minheight")) == 0 ) SetMinHeight(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("maxwidth")) == 0 ) SetMaxWidth(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("maxheight")) == 0 ) SetMaxHeight(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("name")) == 0 ) SetName(pstrValue); else if( _tcsicmp(pstrName, _T("drag")) == 0 ) SetDragEnable(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("drop")) == 0 ) SetDropEnable(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("resourcetext")) == 0 ) SetResourceText(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("text")) == 0 ) SetText(pstrValue); else if( _tcsicmp(pstrName, _T("tooltip")) == 0 ) SetToolTip(pstrValue); else if( _tcsicmp(pstrName, _T("userdata")) == 0 ) SetUserData(pstrValue); else if( _tcsicmp(pstrName, _T("enabled")) == 0 ) SetEnabled(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("mouse")) == 0 ) SetMouseEnabled(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("keyboard")) == 0 ) SetKeyboardEnabled(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("visible")) == 0 ) SetVisible(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("float")) == 0 ) SetFloat(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("shortcut")) == 0 ) SetShortcut(pstrValue[0]); else if( _tcsicmp(pstrName, _T("menu")) == 0 ) SetContextMenuUsed(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("cursor")) == 0 && pstrValue) { if( _tcsicmp(pstrValue, _T("arrow")) == 0 ) SetCursor(DUI_ARROW); else if( _tcsicmp(pstrValue, _T("ibeam")) == 0 ) SetCursor(DUI_IBEAM); else if( _tcsicmp(pstrValue, _T("wait")) == 0 ) SetCursor(DUI_WAIT); else if( _tcsicmp(pstrValue, _T("cross")) == 0 ) SetCursor(DUI_CROSS); else if( _tcsicmp(pstrValue, _T("uparrow")) == 0 ) SetCursor(DUI_UPARROW); else if( _tcsicmp(pstrValue, _T("size")) == 0 ) SetCursor(DUI_SIZE); else if( _tcsicmp(pstrValue, _T("icon")) == 0 ) SetCursor(DUI_ICON); else if( _tcsicmp(pstrValue, _T("sizenwse")) == 0 ) SetCursor(DUI_SIZENWSE); else if( _tcsicmp(pstrValue, _T("sizenesw")) == 0 ) SetCursor(DUI_SIZENESW); else if( _tcsicmp(pstrValue, _T("sizewe")) == 0 ) SetCursor(DUI_SIZEWE); else if( _tcsicmp(pstrValue, _T("sizens")) == 0 ) SetCursor(DUI_SIZENS); else if( _tcsicmp(pstrValue, _T("sizeall")) == 0 ) SetCursor(DUI_SIZEALL); else if( _tcsicmp(pstrValue, _T("no")) == 0 ) SetCursor(DUI_NO); else if( _tcsicmp(pstrValue, _T("hand")) == 0 ) SetCursor(DUI_HAND); } else if( _tcsicmp(pstrName, _T("virtualwnd")) == 0 ) SetVirtualWnd(pstrValue); else if( _tcsicmp(pstrName, _T("innerstyle")) == 0 ) { CDuiString sXmlData = pstrValue; sXmlData.Replace(_T("""), _T("\"")); LPCTSTR pstrList = sXmlData.GetData(); CDuiString sItem; CDuiString sValue; while( *pstrList != _T('\0') ) { sItem.Empty(); sValue.Empty(); while( *pstrList != _T('\0') && *pstrList != _T('=') ) { LPTSTR pstrTemp = ::CharNext(pstrList); while( pstrList < pstrTemp) { sItem += *pstrList++; } } ASSERT( *pstrList == _T('=') ); if( *pstrList++ != _T('=') ) return; ASSERT( *pstrList == _T('\"') ); if( *pstrList++ != _T('\"') ) return; while( *pstrList != _T('\0') && *pstrList != _T('\"') ) { LPTSTR pstrTemp = ::CharNext(pstrList); while( pstrList < pstrTemp) { sValue += *pstrList++; } } ASSERT( *pstrList == _T('\"') ); if( *pstrList++ != _T('\"') ) return; SetAttribute(sItem, sValue); if( *pstrList++ != _T(' ') && *pstrList++ != _T(',') ) return; } } }