BOOL CALLBACK CTitleDlg::TitleDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static CTitleDlg * pThis; switch (message) { case WM_INITDIALOG: { pThis = reinterpret_cast<CTitleDlg *>(lParam); // get a pointer to the calling object // set default values TCHAR buf[10]; HRESULT hr = StringCchPrintf(buf, NUMELMS(buf), TEXT("%u\0"), pThis->m_ulTitle); SetDlgItemText(hDlg, IDC_PLAYCHAPTER, buf); hr = StringCchPrintf(buf, NUMELMS(buf), TEXT("%u\0"), pThis->m_ulChapter); SetDlgItemText(hDlg, IDC_PLAYCHAPTER, buf); //set up spin control HWND hEBox = GetDlgItem(hDlg, IDC_PLAYCHAPTER); CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 999, 1, 1); hEBox = GetDlgItem(hDlg, IDC_PLAYTITLE); CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 99, 1, 1); return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: { // Set the Title specified by the user TCHAR buf[10]; GetDlgItemText(hDlg, IDC_PLAYCHAPTER, buf, sizeof(buf)/sizeof(TCHAR)); pThis->m_ulChapter = _ttoi(buf); GetDlgItemText(hDlg, IDC_PLAYTITLE, buf, sizeof(buf)/sizeof(TCHAR)); pThis->m_ulTitle = _ttoi(buf); EndDialog(hDlg, TRUE); return TRUE; } case IDCANCEL: EndDialog(hDlg, FALSE); return TRUE; } break; } return FALSE; }
// // Option window // void OptionTabWindow::init(HWND w) { struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE; _window = w; TabWindow::init(_window); _spin_edit = GetDlgItem(_window, IDC_OPT_AUTO_INPUT); _spin = CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 80, 0, 50, 50, _window, IDC_OPT_AUTO_UPDOWN, _app._instance, _spin_edit, 60, 1, 30); BOOL onoff = pref.auto_boot ? TRUE : FALSE; EnableWindow(_spin_edit, onoff); EnableWindow(_spin, onoff); SET_CHECK(AUTO, pref.auto_boot); if (pref.auto_boot) { TCHAR tmp[32]; wsprintf(tmp, TEXT("%d"), pref.auto_boot); Edit_SetText(_spin_edit, tmp); } SET_CHECK(VIDEO, pref.reverse_video); SET_CHECK(PAUSE, pref.pause_before_boot); SET_CHECK(DEBUG, pref.load_debug_info); SET_CHECK(SAFETY, pref.safety_message); Edit_SetText(GetDlgItem(w, IDC_OPT_EXTKOPT), pref.boot_extra); }
static HWND create_updown_control(void) { struct subclass_info *info; HWND updown; RECT rect; info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); if (!info) return NULL; GetClientRect(parent_wnd, &rect); updown = CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_ALIGNRIGHT, 0, 0, rect.right, rect.bottom, parent_wnd, 1, GetModuleHandleA(NULL), edit, 100, 0, 50); if (!updown) { HeapFree(GetProcessHeap(), 0, info); return NULL; } info->oldproc = (WNDPROC)SetWindowLongPtrA(updown, GWLP_WNDPROC, (LONG_PTR)updown_subclass_proc); SetWindowLongPtrA(updown, GWLP_USERDATA, (LONG_PTR)info); return updown; }
HWND CUpDown::Create(HWND window, HWND buddy, int pos, UINT id, int upper, int lower, int x, int y, int cx, int cy) { m_window = window; m_inst = reinterpret_cast<HINSTANCE>(GetWindowLongPtr(window, GWLP_HINSTANCE)); m_id = id; m_ctrl = CreateUpDownControl( WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_WRAP | UDS_SETBUDDYINT, x, y, cx, cy, window, id, m_inst, buddy, upper, lower, pos); return m_ctrl; }
INT_PTR UpDown::Create(HWND buddy,HWND parent,int nUpper,int nLower,int nPos) { if(parent==0) parent = GetParent(buddy); if(parent==0) return 0; DWORD style = GetWindowLong(buddy,GWL_STYLE); style |= ES_NUMBER; SetWindowLong(buddy,GWL_STYLE,style); _Handle = CreateUpDownControl(WS_VISIBLE|WS_CHILD|UDS_SETBUDDYINT|UDS_ALIGNRIGHT|UDS_ARROWKEYS,0,0,0,0,parent,Param->Identity,GetInstance(),buddy,nUpper,nLower,nPos); if(_Handle==0){ Warning(L"UpDown.Create"); return 0; } OnCreate.Call(this); _QuondamProc = ::SetWindowLongPtr(_Handle,GWLP_WNDPROC,(LONG)(LONG_PTR)_WndPointer.Procedure()); return (INT_PTR)_Handle; }
static HWND create_updown_control(DWORD style, HWND buddy) { WNDPROC oldproc; HWND updown; RECT rect; GetClientRect(parent_wnd, &rect); updown = CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | style, 0, 0, rect.right, rect.bottom, parent_wnd, 1, GetModuleHandleA(NULL), buddy, 100, 0, 50); if (!updown) return NULL; oldproc = (WNDPROC)SetWindowLongPtrA(updown, GWLP_WNDPROC, (LONG_PTR)updown_subclass_proc); SetWindowLongPtrA(updown, GWLP_USERDATA, (LONG_PTR)oldproc); return updown; }
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { // basic initialization m_windowId = (id == wxID_ANY) ? NewControlId() : id; SetName(name); int x = pos.x; int y = pos.y; int width = size.x; int height = size.y; m_windowStyle = style; SetParent(parent); // get the right size for the control if ( width <= 0 || height <= 0 ) { wxSize size = DoGetBestSize(); if ( width <= 0 ) width = size.x; if ( height <= 0 ) height = size.y; } if ( x < 0 ) x = 0; if ( y < 0 ) y = 0; // translate the styles DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP | /* WS_CLIPSIBLINGS | */ UDS_NOTHOUSANDS | // never useful, sometimes harmful UDS_SETBUDDYINT; // it doesn't harm if we don't have buddy if ( m_windowStyle & wxCLIP_SIBLINGS ) wstyle |= WS_CLIPSIBLINGS; if ( m_windowStyle & wxSP_HORIZONTAL ) wstyle |= UDS_HORZ; if ( m_windowStyle & wxSP_ARROW_KEYS ) wstyle |= UDS_ARROWKEYS; if ( m_windowStyle & wxSP_WRAP ) wstyle |= UDS_WRAP; // create the UpDown control. m_hWnd = (WXHWND)CreateUpDownControl ( wstyle, x, y, width, height, GetHwndOf(parent), m_windowId, wxGetInstance(), NULL, // no buddy m_max, m_min, m_min // initial position ); if ( !m_hWnd ) { wxLogLastError(wxT("CreateUpDownControl")); return false; } if ( parent ) { parent->AddChild(this); } SubclassWin(m_hWnd); SetInitialSize(size); return true; }
BOOL CALLBACK CTimeDlg::TimeDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static CTimeDlg * pThis; switch (message) { case WM_INITDIALOG: { pThis = reinterpret_cast<CTimeDlg *>(lParam); // get a pointer to the calling object // set default values TCHAR buf[10]; wsprintf(buf, TEXT("%u"), pThis->m_Time.bHours); SetDlgItemText(hDlg, IDC_HOURS, buf); wsprintf(buf, TEXT("%u"), pThis->m_Time.bMinutes); SetDlgItemText(hDlg, IDC_MINUTES, buf); wsprintf(buf, TEXT("%u"), pThis->m_Time.bSeconds); SetDlgItemText(hDlg, IDC_SECONDS, buf); //set up spin controls HWND hEBox = GetDlgItem(hDlg, IDC_HOURS); CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 99, 0, pThis->m_Time.bHours); hEBox = GetDlgItem(hDlg, IDC_MINUTES); CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 60, 0, pThis->m_Time.bMinutes); hEBox = GetDlgItem(hDlg, IDC_SECONDS); CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 60, 0, pThis->m_Time.bSeconds); return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: { // Set the Time specified by the user TCHAR buf[10]; GetDlgItemText(hDlg, IDC_HOURS, buf, sizeof(buf)/sizeof(TCHAR)); pThis->m_Time.bHours = (BYTE) _ttoi(buf); GetDlgItemText(hDlg, IDC_MINUTES, buf, sizeof(buf)/sizeof(TCHAR)); pThis->m_Time.bMinutes = (BYTE) _ttoi(buf); GetDlgItemText(hDlg, IDC_SECONDS, buf, sizeof(buf)/sizeof(TCHAR)); pThis->m_Time.bSeconds = (BYTE) _ttoi(buf); } // end of case brackets EndDialog(hDlg, TRUE); return TRUE; case IDCANCEL: EndDialog(hDlg, FALSE); return TRUE; } break; } return FALSE; }