tagging release
[dasher.git] / Src / Win32 / ModuleControlLong.cpp
blob2f9492d480d4f258f8ff77394724b3b30da2edbf
1 #include "ModuleControlLong.h"
3 #include <cstring>
5 LRESULT CModuleControlLong::OnScroll(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
6 int iValue = SendMessage(m_hSlider, TBM_GETPOS, 0, 0);
8 WCHAR tcBuffer[256];
9 _sntprintf(tcBuffer, 100, TEXT("%0.2f"), iValue / static_cast<double>(m_iDivisor));
10 SendMessage(m_hEntry, WM_SETTEXT, 0, (LPARAM) tcBuffer);
12 bHandled = true;
13 return 0;
16 int CModuleControlLong::GetHeightRequest() {
17 return 12;
20 void CModuleControlLong::Initialise(CDasherInterfaceBase *pInterface) {
21 int iValue(pInterface->GetLongParameter(m_iId));
22 SendMessage(m_hSlider, TBM_SETPOS, (WPARAM)false, (LPARAM)iValue);
24 WCHAR tcBuffer[256];
25 _sntprintf(tcBuffer, 100, TEXT("%0.2f"), iValue / static_cast<double>(m_iDivisor));
26 SendMessage(m_hEntry, WM_SETTEXT, 0, (LPARAM) tcBuffer);
29 void CModuleControlLong::Apply(CDasherInterfaceBase *pInterface) {
30 int iValue = SendMessage(m_hSlider, TBM_GETPOS, 0, 0);
31 pInterface->SetLongParameter(m_iId, iValue);
34 void CModuleControlLong::CreateChild(HWND hParent) {
35 m_hSlider = CreateWindowEx(WS_EX_CONTROLPARENT, TRACKBAR_CLASS, NULL,
36 TBS_HORZ | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 0, 0, 0, hParent, NULL, WinHelper::hInstApp, NULL);
38 SendMessage(m_hSlider, TBM_SETRANGE, (WPARAM)true, (LPARAM)MAKELONG(m_iMin, m_iMax));
39 SendMessage(m_hSlider, TBM_SETPAGESIZE, 0, (LPARAM)m_iStep);
41 m_hEntry = CreateWindowEx(WS_EX_CONTROLPARENT | WS_EX_CLIENTEDGE, TEXT("EDIT"), NULL,
42 WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 0, 0, 0, hParent, NULL, WinHelper::hInstApp, NULL);
44 HGDIOBJ hGuiFont;
45 hGuiFont = GetStockObject(DEFAULT_GUI_FONT);
47 SendMessage(m_hEntry, WM_SETFONT, (WPARAM)hGuiFont, (LPARAM)true);
50 void CModuleControlLong::LayoutChild(RECT &sRect) {
51 ::MoveWindow(m_hSlider, sRect.left + 32, sRect.top, sRect.right - sRect.left - 32, sRect.bottom - sRect.top, TRUE);
52 ::MoveWindow(m_hEntry, sRect.left, sRect.top, 32, sRect.bottom - sRect.top, TRUE);