tagging release
[dasher.git] / trunk / Src / Win32 / ModuleControlLongSpin.cpp
blob6c9960ba4ac60e70bd8a584ce04273be860a3e25
1 #include "ModuleControlLongSpin.h"
3 int CModuleControlLongSpin::GetHeightRequest() {
4 return 12;
7 void CModuleControlLongSpin::Initialise(CDasherInterfaceBase *pInterface) {
8 int iValue(pInterface->GetLongParameter(m_iId));
9 SendMessage(m_hSpin, UDM_SETPOS, 0, (LPARAM) MAKELONG ((short)iValue, 0));
10 UpdateEntry(iValue, 0);
13 void CModuleControlLongSpin::Apply(CDasherInterfaceBase *pInterface) {
14 int iValue(SendMessage(m_hSpin, UDM_GETPOS, 0, 0));
15 pInterface->SetLongParameter(m_iId, iValue);
18 void CModuleControlLongSpin::CreateChild(HWND hParent) {
19 m_hEntry = CreateWindowEx(WS_EX_CONTROLPARENT | WS_EX_CLIENTEDGE, TEXT("EDIT"), NULL,
20 WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 0, 0, 0, hParent, NULL, WinHelper::hInstApp, NULL);
22 HGDIOBJ hGuiFont;
23 hGuiFont = GetStockObject(DEFAULT_GUI_FONT);
25 SendMessage(m_hEntry, WM_SETFONT, (WPARAM)hGuiFont, (LPARAM)true);
27 m_hSpin = CreateWindowEx(WS_EX_CLIENTEDGE, UPDOWN_CLASS, TEXT(""),
28 UDS_ALIGNRIGHT | WS_CHILD | WS_TABSTOP |WS_VISIBLE | WS_GROUP, 0, 0, 16, 16,
29 hParent, NULL, WinHelper::hInstApp, NULL);
31 SendMessage(m_hSpin, UDM_SETRANGE, 0, (LPARAM) MAKELONG(m_iMax, m_iMin));
34 void CModuleControlLongSpin::LayoutChild(RECT &sRect) {
35 ::MoveWindow(m_hEntry, sRect.left, sRect.top, sRect.right - sRect.left, sRect.bottom - sRect.top, TRUE);
36 SendMessage(m_hSpin, UDM_SETBUDDY, (WPARAM)m_hEntry, 0);
39 LRESULT CModuleControlLongSpin::OnNotify(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
40 NMHDR *pNotify((LPNMHDR)lParam);
42 switch(pNotify->code) {
43 case UDN_DELTAPOS:
44 UpdateEntry(((LPNMUPDOWN) lParam)->iPos, ((LPNMUPDOWN) lParam)->iDelta);
45 break;
46 default:
47 bHandled = false;
48 break;
51 return 0;
54 void CModuleControlLongSpin::UpdateEntry(int iValue, int iDelta) {
55 WCHAR tcBuffer[256];
56 _sntprintf(tcBuffer, 100, TEXT("%0.4f"), (iValue + iDelta) / static_cast<double>(m_iDivisor));
57 SendMessage(m_hEntry, WM_SETTEXT, 0, (LPARAM) tcBuffer);