void Elapsed_Edit_OnSetFocus (ElapsedInfo *pei, HWND hEdit) { pei->fCanCallBack --; RECT rSpinner; GetRectInParent (pei->hElapsed, &rSpinner); rSpinner.left = rSpinner.right; rSpinner.right = rSpinner.left + GetSystemMetrics (SM_CXVSCROLL); rSpinner.bottom -= 2; // just like Win95 does DWORD dwMin; DWORD dwPos; DWORD dwMax; Elapsed_Edit_GetSpinnerRange (pei, hEdit, &dwMin, &dwPos, &dwMax); CreateSpinner (hEdit, 10, FALSE, dwMin, dwPos, dwMax, &rSpinner); if (pei->hSpinner) DestroyWindow (pei->hSpinner); if (hEdit == pei->hHours) SP_SetFormat (hEdit, TEXT("%lu")); else SP_SetFormat (hEdit, TEXT("%02lu")); pei->hSpinner = SP_GetSpinner (hEdit); pei->hSpinnerBuddy = hEdit; SendMessage (hEdit, EM_SETSEL, (WPARAM)0, (LPARAM)-1); // select all pei->fCanCallBack ++; }
void WLTreeItemAL::_CustomInternalDraw(HDC hDC, RECT const &rcUpdate, RECT const &rcViewInThis) { CRect rcInHost ; GetRectInHost(rcInHost) ; RECT rcInsterset ; if (!IsWndLessVisible() || !::IntersectRect(&rcInsterset, &rcInHost, &rcUpdate)) return ; #ifdef _TRACEDRAW TRACE(_T("--> %S::_InternalOnDraw [%p]\n"), typeid(*this).name(), this) ; CString s ; s.Format(_T("<-- %S::_InternalOnDraw [%p]"), typeid(*this).name(), this) ; hdutils::CPUPerformance cp(s) ; #endif CRect rc ; GetRectInParent(rc) ; if (m_nItemHeight > rcViewInThis.top) { OnDraw(hDC, rcUpdate) ; } CustomOnDrawChild(hDC, rcUpdate, rcViewInThis) ; }
BOOL WhereShouldSplitterGo (HWND hWnd, int id1, int id2, RECT *prWnd, BOOL *pfX) { RECT r1, r2; BOOL rc = TRUE; GetRectInParent (GetDlgItem (hWnd, id1), &r1); GetRectInParent (GetDlgItem (hWnd, id2), &r2); if (r2.left > r1.right) // R1 on left, R2 on right? { *pfX = TRUE; prWnd->top = min (r1.top, r2.top); prWnd->bottom = max (r1.bottom, r2.bottom); prWnd->left = r1.right; prWnd->right = r2.left; } else if (r2.right < r1.left) // R2 on left, R1 on right? { *pfX = TRUE; prWnd->top = min (r1.top, r2.top); prWnd->bottom = max (r1.bottom, r2.bottom); prWnd->left = r2.right; prWnd->right = r1.left; } else if (r2.top > r1.bottom) // R1 on top, R2 on bottom? { *pfX = FALSE; prWnd->left = min (r1.left, r2.left); prWnd->right = max (r1.right, r2.right); prWnd->top = r1.bottom; prWnd->bottom = r2.top; } else if (r2.bottom < r1.top) // R2 on top, R1 on bottom? { *pfX = FALSE; prWnd->left = min (r1.left, r2.left); prWnd->right = max (r1.right, r2.right); prWnd->top = r2.bottom; prWnd->bottom = r1.top; } else // Rectangles intersect! { // Don't know where it should go. rc = FALSE; } return rc; }
void Server_Salvage_OnAdvanced (HWND hDlg) { HWND hGroup = GetDlgItem (hDlg, IDC_ADVANCED_GROUP); RECT rWindow; RECT rClient; RECT rGroup; GetWindowRect (hDlg, &rWindow); GetClientRect (hDlg, &rClient); GetRectInParent (hGroup, &rGroup); if (!IsWindowEnabled (GetDlgItem (hDlg, IDC_SALVAGE_TEMPDIR))) { EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_TEMPDIR), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_SIMUL), TRUE); Server_Salvage_OnSimultaneous (hDlg); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_READONLY), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_BLOCK), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_FORCE), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_FIXDIRS), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_LOG_FILE), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_LOG_INODES), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_LOG_ROOT), TRUE); SetWindowPos (hDlg, NULL, 0, 0, cxRECT(rWindow), cyRECT(rWindow) + cyRECT(rGroup) + 14, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); TCHAR szText[ cchRESOURCE ]; GetString (szText, IDS_ADVANCEDIN_BUTTON); SetDlgItemText (hDlg, IDC_ADVANCED, szText); } else // open now? { SetWindowPos (hDlg, NULL, 0, 0, cxRECT(rWindow), cyRECT(rWindow) - cyRECT(rGroup) - 14, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); TCHAR szText[ cchRESOURCE ]; GetString (szText, IDS_ADVANCEDOUT_BUTTON); SetDlgItemText (hDlg, IDC_ADVANCED, szText); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_TEMPDIR), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_SIMUL), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_NUM), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_READONLY), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_BLOCK), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_FORCE), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_FIXDIRS), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_LOG_FILE), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_LOG_INODES), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SALVAGE_LOG_ROOT), FALSE); } }
void Main_OnInitDialog (HWND hDlg) { // Resize and reposition the main window // RECT rWindow = gr.rMain; if (!rWindow.right) GetWindowRect (hDlg, &rWindow); ResizeWindow (hDlg, awdMain, rwaMoveToHere, &rWindow); // Add tabs to the main window's tab control // HWND hTab = GetDlgItem (hDlg, IDC_TAB); TabCtrl_SetImageList (hTab, AfsAppLib_CreateImageList (FALSE)); TCHAR szText[ cchRESOURCE ]; TC_ITEM tci; tci.mask = TCIF_TEXT | TCIF_PARAM | TCIF_IMAGE; tci.pszText = szText; for (size_t iTab = 0; iTab < cTABS; ++iTab) { tci.iImage = aTABS[ iTab ].idiImage; tci.lParam = (LPARAM)aTABS[ iTab ].tt; GetString (tci.pszText, aTABS[ iTab ].idsText); TabCtrl_InsertItem (hTab, iTab, &tci); } // Subclass the tab control, so that we can make it forward any WM_SIZE // messages to its child window. // Subclass_AddHook (hTab, Main_TabHookProc); // Since we just subclassed this control, our new wndproc wasn't around // when the window was created. Any WM_CREATE processing we'd ordinarily // in that wndproc must therefore be done here. // WM_CREATE: RECT rTab; GetRectInParent (hTab, &rTab); ResizeWindow (hTab, awdTabChild, rwaMoveToHere, &rTab); // Select an appropriate tab and display it. // Main_PrepareTabChild (gr.iTabLast); // Tell the admin client that we're interested in any actions that occur // ULONG status; asc_ActionListen (g.idClient, g.hMain, &status); }
void WIZARD::Refresh (DWORD dwRefFlags) { if (dwRefFlags & REFRESH_LEFT_PANE) { HWND hLHS; if ((hLHS = GetDlgItem (m_hWnd, m_idcLeftPane)) != NULL) { RECT rr; GetClientRect (hLHS, &rr); InvalidateRect (hLHS, &rr, TRUE); UpdateWindow (hLHS); } } if (dwRefFlags & REFRESH_RIGHT_PANE) { HWND hRHS; if ((hRHS = GetDlgItem (m_hWnd, m_idcRightPane)) != NULL) { HWND hOld = GetRightHandWindow(); LPWIZARD_STATE pState; if ((pState = FindState (m_stCurrent)) != NULL) { int stCurrent = m_stCurrent; HWND hNew; if ((hNew = ModelessDialogParam (pState->idd, m_hWnd, pState->dlgproc, pState->lp)) != NULL) { if (stCurrent != m_stCurrent) DestroyWindow (hNew); else { RECT rRHS; GetRectInParent (hRHS, &rRHS); SetWindowPos (hNew, NULL, rRHS.left, rRHS.top, cxRECT(rRHS), cyRECT(rRHS), SWP_NOZORDER | SWP_NOACTIVATE); SetWindowLong (hNew, GWL_ID, pState->idd); ShowWindow (hNew, SW_SHOW); ShowWindow (hRHS, SW_HIDE); } } } if (hOld != NULL) DestroyWindow (hOld); } } }
void Server_PrepareTabControl (HWND hTab) { TabCtrl_SetImageList (hTab, AfsAppLib_CreateImageList (FALSE)); TCHAR szText[ cchRESOURCE ]; TC_ITEM tci; tci.mask = TCIF_TEXT | TCIF_PARAM | TCIF_IMAGE; tci.pszText = szText; for (int iTab = 0; iTab < nCHILDTABS; ++iTab) { tci.iImage = CHILDTABINFO[ iTab ].iImage; tci.lParam = (LPARAM)CHILDTABINFO[ iTab ].tab; GetString (tci.pszText, CHILDTABINFO[ iTab ].idsTabTitle); TabCtrl_InsertItem (hTab, iTab, &tci); } // subclass the TCN_ window, so that it will start sending WM_SIZE // messages to its child window. // procTabControl = GetWindowLongPtr (hTab, GWLP_WNDPROC); SetWindowLongPtr (hTab, GWLP_WNDPROC, (LONG_PTR)Server_SubclassTabControlProc); // Since we just subclassed this control, our new wndproc wasn't around // when the window was created. Any WM_CREATE processing we'd ordinarily // in that wndproc must therefore be done here. // WM_CREATE: RECT rWindow; GetRectInParent (hTab, &rWindow); ResizeWindow (hTab, awdTabChild, rwaMoveToHere, &rWindow); // Finally, select an appropriate tab and display it. // Server_DisplayTab (GetParent (hTab), gr.tabLast); }
void DlgProc_Browse_OnInitDialog (HWND hDlg, BROWSEDIALOGPARAMS *pbdp) { TCHAR szText[ cchRESOURCE ]; LPTSTR psz; pbdp->hDlg = hDlg; // We'll need an imagelist, if we want icons in the listview. // This looks difficult but it's not--tis just a matter of selecting // an appropriate bitmap. // if ((pbdp->hImages = ImageList_Create (cxICON, cyICON, ILC_COLOR4 | ILC_MASK, 1, 1)) != 0) { HBITMAP bmp; if (pbdp->bt == btLOCAL_USER) { bmp = LoadBitmap (APPLIB_HINST, MAKEINTRESOURCE( IDB_LOCAL_USER )); } else if (pbdp->bt == btANY_USER) { bmp = LoadBitmap (APPLIB_HINST, MAKEINTRESOURCE( IDB_FOREIGN_USER )); } else if (pbdp->bt == btLOCAL_GROUP) { bmp = LoadBitmap (APPLIB_HINST, MAKEINTRESOURCE( IDB_LOCAL_GROUP )); } else if (pbdp->bt == btANY_GROUP) { bmp = LoadBitmap (APPLIB_HINST, MAKEINTRESOURCE( IDB_FOREIGN_GROUP )); } if (bmp != NULL) { ImageList_AddMasked (pbdp->hImages, bmp, clrTRANSPARENT); DeleteObject (bmp); } ListView_SetImageList (GetDlgItem (hDlg, IDC_BROWSE_LIST), pbdp->hImages, LVSIL_SMALL); } // There's a default pushbutton on this dialog, so that hitting // RETURN when you're in the Cell combobox will restart the search // (a default pushbutton always gets called when RETURN is hit, // unless your control traps it). But the user doesn't want to *see* // that thing, so move it way off the dialog's client area. // RECT r; GetWindowRect (GetDlgItem (hDlg, IDC_BROWSE_RESTART), &r); SetWindowPos (GetDlgItem (hDlg, IDC_BROWSE_RESTART), NULL, 0 - (r.right-r.left), 0 - (r.bottom-r.top), 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); // Fill in the choices underneath IDC_BROWSE_CELL. Can the // user enter a new cell name? // if (pbdp->fThisCellOnly) { EnableWindow (GetDlgItem (hDlg, IDC_BROWSE_CELL), FALSE); } else { CB_StartChange (GetDlgItem (hDlg, IDC_BROWSE_CELL)); if (!pbdp->lpcl) { TCHAR szDefCell[ cchNAME ]; if (AfsAppLib_GetLocalCell (szDefCell) && *szDefCell) { CB_AddItem (GetDlgItem (hDlg, IDC_BROWSE_CELL), szDefCell, 1); } } else for (size_t ii = 0; ii < pbdp->lpcl->nCells; ++ii) { CB_AddItem (GetDlgItem (hDlg, IDC_BROWSE_CELL), pbdp->lpcl->aCells[ii], 1+ii); } CB_EndChange (GetDlgItem (hDlg, IDC_BROWSE_CELL), 1); } // Select various texts to display in the dialog // psz = FormatString (TEXT("%1"), TEXT("%m"), pbdp->idsTitle); SetWindowText (hDlg, psz); FreeString (psz); GetString (szText, pbdp->idsPrompt); SetDlgItemText (hDlg, IDC_BROWSE_TYPE, szText); // If the caller wants us to display a "[X] No Group" checkbox, do so // by creating a checkbox right underneath the IDC_BROWSE_NAMED edit // control--note that we'll have to hide IDC_BROWSE_STATUS if that's // the case. // if (pbdp->idsNone != 0) { ShowWindow (GetDlgItem (pbdp->hDlg, IDC_BROWSE_STATUS), FALSE); RECT rr; GetRectInParent (GetDlgItem (pbdp->hDlg, IDC_BROWSE_NAMED), &rr); LONG cy; cy = rr.bottom -rr.top; rr.top += cy +3; rr.bottom = rr.top +cy; GetString (szText, pbdp->idsNone); CreateWindow ("Button", szText, WS_CHILD | BS_AUTOCHECKBOX, rr.left, rr.top, rr.right-rr.left, rr.bottom-rr.top, pbdp->hDlg, (HMENU)IDC_BROWSE_NONE, APPLIB_HINST, 0); HFONT hf = (HFONT)GetStockObject (DEFAULT_GUI_FONT); SendMessage (GetDlgItem (pbdp->hDlg, IDC_BROWSE_NONE), WM_SETFONT, (WPARAM)hf, FALSE); ShowWindow (GetDlgItem (pbdp->hDlg, IDC_BROWSE_NONE), TRUE); if (pbdp->szNamed[0] == TEXT('\0')) CheckDlgButton (pbdp->hDlg, IDC_BROWSE_NONE, TRUE); else CheckDlgButton (pbdp->hDlg, IDC_BROWSE_NONE, FALSE); DlgProc_Browse_OnNone (pbdp->hDlg, pbdp); } SetDlgItemText (hDlg, IDC_BROWSE_CELL, pbdp->szCell); SetDlgItemText (hDlg, IDC_BROWSE_NAMED, pbdp->szNamed); // Start looking for users/groups // DlgProc_Browse_StartSearch (pbdp, TRUE); }
HRESULT CALLBACK ElapsedProc (HWND hElapsed, UINT msg, WPARAM wp, LPARAM lp) { ElapsedInfo *pei = NULL; EnterCriticalSection (&csElapsed); if (msg == WM_CREATE) { size_t iElapsed; for (iElapsed = 0; iElapsed < cElapsed; ++iElapsed) { if (aElapsed[ iElapsed ].hElapsed == NULL) break; } if (iElapsed >= cElapsed) { if (!REALLOC (aElapsed, cElapsed, 1+iElapsed, 4)) return FALSE; } memset (&aElapsed[ iElapsed ], 0x00, sizeof(ElapsedInfo)); aElapsed[ iElapsed ].hElapsed = hElapsed; pei = &aElapsed[ iElapsed ]; } else { for (size_t iElapsed = 0; !pei && iElapsed < cElapsed; ++iElapsed) { if (aElapsed[ iElapsed ].hElapsed == hElapsed) pei = &aElapsed[ iElapsed ]; } } LeaveCriticalSection (&csElapsed); if (pei != NULL) { switch (msg) { case WM_CREATE: Elapsed_OnCreate (pei); break; case WM_DESTROY: Elapsed_OnDestroy (pei); break; case WM_RBUTTONDOWN: case WM_LBUTTONDOWN: Elapsed_OnButtonDown (pei, msg, wp, lp); break; case WM_SETFOCUS: PostMessage (GetParent(hElapsed), WM_NEXTDLGCTL, (WPARAM)pei->hHours, TRUE); break; case WM_ENABLE: EnableWindow (pei->hHours, IsWindowEnabled (hElapsed)); EnableWindow (pei->hSep1, IsWindowEnabled (hElapsed)); EnableWindow (pei->hMinutes, IsWindowEnabled (hElapsed)); EnableWindow (pei->hSep2, IsWindowEnabled (hElapsed)); EnableWindow (pei->hSeconds, IsWindowEnabled (hElapsed)); EnableWindow (pei->hSpinner, IsWindowEnabled (hElapsed)); RECT rElapsed; GetRectInParent (hElapsed, &rElapsed); InvalidateRect (GetParent(hElapsed), &rElapsed, TRUE); UpdateWindow (GetParent(hElapsed)); break; case WM_SYSCHAR: case WM_CHAR: switch (wp) { case VK_UP: PostMessage (GetParent(pei->hSpinner), WM_VSCROLL, SB_LINEUP, (LPARAM)pei->hSpinner); break; case VK_DOWN: PostMessage (GetParent(pei->hSpinner), WM_VSCROLL, SB_LINEDOWN, (LPARAM)pei->hSpinner); break; case VK_PRIOR: PostMessage (GetParent(pei->hSpinner), WM_VSCROLL, SB_PAGEUP, (LPARAM)pei->hSpinner); break; case VK_NEXT: PostMessage (GetParent(pei->hSpinner), WM_VSCROLL, SB_PAGEDOWN, (LPARAM)pei->hSpinner); break; case VK_HOME: PostMessage (GetParent(pei->hSpinner), WM_VSCROLL, SB_TOP, (LPARAM)pei->hSpinner); break; case VK_END: PostMessage (GetParent(pei->hSpinner), WM_VSCROLL, SB_BOTTOM, (LPARAM)pei->hSpinner); break; } break; case ELM_GETRANGE: return Elapsed_OnGetRange (pei, wp, lp); case ELM_SETRANGE: return Elapsed_OnSetRange (pei, wp, lp); case ELM_GETTIME: return Elapsed_OnGetTime (pei, wp, lp); case ELM_SETTIME: return Elapsed_OnSetTime (pei, wp, lp); } } return DefWindowProc (hElapsed, msg, wp, lp); }
void Filesets_General_OnEndTask_InitDialog (HWND hDlg, LPTASKPACKET ptp, LPIDENT lpi) { LPTSTR pszText; TCHAR szUnknown[ cchRESOURCE ]; GetString (szUnknown, IDS_UNKNOWN); if (!ptp->rc) { SetDlgItemText (hDlg, IDC_SET_CREATEDATE, szUnknown); SetDlgItemText (hDlg, IDC_SET_UPDATEDATE, szUnknown); SetDlgItemText (hDlg, IDC_SET_ACCESSDATE, szUnknown); SetDlgItemText (hDlg, IDC_SET_BACKUPDATE, szUnknown); SetDlgItemText (hDlg, IDC_SET_USAGE, szUnknown); SetDlgItemText (hDlg, IDC_SET_STATUS, szUnknown); SetDlgItemText (hDlg, IDC_SET_FILES, szUnknown); TCHAR szSvrName[ cchNAME ]; TCHAR szAggName[ cchNAME ]; TCHAR szSetName[ cchNAME ]; lpi->GetServerName (szSvrName); lpi->GetAggregateName (szAggName); lpi->GetFilesetName (szSetName); ErrorDialog (ptp->status, IDS_ERROR_REFRESH_FILESET_STATUS, TEXT("%s%s%s"), szSvrName, szAggName, szSetName); } else { TCHAR szText[ cchRESOURCE ]; EnableWindow (GetDlgItem (hDlg, IDC_SET_LOCK), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SET_UNLOCK), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SET_QUOTA), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_DEF), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_PERCENT), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_DESC), TRUE); if (!FormatTime (szText, TEXT("%s"), &TASKDATA(ptp)->fs.timeCreation)) SetDlgItemText (hDlg, IDC_SET_CREATEDATE, szUnknown); else SetDlgItemText (hDlg, IDC_SET_CREATEDATE, szText); if (!FormatTime (szText, TEXT("%s"), &TASKDATA(ptp)->fs.timeLastUpdate)) SetDlgItemText (hDlg, IDC_SET_UPDATEDATE, szUnknown); else SetDlgItemText (hDlg, IDC_SET_UPDATEDATE, szText); if (!FormatTime (szText, TEXT("%s"), &TASKDATA(ptp)->fs.timeLastAccess)) SetDlgItemText (hDlg, IDC_SET_ACCESSDATE, szUnknown); else SetDlgItemText (hDlg, IDC_SET_ACCESSDATE, szText); if (!FormatTime (szText, TEXT("%s"), &TASKDATA(ptp)->fs.timeLastBackup)) SetDlgItemText (hDlg, IDC_SET_BACKUPDATE, szUnknown); else SetDlgItemText (hDlg, IDC_SET_BACKUPDATE, szText); wsprintf (szText, TEXT("%lu"), TASKDATA(ptp)->fs.nFiles); SetDlgItemText (hDlg, IDC_SET_FILES, szText); size_t nAlerts = Alert_GetCount (lpi); if (nAlerts == 1) { GetString (szText, IDS_SETSTATUS_1ALERT); SetDlgItemText (hDlg, IDC_SET_STATUS, szText); } else if (nAlerts > 1) { pszText = FormatString (IDS_SETSTATUS_2ALERT, TEXT("%lu"), nAlerts); SetDlgItemText (hDlg, IDC_SET_STATUS, pszText); FreeString (pszText); } else // (nAlerts == 0) { if (TASKDATA(ptp)->fs.State & fsBUSY) GetString (szText, IDS_SETSTATUS_BUSY); else if (TASKDATA(ptp)->fs.State & fsSALVAGE) GetString (szText, IDS_SETSTATUS_SALVAGE); else if (TASKDATA(ptp)->fs.State & fsMOVED) GetString (szText, IDS_SETSTATUS_MOVED); else if (TASKDATA(ptp)->fs.State & fsLOCKED) GetString (szText, IDS_SETSTATUS_LOCKED); else if (TASKDATA(ptp)->fs.State & fsNO_VOL) GetString (szText, IDS_SETSTATUS_NO_VOL); else GetString (szText, IDS_STATUS_NOALERTS); SetDlgItemText (hDlg, IDC_SET_STATUS, szText); } if (TASKDATA(ptp)->fs.Type == ftREADWRITE) { Filesets_DisplayQuota (hDlg, &TASKDATA(ptp)->fs); } else { if (TASKDATA(ptp)->fs.Type == ftREPLICA) GetString (szText, IDS_USAGE_REPLICA); else // (TASKDATA(ptp)->fs.Type == ftCLONE) GetString (szText, IDS_USAGE_CLONE); pszText = FormatString (szText, TEXT("%.1B"), (double)TASKDATA(ptp)->fs.ckUsed * cb1KB); SetDlgItemText (hDlg, IDC_SET_USAGE, pszText); FreeString (pszText); if (GetDlgItem (hDlg, IDC_SET_USAGEBAR)) { RECT rUsagebar; GetRectInParent (GetDlgItem (hDlg, IDC_SET_USAGEBAR), &rUsagebar); HFONT hf = (HFONT)SendMessage (GetDlgItem (hDlg, IDC_SET_USAGEBAR), WM_GETFONT, 0, 0); DestroyWindow (GetDlgItem (hDlg, IDC_SET_USAGEBAR)); if (TASKDATA(ptp)->fs.Type == ftREPLICA) GetString (szText, IDS_NO_QUOTA_REPLICA); else // (TASKDATA(ptp)->fs.Type == ftCLONE) GetString (szText, IDS_NO_QUOTA_CLONE); HWND hDesc = CreateWindow (TEXT("static"), szText, WS_CHILD | SS_SIMPLE, rUsagebar.left, rUsagebar.top, cxRECT(rUsagebar), cyRECT(rUsagebar), hDlg, (HMENU)-1, THIS_HINST, 0); SendMessage (hDesc, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0)); ShowWindow (hDesc, SW_SHOW); } EnableWindow (GetDlgItem (hDlg, IDC_SET_QUOTA), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_DEF), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_PERCENT), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_DESC), FALSE); } if (TASKDATA(ptp)->lpsp->perWarnSetFull == 0) { GetString (szText, IDS_SETFULL_WARN_OFF); SetDlgItemText (hDlg, IDC_SET_WARN_SETFULL_DEF, szText); } else { GetString (szText, IDS_SETFULL_WARN_ON); pszText = FormatString (szText, TEXT("%lu"), TASKDATA(ptp)->lpsp->perWarnSetFull); SetDlgItemText (hDlg, IDC_SET_WARN_SETFULL_DEF, pszText); FreeString (pszText); } CheckDlgButton (hDlg, IDC_SET_WARN, (TASKDATA(ptp)->lpfp->perWarnSetFull != 0)); if (TASKDATA(ptp)->lpfp->perWarnSetFull != 0) { if (TASKDATA(ptp)->lpfp->perWarnSetFull != -1) CheckDlgButton (hDlg, IDC_SET_WARN_SETFULL, TRUE); else CheckDlgButton (hDlg, IDC_SET_WARN_SETFULL_DEF, TRUE); } CreateSpinner (GetDlgItem (hDlg, IDC_SET_WARN_SETFULL_PERCENT), 10, FALSE, // base, signed 1, (TASKDATA(ptp)->lpfp->perWarnSetFull == 0 || TASKDATA(ptp)->lpfp->perWarnSetFull == -1) ? perDEFAULT_SETFULL_WARNING : TASKDATA(ptp)->lpfp->perWarnSetFull, 100); // min, default, max Filesets_General_OnWarnings (hDlg, lpi); } }
void FindResizeLimits (HWND hWnd, LONG *pcxMin, LONG *pcxMax, LONG *pcyMin, LONG *pcyMax, rwWindowData *awd) { *pcxMin = 0; *pcxMax = 0; *pcyMin = 0; *pcyMax = 0; if (awd == NULL) { int iwl; if ((iwl = rwFindOrAddWnd (hWnd)) == -1) return; if ((awd = awl[ iwl ].awdLast) == NULL) return; } RECT rNow; GetWindowRect (hWnd, &rNow); for (DWORD ii = 0; awd[ ii ].id != idENDLIST; ++ii) { HWND hControl; if ((hControl = GetDlgItem (hWnd, awd[ ii ].id)) != NULL) { RECT rControl; GetRectInParent (hControl, &rControl); LONG cxMin = 0; LONG cyMin = 0; LONG cxMax = 0; LONG cyMax = 0; if (LOWORD(awd[ ii ].cMinimum)) // X minimum? { if (awd[ ii ].ra & raSizeX) cxMin = cxRECT(rNow) - cxRECT(rControl) + LOWORD(awd[ ii ].cMinimum); else if (awd[ ii ].ra & raSizeXB) cxMax = cxRECT(rNow) + cxRECT(rControl) - LOWORD(awd[ ii ].cMinimum); else if (awd[ ii ].ra & raSizeXC) cxMin = cxRECT(rNow) - (cxRECT(rControl) - LOWORD(awd[ ii ].cMinimum))*2; } if (LOWORD(awd[ ii ].cMaximum)) // X maximum? { if (awd[ ii ].ra & raSizeX) cxMax = cxRECT(rNow) - cxRECT(rControl) + LOWORD(awd[ ii ].cMaximum); else if (awd[ ii ].ra & raSizeXB) cxMin = cxRECT(rNow) + cxRECT(rControl) - LOWORD(awd[ ii ].cMaximum); else if (awd[ ii ].ra & raSizeXC) cxMax = cxRECT(rNow) - (cxRECT(rControl) - LOWORD(awd[ ii ].cMaximum))*2; } if (HIWORD(awd[ ii ].cMinimum)) // Y minimum? { if (awd[ ii ].ra & raSizeY) cyMin = cyRECT(rNow) - cyRECT(rControl) + HIWORD(awd[ ii ].cMinimum); else if (awd[ ii ].ra & raSizeYB) cyMax = cyRECT(rNow) + cyRECT(rControl) - HIWORD(awd[ ii ].cMinimum); else if (awd[ ii ].ra & raSizeYC) cyMin = cyRECT(rNow) - (cyRECT(rControl) - HIWORD(awd[ ii ].cMinimum))*2; } if (HIWORD(awd[ ii ].cMaximum)) // Y maximum? { if (awd[ ii ].ra & raSizeY) cyMax = cyRECT(rNow) - cyRECT(rControl) + HIWORD(awd[ ii ].cMaximum); else if (awd[ ii ].ra & raSizeYB) cyMin = cyRECT(rNow) + cyRECT(rControl) - HIWORD(awd[ ii ].cMaximum); else if (awd[ ii ].ra & raSizeYC) cyMax = cyRECT(rNow) - (cyRECT(rControl) - HIWORD(awd[ ii ].cMaximum))*2; } if (cxMin) *pcxMin = (*pcxMin) ? max( *pcxMin, cxMin ) : cxMin; if (cyMin) *pcyMin = (*pcyMin) ? max( *pcyMin, cyMin ) : cyMin; if (cxMax) *pcxMax = (*pcxMax) ? min( *pcxMax, cxMax ) : cxMax; if (cyMax) *pcyMax = (*pcyMax) ? min( *pcyMax, cyMax ) : cyMax; } } }
void FindSplitterMinMax (HWND hWnd, SplitterData *psd, LONG cOld, LONG *pcdMin, LONG *pcdMax) { *pcdMin = 0; *pcdMax = 0; for (int ii = 0; psd->awd[ ii ].id != idENDLIST; ++ii) { HWND hControl; if ((hControl = GetDlgItem (hWnd, psd->awd[ ii ].id)) != NULL) { RECT rControl; GetRectInParent (hControl, &rControl); if (psd->fX) { LONG cxMin = 0; LONG cxMax = 0; if (LOWORD(psd->awd[ ii ].cMinimum)) // X minimum? { if (psd->awd[ ii ].ra & raSizeX) cxMin = cOld - cxRECT(rControl) + LOWORD(psd->awd[ ii ].cMinimum); else if (psd->awd[ ii ].ra & raSizeXB) cxMax = cOld + cxRECT(rControl) - LOWORD(psd->awd[ ii ].cMinimum); else if (psd->awd[ ii ].ra & raSizeXC) cxMin = cOld - (cxRECT(rControl) - LOWORD(psd->awd[ ii ].cMinimum))*2; } if (LOWORD(psd->awd[ ii ].cMaximum)) // X maximum? { if (psd->awd[ ii ].ra & raSizeX) cxMax = cOld - cxRECT(rControl) + LOWORD(psd->awd[ ii ].cMaximum); else if (psd->awd[ ii ].ra & raSizeXB) cxMin = cOld + cxRECT(rControl) - LOWORD(psd->awd[ ii ].cMaximum); else if (psd->awd[ ii ].ra & raSizeXC) cxMin = cOld - (cxRECT(rControl) - LOWORD(psd->awd[ ii ].cMaximum))*2; } if (cxMin) *pcdMin = (*pcdMin) ? max( *pcdMin, cxMin ) : cxMin; if (cxMax) *pcdMax = (*pcdMax) ? min( *pcdMax, cxMax ) : cxMax; } else { LONG cyMin = 0; LONG cyMax = 0; if (HIWORD(psd->awd[ ii ].cMinimum)) // Y minimum? { if (psd->awd[ ii ].ra & raSizeY) cyMin = cOld - cyRECT(rControl) + HIWORD(psd->awd[ ii ].cMinimum); else if (psd->awd[ ii ].ra & raSizeYB) cyMax = cOld + cyRECT(rControl) - HIWORD(psd->awd[ ii ].cMinimum); else if (psd->awd[ ii ].ra & raSizeYC) cyMin = cOld - (cyRECT(rControl) - HIWORD(psd->awd[ ii ].cMinimum))*2; } if (HIWORD(psd->awd[ ii ].cMaximum)) // Y maximum? { if (psd->awd[ ii ].ra & raSizeY) cyMax = cOld - cyRECT(rControl) + HIWORD(psd->awd[ ii ].cMaximum); else if (psd->awd[ ii ].ra & raSizeYB) cyMin = cOld + cyRECT(rControl) - HIWORD(psd->awd[ ii ].cMaximum); else if (psd->awd[ ii ].ra & raSizeYC) cyMin = cOld - (cyRECT(rControl) - HIWORD(psd->awd[ ii ].cMaximum))*2; } if (cyMin) *pcdMin = (*pcdMin) ? max( *pcdMin, cyMin ) : cyMin; if (cyMax) *pcdMax = (*pcdMax) ? min( *pcdMax, cyMax ) : cyMax; } } } }
void ResizeSplitter (HWND hWnd, SplitterData *psd, LONG cOld, LONG *pcNew) { LONG dx, dy; HWND hItem; size_t nItems = 0; LONG cdMin, cdMax; if (psd == NULL || pcNew == NULL || hWnd == NULL) return; FindSplitterMinMax (hWnd, psd, cOld, &cdMin, &cdMax); *pcNew = limit (cdMin, *pcNew, cdMax); if (*pcNew == cOld) return; dx = (psd->fX) ? (*pcNew - cOld) : 0; dy = (psd->fX) ? 0 : (*pcNew - cOld); for (hItem = GetWindow (hWnd, GW_CHILD); hItem != NULL; hItem = GetWindow (hItem, GW_HWNDNEXT)) { nItems++; } if (nItems != 0) { BOOL fRepaint = FALSE; HDWP dwp = BeginDeferWindowPos (nItems); for (hItem = GetWindow (hWnd, GW_CHILD); hItem != NULL; hItem = GetWindow (hItem, GW_HWNDNEXT)) { RECT rItem; DWORD ra; GetRectInParent (hItem, &rItem); ra = rwFindAction (psd->awd, (GetWindowLong (hItem, GWL_ID))); DeferWindowPos (dwp, hItem, NULL, rItem.left + ((ra & raMoveX) ? dx : (ra & raMoveXB) ? (0-dx) : 0), rItem.top + ((ra & raMoveY) ? dy : (ra & raMoveYB) ? (0-dy) : 0), rItem.right -rItem.left + ((ra & raSizeX) ? dx : (ra & raSizeXB) ? (0-dx) : 0), rItem.bottom -rItem.top + ((ra & raSizeY) ? dy : (ra & raSizeYB) ? (0-dy) : 0), SWP_NOACTIVATE | SWP_NOZORDER); } EndDeferWindowPos (dwp); for (hItem = GetWindow (hWnd, GW_CHILD); hItem != NULL; hItem = GetWindow (hItem, GW_HWNDNEXT)) { DWORD ra = rwFindAction (psd->awd, (GetWindowLong (hItem, GWL_ID))); if (ra & raRepaint) { RECT rItem; GetRectInParent (hItem, &rItem); InvalidateRect (hWnd, &rItem, TRUE); fRepaint = TRUE; } } if (fRepaint) { UpdateWindow (hWnd); } } }
void ResizeWindow (HWND hWnd, rwWindowData *awd, rwAction rwa, RECT *pr) { static BOOL fInHere = FALSE; // prevent reentrancy during SetWindowPos(). int ii; RECT rOld, rNew; if (fInHere) return; // We maintain list of where-was-this-window-last-time; find // This window in that list, or add it. // if ((ii = rwFindOrAddWnd (hWnd, awd)) == -1) goto lblDONE; rOld = awl[ii].rWnd; // previous position // If the window disappears, then remove its entry from the // list of windows. // if (!IsWindow (hWnd)) { awl[ii].hWnd = NULL; goto lblDONE; } // If told to, move and/or resize this parent window. // if (rwa == rwaMoveToHere) { if (pr == NULL) goto lblDONE; fInHere = TRUE; SetWindowPos (hWnd, NULL, pr->left, pr->top, pr->right - pr->left, pr->bottom - pr->top, SWP_NOZORDER | SWP_NOACTIVATE); fInHere = FALSE; rNew = *pr; } else { GetWindowRect (hWnd, &rNew); } // Window has moved from {rOld} to {rNew}, // or // Window's client area has been changed by {*pr} // if (rwa == rwaMoveToHere || rwa == rwaFixupGuts || rwa == rwaNewClientArea) { LONG dx, dy; LONG dxc, dyc; if (rwa == rwaNewClientArea) { dx = pr->right - pr->left; dy = pr->bottom - pr->top; } else { dx = (rNew.right -rNew.left) - (rOld.right -rOld.left); dy = (rNew.bottom -rNew.top) - (rOld.bottom -rOld.top); } if (abs(dx) & 1) awl[ii].cxDeltaCenter += (dx > 0) ? 1 : -1; if (abs(dy) & 1) awl[ii].cyDeltaCenter += (dy > 0) ? 1 : -1; dxc = dx + awl[ii].cxDeltaCenter/2; dyc = dy + awl[ii].cyDeltaCenter/2; awl[ii].cxDeltaCenter %= 2; awl[ii].cyDeltaCenter %= 2; if (dx != 0 || dy != 0) { HWND hItem; size_t nItems = 0; for (hItem = GetWindow (hWnd, GW_CHILD); hItem != NULL; hItem = GetWindow (hItem, GW_HWNDNEXT)) { nItems++; } if (nItems != 0) { DWORD ra; HDWP dwp = BeginDeferWindowPos (nItems); BOOL fRepaint = FALSE; for (hItem = GetWindow (hWnd, GW_CHILD); hItem != NULL; hItem = GetWindow (hItem, GW_HWNDNEXT)) { RECT rItem; GetRectInParent (hItem, &rItem); ra = rwFindAction (awd, (GetWindowLong (hItem, GWL_ID))); DeferWindowPos (dwp, hItem, NULL, rItem.left + ((ra & raMoveX) ? dx : (ra & raMoveXB) ? (0-dx) : (ra & raMoveXC) ? (dxc/2) : 0), rItem.top + ((ra & raMoveY) ? dy : (ra & raMoveYB) ? (0-dy) : (ra & raMoveYC) ? (dyc/2) : 0), rItem.right -rItem.left + ((ra & raSizeX) ? dx : (ra & raSizeXB) ? (0-dx) : (ra & raSizeXC) ? (dxc/2) : 0), rItem.bottom -rItem.top + ((ra & raSizeY) ? dy : (ra & raSizeYB) ? (0-dy) : (ra & raSizeYC) ? (dyc/2) : 0), SWP_NOACTIVATE | SWP_NOZORDER); } EndDeferWindowPos (dwp); for (hItem = GetWindow (hWnd, GW_CHILD); hItem != NULL; hItem = GetWindow (hItem, GW_HWNDNEXT)) { ra = rwFindAction (awd, (GetWindowLong (hItem, GWL_ID))); if (ra & raRepaint) { RECT rItem; GetRectInParent (hItem, &rItem); InvalidateRect (hWnd, &rItem, TRUE); fRepaint = TRUE; } if (ra & raNotify) { RECT rClient; GetClientRect (hItem, &rClient); SendMessage (hItem, WM_SIZE, SIZE_RESTORED, MAKELPARAM( rClient.right-rClient.left, rClient.bottom-rClient.top )); } } if (fRepaint) { UpdateWindow (hWnd); } } } } // Record this window's current position // awl[ii].rWnd = rNew; lblDONE: fInHere = FALSE; }
HRESULT CALLBACK SockAddrProc (HWND hSockAddr, UINT msg, WPARAM wp, LPARAM lp) { SockAddrInfo *psai = NULL; EnterCriticalSection (&csSockAddr); if (msg == WM_CREATE) { size_t iSockAddr; for (iSockAddr = 0; iSockAddr < cSockAddr; ++iSockAddr) { if (aSockAddr[ iSockAddr ].hSockAddr == NULL) break; } if (iSockAddr >= cSockAddr) { if (!REALLOC (aSockAddr, cSockAddr, 1+iSockAddr, 4)) return FALSE; } memset (&aSockAddr[ iSockAddr ], 0x00, sizeof(SockAddrInfo)); aSockAddr[ iSockAddr ].hSockAddr = hSockAddr; psai = &aSockAddr[ iSockAddr ]; } else { for (size_t iSockAddr = 0; !psai && iSockAddr < cSockAddr; ++iSockAddr) { if (aSockAddr[ iSockAddr ].hSockAddr == hSockAddr) psai = &aSockAddr[ iSockAddr ]; } } LeaveCriticalSection (&csSockAddr); if (psai != NULL) { switch (msg) { case WM_CREATE: SockAddr_OnCreate (psai); break; case WM_DESTROY: SockAddr_OnDestroy (psai); break; case WM_RBUTTONDOWN: case WM_LBUTTONDOWN: SockAddr_OnButtonDown (psai, msg, wp, lp); break; case WM_SETFOCUS: PostMessage (GetParent(hSockAddr), WM_NEXTDLGCTL, (WPARAM)psai->hE1, TRUE); break; case WM_ENABLE: EnableWindow (psai->hE1, IsWindowEnabled (hSockAddr)); EnableWindow (psai->hSep1, IsWindowEnabled (hSockAddr)); EnableWindow (psai->hE2, IsWindowEnabled (hSockAddr)); EnableWindow (psai->hSep2, IsWindowEnabled (hSockAddr)); EnableWindow (psai->hE3, IsWindowEnabled (hSockAddr)); EnableWindow (psai->hSep3, IsWindowEnabled (hSockAddr)); EnableWindow (psai->hE4, IsWindowEnabled (hSockAddr)); RECT rSockAddr; GetRectInParent (hSockAddr, &rSockAddr); InvalidateRect (GetParent(hSockAddr), &rSockAddr, TRUE); UpdateWindow (GetParent(hSockAddr)); break; case SAM_GETADDR: return SockAddr_OnGetAddr (psai, wp, lp); case SAM_SETADDR: return SockAddr_OnSetAddr (psai, wp, lp); } } return DefWindowProc (hSockAddr, msg, wp, lp); }
void Time_OnCreate (TimeInfo *pti) { Subclass_AddHook (GetParent(pti->hTime), TimeDlgProc); TCHAR szTimeSep[ cchRESOURCE ]; if (!GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_STIME, szTimeSep, cchRESOURCE)) lstrcpy (szTimeSep, TEXT(":")); TCHAR sz24Hour[ cchRESOURCE ]; if (!GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_ITIME, sz24Hour, cchRESOURCE)) pti->f24Hour = FALSE; else pti->f24Hour = (sz24Hour[0] == TEXT('1')) ? TRUE : FALSE; TCHAR sz0Hour[ cchRESOURCE ]; if (!GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_ITLZERO, sz0Hour, cchRESOURCE)) pti->f0Hours = FALSE; else pti->f0Hours = (sz0Hour[0] == TEXT('1')) ? TRUE : FALSE; RECT rTime; GetClientRect (pti->hTime, &rTime); POINT ptTime = {0,0}; ClientToScreen (pti->hTime, &ptTime); ScreenToClient (GetParent (pti->hTime), &ptTime); SIZE s88; // size of widest likely double-digit number SIZE sTimeSep; // size of ":" SIZE sAMPM; // size of "AM/PM" listbox TCHAR szAM[ cchRESOURCE ]; TCHAR szPM[ cchRESOURCE ]; HDC hdc = GetDC (GetParent (pti->hTime)); GetTextExtentPoint (hdc, TEXT("88"), lstrlen(TEXT("88")), &s88); GetTextExtentPoint (hdc, szTimeSep, lstrlen(szTimeSep), &sTimeSep); if (!pti->f24Hour) Time_GetAMPMSize (hdc, &sAMPM, szAM, szPM); ReleaseDC (GetParent (pti->hTime), hdc); LONG cxNumbers = cxRECT(rTime) - GetSystemMetrics (SM_CXVSCROLL) - (sTimeSep.cx); if (!pti->f24Hour) cxNumbers -= sTimeSep.cx + sAMPM.cx; LONG cxMinutes = max( cxNumbers/2, s88.cx ); LONG cxHours = cxNumbers - cxMinutes; cxMinutes = min (cxMinutes, (LONG)( 1.2 * s88.cx )); cxHours = min (cxHours, (LONG)( 1.2 * s88.cx )); // don't be TOO wide. LONG cy = cyRECT(rTime); LONG yy = ptTime.y; pti->idHours = 100+NextControlID (GetParent (pti->hTime)); pti->hHours = CreateWindow ( TEXT("EDIT"), TEXT(""), WS_CHILD | WS_TABSTOP | ES_MULTILINE | ES_RIGHT | ES_NUMBER, ptTime.x, yy, cxHours, cy, GetParent(pti->hTime), (HMENU)pti->idHours, THIS_HINST, 0); pti->hSep1 = CreateWindow ( TEXT("STATIC"), szTimeSep, WS_CHILD | SS_CENTER, ptTime.x + cxHours, yy, sTimeSep.cx, cy, GetParent(pti->hTime), (HMENU)-1, THIS_HINST, 0); pti->idMinutes = 100+NextControlID (GetParent (pti->hTime)); pti->hMinutes = CreateWindow ( TEXT("EDIT"), TEXT(""), WS_CHILD | WS_TABSTOP | ES_MULTILINE | ES_RIGHT | ES_NUMBER, ptTime.x + cxHours + sTimeSep.cx, yy, cxMinutes, cy, GetParent(pti->hTime), (HMENU)pti->idMinutes, THIS_HINST, 0); if (!pti->f24Hour) { pti->hSep2 = CreateWindow ( TEXT("STATIC"), TEXT(""), WS_CHILD | SS_CENTER, ptTime.x + cxHours + cxMinutes + sTimeSep.cx, yy, sTimeSep.cx, cy, GetParent(pti->hTime), (HMENU)-1, THIS_HINST, 0); pti->idAMPM = 100+NextControlID (GetParent (pti->hTime)); pti->hAMPM = CreateWindow ( TEXT("LISTBOX"), TEXT(""), WS_CHILD | WS_TABSTOP | LBS_NOINTEGRALHEIGHT | LBS_HASSTRINGS | LBS_OWNERDRAWFIXED | LBS_NOTIFY, ptTime.x + cxHours + cxMinutes + 2 * sTimeSep.cx, yy, sAMPM.cx, cy, GetParent(pti->hTime), (HMENU)pti->idAMPM, THIS_HINST, 0); } Subclass_AddHook (pti->hHours, TimeEditProc); Subclass_AddHook (pti->hMinutes, TimeEditProc); if (!pti->f24Hour) Subclass_AddHook (pti->hAMPM, TimeEditProc); HFONT hf = (HFONT)SendMessage (GetParent (pti->hTime), WM_GETFONT, 0, 0); SendMessage (pti->hHours, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0)); SendMessage (pti->hSep1, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0)); SendMessage (pti->hMinutes, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0)); if (!pti->f24Hour) { SendMessage (pti->hSep2, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0)); SendMessage (pti->hAMPM, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0)); } EnableWindow (pti->hHours, IsWindowEnabled (pti->hTime)); EnableWindow (pti->hSep1, IsWindowEnabled (pti->hTime)); EnableWindow (pti->hMinutes, IsWindowEnabled (pti->hTime)); if (!pti->f24Hour) { EnableWindow (pti->hSep2, IsWindowEnabled (pti->hTime)); EnableWindow (pti->hAMPM, IsWindowEnabled (pti->hTime)); LB_StartChange (pti->hAMPM, TRUE); LB_AddItem (pti->hAMPM, szAM, 0); LB_AddItem (pti->hAMPM, szPM, 1); LB_EndChange (pti->hAMPM); LB_SetSelected (pti->hAMPM, 1); } ShowWindow (pti->hHours, TRUE); ShowWindow (pti->hSep1, TRUE); ShowWindow (pti->hMinutes, TRUE); if (!pti->f24Hour) { ShowWindow (pti->hSep2, TRUE); ShowWindow (pti->hAMPM, TRUE); } RECT rWindow; GetWindowRect (pti->hTime, &rWindow); rWindow.right += (cxHours + cxMinutes + sTimeSep.cx) - cxRECT(rTime); if (!pti->f24Hour) rWindow.right += sTimeSep.cx + sAMPM.cx; SetWindowPos (pti->hTime, NULL, 0, 0, cxRECT(rWindow), cyRECT(rWindow), SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); RECT rSpinner; GetRectInParent (pti->hTime, &rSpinner); rSpinner.left = rSpinner.right; rSpinner.right = rSpinner.left + GetSystemMetrics (SM_CXVSCROLL); rSpinner.bottom -= 2; // just like Win95 does CreateSpinner (pti->hHours, 10, FALSE, 0, pti->timeNow.wHour, 24, &rSpinner); pti->hSpinner = SP_GetSpinner (pti->hHours); pti->hSpinnerBuddy = pti->hHours; Time_Edit_SetText (pti, pti->hHours); Time_Edit_SetText (pti, pti->hMinutes); Time_Edit_OnSetFocus (pti, pti->hHours); pti->fCanCallBack = TRUE; }
HRESULT CALLBACK TimeProc (HWND hTime, UINT msg, WPARAM wp, LPARAM lp) { TimeInfo *pti = NULL; EnterCriticalSection (&csTime); if (msg == WM_CREATE) { size_t iTime; for (iTime = 0; iTime < cTime; ++iTime) { if (aTime[ iTime ].hTime == NULL) break; } if (iTime >= cTime) { if (!REALLOC (aTime, cTime, 1+iTime, 4)) return FALSE; } memset (&aTime[ iTime ], 0x00, sizeof(TimeInfo)); aTime[ iTime ].hTime = hTime; pti = &aTime[ iTime ]; } else { for (size_t iTime = 0; !pti && iTime < cTime; ++iTime) { if (aTime[ iTime ].hTime == hTime) pti = &aTime[ iTime ]; } } LeaveCriticalSection (&csTime); if (pti != NULL) { switch (msg) { case WM_CREATE: Time_OnCreate (pti); break; case WM_DESTROY: Time_OnDestroy (pti); break; case WM_RBUTTONDOWN: case WM_LBUTTONDOWN: Time_OnButtonDown (pti, msg, wp, lp); break; case WM_SETFOCUS: PostMessage (GetParent(hTime), WM_NEXTDLGCTL, (WPARAM)pti->hHours, TRUE); break; case WM_ENABLE: EnableWindow (pti->hHours, IsWindowEnabled (hTime)); EnableWindow (pti->hSep1, IsWindowEnabled (hTime)); EnableWindow (pti->hMinutes, IsWindowEnabled (hTime)); EnableWindow (pti->hSpinner, IsWindowEnabled (hTime)); if (!pti->f24Hour) { EnableWindow (pti->hSep2, IsWindowEnabled (hTime)); EnableWindow (pti->hAMPM, IsWindowEnabled (hTime)); } RECT rTime; GetRectInParent (hTime, &rTime); InvalidateRect (GetParent(hTime), &rTime, TRUE); UpdateWindow (GetParent(hTime)); break; case WM_SYSCHAR: case WM_CHAR: switch (wp) { case VK_UP: PostMessage (GetParent(pti->hSpinner), WM_VSCROLL, SB_LINEUP, (LPARAM)pti->hSpinner); break; case VK_DOWN: PostMessage (GetParent(pti->hSpinner), WM_VSCROLL, SB_LINEDOWN, (LPARAM)pti->hSpinner); break; case VK_PRIOR: PostMessage (GetParent(pti->hSpinner), WM_VSCROLL, SB_PAGEUP, (LPARAM)pti->hSpinner); break; case VK_NEXT: PostMessage (GetParent(pti->hSpinner), WM_VSCROLL, SB_PAGEDOWN, (LPARAM)pti->hSpinner); break; case VK_HOME: PostMessage (GetParent(pti->hSpinner), WM_VSCROLL, SB_TOP, (LPARAM)pti->hSpinner); break; case VK_END: PostMessage (GetParent(pti->hSpinner), WM_VSCROLL, SB_BOTTOM, (LPARAM)pti->hSpinner); break; } break; case TM_GETTIME: return Time_OnGetTime (pti, wp, lp); case TM_SETTIME: return Time_OnSetTime (pti, wp, lp); } } return DefWindowProc (hTime, msg, wp, lp); }