- Timestamp:
- Jul 13, 2008, 1:47:20 PM (16 years ago)
- Location:
- trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Forms
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Forms/Control.ab
r542 r544 14 14 Class Control 15 15 Public 16 17 '118 19 16 Sub Control() 20 17 End Sub … … 47 44 48 45 '-------------------------------- 49 ' 1ウィンドウ作成46 ' ウィンドウ作成 50 47 /* 51 48 Function Create( … … 90 87 Public 91 88 Virtual Function WndProc(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT 92 /*93 Select Case msg94 Case WM_MOUSELEAVE95 OnMouseLeave(makeMouseEventFromWPLP(wp, lp))96 mouseEntered = False97 Case WM_KEYDOWN98 OnKeyDown(New KeyEventArgs(makeKeysFormWPLP(wp, lp)))99 Case WM_KEYUP100 OnKeyUp(New KeyEventArgs(makeKeysFormWPLP(wp, lp)))101 Case WM_CHAR102 OnKeyPress(New KeyPressEventArgs(wp As Char))103 ' Case WM_CREATE104 Case WM_DESTROY105 OnDestroy(EventArgs.Empty)106 Case Else107 WndProc = DefWndProc(msg, wp, lp)108 End Select109 */110 89 Dim h = Nothing As MessageEventHandler 111 90 Dim b = messageMap.TryGetValue(Hex$(msg), h) … … 126 105 127 106 Private 128 Static Function makeKeysForm WPLP(wp As WPARAM, lp As LPARAM) As Keys107 Static Function makeKeysFormMsg(e As MessageEventArgs) As Keys 129 108 Dim t As DWord 130 t = wpAnd Keys.KeyCode109 t = e.WParam And Keys.KeyCode 131 110 t Or= (GetKeyState(VK_SHIFT) As Word And &h8000) << 1 132 111 t Or= (GetKeyState(VK_CONTROL) As Word And &h8000) << 2 133 112 t Or= (GetKeyState(VK_MENU) As Word And &h8000) << 3 134 makeKeysFormWPLP = t As Keys 135 End Function 136 137 Static Function makeMouseEventFromWPLP(wp As WPARAM, lp As LPARAM) As MouseEventArgs 138 makeMouseEventFromWPLP = New MouseEventArgs(LOWORD(wp) As MouseButtons, 1, GET_X_LPARAM(lp), GET_Y_LPARAM(lp), 0) 113 makeKeysFormMsg = t As Keys 114 End Function 115 116 Static Function makeMouseEventFromMsg(e As MessageEventArgs) As MouseEventArgs 117 Dim wp = e.WParam 118 Dim lp = e.LParam 119 makeMouseEventFromMsg = New MouseEventArgs(LOWORD(wp) As MouseButtons, 1, GET_X_LPARAM(lp), GET_Y_LPARAM(lp), 0) 139 120 End Function 140 121 … … 146 127 Sub StartWndProc() 147 128 Dim t = This '#177対策 148 messageMap = New System.Collections.Generic.Dictionary<Object, MessageEventHandler>149 129 AddMessageEvent(WM_ERASEBKGND, AddressOf(t.OnEraseBackground)) 150 130 Dim md = New MessageEventHandler(AddressOf(t.OnMouseDownBase)) … … 163 143 AddMessageEvent(WM_MBUTTONDBLCLK, mu) 164 144 AddMessageEvent(WM_XBUTTONDBLCLK, mu) 145 146 AddMessageEvent(WM_MOUSELEAVE, AddressOf(t.OnMouseLeaveBase)) 165 147 AddMessageEvent(WM_PAINT, AddressOf(t.OnPaintBase)) 148 AddMessageEvent(WM_KEYDOWN, AddressOf(t.OnKeyDownBase)) 149 ' AddMessageEvent(WM_CHAR, AddressOf(t.OnChar)) 150 AddMessageEvent(WM_CREATE, AddressOf(t.OnCreateBase)) 166 151 End Sub 167 152 … … 174 159 175 160 Sub OnMouseDownBase(sender As Object, e As MessageEventArgs) 176 OnMouseDown(makeMouseEventFrom WPLP(e.WParam, e.LParam))161 OnMouseDown(makeMouseEventFromMsg(e)) 177 162 End Sub 178 163 179 164 Sub OnMouseUpBase(sender As Object, e As MessageEventArgs) 180 Dim me = makeMouseEventFrom WPLP(e.WParam, e.LParam)165 Dim me = makeMouseEventFromMsg(e) 181 166 If doubleClickFired = False Then 182 OnClick(EventArgs.Empty)167 ' OnClick(System.EventArgs.Empty) 183 168 OnMouseClick(me) 184 169 doubleClickFired = False … … 188 173 189 174 Sub OnMouseDblClkBase(sender As Object, e As MessageEventArgs) 190 Dim me = makeMouseEventFrom WPLP(e.WParam, e.LParam)175 Dim me = makeMouseEventFromMsg(e) 191 176 doubleClickFired = True 192 177 OnMouseDown(me) 193 OnDoubleClick(EventArgs.Empty)178 ' OnDoubleClick(System.EventArgs.Empty) 194 179 OnMouseDoubleClick(me) 195 180 End Sub 196 181 197 182 Sub OnMouseMoveBase(sender As Object, e As MessageEventArgs) 198 Dim me = makeMouseEventFrom WPLP(e.WParam, e.LParam)183 Dim me = makeMouseEventFromMsg(e) 199 184 If mouseEntered Then 200 185 OnMouseMove(me) … … 205 190 End Sub 206 191 192 Sub OnMouseLeaveBase(sender As Object, e As MessageEventArgs) 193 Dim me = makeMouseEventFromMsg(e) 194 OnMouseLeave(me) 195 mouseEntered = False 196 End Sub 197 207 198 Sub OnPaintBase(sender As Object, e As MessageEventArgs) 208 199 Dim ps As PAINTSTRUCT 209 200 BeginPaint(hwnd, ps) 210 'Try211 'OnPaintDC(New PaintDCEventArgs(ps.hdc, ps.rcPaint))212 'Finally201 Try 202 OnPaintDC(New PaintDCEventArgs(ps.hdc, ps.rcPaint)) 203 Finally 213 204 EndPaint(hwnd, ps) 214 ' End Try 215 End Sub 216 205 End Try 206 End Sub 207 208 Sub OnKeyDownBase(sender As Object, e As MessageEventArgs) 209 OnKeyDown(New KeyEventArgs(makeKeysFormMsg(e))) 210 End Sub 211 212 Sub OnKeyUpBase(sender As Object, e As MessageEventArgs) 213 OnKeyUp(New KeyEventArgs(makeKeysFormMsg(e))) 214 End Sub 215 216 ' コメントアウト解除のときはStartWndProcのコメントアウト解除も忘れないこと 217 ' Sub OnChar(sender As Object, e As MessageEventArgs) 218 ' OnKeyPress(New KeyPressEventArgs(e.WParam As Char)) 219 ' End Sub 220 221 Sub OnCreateBase(sender As Object, e As MessageEventArgs) 222 OnCreate(New CreateEventArgs(e.LParam As *CREATESTRUCT)) 223 End Sub 217 224 218 225 messageMap As System.Collections.Generic.Dictionary<Object /*DWord*/, MessageEventHandler> … … 260 267 '-------- 261 268 'イベント 262 ' 3263 269 264 270 #include "ControlEvent.sbp" 265 271 266 272 '-------------------------------- 267 ' 1インスタンスメンバ変数273 ' インスタンスメンバ変数 268 274 Private 269 275 hwnd As HWND … … 281 287 282 288 '-------------------------------- 283 ' 1初期ウィンドウクラス289 ' 初期ウィンドウクラス 284 290 Private 285 291 Static Function WndProcFirst(hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT … … 339 345 340 346 '-------------------------------- 341 ' 1初期化終了関連(特にウィンドウクラス)347 ' 初期化終了関連(特にウィンドウクラス) 342 348 Private 343 349 'ウィンドウ作成時にウィンドウプロシージャへThisを伝えるためのもの … … 450 456 Inherits Form 451 457 Public 452 Sub NcDestory(sender As Object, et As EventArgs) 458 Sub t() 459 Dim f = This 460 f.AddMessageEvent(WM_DESTROY, AddressOf (f.Destory)) 461 f.AddPaintDC(AddressOf (f.Paint)) 462 End Sub 463 464 Sub Destory(sender As Object, e As EventArgs) 465 OutputDebugString(Ex"Destory\r\n") 453 466 PostQuitMessage(0) 454 467 End Sub 468 469 Sub Paint(sender As Object, e As PaintDCEventArgs) 470 TextOut(e.Handle, 10, 10, "Hello world!", 12) 471 End Sub 455 472 End Class 456 473 457 474 Dim f = New MyForm 475 f.t() 458 476 f.Create() 459 Dim h = New MessageEventHandler(AddressOf (f.NcDestory))460 f.AddMessageEvent(WM_NCDESTROY, h)461 477 ShowWindow(f.Handle, SW_SHOW) 462 478 … … 481 497 482 498 End 483 -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Forms/ControlEvent.sbp
r542 r544 1 2 1 Public 3 2 Sub AddPaintDC(h As PaintDCEventHandler) … … 23 22 24 23 Public 25 Sub AddClick(h As System.EventHandler)26 If IsNothing(click) Then27 click = h28 Else29 click += h30 End If31 End Sub32 Sub RemoveClick(h As System.EventHandler)33 If Not IsNothing(click) Then34 click -= h35 End If36 End Sub37 Private38 Sub OnClick(e As System.EventArgs)39 If Not IsNothing(click) Then40 click(This, e)41 End If42 End Sub43 Private44 click As System.EventHandler45 46 Public47 Sub AddDoubleClick(h As System.EventHandler)48 If IsNothing(doubleClick) Then49 doubleClick = h50 Else51 doubleClick += h52 End If53 End Sub54 Sub RemoveDoubleClick(h As System.EventHandler)55 If Not IsNothing(doubleClick) Then56 doubleClick -= h57 End If58 End Sub59 Private60 Sub OnDoubleClick(e As System.EventArgs)61 If Not IsNothing(doubleClick) Then62 doubleClick(This, e)63 End If64 End Sub65 Private66 doubleClick As System.EventHandler67 68 Public69 24 Sub AddMouseEnter(h As MouseEventHandler) 70 25 If IsNothing(mouseEnter) Then … … 285 240 Private 286 241 keyUp As KeyEventHandler 287 /*288 Public289 Sub AddKeyPress(h As KeyPressEventHandler)290 If IsNothing(keyPress) Then291 keyPress = h292 Else293 keyPress += h294 End If295 End Sub296 Sub RemoveKeyPress(h As KeyPressEventHandler)297 If Not IsNothing(keyPress) Then298 keyPress -= h299 End If300 End Sub301 Private302 Sub OnKeyPress(e As KeyPressEventArgs)303 If Not IsNothing(keyPress) Then304 keyPress(This, e)305 End If306 End Sub307 Private308 keyPress As KeyPressEventHandler309 242 310 243 Public … … 329 262 Private 330 263 create As CreateEventHandler 331 */ 264 -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Forms/ControlEventList.txt
r542 r544 1 1 PaintDC PaintDCEvent ウィンドウの描画が必要なときに呼び出されます。 2 Click Event クリックされたときに呼び出されます。3 DoubleClick Event ダブルクリックされたときに呼び出されます。2 'Click Event クリックされたときに呼び出されます。 3 'DoubleClick Event ダブルクリックされたときに呼び出されます。 4 4 'EnableChanged Event 有効状態が変化したときに呼び出されます。 5 5 'Move Event ウィンドウが移動したときに呼び出されます。 -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Forms/EventArgs.ab
r542 r544 491 491 Delegate Sub CreateEventHandler(sender As Object, e As CreateEventArgs) 492 492 493 Class FormClosingEventArgs 494 Inherits EventArgs 495 Public 496 Sub FormClosingEventArgs() 497 c = False 498 End Sub 499 500 Function Cancel() As Boolean 501 Cancel = c 502 End Function 503 504 Sub Cancel(cancel As Boolean) 505 c = cancel 506 End Sub 507 Private 508 c As Boolean 509 End Class 510 511 Delegate Sub FormClosingEventHandler(sender As Object, e As FormClosingEventArgs) 512 493 513 End Namespace 'Forms 494 514 End Namespace 'UI
Note:
See TracChangeset
for help on using the changeset viewer.