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

Last change on this file since 646 was 646, checked in by イグトランス (egtra), 16 years ago

WindowHandleをWindows.UIの一部として使うために改造。メンバ関数の厳選、例外処理の導入など。

File size: 17.0 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
[551]219 makeMouseEventFromMsg = New MouseArgs(LOWORD(wp) As MouseButtons, 1, GET_X_LPARAM(lp), GET_Y_LPARAM(lp), 0)
[542]220 End Function
[473]221
[575]222Protected
[542]223 /*!
[575]224 @brief 最初にウィンドウプロシージャを使うための前処理を行う関数
[542]225 @date 2008/07/11
[575]226 WndProcFirstを使うときは、この関数を呼んでおく必要がある。
[542]227 */
228 Sub StartWndProc()
[575]229 TlsSetValue(tlsIndex, ObjPtr(This))
230 registerStandardEvent()
231 End Sub
232Private
233 /*!
234 @brief 主なメッセージハンドラの登録を行う関数
235 @date 2008/08/02
236 */
237 Sub registerStandardEvent()
[547]238 AddMessageEvent(WM_ERASEBKGND, AddressOf(OnEraseBackground))
[551]239 Dim md = New MessageHandler(AddressOf(OnMouseDownBase))
[542]240 AddMessageEvent(WM_LBUTTONDOWN, md)
241 AddMessageEvent(WM_RBUTTONDOWN, md)
242 AddMessageEvent(WM_MBUTTONDOWN, md)
243 AddMessageEvent(WM_XBUTTONDOWN, md)
[551]244 Dim mu = New MessageHandler(AddressOf(OnMouseUpBase))
[542]245 AddMessageEvent(WM_LBUTTONUP, mu)
246 AddMessageEvent(WM_RBUTTONUP, mu)
247 AddMessageEvent(WM_MBUTTONUP, mu)
248 AddMessageEvent(WM_XBUTTONUP, mu)
[551]249 Dim mb = New MessageHandler(AddressOf(OnMouseDblClkBase))
[564]250 AddMessageEvent(WM_LBUTTONDBLCLK, mb)
251 AddMessageEvent(WM_RBUTTONDBLCLK, mb)
252 AddMessageEvent(WM_MBUTTONDBLCLK, mb)
253 AddMessageEvent(WM_XBUTTONDBLCLK, mb)
[544]254
[547]255 AddMessageEvent(WM_MOUSEMOVE, AddressOf(OnMouseMoveBase))
256 AddMessageEvent(WM_MOUSELEAVE, AddressOf(OnMouseLeaveBase))
[564]257 AddMessageEvent(WM_MOUSEHOVER, AddressOf(OnMouseHoverBase))
[547]258 AddMessageEvent(WM_PAINT, AddressOf(OnPaintBase))
259 AddMessageEvent(WM_KEYDOWN, AddressOf(OnKeyDownBase))
[551]260 AddMessageEvent(WM_CHAR, AddressOf(OnChar))
[547]261 AddMessageEvent(WM_CREATE, AddressOf(OnCreateBase))
[561]262 AddMessageEvent(WM_SIZE, AddressOf(OnSize))
[542]263 End Sub
[473]264
[551]265 Sub OnEraseBackground(sender As Object, e As MessageArgs)
[615]266 Dim a = New PaintBackgroundArgs(e.WParam, e.LParam)
267 e.Handled = e.Handled And OnPaintBackground(a)
268 e.LResult = a.Painted
[542]269 End Sub
[473]270
[551]271 Sub OnMouseDownBase(sender As Object, e As MessageArgs)
[615]272 e.Handled = e.Handled And OnMouseDown(makeMouseEventFromMsg(e))
[542]273 End Sub
274
[551]275 Sub OnMouseUpBase(sender As Object, e As MessageArgs)
[544]276 Dim me = makeMouseEventFromMsg(e)
[542]277 If doubleClickFired = False Then
[561]278 OnClick(Args.Empty)
[542]279 OnMouseClick(me)
[575]280 Else
[542]281 doubleClickFired = False
282 End If
[615]283 e.Handled = e.Handled And OnMouseUp(me)
[542]284 End Sub
285
[551]286 Sub OnMouseDblClkBase(sender As Object, e As MessageArgs)
[544]287 Dim me = makeMouseEventFromMsg(e)
[542]288 doubleClickFired = True
289 OnMouseDown(me)
[561]290 OnDoubleClick(Args.Empty)
[615]291 e.Handled = e.Handled And OnMouseDoubleClick(me)
[542]292 End Sub
293
[551]294 Sub OnMouseMoveBase(sender As Object, e As MessageArgs)
[544]295 Dim me = makeMouseEventFromMsg(e)
[575]296 If mouseEntered = False Then
[542]297 mouseEntered = True
298 OnMouseEnter(me)
[564]299 trackMouseEvent(TME_LEAVE Or TME_HOVER)
[542]300 End If
[615]301 e.Handled = e.Handled And OnMouseMove(me)
[542]302 End Sub
303
[551]304 Sub OnMouseLeaveBase(sender As Object, e As MessageArgs)
[615]305 e.Handled = e.Handled And OnMouseLeave(Args.Empty)
[544]306 mouseEntered = False
307 End Sub
308
[564]309 Sub OnMouseHoverBase(sender As Object, e As MessageArgs)
310 Dim me = makeMouseEventFromMsg(e)
[615]311 e.Handled = e.Handled And OnMouseHover(me)
[564]312 End Sub
313
[551]314 Sub OnPaintBase(sender As Object, e As MessageArgs)
[615]315 If ActiveBasic.IsNothing(paintDC) Then
316 e.Handled = False
317 Else
318 Dim ps As PAINTSTRUCT
[646]319 BeginPaint(hwnd, ps)
[615]320 Try
321 OnPaintDC(New PaintDCArgs(ps.hdc, ps.rcPaint))
322 Finally
[646]323 EndPaint(hwnd, ps)
[615]324 End Try
325 End If
[542]326 End Sub
327
[551]328 Sub OnKeyDownBase(sender As Object, e As MessageArgs)
[615]329 e.Handled = e.Handled And OnKeyDown(New KeyArgs(makeKeysFormMsg(e)))
[544]330 End Sub
[542]331
[551]332 Sub OnKeyUpBase(sender As Object, e As MessageArgs)
[615]333 e.Handled = e.Handled And OnKeyUp(New KeyArgs(makeKeysFormMsg(e)))
[544]334 End Sub
335
[551]336 Sub OnChar(sender As Object, e As MessageArgs)
[615]337 e.Handled = e.Handled And OnKeyPress(New KeyPressArgs(e.WParam As Char))
[551]338 End Sub
[544]339
[551]340 Sub OnCreateBase(sender As Object, e As MessageArgs)
[615]341 e.Handled = e.Handled And OnCreate(New CreateArgs(e.LParam As *CREATESTRUCT))
[544]342 End Sub
343
[561]344 Sub OnSize(sender As Object, e As MessageArgs)
[615]345 e.Handled = e.Handled And OnResize(New ResizeArgs(e.WParam, e.LParam))
[561]346 End Sub
347
[551]348 messageMap As System.Collections.Generic.Dictionary<Object /*DWord*/, MessageHandler>
[542]349
350Public
[473]351 /*!
[542]352 @biref メッセージイベントハンドラを登録する。
[473]353 @date 2007/12/04
354 */
[551]355 Sub AddMessageEvent(message As DWord, h As MessageHandler)
[542]356 If Not IsNothing(h) Then
357 If IsNothing(messageMap) Then
[551]358 messageMap = New System.Collections.Generic.Dictionary<Object, MessageHandler>
[542]359 End If
360 Dim msg = Hex$(message)
[551]361 Dim m = Nothing As MessageHandler
[542]362 If messageMap.TryGetValue(msg, m) Then
363 messageMap.Item[msg] = m + h
364 Else
365 messageMap.Item[msg] = h
366 End If
367 End If
[473]368 End Sub
369
[542]370 /*!
371 @biref メッセージイベントハンドラ登録を解除する。
372 @date 2007/12/04
373 */
[551]374 Sub RemoveMessageEvent(message As DWord, a As MessageHandler)
[542]375 If Not IsNothing(a) Then
376 If Not IsNothing(messageMap) Then
[545]377 Dim msg = Hex$(message)
[542]378 Dim m = messageMap.Item[msg]
379 If Not IsNothing(m) Then
380 messageMap.Item[msg] = m - a
381 End If
382 End If
383 End If
384 End Sub
385
386'--------------------------------
387' ウィンドウメッセージ処理
388
389
[473]390'--------
391'イベント
392
393#include "ControlEvent.sbp"
394
395'--------------------------------
[544]396' インスタンスメンバ変数
[473]397Private
[542]398 /*!
[615]399 @brief サブクラス化前のウィンドウプロシージャ
400 @date 2008/08/23
401 サブクラス化していなければNULL
402 */
403 prevWndProc As WNDPROC
404 /*!
[542]405 @brief マウスカーソルがクライアント領域に入っているかどうかのフラグ
406 外から中に入ってきたときにMouseEnterイベントを発生させるために用意している。
407 */
408 mouseEntered As Boolean
409 /*!
410 @brief ダブルクリックが起こったかどうかのフラグ
411 Click/MouseClickイベントのために用意している。
412 @date 2008/07/12
413 */
414 doubleClickFired As Boolean
[473]415
416'--------------------------------
[544]417' 初期ウィンドウクラス
[575]418Protected
[473]419 Static Function WndProcFirst(hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
420 Imports System.Runtime.InteropServices
421
[547]422 Dim rThis = FromHWndCore(hwnd)
[473]423 If IsNothing(rThis) Then
[575]424 rThis = _System_PtrObj(TlsGetValue(tlsIndex)) As Control
[473]425 TlsSetValue(tlsIndex, 0)
[575]426 If IsNothing(rThis) Then
[473]427 Goto *InstanceIsNotFound
428 End If
429 ' ウィンドウが作られて最初にWndProcFirstが呼ばれたとき
[575]430 rThis.AssociateHWnd(hwnd)
[473]431 End If
432 If msg = WM_NCDESTROY Then
[551]433 rThis.UnassociateHWnd()
[615]434 rThis.hwnd = 0
[473]435 End If
[551]436 If msg = WM_DESTROY And IsNothing(rThis.finalDestroy) = False Then
437 Dim f = rThis.finalDestroy
438 f(rThis, Args.Empty)
439 End If
440 WndProcFirst = rThis.WndProc(msg, wp, lp)
[473]441 Exit Function
442
443 *InstanceIsNotFound
[615]444 Dim err = String.Concat("Control.WndProcFirst: The attached instance is not found. msg = &h",
445 Hex$(msg), Ex"\r\n")
[559]446 OutputDebugString(ToTCStr(err))
[473]447 WndProcFirst = DefWindowProc(hwnd, msg, wp, lp)
448 End Function
[542]449
[551]450 /*!
451 @brief Controlインスタンスとウィンドウハンドルを結び付ける。
[615]452 @param[in] hwndNew 結び付けるウィンドウハンドル
[551]453 @date 2008/07/16
[575]454 これを実行することで、UnassociateHWndされるまでControlがGC対象にならなくなると共に、
455 FromHWndでウィンドウハンドルからControlインスタンスの取得が可能となる。
[551]456 */
[615]457 Sub AssociateHWnd(hwndNew As HWND)
[637]458 SetHWnd(hwndNew)
[615]459 Prop[PropertyInstance] = ObjPtr(This) As HANDLE
[575]460 comImpl.AddRef()
[559]461 End Sub
[551]462
463 /*!
464 @brief オーナーの破棄時にこのControlインスタンスとウィンドウハンドルの結び付けを解除するよう登録する。
465 @param[in] owner 結び付けの解除を連動させるControl
466 @date 2008/07/16
467 ownerのFinalDestoryでこのControlとHWNDとの結び付けを解除する。
468 */
469 Sub RegisterUnassociateHWnd(owner As Control)
470 If IsNothing(owner) = False Then
471 Dim e = New Handler(AddressOf(UnassociateHWndOnEvent))
472 If IsNothing(finalDestroy) Then
473 owner.finalDestroy = e
474 Else
475 owner.finalDestroy += e
476 End If
477 End If
478 End Sub
479
480 Sub UnassociateHWndOnEvent(sender As Object, e As Args)
481 UnassociateHWnd()
[615]482 hwnd = 0
[551]483 End Sub
484
485 Sub UnassociateHWnd()
[575]486 comImpl.Release()
[551]487 End Sub
488
[473]489' Static Const WM_CONTROL_INVOKE = WM_USER + 0 As DWord
490' Static Const WM_CONTROL_BEGININVOKE = WM_USER + 1 As DWord
491
492'--------------------------------
[575]493' インタフェース実装
494
495Public
496 Virtual Function QueryInterfaceImpl(ByRef iid As IID, ByRef pv As VoidPtr) As HRESULT
497 QueryInterfaceImpl = E_NOTIMPL
498 End Function
499
500Private
[615]501 /*!
502 @brief ウィンドウの寿命管理
503 Controlには次のAddRef-Releaseの対がある。
504 @li createImpl - WM_NCDESTROY(ウィンドウプロシージャがWndProcFirstの場合)
505 @li createImpl - UnassociateHWnd←UnassociateHWndOnEvent←RegisterUnassociateHWnd(その他のウィンドウクラスの場合)
506 @li Attach - WM_NCDESTROY(サブクラス化された場合)
507 なお、Control派生クラスをサブクラス化すると、後ろ2つが両方適用される。
508 */
[575]509 comImpl As COM.ComClassDelegationImpl
[615]510
[575]511'--------------------------------
[542]512' その他の補助関数
513Private
[564]514 Function trackMouseEvent(flags As DWord) As BOOL
515 If pTrackMouseEvent <> 0 Then
[542]516 Dim tme As TRACKMOUSEEVENT
517 With tme
518 .cbSize = Len(tme)
[564]519 .dwFlags = flags
520 .hwndTrack = hwnd
[542]521 .dwHoverTime = HOVER_DEFAULT
522 End With
[564]523 trackMouseEvent = pTrackMouseEvent(tme)
[542]524 End If
[564]525 End Function
[542]526
527'--------------------------------
[544]528' 初期化終了関連(特にウィンドウクラス)
[542]529Private
[473]530 'ウィンドウ作成時にウィンドウプロシージャへThisを伝えるためのもの
531 Static tlsIndex As DWord
532
533 Static hInstance As HINSTANCE
534 Static atom As ATOM
[542]535 Static hmodComctl As HMODULE
[564]536 Static pTrackMouseEvent As Detail.PTrackMouseEvent
[473]537
538 Static Const WindowClassName = "ActiveBasic.Windows.UI.Control"
539 Static Const PropertyInstance = 0 As ATOM
540Public
541 Static Sub Initialize(hinst As HINSTANCE)
542 tlsIndex = TlsAlloc()
[637]543 If tlsIndex = TLS_OUT_OF_INDEXES Then
544 ThrowWithLastError("Control.Initialize: TlsAlloc failed.")
545 End If
[473]546 hInstance = hinst
[564]547 hmodComctl = LoadLibrary("comctl32.dll")
548 pTrackMouseEvent = GetProcAddress(hmodComctl, ToMBStr("_TrackMouseEvent")) As Detail.PTrackMouseEvent
[473]549
550 Dim PropertyInstanceString = WindowClassName + " " + Hex$(GetCurrentProcessId())
551 PropertyInstance = GlobalAddAtom(ToTCStr(PropertyInstanceString))
[637]552 If PropertyInstance = 0 Then
553 ThrowWithLastError("Control.Initialize: GlobalAddAtom failed.")
554 End If
[473]555
556 Dim wcx As WNDCLASSEX
557 With wcx
558 .cbSize = Len (wcx)
559 .style = CS_HREDRAW Or CS_VREDRAW Or CS_DBLCLKS
560 .lpfnWndProc = AddressOf (WndProcFirst)
561 .cbClsExtra = 0
562 .cbWndExtra = 0
563 .hInstance = hinst
564 .hIcon = 0
565 .hCursor = LoadImage(0, MAKEINTRESOURCE(IDC_ARROW), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE Or LR_SHARED) As HCURSOR
566 .hbrBackground = 0
567 .lpszMenuName = 0
568 .lpszClassName = ToTCStr(WindowClassName)
569 .hIconSm = 0
570 End With
571 atom = RegisterClassEx(wcx)
572 If atom = 0 Then
[637]573 ThrowWithLastErrorNT("Control.Initialize: RegisterClasseEx failed.")
[473]574 End If
575 End Sub
576
577 Static Sub Uninitialize()
[542]578 If atom <> 0 Then
579 UnregisterClass(atom As ULONG_PTR As PCSTR, hInstance)
580 End If
581 If tlsIndex <> 0 And tlsIndex <> &hffffffff Then
582 TlsFree(tlsIndex)
583 End If
[564]584 If hmodComctl <> 0 Then
585 FreeLibrary(hmodComctl)
586 End If
[542]587 If PropertyInstance <> 0 Then
588 GlobalDeleteAtom(PropertyInstance)
589 End If
[473]590 End Sub
591End Class
592
[637]593/*!
594@brief WM_COMMANDで通知を行うコントロールの基底クラス
595@date 2008/08/28
596@auther Egtra
597親がWM_COMMANDを受け取ったら、RaiseCommandEventを呼ぶことを意図している。
598(Formで実装済み)
599*/
600Class WmCommandControl
601 Inherits Control
602Public
603 Abstract Function RaiseCommandEvent(notificationCode As Word) As Boolean
604End Class
605
[473]606End Namespace 'UI
607End Namespace 'Widnows
608End Namespace 'ActiveBasic
Note: See TracBrowser for help on using the repository browser.