Changeset 637 for trunk/ab5.0
- Timestamp:
- Sep 29, 2008, 1:02:27 AM (16 years ago)
- Location:
- trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Button.ab
r561 r637 13 13 */ 14 14 Class Button 15 Inherits Control15 Inherits WmCommandControl 16 16 Protected 17 17 Override Sub GetCreateStruct(ByRef cs As CREATESTRUCT) … … 26 26 End Sub 27 27 28 Override Function RaiseCommandEvent(notificationCode As Word) As Boolean 29 Dim lr As LRESULT 30 RaiseCommandEvent = False 31 Select Case notificationCode 32 Case BN_CLICKED 33 RaiseCommandEvent = OnClick(Args.Empty) 34 Case BN_DBLCLK 35 RaiseCommandEvent = OnDoubleClick(Args.Empty) 36 Case BN_SETFOCUS 37 RaiseCommandEvent = ProcessMessage(WM_SETFOCUS, 0, 0, lr) 38 Case BN_KILLFOCUS 39 RaiseCommandEvent = ProcessMessage(WM_KILLFOCUS, 0, 0, lr) 40 'ここに挙げられなかったBNメッセージは、16ビットWindowsとの互換性のためとされているもの。 41 End Select 42 End Function 43 28 44 End Class 29 45 -
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 -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Dialog.ab
r576 r637 8 8 Inherits Form 9 9 Public 10 11 Override Function DefWndProc(m As DWord, w As WPARAM, l As LPARAM) As LRESULT12 DefWndProc = FALSE13 End Function14 15 10 Function DoModal(hwndParent As HWND) As Long 16 11 Dim temp[31] As Byte … … 20 15 StartWndProc() 21 16 DoModal = DialogBoxIndirectParam(Control.hInstance, temp As *DLGTEMPLATE, hwndParent, AddressOf(DefDlgProc), 0) 17 End Function 18 Protected 19 Override Function DefWndProc(m As DWord, w As WPARAM, l As LPARAM) As LRESULT 20 DefWndProc = FALSE 22 21 End Function 23 22 -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/EditBox.ab
r561 r637 8 8 /*! 9 9 @brief エディトコントロールのクラス 10 @date 200 7/07/2110 @date 2008/07/21 11 11 @auther Egtra 12 12 */ 13 13 Class EditBox 14 Inherits Control14 Inherits WmCommandControl 15 15 Protected 16 16 Override Sub GetCreateStruct(ByRef cs As CREATESTRUCT) … … 19 19 End With 20 20 End Sub 21 Public 22 Override Function RaiseCommandEvent(notificationCode As Word) As Boolean 23 RaiseCommandEvent = False 24 End Function 21 25 22 26 'ToDo: Lineなどを設ける -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Form.ab
r615 r637 39 39 40 40 Sub OnCommand(sender As Object, e As MessageArgs) 41 Dim id = e.WParam And &hffff 'LOWORD(e.WParam)42 Dim cmd = ( e.WParam >> 16) And &hffff'HIWORD(e.WParam)41 ' Dim id = e.WParam And &hffff 'LOWORD(e.WParam) 42 Dim cmd = ((e.WParam >> 16) And &hffff) As Word 'HIWORD(e.WParam) 43 43 Dim hwnd = e.LParam As HWND 44 If cmd = BN_CLICKED Andhwnd <> 0 Then45 Dim c = Control.FromHWnd(hwnd) 44 If hwnd <> 0 Then 45 Dim c = Control.FromHWnd(hwnd) As WmCommandControl 46 46 If IsNothing(c) = False Then 47 Dim b = c As Button 48 b.RaiseClick() 47 c.RaiseCommandEvent(cmd) 49 48 End If 50 49 End If -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/WindowHandle.sbp
r615 r637 308 308 End Function 309 309 */ 310 Function Move(x As Long, y As Long, width As Long, height As Long, repaint As Boolean) As Boolean310 Function Move(x As Long, y As Long, width As Long, height As Long, repaint = True As Boolean) As Boolean 311 311 Return MoveWindow(hwnd, x, y, width, height, repaint) As Boolean 312 312 End Function 313 313 314 Function Move(x As Long, y As Long, width As Long, height As Long) As Boolean 315 Return MoveWindow(hwnd, x, y, width, height, TRUE) As Boolean 316 End Function 317 318 Function Move(ByRef rc As RECT, repaint As Boolean) As Boolean 314 Function Move(ByRef rc As RECT, repaint = True As Boolean) As Boolean 319 315 With rc 320 316 Return MoveWindow(hwnd, .left, .top, .right - .left, .bottom - .top, repaint) As Boolean … … 322 318 End Function 323 319 324 Function Move(ByRef rc As RECT) As Boolean325 With rc326 Return MoveWindow(hwnd, .left, .top, .right - .left, .bottom - .top, TRUE) As Boolean327 End With328 End Function329 320 /* 330 321 Function OpenClipboard() As Boolean … … 586 577 587 578 Const Function Maximized() As Boolean 588 Return Is Iconic() As Boolean579 Return IsZoomed(hwnd) As Boolean 589 580 End Function 590 581 … … 668 659 sb.Length = size 669 660 Dim length = GetWindowText(hwnd, StrPtr(sb), size) 661 sb.Length(length) 670 662 Text = sb.ToString 671 663 End Function
Note:
See TracChangeset
for help on using the changeset viewer.