EnglishРусский  

   ..

   addustr.g

   app.g

   btn.g

   btnpic.g

   comp.g

   ctrl.g

   dialogs.g

   edit.g

   events.g

   fonts.g

   form.g

   gray.g

   grey.g

   images.g

   label.g

   labeled.g

   locustr.g

   menu.g

   panel.g

   picture.g

   s.txt

   styles.g

   tab.g

   tabitem.g

   tabpage.g

   toolbar.g

   tray.g

   url.g

   vis.g

   viswin.g

Ads

Perfect Automation tool
All-In-One: Script editor, Launcher, Scheduler, Keyboard & Mouse Recorder. Try now!

CreateInstall
Freeware and commercial installers.

Cell Phone Batteries
Batteries Plus offers batteries for laptop, camcorder, cell phone, camera.

Gentee needs your help!
How to advertise with us
 
laptop battery

source\lib\vis\ctrl.g
   1 /******************************************************************************
   2 *
   3 * Copyright (C) 2004-2007, The Gentee Group. All rights reserved. 
   4 * This file is part of the Gentee open source project - http://www.gentee.com. 
   5 * 
   6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
   7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
   8 * ACCEPTANCE OF THE AGREEMENT.
   9 *
  10 * ID: vis.ctrl 17.07.07 0.0.A.
  11 *
  12 * Author: Alexander Krivonogov ( gentee )
  13 *
  14 ******************************************************************************/
  15 /* Компонента vCtrl, порождена от vComp
  16 События
  17    
  18 */
  19 
  20 
  21 include
  22 {   
  23    "virtctrl.g"   
  24    //"addustr.g"   
  25 }
  26 
  27 type winmsg <inherit=MSG>{
  28    //uint hwnd   
  29    //uint msg
  30    //uint wpar
  31    //uint lpar
  32    uint flags 
  33 }
  34 
  35 type winmsgsh {
  36    uint hwnd
  37    uint msg
  38    ushort wparlo
  39    ushort wparhi
  40    ushort lparlo
  41    ushort lparhi
  42    uint flags 
  43 }
  44 
  45 type winmsgmouse{
  46    uint hwnd
  47    uint msg
  48    uint wpar
  49    ushort x
  50    ushort y
  51    uint flags
  52 }
  53 
  54 type winmsgcmd {
  55    uint hwnd
  56    uint msg   
  57    ushort id
  58    ushort ntf 
  59    uint ctrlhwnd
  60    uint flags
  61 }      
  62 
  63 /*
  64 operator vloc =( vloc l, r )
  65 {
  66    mcopy( &l, &r, sizeof(vloc) )
  67    return l
  68 }
  69 
  70 operator uint ==( vloc l, r )
  71 {
  72    return l.left == r.left && l.top == r.top && l.width == r.width && l.height == r.height
  73 }
  74 */
  75 
  76 
  77 type vCtrl <inherit = vVirtCtrl>
  78 {
  79 //Hidden Fields
  80 
  81    uint prevwndproc         
  82    vloc clloc
  83    uint hwnd   
  84    
  85       
  86    uint pCanContain
  87    uint pCanFocus
  88    uint pTabStop      
  89    uint pAlign
  90    uint pRight
  91    uint pBottom
  92    uint pCtrls //Количество дочерних контролов
  93    str  pFont   
  94    uint hFont    
  95    uint pPopupMenu
  96    
  97    str  pStyle
  98    uint aStyle 
  99 
 100    uint flgnoposchanged   
 101    uint flgXPStyle  //Контрол должен поддерживать обработку фона для XP
 102    uint flgRePaint //Принудительная перерисовка при изменении размеров нужна для STATIC
 103    uint flgNoPosChanging //Запрет на перемещение и изменение размеров
 104    //uint flgPosChanging
 105    
 106 //Public Fields   
 107 //   arr  ctrls of uint         
 108 
 109 //Events            
 110    oneventpos  onposchanging
 111    evEvent     onPosChanged
 112    evEvent     onownersize
 113    evMouse     OnMouse
 114    evKey       OnKey
 115    
 116    //oneventuint onfocus
 117    evValUint   OnFocus
 118    //uint oncomnotify
 119 }
 120 
 121 define {   
 122    mReCreateWin  = $vVirtCtrl_last    
 123    mDestroyWin
 124    mPosChanged 
 125    //mPosChanging   
 126    mWinCmd
 127    mWinNtf
 128    mWinDrawItem
 129     mWinMeasureItem
 130    mFocus
 131    mKey
 132    mMouse   
 133    mFontChanged
 134    
 135    mDesChanging
 136    mDesChanged
 137    
 138    mGetHint   
 139    
 140    mClColor
 141    
 142    vCtrl_last
 143 }
 144 
 145 extern {
 146 func uint myproc( uint hwnd, uint msg, uint wpar, uint lpar )
 147 property uint vCtrl.TabOrder
 148 property vCtrl.TabOrder( uint newidx )
 149 }
 150 
 151 
 152 define {
 153    TAB_INSERT = 1
 154    TAB_REMOVE
 155    TAB_MOVE   
 156 }
 157 
 158 
 159 define <export>
 160 {   
 161    alhLeft       = 0x01
 162    alhClient     = 0x02
 163    alhRight      = 0x04     
 164    alhCenter     = 0x08
 165    alhLeftRight  = 0x10
 166    ALH_MASK      = 0xFF              
 167    
 168    alvTop        = 0x0100
 169    alvClient     = 0x0200   
 170    alvBottom     = 0x0400
 171    alvCenter     = 0x0800   
 172    alvTopBottom  = 0x1000
 173    ALV_MASK      = 0xFF00
 174 }
 175 
 176 
 177 
 178 
 179 
 180 
 181 func win_move( uint hwnd, int x, y )
 182 {
 183    SetWindowPos( hwnd, 0, x, y, 0, 0, $SWP_NOACTIVATE | $SWP_NOZORDER | $SWP_NOSIZE )
 184 }
 185 
 186 func win_loc( uint hwnd, int x, y, width, height )
 187 {   
 188    MoveWindow( hwnd, x, y, width, height, 1 )
 189 }
 190 
 191 
 192 
 193 method vCtrl.ownerresize( vloc n )
 194 {   
 195    if &this.Owner()      
 196    {
 197        int width, height
 198       
 199       //n.left -= this.Owner->vCtrl.clloc.left
 200       //n.top -= this.Owner->vCtrl.clloc.top
 201       
 202    
 203       width = this.Owner->vCtrl.clloc.width
 204       height = this.Owner->vCtrl.clloc.height
 205     
 206       switch this.pAlign & $ALV_MASK
 207       {
 208          case $alvTop
 209          {
 210             //Привязать к позиции верхнего края
 211             //Ничего делать не надо            
 212          }
 213          case $alvClient 
 214          {              
 215             //Растянуть на всю высоту
 216             n.top = 0
 217             n.height = height            
 218          }
 219          case $alvBottom 
 220          {
 221             //Привязать к позиции нижнего края
 222             n.top = height - n.height - this.pBottom             
 223          }
 224          case $alvCenter 
 225          {          
 226             //Центрировать
 227             n.top = (height - n.height )>>1            
 228          }
 229          case $alvTopBottom
 230          {
 231             n.height = height - n.top - this.pBottom
 232          }
 233       }
 234       switch this.pAlign & $ALH_MASK
 235       {
 236          case $alhLeft
 237          {
 238             //Привязать к позиции верхнего края
 239             //Ничего делать не надо
 240          }
 241          case $alhClient 
 242          {           
 243             //Растянуть на всю высоту
 244             n.left = 0
 245             n.width = width
 246          }
 247          case $alhRight
 248          {       
 249             //Привязать к позиции нижнего края
 250             n.left = width - n.width - this.pRight             
 251          }
 252          case $alhCenter 
 253          {
 254             //Центрировать
 255             n.left = (width - n.width )>>1            
 256          }
 257          case $alhLeftRight 
 258          {           
 259             //Растягивать с отступами
 260             n.width = width - this.pRight - n.left
 261          }
 262       }
 263    }      
 264 }
 265 
 266 
 267 method vCtrl.CreateWin( ustr class, uint exstyle, style )
 268 {
 269    //print( "Createwin \(?( this.pOwner, this.pOwner->vCtrl.hwnd, 0)) \n" )
 270    this.hwnd = CreateWindowEx( exstyle, class.ptr(), "".ustr().ptr(), style, 
 271       this.loc.left, this.loc.top, this.loc.width, this.loc.height, ?( this.pOwner, this.pOwner->vCtrl.hwnd, 0), 0, GetModuleHandle( 0 ), &this )       
 272 }
 273 
 274 func vCtrl getctrl( uint hwnd )
 275 {  
 276    uint ctrl = GetWindowLong( hwnd, $GWL_USERDATA )
 277    while !ctrl && hwnd
 278    {
 279       hwnd = GetParent( hwnd )
 280       ctrl = GetWindowLong( hwnd, $GWL_USERDATA )
 281    }   
 282    return ctrl->vCtrl
 283 }
 284 
 285 method vCtrl.SetStyle( uint mask, is )
 286 {
 287    if this.hwnd 
 288    {
 289       uint style = GetWindowLong( this.hwnd, $GWL_STYLE )
 290       if is : style |= mask
 291       else : style &= ~mask
 292       SetWindowLong( this.hwnd, $GWL_STYLE, style )
 293       SetWindowPos( this.hwnd, 0, 0, 0, 0, 0,  
 294                         $SWP_NOACTIVATE | $SWP_NOZORDER | $SWP_NOMOVE | $SWP_NOSIZE )                     
 295       InvalidateRect( this.hwnd, 0->RECT, 1 )
 296    }   
 297 }
 298 method uint vCtrl.GetStyle( uint mask )
 299 {
 300    return ?(GetWindowLong( this.hwnd, $GWL_STYLE ) & mask == mask, 1,0)
 301 }
 302 
 303 
 304 method uint vCtrl.WinMsg( uint message )
 305 { 
 306    return SendMessage( this.hwnd, message, 0, 0 )
 307 }
 308 
 309 method uint vCtrl.WinMsg( uint message, wpar )
 310 {
 311    return SendMessage( this.hwnd, message, wpar, 0 )
 312 }
 313 
 314 method uint vCtrl.WinMsg( uint message, wpar, lpar )
 315 {
 316    return SendMessage( this.hwnd, message, wpar, lpar )
 317 }
 318 
 319 method vCtrl.ChangeStyle( uint addstyle, remstyle )
 320 {
 321    STYLESTRUCT stls
 322    uint style = GetWindowLong( this.hwnd, $GWL_STYLE )
 323    stls.styleOld = style
 324    style &= ~remstyle
 325    style |= addstyle
 326    stls.styleNew = style   
 327    SetWindowLong( this.hwnd, $GWL_STYLE, style )
 328    
 329    this.WinMsg( 0x7d, $GWL_STYLE, &stls)//$WM_STYLECHANGED )
 330    
 331 }
 332 
 333 /*method vCtrl.ReCreateWin()
 334 {
 335    .Virtual( $mDestroyWin )   
 336    .Virtual( $mCreateWin )
 337    if .pOwner  
 338    {
 339       SetWindowLong( .hwnd, $GWL_STYLE, GetWindowLong( .hwnd, $GWL_STYLE ) | $WS_CHILD )     	   
 340       SetParent( .hwnd, .pOwner->vCtrl.hwnd )
 341       this.TabOrder = this.TabOrder
 342    }
 343 }*/
 344 
 345 
 346 
 347 /*------------------------------------------------------------------------------
 348    Propirties
 349 */
 350 /*
 351 property int vCtrl.Left
 352 { 
 353    //if this.Owner : return this.loc.left + this.Owner->vCtrl.clloc.left
 354    return this.loc.left
 355 }
 356 
 357 property vCtrl.Left( int val )
 358 {  
 359    //if val != this.loc.left
 360    {      
 361       eventpos ep
 362       this.loc.left = val
 363       ep.loc = this.loc
 364       ep.loc.left = val
 365       ep.move = 1
 366       ep.code = $e_poschanging      
 367       .Virtual( $mPosChanging, ep )    
 368    } 
 369 }
 370 
 371 property int vCtrl.Top
 372 {
 373    //if this.Owner : return this.loc.top + this.Owner->vCtrl.clloc.top
 374    return this.loc.top
 375 }
 376 
 377 property vCtrl.Top( int val )
 378 {   
 379    //if val != this.loc.top
 380    {
 381       eventpos ep
 382       this.loc.top = val
 383       ep.loc = this.loc
 384       ep.loc.top = val
 385       ep.move = 1
 386       ep.code = $e_poschanging
 387       .Virtual( $mPosChanging, ep )
 388    }
 389 }
 390 
 391 property int vCtrl.Width
 392 {
 393    return this.loc.width
 394 }
 395 
 396 property vCtrl.Width( int val )
 397 {
 398    if val < 0 : val = 0   
 399    if val != this.loc.width
 400    {   
 401       eventpos ep      
 402       ep.loc = this.loc
 403       ep.loc.width = val
 404       ep.move = 1
 405       ep.code = $e_poschanging         
 406       .Virtual( $mPosChanging, ep )    
 407    }
 408 }
 409 
 410 property int vCtrl.Height
 411 {
 412    return this.loc.height
 413 }
 414 
 415 
 416 property vCtrl.Height( int val )
 417 {
 418    if val < 0 : val = 0
 419    if val != this.loc.height
 420    {
 421       
 422       eventpos ep
 423       ep.loc = this.loc
 424       ep.loc.height = val
 425       ep.move = 1
 426       ep.code = $e_poschanging      
 427       .Virtual( $mPosChanging, ep )       
 428    } 
 429 }
 430 */
 431 property int vCtrl.Right
 432 {
 433    return this.pRight
 434 }
 435 
 436 property vCtrl.Right( int val )
 437 {   
 438    if val != this.pRight 
 439    {
 440       this.pRight = val
 441       if this.pAlign & ( $alhRight | $alhLeftRight )
 442       {
 443          eventpos ep      
 444          ep.loc = this.loc      
 445          ep.move = 1
 446          ep.code = $e_poschanging
 447          .Virtual( $mPosChanging, ep )
 448       }
 449    }   
 450 }
 451 
 452 property int vCtrl.Bottom
 453 {
 454    return this.pBottom
 455 }
 456 
 457 property vCtrl.Bottom( int val )
 458 {   
 459    if val != this.pBottom 
 460    {
 461       this.pBottom = val
 462       if this.pAlign & ( $alvBottom | $alvTopBottom )
 463       {
 464          eventpos ep      
 465          ep.loc = this.loc      
 466          ep.move = 1
 467          ep.code = $e_poschanging         
 468          .Virtual( $mPosChanging, ep )
 469       }      
 470    }   
 471 }
 472 /*
 473 property vCtrl.Visible( uint val )
 474 {   
 475    if val != this.pVisible
 476    {   
 477       this.pVisible = val 
 478       if !this.p_designing
 479       {     
 480          .Virtual( $mUpdateVisible )                  
 481       }
 482    }
 483 }
 484 
 485 property uint vCtrl.Visible
 486 {
 487    return this.pVisible
 488 }
 489 
 490 property vCtrl.Enabled( uint val )
 491 {
 492    if val != this.pEnabled
 493    {
 494       .Virtual( $mSetEnabled, val )           
 495    }
 496 }
 497 
 498 property uint vCtrl.Enabled
 499 {
 500    return this.pEnabled
 501 }
 502 */
 503 property uint vCtrl.TabStop
 504 {
 505    return this.pTabStop
 506 }
 507 
 508 property vCtrl.TabStop( uint val )
 509 {
 510    if val != this.pTabStop
 511    {
 512       this.pTabStop = val
 513    }
 514 }
 515 
 516 property uint vCtrl.TabOrder
 517 {
 518    return this.cidx
 519 }
 520 
 521 property vCtrl.TabOrder( uint newidx )
 522 {
 523    if this.pOwner && this.pOwner->vComp.TypeIs( vCtrl )
 524    {  
 525       uint ctrls as this.pOwner->vCtrl.Comps//ctrls
 526       uint oldidx, i      
 527       uint prevhwnd      
 528       newidx = min( max( -0, int( newidx )), *ctrls - 1 )          
 529       if newidx != this.cidx
 530       {  
 531          oldidx = this.cidx
 532          if newidx > oldidx
 533          {            
 534             fornum i = oldidx + 1, newidx + 1 
 535             {
 536                ctrls[i]->vCtrl.cidx--
 537                ctrls[i-1] = ctrls[i]
 538             }            
 539          }
 540          else
 541          {            
 542             for i = oldidx - 1, int(i) >= newidx, i--
 543             {
 544                ctrls[i]->vCtrl.cidx++
 545                ctrls[i+1] = ctrls[i]
 546             }
 547          }       
 548          ctrls[newidx] = &this
 549          this.cidx = newidx         
 550          //if newidx < /**ctrls*/.pCtrls-1 : prevhwnd = ctrls[newidx+1]->vCtrl.hwnd
 551          if newidx > 0 : prevhwnd = ctrls[newidx-1]->vCtrl.hwnd
 552          else : prevhwnd = 1
 553          SetWindowPos( this.hwnd, prevhwnd, 0, 0, 0, 0, $SWP_NOACTIVATE | $SWP_NOSIZE | $SWP_NOMOVE )
 554       }
 555    }
 556 }
 557 
 558 
 559 property uint vCtrl.VertAlign
 560 {
 561    return this.pAlign & $ALV_MASK
 562 }
 563 
 564 
 565 property vCtrl.VertAlign( uint flg )
 566 {
 567    flg &= $ALV_MASK   
 568    
 569    this.pAlign = this.pAlign & $ALH_MASK | flg      
 570    if flg & ( $alvBottom | $alvTopBottom )
 571    {
 572       if this.p_designing && this.Owner 
 573       {
 574          this.pBottom = this.Owner->vCtrl.clloc.height - this.loc.top - this.loc.height
 575       } 
 576    }
 577    eventpos evp
 578    evp.code = $e_poschanging
 579    evp.loc = this.loc
 580    evp.move = 1
 581    .Virtual( $mPosChanging, evp )
 582   
 583 }
 584 
 585 
 586 property uint vCtrl.HorzAlign
 587 {
 588    return this.pAlign & $ALH_MASK
 589 }
 590 
 591 property vCtrl.HorzAlign( uint flg )
 592 {
 593    flg &= $ALH_MASK
 594    
 595    this.pAlign = this.pAlign & $ALV_MASK | flg   
 596    if flg & ( $alhRight | $alhLeftRight )
 597    {
 598       if this.p_designing && this.Owner 
 599       {
 600          this.pRight = this.Owner->vCtrl.clloc.width - this.loc.left - this.loc.width
 601       } 
 602    }   
 603    eventpos evp
 604    evp.code = $e_poschanging
 605    evp.loc = this.loc
 606    evp.move = 1
 607 
 608    .Virtual( $mPosChanging, evp ) 
 609 }
 610 
 611 
 612 /* Свойство str vCtrl.Font - Get Set
 613 Усотанавливает или получает псевдоним( настройки шрифта контрола )
 614 */
 615 property str vCtrl.Font <result>
 616 {
 617    result = this.pFont
 618 }
 619 
 620 property vCtrl.Font( str val )
 621 {   
 622    if val != this.pFont
 623    {  
 624       //App.FntM.Default()
 625       this.pFont = val     
 626       .Virtual( $mFontChanged )
 627    }
 628 }
 629 
 630 property str vCtrl.Style <result>
 631 {
 632    result = this.pStyle
 633 }
 634 
 635 property vCtrl.Style( str val )
 636 {   
 637    if val != this.pStyle
 638    {  
 639       //App.FntM.Default()
 640       this.pStyle = val     
 641       .Virtual( $mFontChanged )
 642    }
 643 }
 644 
 645 /*------------------------------------------------------------------------------
 646    Windows Mesages Methods
 647 */
 648 
 649 method uint vCtrl.wmsize <alias=vCtrl_wmsize>( winmsg wmsg )
 650 {
 651    RECT r       
 652         
 653    this.clloc.width  = wmsg.lpar & 0x7FFF
 654    this.clloc.height = (wmsg.lpar >> 16 ) & 0x7FFF
 655 /*      
 656    this.Owner->vCtrl.WinMsg( $WM_NCCALCSIZE, 0, &r )
 657    this.clloc.left = r.left
 658    this.clloc.top  = r.top
 659 */   
 660    GetWindowRect( this.hwnd, r )
 661    this.loc.width = r.right - r.left
 662    this.loc.height = r.bottom - r.top
 663    
 664    
 665    evparValUint evu   
 666    evu.val = 1   
 667    .Virtual( $mPosChanged, evu )
 668    .flgnoposchanged = 0
 669   
 670    return 0
 671 }
 672 
 673 
 674 method uint vCtrl.wmmoving_sizing <alias=vCtrl_wmmoving_sizing>( winmsg wmsg )
 675 {
 676    uint lpar = wmsg.lpar
 677    eventpos ev_p
 678    ev_p.loc.left = lpar->RECT.left 
 679    ev_p.loc.top = lpar->RECT.top
 680    ev_p.loc.width = lpar->RECT.right - lpar->RECT.left
 681    ev_p.loc.height = lpar->RECT.bottom - lpar->RECT.top
 682    ev_p.code = $e_poschanging
 683    //this.event( ev_p )
 684    this.Virtual( $mPosChanging, ev_p )
 685    lpar->RECT.left = ev_p.loc.left 
 686    lpar->RECT.top = ev_p.loc.top
 687    lpar->RECT.right = ev_p.loc.left + ev_p.loc.width  
 688    lpar->RECT.bottom = ev_p.loc.top +  ev_p.loc.height
 689    wmsg.flags = 1   
 690    return 1
 691 }          
 692 
 693 method uint vCtrl.wmfocus <alias=vCtrl_wmfocus> ( winmsg wmsg )
 694 {   
 695    evparValUint eu
 696    eu.code = $e_focus
 697    eu.val = ( wmsg.msg == $WM_SETFOCUS )
 698    SendMessage (this.hwnd, 0x0128/*$WM_UPDATEUISTATE*/, (0x01/*$UISF_HIDEFOCUS*/<<16)|2/*$UIS_CLEAR*/, 0);
 699    this.Virtual( $mFocus, eu )    
 700    //wmsg.flags = 1               
 701    return 0            
 702 }
 703 
 704 method uint vCtrl.wmkey <alias=vCtrl_wmkey> ( winmsg wmsg )
 705 {
 706    subfunc uint key( uint evktype )
 707    {         
 708       evparKey ek             
 709       ek.evktype = evktype               
 710       ek.code = $e_key          
 711       ek.key = wmsg.wpar                     
 712       if GetKeyState( $VK_MENU ) & 0x8000 : ek.mstate |= $mstAlt
 713       if GetKeyState( $VK_CONTROL ) & 0x8000 : ek.mstate |= $mstCtrl
 714       if GetKeyState( $VK_SHIFT ) & 0x8000 : ek.mstate |= $mstShift
 715       wmsg.flags = this.Virtual( $mKey, ek )                   
 716       return 0
 717    }  
 718    
 719    switch wmsg.msg
 720    {
 721       case $WM_KEYDOWN, $WM_SYSKEYDOWN
 722       {               
 723          return key( $evkDown )                                              
 724       }
 725       case $WM_KEYUP, $WM_SYSKEYUP
 726       {
 727          return key( $evkUp )               
 728       }            
 729       case $WM_CHAR, $WM_SYSCHAR
 730       {
 731          return key( $evkPress )
 732       }
 733       default : return 0
 734    }   
 735 }
 736 
 737 
 738 method uint vCtrl.mClColor <alias=vCtrl_mClColor>( winmsg wmsg )
 739 {
 740    uint hbrush
 741    if .aStyle 
 742    {
 743       SetBkMode( wmsg.wpar, $TRANSPARENT )
 744       if .aStyle->Style.fTextColor 
 745       {        
 746          SetTextColor( wmsg.wpar, .aStyle->Style.pTextColor  )
 747       }
 748       wmsg.flags = 1      
 749       if .aStyle->Style.hBrush
 750       {
 751          hbrush = .aStyle->Style.hBrush//GetStockObject(0)         
 752       }      
 753       //SelectObject( wmsg.wpar, hbrush )      
 754       return hbrush//GetStockObject(18)
 755    }
 756    //if .Name == "xxx" : print( "themed \(isThemed)\n" )
 757    if isThemed //? && .flgXPStyle
 758    {
 759       
 760       uint hfont = GetCurrentObject( wmsg.wpar, $OBJ_FONT )
 761       SetBkMode( wmsg.wpar, $TRANSPARENT )
 762       pDrawThemeParentBackground->stdcall( /*getctrl(wmsg.lpar)*/.hwnd, wmsg.wpar, 0 )
 763       wmsg.flags = 1
 764       SelectObject( wmsg.wpar, hfont )
 765       if !hbrush: hbrush = GetStockObject(5)       
 766    }   
 767    //if wmsg.flags : return hbrush
 768    return hbrush
 769 }
 770 
 771 method uint vCtrl.wmclcolorbtn <alias=vCtrl_wmclcolorbtn>(winmsg wmsg )
 772 {
 773    uint ctrl as getctrl(wmsg.lpar)
 774    if &ctrl :  return ctrl.Virtual( $mClColor, wmsg )
 775    //return 5
 776    return 0
 777 /*   if isThemed && .flgXPStyle
 778    { 
 779       uint hfont = GetCurrentObject( wmsg.wpar, $OBJ_FONT )
 780       SetBkMode( wmsg.wpar, $TRANSPARENT )
 781       pDrawThemeParentBackground->stdcall( getctrl(wmsg.lpar).hwnd, wmsg.wpar, 0 )
 782       wmsg.flags = 1
 783       SelectObject( wmsg.wpar, hfont )
 784       return GetStockObject(5)
 785    }
 786    return 0*/
 787 }
 788 
 789 method uint vCtrl.wmerasebkgnd <alias=vCtrl_wmerasebkgnd>( winmsg wmsg )
 790 {
 791    if isThemed && .flgXPStyle
 792    {
 793       RECT r      
 794       r.right = this.Width//.clloc.width      
 795       r.bottom = this.Height//.clloc.height
 796       pDrawThemeParentBackground->stdcall( this.hwnd, wmsg.wpar, &r )
 797       wmsg.flags = 1
 798       return 1
 799    }
 800    /*print( "erase \( this.Name )\n" )
 801    uint hdc
 802    	PAINTSTRUCT lp   
 803    //   hdc = BeginPaint( this.hwnd, lp )
 804       RECT r
 805       r.left = 0
 806       r.top = 0
 807       r.right = this.loc.width
 808       r.bottom = this.loc.height   
 809       FillRect( wmsg.wpar, r, $COLOR_BTNFACE + 1 ) -*/                      
 810    //	EndPaint( this.hwnd, lp )
 811  //     InvalidateRect( this.hwnd, 0->RECT, 0 )  
 812    return 0   
 813 }
 814 /*------------------------------------------------------------------------------
 815    Virtual Methods
 816 */
 817 
 818 method vCtrl.mReCreateWin <alias=vCtrl_mReCreateWin> ()
 819 {
 820    if this.hwnd
 821    {
 822       uint i
 823       uint oldhwnd = this.hwnd
 824       this.hwnd = 0
 825       /*if .pOwner  
 826       {
 827          SetWindowLong( .hwnd, $GWL_STYLE, GetWindowLong( .hwnd, $GWL_STYLE ) | $WS_CHILD )     	   
 828          SetParent( .hwnd, .pOwner->vCtrl.hwnd )
 829          this.TabOrder = this.TabOrder
 830       }*/      
 831       .Virtual( $mCreateWin )      
 832       if .pOwner  
 833       {
 834          SetWindowLong( .hwnd, $GWL_STYLE, GetWindowLong( .hwnd, $GWL_STYLE ) | $WS_CHILD )     	   
 835          SetParent( .hwnd, .pOwner->vCtrl.hwnd )         
 836          this.TabOrder = this.TabOrder         
 837       }
 838       //print( "recreate3 \(GetStockObject( $DEFAULT_GUI_FONT ) ))\n" )
 839       fornum i = 0, .pCtrls
 840       {
 841          if .Comps[i]->vComp.TypeIs( vCtrl )
 842          {
 843             SetParent( .Comps[i]->vCtrl.hwnd, this.hwnd )
 844          }         
 845       }
 846       //print( "recreate4\n" )  
 847       SetWindowLong( oldhwnd, $GWL_USERDATA, 0 )      
 848       DestroyWindow( oldhwnd )      
 849       
 850    }  
 851 }
 852 
 853 method vCtrl vCtrl.mCreateWin <alias=vCtrl_mCreateWin> ()
 854 {  
 855    this.WinMsg( $WM_SETFONT, GetStockObject( $DEFAULT_GUI_FONT ) )
 856    SetWindowLong( this.hwnd, $GWL_USERDATA, &this )   
 857    uint addr
 858    if .prevwndproc == -1
 859    {
 860       addr = 1
 861       .prevwndproc = 0
 862    }
 863    //else : this.prevwndproc = SetWindowLong( this.hwnd, $GWL_WNDPROC, callback( &myproc, 4 ))
 864    this.prevwndproc = SetWindowLong( this.hwnd, $GWL_WNDPROC, callback( &myproc, 4 ))
 865    if addr : .prevwndproc = 0
 866    
 867    //! Нужно ли это
 868    RECT r
 869    GetClientRect( this.hwnd, r )   
 870    this.clloc.width  = r.right - r.left
 871    this.clloc.height = r.bottom - r.top
 872    
 873    evparValUint evu
 874    evu.val = 1   
 875    .Virtual( $mPosChanged, evu )
 876    //vloc l =.loc
 877    //SetWindowPos( this.hwnd, 0, 0,0,0,0, $SWP_NOACTIVATE | $SWP_NOZORDER )  
 878    //SetWindowPos( this.hwnd, 0, l.left, l.top, l.width, l.height, $SWP_NOACTIVATE | $SWP_NOZORDER )
 879    //SetWindowPos( this.hwnd, 0, .loc.left, .loc.top, .loc.width, .loc.height, $SWP_NOACTIVATE | $SWP_NOZORDER )
 880     
 881    return this
 882 }
 883 
 884 method vCtrl.mDestroyWin <alias=vCtrl_mDestroyWin> ()
 885 {
 886    if this.hwnd 
 887    {
 888       DestroyWindow( this.hwnd )   
 889       this.hwnd = 0
 890    }   
 891 }
 892 
 893 
 894 method vCtrl.mPosChanging <alias=vCtrl_mPosChanging>( evparEvent ev )
 895 {      
 896 if .flgNoPosChanging : return
 897    uint evp as ev->eventpos            
 898    this.ownerresize( evp.loc )       
 899    if evp.move 
 900    {   
 901 ifdef $DESIGNING {
 902    uint owner
 903    owner as vCtrl
 904    if this.p_designing && evp.loc != this.loc
 905    {   
 906       //print( "loc \(evp.loc.left) \(evp.loc.top) \(evp.loc.width) \(evp.loc.height)\n" )
 907       owner as this
 908       do 
 909       {
 910          owner as owner.Owner
 911       }
 912       while owner && owner.p_designing             
 913       if owner : owner as owner.Owner
 914       //if owner : owner as owner.Owner
 915       if owner : owner.Virtual( $mDesChanging, &this )  
 916    }     
 917 }
 918       //.flgPosChanging = 1 
 919       this.onposchanging.run( evp )
 920       //SetWindowPos( this.hwnd, 0, evp.loc.left, evp.loc.top, evp.loc.width, evp.loc.height, $SWP_NOACTIVATE | $SWP_NOZORDER /*| $SWP_NOCOPYBITS*/ )
 921       MoveWindow( this.hwnd, evp.loc.left, evp.loc.top, evp.loc.width, evp.loc.height, 1 )
 922       //SetWindowPos( this.hwnd, 0, evp.loc.left, evp.loc.top, evp.loc.width, evp.loc.height, $SWP_NOACTIVATE | $SWP_NOZORDER /*| $SWP_NOCOPYBITS*/ )       
 923       //.flgPosChanging = 0
 924       /*UpdateWindow( 0 )
 925       if this.Owner
 926       { 
 927       UpdateWindow( this.Owner->vCtrl.hwnd )
 928       }      */
 929       //RedrawWindow( this.hwnd, 0->RECT, 0, 0x507)
 930 /*ifdef $DESIGNING {
 931    if owner : owner.Virtual( $mDesChanged, &this )
 932 } */     
 933    }  
 934 
 935 }
 936 
 937 method vCtrl.mPosChanged <alias=vCtrl_mPosChanged>( evparEvent ev )
 938 {
 939    
 940    uint evu as ev->evparValUint
 941    uint i   
 942    if evu.val
 943    {      
 944       //foreach chctrl, this.ctrls
 945       fornum i = 0, .pCtrls               
 946       {  
 947          uint chctrl as this.Comps[ i ]->vCtrl//vCtrl         
 948          eventpos ep                  
 949          ep.loc = chctrl.loc
 950          ep.move = 1
 951          chctrl.Virtual( $mPosChanging, ep )                  
 952       }   
 953    }
 954    if &this.Owner()
 955    {      
 956       this.Owner->vCtrl.Virtual( $mChildPosChanged, 0 )
 957    }
 958    this.onPosChanged.run( ev )
 959    if .flgRePaint: InvalidateRect( .hwnd, 0->RECT, 1 )
 960    
 961    ifdef $DESIGNING {
 962    uint owner
 963    owner as vCtrl
 964    if this.p_designing 
 965    {   
 966       //print( "loc \(evp.loc.left) \(evp.loc.top) \(evp.loc.width) \(evp.loc.height)\n" )
 967       owner as this
 968       do 
 969       {
 970          owner as owner.Owner
 971       }
 972       while owner && owner.p_designing             
 973       if owner : owner as owner.Owner
 974       //if owner : owner as owner.Owner
 975       if owner : owner.Virtual( $mDesChanged, &this )  
 976    }     
 977 }
 978 }
 979 
 980 
 981 method vCtrl.mPreDel <alias=vCtrl_mPreDel>()
 982 {
 983 //print( "ctrl.mPreDel\n" )
 984    this->vComp.mPreDel()    
 985    if this.hwnd
 986    {   
 987       DestroyWindow( this.hwnd )            
 988       this.hwnd = 0
 989    }
 990    /*if this.pOwner
 991    {  
 992 
 993       this.pOwner->vCtrl.Virtual( $mRemove, this )
 994 
 995    } */
 996       
 997 }
 998 
 999 
