- Timestamp:
- Aug 24, 2008, 5:28:59 PM (16 years ago)
- Location:
- trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/ApplicationEvent.sbp
r559 r615 13 13 End Sub 14 14 Protected 15 Static Sub OnThreadExit(e As Args)15 Static Function OnThreadExit(e As Args) As Boolean 16 16 If Not IsNothing(threadExit) Then 17 17 threadExit(This, e) 18 Return True 18 19 End If 19 End Sub20 End Function 20 21 Private 21 22 Static threadExit As Handler -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Control.ab
r604 r615 12 12 End Namespace 13 13 14 /* 15 @brief Windowsのウィンドウを管理する基底クラス 16 @auther Egtra 17 */ 14 18 Class Control 15 19 Inherits WindowHandle … … 24 28 Sub Control() 25 29 comImpl = New COM.ComClassDelegationImpl(This) 26 End Sub27 28 Virtual Sub ~Control()29 30 End Sub 30 31 … … 52 53 '-------------------------------- 53 54 ' ウィンドウ作成 54 ' Function Create(55 ' parent As HWND,56 ' rect As RECT,57 ' name As String,58 ' style As DWord,59 ' exStyle = 0 As DWord,60 ' menu = 0 As HMENU) As HWND61 55 62 56 Public … … 108 102 CreateEx(parent, style Or WS_CHILD Or WS_VISIBLE, exStyle, id As ULONG_PTR As HMENU) 109 103 End Sub 104 110 105 Protected 111 106 Abstract Sub GetCreateStruct(ByRef cs As CREATESTRUCT) 112 107 113 108 Sub createImpl(ByRef cs As CREATESTRUCT, parent As Control) 114 If hwnd <> 0 Then 115 Throw New System.InvalidOperationException("Window already created.") 116 End If 109 throwIfAlreadyCreated() 117 110 118 111 StartWndProc() … … 123 116 .x, .y, .cx, .cy, .hwndParent, .hMenu, .hInstance, .lpCreateParams) 124 117 If hwnd = 0 Then 125 ActiveBasic.Windows.ThrowWithLastError()118 ThrowWithLastErrorNT("Control.CreateEx") 126 119 End If 127 120 … … 134 127 If IsNothing(parent) = False Then 135 128 RegisterUnassociateHWnd(parent) 129 End If 130 End Sub 131 132 Public 133 Sub Attach(hwndNew As HWND) 134 throwIfAlreadyCreated() 135 If hwndNew = 0 Then 136 Throw New System.ArgumentNullException("Control.Attach") 137 End If 138 registerStandardEvent() 139 AssociateHWnd(hwndNew) 140 prevWndProc = SetWindowLongPtr(GWLP_WNDPROC, AddressOf(WndProcFirst) As LONG_PTR) As WNDPROC 141 End Sub 142 143 Private 144 Sub throwIfAlreadyCreated() 145 If hwnd <> 0 Then 146 Throw New System.InvalidOperationException("Window already created.") 136 147 End If 137 148 End Sub … … 148 159 Dim a = New MessageArgs(hwnd, msg, wp, lp) 149 160 h(This, a) 150 WndProc = a.LResult 151 Exit Function 161 If a.Handled Then 162 WndProc = a.LResult 163 Exit Function 164 End If 152 165 End If 153 166 End If … … 156 169 157 170 Virtual Function DefWndProc(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT 158 DefWndProc = DefWindowProc(hwnd, msg, wp, lp) 171 If prevWndProc Then 172 DefWndProc = CallWindowProc(prevWndProc, hwnd, msg, wp, lp) 173 Else 174 DefWndProc = DefWindowProc(hwnd, msg, wp, lp) 175 End If 159 176 End Function 160 177 … … 219 236 220 237 Sub OnEraseBackground(sender As Object, e As MessageArgs) 221 If IsNothing(paintBackground) Then 222 Dim rc = ClientRect 223 FillRect(e.WParam As HDC, rc, (COLOR_3DFACE + 1) As HBRUSH) 224 Else 225 OnPaintBackground(New PaintBackgroundArgs(e.WParam, e.LParam)) 226 End If 227 e.LResult = TRUE 238 Dim a = New PaintBackgroundArgs(e.WParam, e.LParam) 239 e.Handled = e.Handled And OnPaintBackground(a) 240 e.LResult = a.Painted 228 241 End Sub 229 242 230 243 Sub OnMouseDownBase(sender As Object, e As MessageArgs) 231 OnMouseDown(makeMouseEventFromMsg(e))244 e.Handled = e.Handled And OnMouseDown(makeMouseEventFromMsg(e)) 232 245 End Sub 233 246 … … 240 253 doubleClickFired = False 241 254 End If 242 OnMouseUp(me)255 e.Handled = e.Handled And OnMouseUp(me) 243 256 End Sub 244 257 … … 248 261 OnMouseDown(me) 249 262 OnDoubleClick(Args.Empty) 250 OnMouseDoubleClick(me)263 e.Handled = e.Handled And OnMouseDoubleClick(me) 251 264 End Sub 252 265 … … 258 271 trackMouseEvent(TME_LEAVE Or TME_HOVER) 259 272 End If 260 OnMouseMove(me)273 e.Handled = e.Handled And OnMouseMove(me) 261 274 End Sub 262 275 263 276 Sub OnMouseLeaveBase(sender As Object, e As MessageArgs) 264 OnMouseLeave(Args.Empty)277 e.Handled = e.Handled And OnMouseLeave(Args.Empty) 265 278 mouseEntered = False 266 279 End Sub … … 268 281 Sub OnMouseHoverBase(sender As Object, e As MessageArgs) 269 282 Dim me = makeMouseEventFromMsg(e) 270 OnMouseHover(me)283 e.Handled = e.Handled And OnMouseHover(me) 271 284 End Sub 272 285 273 286 Sub OnPaintBase(sender As Object, e As MessageArgs) 274 Dim ps As PAINTSTRUCT 275 BeginPaint(ps) 276 Try 277 OnPaintDC(New PaintDCArgs(ps.hdc, ps.rcPaint)) 278 Finally 279 EndPaint(ps) 280 End Try 287 If ActiveBasic.IsNothing(paintDC) Then 288 e.Handled = False 289 Else 290 Dim ps As PAINTSTRUCT 291 BeginPaint(ps) 292 Try 293 OnPaintDC(New PaintDCArgs(ps.hdc, ps.rcPaint)) 294 Finally 295 EndPaint(ps) 296 End Try 297 End If 281 298 End Sub 282 299 283 300 Sub OnKeyDownBase(sender As Object, e As MessageArgs) 284 OnKeyDown(New KeyArgs(makeKeysFormMsg(e)))301 e.Handled = e.Handled And OnKeyDown(New KeyArgs(makeKeysFormMsg(e))) 285 302 End Sub 286 303 287 304 Sub OnKeyUpBase(sender As Object, e As MessageArgs) 288 OnKeyUp(New KeyArgs(makeKeysFormMsg(e)))305 e.Handled = e.Handled And OnKeyUp(New KeyArgs(makeKeysFormMsg(e))) 289 306 End Sub 290 307 291 308 Sub OnChar(sender As Object, e As MessageArgs) 292 OnKeyPress(New KeyPressArgs(e.WParam As Char))309 e.Handled = e.Handled And OnKeyPress(New KeyPressArgs(e.WParam As Char)) 293 310 End Sub 294 311 295 312 Sub OnCreateBase(sender As Object, e As MessageArgs) 296 OnCreate(New CreateArgs(e.LParam As *CREATESTRUCT))313 e.Handled = e.Handled And OnCreate(New CreateArgs(e.LParam As *CREATESTRUCT)) 297 314 End Sub 298 315 299 316 Sub OnSize(sender As Object, e As MessageArgs) 300 OnResize(New ResizeArgs(e.WParam, e.LParam))317 e.Handled = e.Handled And OnResize(New ResizeArgs(e.WParam, e.LParam)) 301 318 End Sub 302 319 … … 352 369 Private 353 370 /*! 371 @brief サブクラス化前のウィンドウプロシージャ 372 @date 2008/08/23 373 サブクラス化していなければNULL 374 */ 375 prevWndProc As WNDPROC 376 /*! 354 377 @brief マウスカーソルがクライアント領域に入っているかどうかのフラグ 355 378 外から中に入ってきたときにMouseEnterイベントを発生させるために用意している。 … … 381 404 If msg = WM_NCDESTROY Then 382 405 rThis.UnassociateHWnd() 406 rThis.hwnd = 0 383 407 End If 384 408 If msg = WM_DESTROY And IsNothing(rThis.finalDestroy) = False Then 385 409 Dim f = rThis.finalDestroy 386 410 f(rThis, Args.Empty) 387 ' finalDestroy(This, Args.Empty)388 411 End If 389 412 WndProcFirst = rThis.WndProc(msg, wp, lp) … … 391 414 392 415 *InstanceIsNotFound 393 Dim err = "ActiveBasic.Windows.UI.Control.WndProcFirst: The attached instance is not found. msg = &h" _394 + Hex$(msg) + Ex"\r\n"416 Dim err = String.Concat("Control.WndProcFirst: The attached instance is not found. msg = &h", 417 Hex$(msg), Ex"\r\n") 395 418 OutputDebugString(ToTCStr(err)) 396 419 WndProcFirst = DefWindowProc(hwnd, msg, wp, lp) … … 399 422 /*! 400 423 @brief Controlインスタンスとウィンドウハンドルを結び付ける。 401 @param[in] hwnd 結び付けるウィンドウハンドル424 @param[in] hwndNew 結び付けるウィンドウハンドル 402 425 @date 2008/07/16 403 426 これを実行することで、UnassociateHWndされるまでControlがGC対象にならなくなると共に、 404 427 FromHWndでウィンドウハンドルからControlインスタンスの取得が可能となる。 405 428 */ 406 Sub AssociateHWnd(hwnd As HWND)407 This.hwnd = hwnd408 This.Prop[PropertyInstance] = ObjPtr(This) As HANDLE429 Sub AssociateHWnd(hwndNew As HWND) 430 hwnd = hwndNew 431 Prop[PropertyInstance] = ObjPtr(This) As HANDLE 409 432 comImpl.AddRef() 410 433 End Sub … … 429 452 Sub UnassociateHWndOnEvent(sender As Object, e As Args) 430 453 UnassociateHWnd() 454 hwnd = 0 431 455 End Sub 432 456 … … 447 471 448 472 Private 473 /*! 474 @brief ウィンドウの寿命管理 475 Controlには次のAddRef-Releaseの対がある。 476 @li createImpl - WM_NCDESTROY(ウィンドウプロシージャがWndProcFirstの場合) 477 @li createImpl - UnassociateHWnd←UnassociateHWndOnEvent←RegisterUnassociateHWnd(その他のウィンドウクラスの場合) 478 @li Attach - WM_NCDESTROY(サブクラス化された場合) 479 なお、Control派生クラスをサブクラス化すると、後ろ2つが両方適用される。 480 */ 449 481 comImpl As COM.ComClassDelegationImpl 482 450 483 '-------------------------------- 451 484 ' その他の補助関数 … … 526 559 End If 527 560 End Sub 528 529 561 End Class 530 562 -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/ControlEvent.sbp
r564 r615 13 13 End Sub 14 14 Protected 15 Sub OnPaintDC(e As PaintDCArgs)15 Function OnPaintDC(e As PaintDCArgs) As Boolean 16 16 If Not IsNothing(paintDC) Then 17 17 paintDC(This, e) 18 End If 19 End Sub 18 Return True 19 End If 20 End Function 20 21 Private 21 22 paintDC As PaintDCHandler … … 35 36 End Sub 36 37 Protected 37 Sub OnClick(e As Args)38 Function OnClick(e As Args) As Boolean 38 39 If Not IsNothing(click) Then 39 40 click(This, e) 40 End If 41 End Sub 41 Return True 42 End If 43 End Function 42 44 Private 43 45 click As Handler … … 57 59 End Sub 58 60 Protected 59 Sub OnDoubleClick(e As Args)61 Function OnDoubleClick(e As Args) As Boolean 60 62 If Not IsNothing(doubleClick) Then 61 63 doubleClick(This, e) 62 End If 63 End Sub 64 Return True 65 End If 66 End Function 64 67 Private 65 68 doubleClick As Handler … … 79 82 End Sub 80 83 Protected 81 Sub OnMove(e As Args)84 Function OnMove(e As Args) As Boolean 82 85 If Not IsNothing(move) Then 83 86 move(This, e) 84 End If 85 End Sub 87 Return True 88 End If 89 End Function 86 90 Private 87 91 move As Handler … … 101 105 End Sub 102 106 Protected 103 Sub OnResize(e As ResizeArgs)107 Function OnResize(e As ResizeArgs) As Boolean 104 108 If Not IsNothing(resize) Then 105 109 resize(This, e) 106 End If 107 End Sub 110 Return True 111 End If 112 End Function 108 113 Private 109 114 resize As ResizeHandler … … 123 128 End Sub 124 129 Protected 125 Sub OnMouseEnter(e As MouseArgs)130 Function OnMouseEnter(e As MouseArgs) As Boolean 126 131 If Not IsNothing(mouseEnter) Then 127 132 mouseEnter(This, e) 128 End If 129 End Sub 133 Return True 134 End If 135 End Function 130 136 Private 131 137 mouseEnter As MouseHandler … … 145 151 End Sub 146 152 Protected 147 Sub OnMouseMove(e As MouseArgs)153 Function OnMouseMove(e As MouseArgs) As Boolean 148 154 If Not IsNothing(mouseMove) Then 149 155 mouseMove(This, e) 150 End If 151 End Sub 156 Return True 157 End If 158 End Function 152 159 Private 153 160 mouseMove As MouseHandler … … 167 174 End Sub 168 175 Protected 169 Sub OnMouseHover(e As MouseArgs)176 Function OnMouseHover(e As MouseArgs) As Boolean 170 177 If Not IsNothing(mouseHover) Then 171 178 mouseHover(This, e) 172 End If 173 End Sub 179 Return True 180 End If 181 End Function 174 182 Private 175 183 mouseHover As MouseHandler … … 189 197 End Sub 190 198 Protected 191 Sub OnMouseLeave(e As Args)199 Function OnMouseLeave(e As Args) As Boolean 192 200 If Not IsNothing(mouseLeave) Then 193 201 mouseLeave(This, e) 194 End If 195 End Sub 202 Return True 203 End If 204 End Function 196 205 Private 197 206 mouseLeave As Handler … … 211 220 End Sub 212 221 Protected 213 Sub OnMouseDown(e As MouseArgs)222 Function OnMouseDown(e As MouseArgs) As Boolean 214 223 If Not IsNothing(mouseDown) Then 215 224 mouseDown(This, e) 216 End If 217 End Sub 225 Return True 226 End If 227 End Function 218 228 Private 219 229 mouseDown As MouseHandler … … 233 243 End Sub 234 244 Protected 235 Sub OnMouseClick(e As MouseArgs)245 Function OnMouseClick(e As MouseArgs) As Boolean 236 246 If Not IsNothing(mouseClick) Then 237 247 mouseClick(This, e) 238 End If 239 End Sub 248 Return True 249 End If 250 End Function 240 251 Private 241 252 mouseClick As MouseHandler … … 255 266 End Sub 256 267 Protected 257 Sub OnMouseDoubleClick(e As MouseArgs)268 Function OnMouseDoubleClick(e As MouseArgs) As Boolean 258 269 If Not IsNothing(mouseDoubleClick) Then 259 270 mouseDoubleClick(This, e) 260 End If 261 End Sub 271 Return True 272 End If 273 End Function 262 274 Private 263 275 mouseDoubleClick As MouseHandler … … 277 289 End Sub 278 290 Protected 279 Sub OnMouseUp(e As MouseArgs)291 Function OnMouseUp(e As MouseArgs) As Boolean 280 292 If Not IsNothing(mouseUp) Then 281 293 mouseUp(This, e) 282 End If 283 End Sub 294 Return True 295 End If 296 End Function 284 297 Private 285 298 mouseUp As MouseHandler … … 299 312 End Sub 300 313 Protected 301 Sub OnKeyDown(e As KeyArgs)314 Function OnKeyDown(e As KeyArgs) As Boolean 302 315 If Not IsNothing(keyDown) Then 303 316 keyDown(This, e) 304 End If 305 End Sub 317 Return True 318 End If 319 End Function 306 320 Private 307 321 keyDown As KeyHandler … … 321 335 End Sub 322 336 Protected 323 Sub OnKeyUp(e As KeyArgs)337 Function OnKeyUp(e As KeyArgs) As Boolean 324 338 If Not IsNothing(keyUp) Then 325 339 keyUp(This, e) 326 End If 327 End Sub 340 Return True 341 End If 342 End Function 328 343 Private 329 344 keyUp As KeyHandler … … 343 358 End Sub 344 359 Protected 345 Sub OnKeyPress(e As KeyPressArgs)360 Function OnKeyPress(e As KeyPressArgs) As Boolean 346 361 If Not IsNothing(keyPress) Then 347 362 keyPress(This, e) 348 End If 349 End Sub 363 Return True 364 End If 365 End Function 350 366 Private 351 367 keyPress As KeyPressHandler … … 365 381 End Sub 366 382 Protected 367 Sub OnCreate(e As CreateArgs)383 Function OnCreate(e As CreateArgs) As Boolean 368 384 If Not IsNothing(create) Then 369 385 create(This, e) 370 End If 371 End Sub 386 Return True 387 End If 388 End Function 372 389 Private 373 390 create As CreateHandler … … 387 404 End Sub 388 405 Protected 389 Sub OnDestroy(e As Args)406 Function OnDestroy(e As Args) As Boolean 390 407 If Not IsNothing(destroy) Then 391 408 destroy(This, e) 392 End If 393 End Sub 409 Return True 410 End If 411 End Function 394 412 Private 395 413 destroy As Handler … … 409 427 End Sub 410 428 Protected 411 Sub OnPaintBackground(e As PaintBackgroundArgs)429 Function OnPaintBackground(e As PaintBackgroundArgs) As Boolean 412 430 If Not IsNothing(paintBackground) Then 413 431 paintBackground(This, e) 414 End If 415 End Sub 432 Return True 433 End If 434 End Function 416 435 Private 417 436 paintBackground As PaintBackgroundHandler -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/EventArgs.ab
r575 r615 21 21 lp = lParam 22 22 lr = 0 23 handled = True 23 24 End Sub 24 25 … … 45 46 Sub LResult(lResult As LRESULT) 46 47 lr = lResult 48 End Sub 49 50 Const Function Handled() As Boolean 51 Handled = handled 52 End Function 53 54 Sub Handled(h As Boolean) 55 handled = h 47 56 End Sub 48 57 Private … … 52 61 lp As LPARAM 53 62 lr As LRESULT 63 handled As Boolean 54 64 End Class 55 65 … … 550 560 Sub PaintBackgroundArgs(hdc As HDC) 551 561 This.hdc = hdc 562 This.painted = True 552 563 End Sub 553 564 … … 559 570 Handle = hdc 560 571 End Function 572 573 Const Function Painted() As Boolean 574 Painted = painted 575 End Function 576 577 Sub Painted(p As Boolean) 578 painted = p 579 End Sub 561 580 Private 562 581 hdc As HDC 582 painted As Boolean 563 583 End Class 564 584 -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Form.ab
r561 r615 18 18 Public 19 19 Sub Form() 20 AddMessageEvent(WM_COMMAND, AddressOf (OnCommand)) 20 AddMessageEvent(WM_COMMAND, AddressOf(OnCommand)) 21 AddPaintBackground(AddressOf(OnPaintBackground)) 21 22 End Sub 22 23 … … 30 31 .cy = CW_USEDEFAULT 31 32 End With 33 End Sub 34 35 Sub OnPaintBackground(sender As Object, e As PaintBackgroundArgs) 36 Dim rc = ClientRect 37 FillRect(e.Handle, rc, (COLOR_3DFACE + 1) As HBRUSH) 32 38 End Sub 33 39 -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/FormEvent.sbp
r551 r615 13 13 End Sub 14 14 Protected 15 Sub OnQueryClose(e As FormClosingArgs)15 Function OnQueryClose(e As FormClosingArgs) As Boolean 16 16 If Not IsNothing(queryClose) Then 17 17 queryClose(This, e) 18 Return True 18 19 End If 19 End Sub20 End Function 20 21 Private 21 22 queryClose As FormClosingHandler -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/MakeControlEventHandler.ab
r559 r615 46 46 ' out.WriteLine(Ex"\t@brief " & comment) 47 47 ' out.WriteLine(Ex"\t*/") 48 out.WriteLine(Ex"\t" & staticKeyword & " Sub On" & eventName & "(e As " & argsType & ")")48 out.WriteLine(Ex"\t" & staticKeyword & "Function On" & eventName & "(e As " & argsType & ") As Boolean") 49 49 out.WriteLine(Ex"\t\tIf Not IsNothing(" & eventMember & ") Then") 50 50 out.WriteLine(Ex"\t\t\t" & eventMember & "(This, e)") 51 out.WriteLine(Ex"\t\t\tReturn True") 51 52 out.WriteLine(Ex"\t\tEnd If") 52 out.WriteLine(Ex"\tEnd Sub")53 out.WriteLine(Ex"\tEnd Function") 53 54 out.WriteLine("Private") 54 55 out.WriteLine(Ex"\t" & staticKeyword & eventMember & " As " & handlerType) … … 72 73 Dim a = ActiveBasic.Strings.Detail.Split(s, 9) 'Tab 73 74 If a.Count >= 3 Then 74 OutputEventHandlerCode(out, a [0], a[1], a[2], isStatic)75 OutputEventHandlerCode(out, a.Item[0], a.Item[1], a.Item[2], isStatic) 75 76 End If 76 77 Loop -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/WindowHandle.sbp
r547 r615 547 547 _System_SetWindowLongPtr(hwnd, GWLP_ID, newId) 548 548 End Sub 549 549 #endif 550 550 Function DlgItem(idDlgItem As Long) As WindowHandle 551 551 Dim w As WindowHandle(GetDlgItem(hwnd, idDlgItem)) 552 552 Return w 553 553 End Function 554 #endif 554 555 555 Const Function ExStyle() As DWord 556 556 Return _System_GetWindowLongPtr(hwnd, GWL_EXSTYLE) As DWord -
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/Windows.ab
r603 r615 112 112 @brief Windowsのエラー値を基に例外を投げる 113 113 @param[in] dwErrorCode Win32エラーコード 114 @param[in] msg 補足説明 114 115 @throw WindowsException 常に投げられる。 115 116 @date 2008/07/13 116 117 @auther Egtra 117 118 */ 118 Sub ThrowWithErrorCode(dwErrorCode As DWord )119 Throw New WindowsException(HRESULT_FROM_WIN32(dwErrorCode) )119 Sub ThrowWithErrorCode(dwErrorCode As DWord, msg = Nothing As String) 120 Throw New WindowsException(HRESULT_FROM_WIN32(dwErrorCode), msg) 120 121 End Sub 121 122 122 /*! 123 @brief 内部でGetLastErrorを呼んで、その値を基に例外を投げる。 124 @throw WindowsException 常に投げられる。 123 @brief WindowsExceptionを投げるラッパ。直前に呼び出したAPI関数などが失敗したときに用いる。 124 @param[in] msg 補足説明 125 @throw WindowsException 常に投げられる。 126 @date 2008/08/20 127 @auther Egtra 128 WindowsExceptionを構築する際、GetLastError()の値を渡す。 129 この関数では、直前のAPI関数が成功したかどうかを調べられないことに注意。 130 */ 131 Sub ThrowWithLastError(msg = Nothing As String) 132 ThrowWithErrorCode(GetLastError(), msg) 133 End Sub 134 /*! 135 @brief (主にuser32の全部、gdi32の一部が対象)WindowsExceptionを投げるラッパ。直前に呼び出したAPI関数などが失敗したときに用いる。 136 @param[in] msg 補足説明 137 @throw WindowsException 常に投げられる。 125 138 @date 2008/08/26 126 139 @auther Egtra 140 user32やgdi32の一部など、9xではGetLastErrorでエラーメッセージが取得できないものがある。 141 そのため、9xでは一律にmsgのみでWindowsExceptionを構築して投げるようにしている。 142 143 ところで、CEではNT同様GetLastErrorが使用できるため、 144 CEへの移植を仮定すると、関数名にNTと付けるのがそぐわないと感じる。代案募集中。 127 145 */ 128 Sub ThrowWithLastError() 129 ThrowWithErrorCode(GetLastError()) 146 Sub ThrowWithLastErrorNT(msg As String) 147 If Not Version.Is9x() Then 148 ThrowWithErrorCode(GetLastError(), msg) 149 Else 150 Throw New WindowsException(msg) 151 End If 130 152 End Sub 131 153 /*! 132 154 @brief HRESULT値を基に例外を投げる。 133 @ date 2008/07/13134 @param[in] hr HRESULT値155 @param[in] hr HRESULT値 156 @param[in] msg 補足説明 135 157 @throw WindowsException FAILED(hr)が真の場合 136 @auther Egtra 158 @date 2008/07/13 159 @auther Egtra 137 160 hrが成功値 (FAILED(hr) = False) の場合、この関数は何も行わない。 138 161 */ 139 Sub ThrowIfFailed(hr As HRESULT )162 Sub ThrowIfFailed(hr As HRESULT, msg = Nothing As String) 140 163 If FAILED(hr) Then 141 Throw New WindowsException(hr )164 Throw New WindowsException(hr, msg) 142 165 End If 143 166 End Sub
Note:
See TracChangeset
for help on using the changeset viewer.