source: trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Control.ab@ 674

Last change on this file since 674 was 674, checked in by NoWest, 15 years ago

チケット1 #198 の問題でマウスイベントが正常に動きませんので、
暫定的に変換プログラムを挿入しました。

File size: 17.7 KB
RevLine 
[473]1'Classes/ActiveBasic/Windows/UI/Control.ab
2
[545]3#require <Classes/ActiveBasic/Windows/UI/EventArgs.ab>
[575]4#require <Classes/ActiveBasic/COM/ComClassBase.ab>
[473]5
6Namespace ActiveBasic
7Namespace Windows
8Namespace UI
9
[564]10Namespace Detail
11 TypeDef PTrackMouseEvent = *Function(ByRef tme As TRACKMOUSEEVENT) As BOOL
12End Namespace
[542]13
[615]14/*
15@brief Windowsのウィンドウを管理する基底クラス
16@auther Egtra
17*/
[473]18Class Control
[547]19 Inherits WindowHandle
[575]20 Implements ActiveBasic.COM.InterfaceQuerable
[473]21Public
[551]22 /*!
23 @brief Destroyイベントよりも後に呼ばれるDestroyイベントデリゲート
24 @date 2008/07/16
25 */
26 finalDestroy As ActiveBasic.Windows.UI.Handler
[547]27
[473]28 Sub Control()
[575]29 comImpl = New COM.ComClassDelegationImpl(This)
[473]30 End Sub
31
[542]32 Function Handle() As HWND
33 Handle = hwnd
[473]34 End Function
35
[575]36 /*!
37 @brief HWNDからControlインスタンスを取得する。
38 @param[in] hwnd 対象のウィンドウハンドル
[646]39 @return 対応するControlインスタンス。存在しなければ作成される。ただし、hwndがNULLならNothing。
[575]40 */
[473]41 Static Function FromHWnd(hwnd As HWND) As Control
42 FromHWnd = Nothing
[646]43 If IsWindow(hwnd) Then
[473]44 FromHWnd = FromHWndCore(hwnd)
[646]45 If ActiveBasic.IsNothing(FromHWnd) Then
46 Dim lock = New ActiveBasic.Windows.CriticalSectionLock(_System_CriticalSection)
47 Try
48 FromHWnd = New Control
49 FromHWnd.registerStandardEvent()
50 FromHWnd.AssociateHWnd(hwnd)
51 Finally
52 lock.Dispose()
53 End Try
54 End If
[473]55 End If
56 End Function
57
58Private
59 Static Function FromHWndCore(hwnd As HWND) As Control
[575]60 FromHWndCore = _System_PtrObj(GetProp(hwnd, PropertyInstance As ULONG_PTR As PCTSTR) As VoidPtr) As Control
[473]61 End Function
62
63'--------------------------------
[544]64' ウィンドウ作成
[542]65
[473]66Public
[575]67 /*!
68 @brief ウィンドウを作成する(詳細版)。
69 @date 2008/08/02
70 通常はCreateやCreateFormその他を使ってください。
71 */
72 Sub CreateEx(parent As Control, style As DWord, exStyle As DWord, hmenu As HMENU)
[473]73 Dim cs As CREATESTRUCT
[551]74 With cs
75 .dwExStyle = exStyle
76 .lpszClass = (atom As ULONG_PTR) As LPCTSTR
77 .lpszName = 0
[575]78 .style = style
[561]79 .x = 0
80 .y = 0
81 .cx = 0
82 .cy = 0
[551]83 If IsNothing(parent) Then
84 .hwndParent = 0
85 Else
86 .hwndParent = parent As HWND
87 End If
88 .hMenu = hmenu
89 .hInstance = hInstance
90 End With
[473]91 GetCreateStruct(cs)
[551]92 createImpl(cs, parent)
[547]93 End Sub
[473]94
[575]95 /*!
96 @brief ウィンドウを作成する(子ウィンドウ以外)。
97 @date 2008/08/02
98 */
99 Sub CreateForm(style As DWord, exStyle As DWord, owner = Nothing As Control, hmenu = 0 As HMENU)
100 CreateEx(owner, style, exStyle, hmenu)
[551]101 End Sub
[575]102
103 Sub CreateForm()
104 CreateEx(Nothing, 0, 0, 0)
105 End Sub
106
107 /*!
108 @brief 子ウィンドウを作成する。
109 @date 2008/08/02
110 */
111 Sub Create(parent As Control, style = 0 As DWord, exStyle = 0 As DWord, id = 0 As Long)
112 CreateEx(parent, style Or WS_CHILD Or WS_VISIBLE, exStyle, id As ULONG_PTR As HMENU)
113 End Sub
[615]114
[473]115Protected
[646]116 Virtual Sub GetCreateStruct(ByRef cs As CREATESTRUCT)
117 End Sub
[473]118
[551]119 Sub createImpl(ByRef cs As CREATESTRUCT, parent As Control)
[615]120 throwIfAlreadyCreated()
[559]121
[542]122 StartWndProc()
123
[473]124 With cs
[561]125 'よそのウィンドウクラスの場合、WndProcFirst内のhwndの代入が行われないため、ここでも行っておく。
[551]126 hwnd = CreateWindowEx(.dwExStyle, .lpszClass, .lpszName, .style,
[473]127 .x, .y, .cx, .cy, .hwndParent, .hMenu, .hInstance, .lpCreateParams)
[547]128 If hwnd = 0 Then
[615]129 ThrowWithLastErrorNT("Control.CreateEx")
[547]130 End If
[551]131
132 If IsNothing(FromHWndCore(hwnd)) <> False Then
[575]133 AssociateHWnd(hwnd)
[551]134 TlsSetValue(tlsIndex, 0)
135 End If
[473]136 End With
[551]137
138 If IsNothing(parent) = False Then
139 RegisterUnassociateHWnd(parent)
140 End If
[547]141 End Sub
[473]142
[615]143Public
[646]144/*
[615]145 Sub Attach(hwndNew As HWND)
146 throwIfAlreadyCreated()
147 If hwndNew = 0 Then
148 Throw New System.ArgumentNullException("Control.Attach")
149 End If
150 registerStandardEvent()
151 AssociateHWnd(hwndNew)
[637]152 End Sub
[646]153*/
[637]154 Sub BeginSubclass()
155 throwIfNotCreated()
[646]156 prevWndProc = SetWindowLongPtr(hwnd, GWLP_WNDPROC, AddressOf(WndProcFirst) As LONG_PTR) As WNDPROC
[615]157 End Sub
158
159Private
160 Sub throwIfAlreadyCreated()
161 If hwnd <> 0 Then
[637]162 Throw New System.InvalidOperationException("Window is already created.")
[615]163 End If
164 End Sub
165
[637]166 Sub throwIfNotCreated()
167 If hwnd = 0 Then
168 Throw New System.InvalidOperationException("Window is not already created.")
169 End If
170 End Sub
171
[473]172'--------------------------------
173' ウィンドウプロシージャ
[637]174
175Protected
[473]176 Virtual Function WndProc(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
[637]177 If Not ProcessMessage(msg, wp, lp, WndProc) Then
178 WndProc = DefWndProc(msg, wp, lp)
179 End If
180 End Function
181
182 Virtual Function DefWndProc(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
183 If prevWndProc Then
184 DefWndProc = CallWindowProc(prevWndProc, hwnd, msg, wp, lp)
185 Else
186 DefWndProc = DefWindowProc(hwnd, msg, wp, lp)
187 End If
188 End Function
189Protected
190 Function ProcessMessage(msg As DWord, wp As WPARAM, lp As LPARAM, ByRef lr As LRESULT) As Boolean
[551]191 Dim h = Nothing As MessageHandler
[542]192 Dim b = messageMap.TryGetValue(Hex$(msg), h)
193 If b Then
194 If Not IsNothing(h) Then
[551]195 Dim a = New MessageArgs(hwnd, msg, wp, lp)
[542]196 h(This, a)
[615]197 If a.Handled Then
[637]198 lr = a.LResult
199 ProcessMessage = True
[615]200 Exit Function
201 End If
[542]202 End If
203 End If
[637]204 ProcessMessage = False
[473]205 End Function
206Private
[551]207 Static Function makeKeysFormMsg(e As MessageArgs) As Keys
[473]208 Dim t As DWord
[544]209 t = e.WParam And Keys.KeyCode
[473]210 t Or= (GetKeyState(VK_SHIFT) As Word And &h8000) << 1
211 t Or= (GetKeyState(VK_CONTROL) As Word And &h8000) << 2
212 t Or= (GetKeyState(VK_MENU) As Word And &h8000) << 3
[544]213 makeKeysFormMsg = t As Keys
[473]214 End Function
215
[551]216 Static Function makeMouseEventFromMsg(e As MessageArgs) As MouseArgs
[544]217 Dim wp = e.WParam
218 Dim lp = e.LParam
[674]219
220 /*************************************************/
221 Dim mb As MouseButtons
222 If LOWORD(wp) = 0 Then mb = MouseButtons.None
223 If LOWORD(wp) and MK_LBUTTON Then mb or = MouseButtons.Left
224 If LOWORD(wp) and MK_RBUTTON Then mb or = MouseButtons.Right
225 If LOWORD(wp) and MK_MBUTTON Then mb or = MouseButtons.Middle
226 If LOWORD(wp) and MK_XBUTTON1 Then mb or = MouseButtons.XButton1
227 If LOWORD(wp) and MK_XBUTTON2 Then mb or = MouseButtons.XButton2
228 If LOWORD(wp) and MK_SHIFT Then mb or = MouseButtons.Shift
229 If LOWORD(wp) and MK_CONTROL Then mb or = MouseButtons.Control
230 makeMouseEventFromMsg = New MouseArgs(mb, 1, GET_X_LPARAM(lp), GET_Y_LPARAM(lp), 0)
231 /*************************************************/
232
233 'makeMouseEventFromMsg = New MouseArgs(LOWORD(wp) As MouseButtons, 1, GET_X_LPARAM(lp), GET_Y_LPARAM(lp), 0)
[542]234 End Function
[473]235
[575]236Protected
[542]237 /*!
[575]238 @brief 最初にウィンドウプロシージャを使うための前処理を行う関数
[542]239 @date 2008/07/11
[575]240 WndProcFirstを使うときは、この関数を呼んでおく必要がある。
[542]241 */
242 Sub StartWndProc()
[575]243 TlsSetValue(tlsIndex, ObjPtr(This))
244 registerStandardEvent()
245 End Sub
246Private
247 /*!
248 @brief 主なメッセージハンドラの登録を行う関数
249 @date 2008/08/02
250 */
251 Sub registerStandardEvent()
[547]252 AddMessageEvent(WM_ERASEBKGND, AddressOf(OnEraseBackground))
[551]253 Dim md = New MessageHandler(AddressOf(OnMouseDownBase))
[542]254 AddMessageEvent(WM_LBUTTONDOWN, md)
255 AddMessageEvent(WM_RBUTTONDOWN, md)
256 AddMessageEvent(WM_MBUTTONDOWN, md)
257 AddMessageEvent(WM_XBUTTONDOWN, md)
[551]258 Dim mu = New MessageHandler(AddressOf(OnMouseUpBase))
[542]259 AddMessageEvent(WM_LBUTTONUP, mu)
260 AddMessageEvent(WM_RBUTTONUP, mu)
261 AddMessageEvent(WM_MBUTTONUP, mu)
262 AddMessageEvent(WM_XBUTTONUP, mu)
[551]263 Dim mb = New MessageHandler(AddressOf(OnMouseDblClkBase))
[564]264 AddMessageEvent(WM_LBUTTONDBLCLK, mb)
265 AddMessageEvent(WM_RBUTTONDBLCLK, mb)
266 AddMessageEvent(WM_MBUTTONDBLCLK, mb)
267 AddMessageEvent(WM_XBUTTONDBLCLK, mb)
[544]268
[547]269 AddMessageEvent(WM_MOUSEMOVE, AddressOf(OnMouseMoveBase))
270 AddMessageEvent(WM_MOUSELEAVE, AddressOf(OnMouseLeaveBase))
[564]271 AddMessageEvent(WM_MOUSEHOVER, AddressOf(OnMouseHoverBase))
[547]272 AddMessageEvent(WM_PAINT, AddressOf(OnPaintBase))
273 AddMessageEvent(WM_KEYDOWN, AddressOf(OnKeyDownBase))
[551]274 AddMessageEvent(WM_CHAR, AddressOf(OnChar))
[547]275 AddMessageEvent(WM_CREATE, AddressOf(OnCreateBase))
[561]276 AddMessageEvent(WM_SIZE, AddressOf(OnSize))
[542]277 End Sub
[473]278
[551]279 Sub OnEraseBackground(sender As Object, e As MessageArgs)
[615]280 Dim a = New PaintBackgroundArgs(e.WParam, e.LParam)
281 e.Handled = e.Handled And OnPaintBackground(a)
282 e.LResult = a.Painted
[542]283 End Sub
[473]284
[551]285 Sub OnMouseDownBase(sender As Object, e As MessageArgs)
[615]286 e.Handled = e.Handled And OnMouseDown(makeMouseEventFromMsg(e))
[542]287 End Sub
288
[551]289 Sub OnMouseUpBase(sender As Object, e As MessageArgs)
[544]290 Dim me = makeMouseEventFromMsg(e)
[542]291 If doubleClickFired = False Then
[561]292 OnClick(Args.Empty)
[542]293 OnMouseClick(me)
[575]294 Else
[542]295 doubleClickFired = False
296 End If
[615]297 e.Handled = e.Handled And OnMouseUp(me)
[542]298 End Sub
299
[551]300 Sub OnMouseDblClkBase(sender As Object, e As MessageArgs)
[544]301 Dim me = makeMouseEventFromMsg(e)
[542]302 doubleClickFired = True
303 OnMouseDown(me)
[561]304 OnDoubleClick(Args.Empty)
[615]305 e.Handled = e.Handled And OnMouseDoubleClick(me)
[542]306 End Sub
307
[551]308 Sub OnMouseMoveBase(sender As Object, e As MessageArgs)
[544]309 Dim me = makeMouseEventFromMsg(e)
[575]310 If mouseEntered = False Then
[542]311 mouseEntered = True
312 OnMouseEnter(me)
[564]313 trackMouseEvent(TME_LEAVE Or TME_HOVER)
[542]314 End If
[615]315 e.Handled = e.Handled And OnMouseMove(me)
[542]316 End Sub
317
[551]318 Sub OnMouseLeaveBase(sender As Object, e As MessageArgs)
[615]319 e.Handled = e.Handled And OnMouseLeave(Args.Empty)
[544]320 mouseEntered = False
321 End Sub
322
[564]323 Sub OnMouseHoverBase(sender As Object, e As MessageArgs)
324 Dim me = makeMouseEventFromMsg(e)
[615]325 e.Handled = e.Handled And OnMouseHover(me)
[564]326 End Sub
327
[551]328 Sub OnPaintBase(sender As Object, e As MessageArgs)
[615]329 If ActiveBasic.IsNothing(paintDC) Then
330 e.Handled = False
331 Else
332 Dim ps As PAINTSTRUCT
[646]333 BeginPaint(hwnd, ps)
[615]334 Try
335 OnPaintDC(New PaintDCArgs(ps.hdc, ps.rcPaint))
336 Finally
[646]337 EndPaint(hwnd, ps)
[615]338 End Try
339 End If
[542]340 End Sub
341
[551]342 Sub OnKeyDownBase(sender As Object, e As MessageArgs)
[615]343 e.Handled = e.Handled And OnKeyDown(New KeyArgs(makeKeysFormMsg(e)))
[544]344 End Sub
[542]345
[551]346 Sub OnKeyUpBase(sender As Object, e As MessageArgs)
[615]347 e.Handled = e.Handled And OnKeyUp(New KeyArgs(makeKeysFormMsg(e)))
[544]348 End Sub
349
[551]350 Sub OnChar(sender As Object, e As MessageArgs)
[615]351 e.Handled = e.Handled And OnKeyPress(New KeyPressArgs(e.WParam As Char))
[551]352 End Sub
[544]353
[551]354 Sub OnCreateBase(sender As Object, e As MessageArgs)
[615]355 e.Handled = e.Handled And OnCreate(New CreateArgs(e.LParam As *CREATESTRUCT))
[544]356 End Sub
357
[561]358 Sub OnSize(sender As Object, e As MessageArgs)
[615]359 e.Handled = e.Handled And OnResize(New ResizeArgs(e.WParam, e.LParam))
[561]360 End Sub
361
[551]362 messageMap As System.Collections.Generic.Dictionary<Object /*DWord*/, MessageHandler>
[542]363
364Public
[473]365 /*!
[542]366 @biref メッセージイベントハンドラを登録する。
[473]367 @date 2007/12/04
368 */
[551]369 Sub AddMessageEvent(message As DWord, h As MessageHandler)
[542]370 If Not IsNothing(h) Then
371 If IsNothing(messageMap) Then
[551]372 messageMap = New System.Collections.Generic.Dictionary<Object, MessageHandler>
[542]373 End If
374 Dim msg = Hex$(message)
[551]375 Dim m = Nothing As MessageHandler
[542]376 If messageMap.TryGetValue(msg, m) Then
377 messageMap.Item[msg] = m + h
378 Else
379 messageMap.Item[msg] = h
380 End If
381 End If
[473]382 End Sub
383
[542]384 /*!
385 @biref メッセージイベントハンドラ登録を解除する。
386 @date 2007/12/04
387 */
[551]388 Sub RemoveMessageEvent(message As DWord, a As MessageHandler)
[542]389 If Not IsNothing(a) Then
390 If Not IsNothing(messageMap) Then
[545]391 Dim msg = Hex$(message)
[542]392 Dim m = messageMap.Item[msg]
393 If Not IsNothing(m) Then
394 messageMap.Item[msg] = m - a
395 End If
396 End If
397 End If
398 End Sub
399
400'--------------------------------
401' ウィンドウメッセージ処理
402
403
[473]404'--------
405'イベント
406
407#include "ControlEvent.sbp"
408
409'--------------------------------
[544]410' インスタンスメンバ変数
[473]411Private
[542]412 /*!
[615]413 @brief サブクラス化前のウィンドウプロシージャ
414 @date 2008/08/23
415 サブクラス化していなければNULL
416 */
417 prevWndProc As WNDPROC
418 /*!
[542]419 @brief マウスカーソルがクライアント領域に入っているかどうかのフラグ
420 外から中に入ってきたときにMouseEnterイベントを発生させるために用意している。
421 */
422 mouseEntered As Boolean
423 /*!
424 @brief ダブルクリックが起こったかどうかのフラグ
425 Click/MouseClickイベントのために用意している。
426 @date 2008/07/12
427 */
428 doubleClickFired As Boolean
[473]429
430'--------------------------------
[544]431' 初期ウィンドウクラス
[575]432Protected
[473]433 Static Function WndProcFirst(hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
434 Imports System.Runtime.InteropServices
435
[547]436 Dim rThis = FromHWndCore(hwnd)
[473]437 If IsNothing(rThis) Then
[575]438 rThis = _System_PtrObj(TlsGetValue(tlsIndex)) As Control
[473]439 TlsSetValue(tlsIndex, 0)
[575]440 If IsNothing(rThis) Then
[473]441 Goto *InstanceIsNotFound
442 End If
443 ' ウィンドウが作られて最初にWndProcFirstが呼ばれたとき
[575]444 rThis.AssociateHWnd(hwnd)
[473]445 End If
446 If msg = WM_NCDESTROY Then
[551]447 rThis.UnassociateHWnd()
[615]448 rThis.hwnd = 0
[473]449 End If
[551]450 If msg = WM_DESTROY And IsNothing(rThis.finalDestroy) = False Then
451 Dim f = rThis.finalDestroy
452 f(rThis, Args.Empty)
453 End If
454 WndProcFirst = rThis.WndProc(msg, wp, lp)
[473]455 Exit Function
456
457 *InstanceIsNotFound
[615]458 Dim err = String.Concat("Control.WndProcFirst: The attached instance is not found. msg = &h",
459 Hex$(msg), Ex"\r\n")
[559]460 OutputDebugString(ToTCStr(err))
[473]461 WndProcFirst = DefWindowProc(hwnd, msg, wp, lp)
462 End Function
[542]463
[551]464 /*!
465 @brief Controlインスタンスとウィンドウハンドルを結び付ける。
[615]466 @param[in] hwndNew 結び付けるウィンドウハンドル
[551]467 @date 2008/07/16
[575]468 これを実行することで、UnassociateHWndされるまでControlがGC対象にならなくなると共に、
469 FromHWndでウィンドウハンドルからControlインスタンスの取得が可能となる。
[551]470 */
[615]471 Sub AssociateHWnd(hwndNew As HWND)
[637]472 SetHWnd(hwndNew)
[615]473 Prop[PropertyInstance] = ObjPtr(This) As HANDLE
[575]474 comImpl.AddRef()
[559]475 End Sub
[551]476
477 /*!
478 @brief オーナーの破棄時にこのControlインスタンスとウィンドウハンドルの結び付けを解除するよう登録する。
479 @param[in] owner 結び付けの解除を連動させるControl
480 @date 2008/07/16
481 ownerのFinalDestoryでこのControlとHWNDとの結び付けを解除する。
482 */
483 Sub RegisterUnassociateHWnd(owner As Control)
484 If IsNothing(owner) = False Then
485 Dim e = New Handler(AddressOf(UnassociateHWndOnEvent))
486 If IsNothing(finalDestroy) Then
487 owner.finalDestroy = e
488 Else
489 owner.finalDestroy += e
490 End If
491 End If
492 End Sub
493
494 Sub UnassociateHWndOnEvent(sender As Object, e As Args)
495 UnassociateHWnd()
[615]496 hwnd = 0
[551]497 End Sub
498
499 Sub UnassociateHWnd()
[575]500 comImpl.Release()
[551]501 End Sub
502
[473]503' Static Const WM_CONTROL_INVOKE = WM_USER + 0 As DWord
504' Static Const WM_CONTROL_BEGININVOKE = WM_USER + 1 As DWord
505
506'--------------------------------
[575]507' インタフェース実装
508
509Public
510 Virtual Function QueryInterfaceImpl(ByRef iid As IID, ByRef pv As VoidPtr) As HRESULT
511 QueryInterfaceImpl = E_NOTIMPL
512 End Function
513
514Private
[615]515 /*!
516 @brief ウィンドウの寿命管理
517 Controlには次のAddRef-Releaseの対がある。
518 @li createImpl - WM_NCDESTROY(ウィンドウプロシージャがWndProcFirstの場合)
519 @li createImpl - UnassociateHWnd←UnassociateHWndOnEvent←RegisterUnassociateHWnd(その他のウィンドウクラスの場合)
520 @li Attach - WM_NCDESTROY(サブクラス化された場合)
521 なお、Control派生クラスをサブクラス化すると、後ろ2つが両方適用される。
522 */
[575]523 comImpl As COM.ComClassDelegationImpl
[615]524
[575]525'--------------------------------
[542]526' その他の補助関数
527Private
[564]528 Function trackMouseEvent(flags As DWord) As BOOL
529 If pTrackMouseEvent <> 0 Then
[542]530 Dim tme As TRACKMOUSEEVENT
531 With tme
532 .cbSize = Len(tme)
[564]533 .dwFlags = flags
534 .hwndTrack = hwnd
[542]535 .dwHoverTime = HOVER_DEFAULT
536 End With
[564]537 trackMouseEvent = pTrackMouseEvent(tme)
[542]538 End If
[564]539 End Function
[542]540
541'--------------------------------
[544]542' 初期化終了関連(特にウィンドウクラス)
[542]543Private
[473]544 'ウィンドウ作成時にウィンドウプロシージャへThisを伝えるためのもの
545 Static tlsIndex As DWord
546
547 Static hInstance As HINSTANCE
548 Static atom As ATOM
[542]549 Static hmodComctl As HMODULE
[564]550 Static pTrackMouseEvent As Detail.PTrackMouseEvent
[473]551
552 Static Const WindowClassName = "ActiveBasic.Windows.UI.Control"
553 Static Const PropertyInstance = 0 As ATOM
554Public
555 Static Sub Initialize(hinst As HINSTANCE)
556 tlsIndex = TlsAlloc()
[637]557 If tlsIndex = TLS_OUT_OF_INDEXES Then
558 ThrowWithLastError("Control.Initialize: TlsAlloc failed.")
559 End If
[473]560 hInstance = hinst
[564]561 hmodComctl = LoadLibrary("comctl32.dll")
562 pTrackMouseEvent = GetProcAddress(hmodComctl, ToMBStr("_TrackMouseEvent")) As Detail.PTrackMouseEvent
[473]563
564 Dim PropertyInstanceString = WindowClassName + " " + Hex$(GetCurrentProcessId())
565 PropertyInstance = GlobalAddAtom(ToTCStr(PropertyInstanceString))
[637]566 If PropertyInstance = 0 Then
567 ThrowWithLastError("Control.Initialize: GlobalAddAtom failed.")
568 End If
[473]569
570 Dim wcx As WNDCLASSEX
571 With wcx
572 .cbSize = Len (wcx)
573 .style = CS_HREDRAW Or CS_VREDRAW Or CS_DBLCLKS
574 .lpfnWndProc = AddressOf (WndProcFirst)
575 .cbClsExtra = 0
576 .cbWndExtra = 0
577 .hInstance = hinst
578 .hIcon = 0
579 .hCursor = LoadImage(0, MAKEINTRESOURCE(IDC_ARROW), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE Or LR_SHARED) As HCURSOR
580 .hbrBackground = 0
581 .lpszMenuName = 0
582 .lpszClassName = ToTCStr(WindowClassName)
583 .hIconSm = 0
584 End With
585 atom = RegisterClassEx(wcx)
586 If atom = 0 Then
[637]587 ThrowWithLastErrorNT("Control.Initialize: RegisterClasseEx failed.")
[473]588 End If
589 End Sub
590
591 Static Sub Uninitialize()
[542]592 If atom <> 0 Then
593 UnregisterClass(atom As ULONG_PTR As PCSTR, hInstance)
594 End If
595 If tlsIndex <> 0 And tlsIndex <> &hffffffff Then
596 TlsFree(tlsIndex)
597 End If
[564]598 If hmodComctl <> 0 Then
599 FreeLibrary(hmodComctl)
600 End If
[542]601 If PropertyInstance <> 0 Then
602 GlobalDeleteAtom(PropertyInstance)
603 End If
[473]604 End Sub
605End Class
606
[637]607/*!
608@brief WM_COMMANDで通知を行うコントロールの基底クラス
609@date 2008/08/28
610@auther Egtra
611親がWM_COMMANDを受け取ったら、RaiseCommandEventを呼ぶことを意図している。
612(Formで実装済み)
613*/
614Class WmCommandControl
615 Inherits Control
616Public
617 Abstract Function RaiseCommandEvent(notificationCode As Word) As Boolean
618End Class
619
[473]620End Namespace 'UI
621End Namespace 'Widnows
622End Namespace 'ActiveBasic
Note: See TracBrowser for help on using the repository browser.