<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=68658&amp;view=findpost&amp;p=479186</guid>
        <pubDate>Sat, 09 Oct 2004 10:18:07 +0000</pubDate>
        <title>Собственный UpDown в UserControl</title>
        <link>https://forum.sources.ru/index.php?showtopic=68658&amp;view=findpost&amp;p=479186</link>
        <description><![CDATA[oal: Подскажите, пожалуйста, почему при создании элемента UpDpwn   :wall: <br>
1. не устанавливается Buddy контроль; <br>
2. не работает AutoChangeBuddyText; <br>
3. не работает ShowThousandsSeparator. <br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">Private Function Create(Optional ByVal dwSelect As Boolean = False) </div><div class="code_line">Dim dwMax As Long </div><div class="code_line">Dim dwMin As Long </div><div class="code_line">Dim dwValue As Long </div><div class="code_line">Dim dwBase As Long </div><div class="code_line">Dim dwStyle As Long </div><div class="code_line">Dim c As Control </div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;If m_hWnd &#60;&#62; 0 Then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39; Сохранить предыдущие установки элемента управления </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If dwSelect Or m_ReadProp Then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwMax = Max </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwMin = Min </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwValue = Value </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GetAccel </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwBase = Base </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;End If </div><div class="code_line">&nbsp;&nbsp; &nbsp;End If </div><div class="code_line">&nbsp;&nbsp; &nbsp;&#39;// Гарантировать, что мы уже не имеем управления UpDown: </div><div class="code_line">&nbsp;&nbsp; &nbsp;Detach </div><div class="code_line">&nbsp;&nbsp; &nbsp;&#39;// Создать контроль: </div><div class="code_line">&nbsp;&nbsp; &nbsp;dwStyle = WS_VISIBLE Or WS_CHILD </div><div class="code_line">&nbsp;&nbsp; &nbsp;dwStyle = dwStyle Or m_Alignment Or m_Orientation </div><div class="code_line">&nbsp;&nbsp; &nbsp;If m_ArrowKeysChange Then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dwStyle = dwStyle Or UDS_ARROWKEYS </div><div class="code_line">&nbsp;&nbsp; &nbsp;End If </div><div class="code_line">&nbsp;&nbsp; &nbsp;If m_AutoChangeBuddyText Then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dwStyle = dwStyle Or UDS_SETBUDDYINT </div><div class="code_line">&nbsp;&nbsp; &nbsp;End If </div><div class="code_line">&nbsp;&nbsp; &nbsp;If Not (m_ShowThousandsSeparator) Then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dwStyle = dwStyle Or UDS_NOTHOUSANDS </div><div class="code_line">&nbsp;&nbsp; &nbsp;End If </div><div class="code_line">&nbsp;&nbsp; &nbsp;If m_Wrap Then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dwStyle = dwStyle Or UDS_WRAP </div><div class="code_line">&nbsp;&nbsp; &nbsp;End If </div><div class="code_line">&nbsp;&nbsp; &nbsp;&#39;// Проверка коректности </div><div class="code_line">&nbsp;&nbsp; &nbsp;Debug.Assert (m_hWnd = 0) </div><div class="code_line">&nbsp;&nbsp; &nbsp;If (m_hWnd = 0) Then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#39;// Создать элемент управления UpDown </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_hWnd = CreateWindowEx(WS_EX_STATICEDGE, UPDOWN_CLASS, vbNullString, dwStyle, _ </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0, 0, UserControl.ScaleWidth \ Screen.TwipsPerPixelX, UserControl.ScaleHeight \ Screen.TwipsPerPixelY, _ </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;UserControl.hWnd, 0, App.hInstance, ByVal 0&amp;) </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;If (m_hWnd &#60;&#62; 0) Then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;UserControl.ParentControls.ParentControlsType = vbExtender </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If m_BuddyControl &#60;&#62; &quot;&quot; Then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;On Error GoTo ErrorHandler </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;For Each c In UserControl.Parent.Controls </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If m_BuddyControl = c.Name Then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39; Сохранить дескриптор указанного элемента управления </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m_BuddyhWnd = c.hWnd </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Exit For </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End If </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Next c </div><div class="code_line">ErrorHandler: &nbsp; Call SendMessage(m_hWnd, UDM_SETBUDDY, m_BuddyhWnd, ByVal 0&amp;) </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Debug.Print SendMessage(m_hWnd, UDM_GETBUDDY, 0, ByVal 0&amp;) &amp; &quot;; &quot; &amp; m_BuddyhWnd &#39; (не возвращается дескриптор Buddy)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End If </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetAccel </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If dwSelect Or m_ReadProp Then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Max = dwMax </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Min = dwMin </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Value = dwValue </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Base = dwBase </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m_ReadProp = False </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End If </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;End If </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;If (Ambient.UserMode) Then </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;// Запуск класса </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SubClass </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m_SubClass = True </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;End If </div><div class="code_line">&nbsp;&nbsp; &nbsp;End If </div><div class="code_line">End Function </div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
Пробовал тот же алгоритм создания элемента UpDown при инициализации формы (Form_Load) - все прекрасно работает]]></description>
        <author>oal</author>
        <category>Visual Basic: Общие вопросы</category>
      </item>
	
      </channel>
      </rss>
	