1000 method vCtrl.mRemove <alias=vCtrl_mRemove>( vComp remcomp )
1001 {
1002 //print( "Ctrl remove1\n" )
1003    if remcomp.TypeIs( vVirtCtrl )
1004    {
1005       uint ctrl as remcomp->vVirtCtrl       
1006       uint ar as this.Comps//ctrls
1007       uint i
1008       //this.childtaborder( ctrl, 0, $TAB_REMOVE )      
1009       if ar[ctrl.cidx] == &ctrl
1010       {
1011       
1012          ar.del(ctrl.cidx,1)//ctrl.cidx)
1013                
1014          fornum i = ctrl.cidx, *ar 
1015          {
1016             ar[i]->vCtrl.cidx--
1017          }
1018         
1019          this.pCtrls--
1020       }
1021       
1022    }
1023    else
1024    {
1025 //print( "Ctrl remove2\n" )   
1026       this->vComp.mRemove( remcomp )
1027 //print( "Ctrl remove3\n" )            
1028    }
1029 }
1030 
1031 method vCtrl.mSetEnabled <alias=vCtrl_mSetEnabled>( )// uint val )
1032 {
1033    //.pEnabled = val
1034    EnableWindow( .hwnd, .pEnabled )
1035 }
1036  
1037 method vCtrl.mSetVisible <alias=vCtrl_mSetVisible>( )
1038 {  
1039    ShowWindow( this.hwnd, ?( .pVisible || this.p_designing, 
1040       $SW_SHOWNOACTIVATE, $SW_HIDE ))   
1041 }
1042 
1043 method vCtrl.mSetCaption <alias=vCtrl_mSetCaption>( ustr caption )
1044 {  
1045    SetWindowText( this.hwnd, caption.ptr() )   
1046 }
1047 
1048 
1049 
1050 method vCtrl.mFontChanged <alias=vCtrl_mFontChanged>( )
1051 {
1052    /*uint hFont as App.FntM.GetFont( .pFont )
1053    if &hFont
1054    {  
1055       .hFont = hFont->Font.hFont
1056    }
1057    else
1058    {
1059       .hFont = GetStockObject( $DEFAULT_GUI_FONT )  
1060    }
1061    this.WinMsg( $WM_SETFONT, .hFont )
1062    */
1063    .aStyle = &App.StyleM.GetStyle( .pStyle )   
1064    if .aStyle && .aStyle->Style.hFont
1065    {   
1066       this.WinMsg( $WM_SETFONT, .aStyle->Style.hFont )
1067    }
1068    InvalidateRect( this.hwnd, 0->RECT, 1 )
1069 } 
1070 
1071 /*------------------------------------------------------------------------------
1072    Registration
1073 */
1074 
1075 
1076 method vCtrl vCtrl.init()
1077 {
1078    this.pTypeId = vCtrl   
1079    
1080    //this.pVisible = 1
1081    //this.pEnabled = 1 
1082    this.loc.width = 20  
1083    this.loc.height = 20
1084    this.pAlign = $alvTop | $alhLeft
1085    return this
1086 }
1087 
1088 /*method vCtrl.getevents( uint typeid, compMan cm )
1089 {   
1090 
1091 }
1092 */
1093 /*method vCtrl.v_focus <alias=vCtrl_focus>( eventuint ev )
1094 {
1095    if ev.val : this.form->vform.curtab = &this
1096       this.onfocus.run( ev )
1097 }
1098 */
1099 
1100 
1101 func uint myproc( uint hwnd, uint msg, uint wpar, uint lpar )
1102 {
1103    uint ctrl = GetWindowLong( hwnd, $GWL_USERDATA )   
1104    if ctrl
1105    {     
1106       uint res
1107       //print( "ss \(msg) \(ctrl) \(ctrl->vCtrl.TypeName)\n")
1108       if ctrl->vCtrl.pTypeDef 
1109       {    
1110          //uint msgtbl = min( msg, $WM_USER )
1111          //print( "ss \(msg) \(ctrl->vCtrl.TypeName)\n")
1112          winmsg mymsg
1113          uint addr //= (&ctrl->vCtrl.curproctbl->proctbl.tbl[ msg << 2 ])->uint
1114          //print("z4 \(msg) \(ctrl) \(ctrl->vCtrl.pTypeDef)")
1115          //if msgtbl == $WM_USER : print( "wmuser1\n")
1116          if msg < $WM_USER
1117          {
1118             addr = (ctrl->vCtrl.pTypeDef->tTypeDef.ProcTbl.data + ( msg << 2 ))->uint
1119          }
1120          else
1121          {         
1122             uint i
1123             for i = 0, i < *ctrl->vCtrl.pTypeDef->tTypeDef.ProcUserTbl, i += 2
1124             {            
1125                if ctrl->vCtrl.pTypeDef->tTypeDef.ProcUserTbl[i] == msg
1126                {
1127                   addr = ctrl->vCtrl.pTypeDef->tTypeDef.ProcUserTbl[ i + 1 ]                  
1128                   break
1129                }  
1130             }
1131          }                  
1132          mymsg.flags = 0      
1133          if addr 
1134          {           
1135             mymsg.msg = msg
1136             mymsg.hwnd = hwnd
1137             mymsg.wpar = wpar
1138             mymsg.lpar = lpar            
1139             res = addr->func( ctrl, &mymsg )            
1140             if mymsg.flags 
1141             {               
1142             //print( "res = [\(res)]\n" )         
1143                return res
1144             }
1145          }               
1146       }      
1147  
1148       if ctrl->vCtrl.prevwndproc  
1149       {         
1150          return CallWindowProc( ctrl->vCtrl.prevwndproc, hwnd, msg, wpar, lpar )         
1151       }
1152       
1153 /*      if msg == $WM_DESTROY {
1154          print( "WM_DESTROY\n" )
1155          PostQuitMessage( 0 )
1156          return 1
1157       }*/
1158       
1159       //print( "myproc2\n" ) 
1160       
1161    }
1162    return DefWindowProc( hwnd, msg, wpar, lpar );   
1163 }
Edit