- Timestamp:
- Sep 29, 2008, 1:02:27 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Control.ab
r615 r637 138 138 registerStandardEvent() 139 139 AssociateHWnd(hwndNew) 140 End Sub 141 142 Sub BeginSubclass() 143 throwIfNotCreated() 140 144 prevWndProc = SetWindowLongPtr(GWLP_WNDPROC, AddressOf(WndProcFirst) As LONG_PTR) As WNDPROC 141 145 End Sub … … 144 148 Sub throwIfAlreadyCreated() 145 149 If hwnd <> 0 Then 146 Throw New System.InvalidOperationException("Window already created.") 150 Throw New System.InvalidOperationException("Window is already created.") 151 End If 152 End Sub 153 154 Sub throwIfNotCreated() 155 If hwnd = 0 Then 156 Throw New System.InvalidOperationException("Window is not already created.") 147 157 End If 148 158 End Sub … … 150 160 '-------------------------------- 151 161 ' ウィンドウプロシージャ 152 'Protected 153 P ublic162 163 Protected 154 164 Virtual Function WndProc(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT 165 If Not ProcessMessage(msg, wp, lp, WndProc) Then 166 WndProc = DefWndProc(msg, wp, lp) 167 End If 168 End Function 169 170 Virtual Function DefWndProc(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT 171 If prevWndProc Then 172 DefWndProc = CallWindowProc(prevWndProc, hwnd, msg, wp, lp) 173 Else 174 DefWndProc = DefWindowProc(hwnd, msg, wp, lp) 175 End If 176 End Function 177 Protected 178 Function ProcessMessage(msg As DWord, wp As WPARAM, lp As LPARAM, ByRef lr As LRESULT) As Boolean 155 179 Dim h = Nothing As MessageHandler 156 180 Dim b = messageMap.TryGetValue(Hex$(msg), h) … … 160 184 h(This, a) 161 185 If a.Handled Then 162 WndProc = a.LResult 186 lr = a.LResult 187 ProcessMessage = True 163 188 Exit Function 164 189 End If 165 190 End If 166 191 End If 167 WndProc = DefWndProc(msg, wp, lp) 168 End Function 169 170 Virtual Function DefWndProc(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT 171 If prevWndProc Then 172 DefWndProc = CallWindowProc(prevWndProc, hwnd, msg, wp, lp) 173 Else 174 DefWndProc = DefWindowProc(hwnd, msg, wp, lp) 175 End If 176 End Function 177 192 ProcessMessage = False 193 End Function 178 194 Private 179 195 Static Function makeKeysFormMsg(e As MessageArgs) As Keys … … 428 444 */ 429 445 Sub AssociateHWnd(hwndNew As HWND) 430 hwnd = hwndNew446 SetHWnd(hwndNew) 431 447 Prop[PropertyInstance] = ObjPtr(This) As HANDLE 432 448 comImpl.AddRef() … … 513 529 Static Sub Initialize(hinst As HINSTANCE) 514 530 tlsIndex = TlsAlloc() 531 If tlsIndex = TLS_OUT_OF_INDEXES Then 532 ThrowWithLastError("Control.Initialize: TlsAlloc failed.") 533 End If 515 534 hInstance = hinst 516 535 hmodComctl = LoadLibrary("comctl32.dll") … … 519 538 Dim PropertyInstanceString = WindowClassName + " " + Hex$(GetCurrentProcessId()) 520 539 PropertyInstance = GlobalAddAtom(ToTCStr(PropertyInstanceString)) 540 If PropertyInstance = 0 Then 541 ThrowWithLastError("Control.Initialize: GlobalAddAtom failed.") 542 End If 521 543 522 544 Dim wcx As WNDCLASSEX … … 537 559 atom = RegisterClassEx(wcx) 538 560 If atom = 0 Then 539 Dim buf[1023] As TCHAR 540 wsprintf(buf, Ex"ActiveBasic.Windows.UI.Control.Control: RegisterClasseEx failed. Error code: &h%08X\r\n", GetLastError()) 541 OutputDebugString(buf) 542 Debug 543 ExitThread(0) 561 ThrowWithLastErrorNT("Control.Initialize: RegisterClasseEx failed.") 544 562 End If 545 563 End Sub … … 561 579 End Class 562 580 581 /*! 582 @brief WM_COMMANDで通知を行うコントロールの基底クラス 583 @date 2008/08/28 584 @auther Egtra 585 親がWM_COMMANDを受け取ったら、RaiseCommandEventを呼ぶことを意図している。 586 (Formで実装済み) 587 */ 588 Class WmCommandControl 589 Inherits Control 590 Public 591 Abstract Function RaiseCommandEvent(notificationCode As Word) As Boolean 592 End Class 593 563 594 End Namespace 'UI 564 595 End Namespace 'Widnows
Note:
See TracChangeset
for help on using the changeset viewer.