Resize Column DataWindow Tabular Layouts In PowerBuilder
This NVO (Get from PBDelta) is used make the column headings of datawindow controls act like a listview control, with the ability to drag and resize column headers. Similar to a grid datawindow but this works for tabular layouts.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
Forward Global Type nvo_dw_listview From nonvisualobject End Type Type point From structure within nvo_dw_listview End Type End Forward Type point From structure Long l_x Long l_y End Type Global Type nvo_dw_listview From nonvisualobject End Type Global nvo_dw_listview nvo_dw_listview Type Prototypes Private: // Mouse Capture Function Long SetCap( Long lhwnd ) Library 'user32' Alias For SetCapture Function Long RelCap() Library 'user32' Alias For ReleaseCapture // Get text size Function ULong GetDC(ULong hWnd) Library 'user32' Function Long ReleaseDC(ULong hWnd, ULong hdcr) Library 'user32' Function Boolean GetTextExtentPoint32A(ULong hdcr, String lpString, Long nCount, Ref point size) Library 'gdi32' Alias For "GetTextExtentPoint32A;Ansi" Function ULong SelectObject(ULong hdc, ULong hWnd) Library 'gdi32' End Prototypes Type Variables Protected: Long il_Gaps[] Long il_NGaps, il_CurGap Long il_HeaderHeight Long il_I String is_ObjectNames[] String is_ColumnNames[] Boolean ib_Hot Boolean ib_Resize Constant Long cil_MinWidth = 10 // added this so remove the requirement for my class library Window iw_ParentWindow datawindow idw_Parent End Variables Forward Prototypes Public Function Integer perform (String as_event, Ref Any aa_args[]) Protected Subroutine findgap (Integer xpos) Protected Subroutine mouseresize (Integer xpos) Protected Subroutine releasecapture () Protected Subroutine setcapture () Protected Function Window ParentWindow () Protected Function Integer extractcolumns (String as_widths, Ref Integer ai_widths[]) Public Function String savecolumns () Public Function Integer loadcolumns (String as_widths) Public Function Integer il_curgap () Public Subroutine duplicatecolumn (Integer ai_fromgap, Integer ai_togap) Protected Subroutine resizecolumns (Integer xpos, Integer ai_col) Public Subroutine doubleclick (String as_name) Public Subroutine idw_parent (datawindow adw_dw) Public Subroutine setparentwindow (Window aw_w) Public Function datawindow idw_parent () End Prototypes Public Function Integer perform (String as_event, Ref Any aa_args[]); //==================================================================== // Function: nvo_dw_listview.perform() //-------------------------------------------------------------------- // Description: This function recieves the notification of the events // from the datawindow. The code is kept to a minimum // because we will be recieveing mousemove notifications of // which there will be loads so we need to execute this // function as quickly as possible. //-------------------------------------------------------------------- // Arguments: // string as_event : Event that occured // ref any aa_args[]: Arguments to the event //-------------------------------------------------------------------- // Returns: integer -1, error occured, 0, no processing, 1, event was processed //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/27 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== DWObject ldwo_DWO Choose Case as_event Case 'mousemove' If ib_Resize Then This.MouseResize( aa_args[ 1 ] ) Else il_CurGap = 0 If aa_args[ 2 ] > il_HeaderHeight Then Return 0 FindGap( aa_args[ 1 ] ) End If Case 'clicked', 'lbuttondown' This.SetCapture() If il_CurGap > 0 Then ib_Resize = True Post Function SetPointer( SizeWE! ) End If Case 'doubleclicked' ldwo_DWO = aa_args[ 4 ] If ldwo_DWO.Type = 'text' Then If ldwo_DWO.band = 'header' Then This.DoubleClick( ldwo_DWO.Name ) End If End If Case 'lbuttonup' ib_Resize = False This.ReleaseCapture() Case Else Return 0 End Choose Return 1 End Function Protected Subroutine findgap (Integer xpos); //==================================================================== // Function: nvo_dw_listview.findgap() //-------------------------------------------------------------------- // Description: Figure out if the mouse is positioned over a gap in the column headers. If it is then switch the mouse pointer. //-------------------------------------------------------------------- // Arguments: // integer xpos: X Position of the mouse. //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/27 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Long ll_X ll_X = Long( idw_Parent().Describe( 'datawindow.horizontalscrollposition' ) ) If ll_X > 0 Then & xpos += UnitsToPixels( ll_X, XUnitsToPixels! ) For il_I = 1 To il_NGaps If xpos < il_Gaps[ il_I ] Then Exit If xpos = il_Gaps[ il_I ] Or xpos = il_Gaps[ il_I ] + 1 Then SetPointer( SizeWE! ) il_CurGap = il_I Return End If Next End Subroutine Protected Subroutine mouseresize (Integer xpos); //==================================================================== // Function: nvo_dw_listview.mouseresize() //-------------------------------------------------------------------- // Description: Call the resize columns function. //-------------------------------------------------------------------- // Arguments: // integer xpos: X Position of the mouse drag that resized the columns. //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/27 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== SetPointer( SizeWE! ) Long ll_X ll_X = Long( idw_Parent().Describe( 'datawindow.horizontalscrollposition' ) ) If ll_X > 0 Then xpos += UnitsToPixels( ll_X, XUnitsToPixels! ) This.ResizeColumns( xpos, il_CurGap ) End Subroutine Protected Subroutine releasecapture (); RelCap() End Subroutine Protected Subroutine setcapture (); SetCap( Handle( This.idw_Parent() ) ) End Subroutine Protected Function Window ParentWindow (); Return iw_ParentWindow End Function Protected Function Integer extractcolumns (String as_widths, Ref Integer ai_widths[]); //==================================================================== // Function: nvo_dw_listview.extractcolumns() //-------------------------------------------------------------------- // Description: Extract the internal column width settings from the string created by the SaveColumns function and // view and return them in an encoded string. //-------------------------------------------------------------------- // Arguments: // string as_widths: encoded string to remove the settings from. // ref integer ai_widths[]: Reference variable to load the widths into. //-------------------------------------------------------------------- // Returns: integer: The number of column widths extracted from the string. //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/27 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Long ll_Pos, ll_I If LenA( as_widths ) = 0 Then Return 0 ll_Pos = PosA( as_widths, '~t' ) Do While ll_Pos > 0 ll_I ++ ai_widths[ ll_I ] = Long( LeftA( as_widths, ll_Pos - 1 ) ) as_widths = MidA( as_widths, ll_Pos + 1 ) ll_Pos = PosA( as_widths, '~t' ) Loop Return ll_I End Function Public Function String savecolumns (); //==================================================================== // Function: nvo_dw_listview.savecolumns() //-------------------------------------------------------------------- // Description: Extract the internal column width settings and return them in an encoded string //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: string: An encoded string containing the columns widths //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/27 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Long ll_Cols, ll_I String ls_Details ll_Cols = il_NGaps For ll_I = 1 To ll_Cols ls_Details += String( il_Gaps[ ll_I ] ) + '~t' Next Return ls_Details End Function Public Function Integer loadcolumns (String as_widths); //==================================================================== // Function: nvo_dw_listview.loadcolumns() //-------------------------------------------------------------------- // Description: Load the columns widths create by the savecolumns function back into the datawindow. //-------------------------------------------------------------------- // Arguments: // string as_widths: The encoded width string containing the column widths. //-------------------------------------------------------------------- // Returns: integer: 1 all loaded ok , -1 load failed //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/27 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Integer li_Widths[], li_Cols, li_i Integer li_X, li_Width String ls_Modify datawindow ldw_DW ldw_DW = idw_Parent() li_Cols = This.ExtractColumns( as_widths, li_Widths ) For li_i = 1 To li_Cols // Alter the width and height based on the extracted values If li_i > 1 Then // Alter the X value based on the new gap // Alter the width based on the difference betweene th gaps li_X = li_Widths[ li_i - 1 ] li_Width = li_Widths[ li_i ] - li_X Else // its the first one so we base it on the current start X li_X = UnitsToPixels( Long( ldw_DW.Describe( is_ObjectNames[ 1 ] + '.x' ) ), XUnitsToPixels! ) -4 li_Width = li_Widths[ 1 ] - li_X End If ls_Modify += is_ObjectNames[ li_i ] + '.x=' + String( PixelsToUnits( li_X + 4, XPixelsToUnits! ) ) + ' ' ls_Modify += is_ObjectNames[ li_i ] + '.width=' + String( PixelsToUnits( li_Width - 4, XPixelsToUnits! ) ) + ' ' ls_Modify += is_ColumnNames[ li_i ] + '.x=' + String( PixelsToUnits( li_X + 4, XPixelsToUnits! ) ) + ' ' ls_Modify += is_ColumnNames[ li_i ] + '.width=' + String( PixelsToUnits( li_Width - 4, XPixelsToUnits! ) ) + ' ' // do this rather than a straight copy, in case there are none il_Gaps[ li_i ] = li_Widths[ li_i ] Next ldw_DW.Modify( ls_Modify ) Return 1 End Function Public Function Integer il_curgap (); Return il_CurGap End Function Public Subroutine duplicatecolumn (Integer ai_fromgap, Integer ai_togap); //==================================================================== // Function: nvo_dw_listview.duplicatecolumn() //-------------------------------------------------------------------- // Description: Resize a column to be the same width as the specified column. //-------------------------------------------------------------------- // Arguments: // integer ai_fromgap: Columns whose width we want to use. // integer ai_togap: Column that want the new width. //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/27 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Long ll_LWidth, ll_LX, ll_RX, ll_I String ls_Modify datawindow ldw_DW ldw_DW = This.idw_parent() ll_LWidth = UnitsToPixels( Long( ldw_DW.Describe( is_ObjectNames[ ai_fromgap ] + '.Width' ) ), XUnitsToPixels! ) ll_LX = UnitsToPixels( Long( ldw_DW.Describe( is_ObjectNames[ ai_togap ] + '.X' ) ), XUnitsToPixels! ) This.ResizeColumns( ll_LX + ll_LWidth, ai_togap ) End Subroutine Protected Subroutine resizecolumns (Integer xpos, Integer ai_col); //==================================================================== // Function: nvo_dw_listview.resizecolumns() //-------------------------------------------------------------------- // Description: Resize the two columns to the new location the left hand // column's width should be X to the new pos if the new pos // < x then = 0 the right hand column X and width should // change to be the difference between current and new. We // always recalc from scratch as we may have missed some // mouse move events due to queue overflow. //-------------------------------------------------------------------- // Arguments: // integer xpos: X Position of the mouse drag that resized the columns. // integer ai_col: Column that was resized. //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/27 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Long ll_LWidth, ll_LX, ll_RX, ll_I String ls_Modify datawindow ldw_DW ldw_DW = This.idw_parent() ll_LX = UnitsToPixels( Long( ldw_DW.Describe( is_ObjectNames[ ai_col ] + '.X' ) ), XUnitsToPixels! ) If xpos < ll_LX Then // Make column small. ll_LWidth = cil_MinWidth ls_Modify = is_ObjectNames[ ai_col ] + '.Width=' + String( cil_MinWidth ) ls_Modify += is_ColumnNames[ ai_col ] + '.Width=' + String( cil_MinWidth ) xpos = ll_LX + UnitsToPixels( cil_MinWidth, XUnitsToPixels! ) Else // Calc new column width ll_LWidth = xpos - ll_LX ls_Modify = is_ObjectNames[ ai_col ] + '.Width=' + String( PixelsToUnits( ll_LWidth , XPixelsToUnits! ) ) ls_Modify += is_ColumnNames[ ai_col ] + '.Width=' + String( PixelsToUnits( ll_LWidth , XPixelsToUnits! ) ) End If // If this is not the last column then modify the next column too! If ai_col < il_NGaps Then For ll_I = ai_col + 1 To il_NGaps ll_RX = UnitsToPixels( Long( ldw_DW.Describe( is_ObjectNames[ ll_I ] + '.X' ) ), XUnitsToPixels! ) // Calc the right hand column X ll_RX = ll_RX + xpos - il_Gaps[ ai_col ] il_Gaps[ ll_I ] += xpos - il_Gaps[ ai_col ] ls_Modify += ' ' + is_ObjectNames[ ll_I ] + '.X=' + String( PixelsToUnits( ll_RX , XPixelsToUnits! ) ) ls_Modify += ' ' + is_ColumnNames[ ll_I ] + '.X=' + String( PixelsToUnits( ll_RX , XPixelsToUnits! ) ) Next End If ldw_DW.Modify( ls_Modify ) // set the new gap to be the current x il_Gaps[ ai_col ] = xpos End Subroutine Public Subroutine doubleclick (String as_name); //==================================================================== // Function: nvo_dw_listview.doubleclick() //-------------------------------------------------------------------- // Description: This fucntion works out the maximum width of the column and resizes the column to fit this size //-------------------------------------------------------------------- // Arguments: // string as_name : The name of the column header double clicked. //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/27 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== String ls_Text, ls_FontFace, ls_Column Integer li_FontSize, li_i, li_Weight, li_Max, li_MaxWidth, li_Col Integer li_Size, li_Len, li_Return, li_WM_GETFONT = 49, li_Gap ULong lul_Hdc, lul_Handle, lul_hFont datawindow ldw_DW point lstr_Size StaticText lst_Text // a text item in the header was double clicked, figure out // which one was double clicked and then create an object // we can use to figure out the column widths. For li_i = 1 To il_NGaps If is_ObjectNames[ li_i ] = as_name Then ls_Column = is_ColumnNames[ li_i ] Exit End If Next If ls_Column = '' Then Return li_Gap = li_i ldw_DW = This.idw_Parent() li_Col = Integer( ldw_DW.Describe( ls_Column + '.id' ) ) // Datawindow syntax specifies font point size is negative li_FontSize = Long( ldw_DW.Describe( ls_Column + '.Font.Height' ) ) li_FontSize = -1 * li_FontSize ls_FontFace = ldw_DW.Describe( ls_Column + '.Font.Face' ) li_Weight = Long( ldw_DW.Describe( ls_Column + '.Font.Weight' ) ) If Lower( ls_FontFace ) = 'courier new' Then // its a fixed width font so we do not need the API processing li_Max = ldw_DW.RowCount() li_MaxWidth = 0 For li_i = 1 To li_Max li_Len = LenA( String( ldw_DW.Object.Data[ li_i, li_Col ] ) ) li_Len *= 7 If li_Len > li_MaxWidth Then li_MaxWidth = li_Len Next li_MaxWidth += UnitsToPixels( Long( ldw_DW.Describe( is_ObjectNames[ li_Gap ] + '.X' ) ), XUnitsToPixels! ) ResizeColumns( li_MaxWidth, li_Gap ) Else li_Return = This.ParentWindow().OpenUserObject( lst_Text ) If li_Return = 1 Then If Lower( ls_FontFace ) = 'tahoma' Then lst_Text.FaceName = 'MS Sans Serif' Else lst_Text.FaceName = ls_FontFace End If lst_Text.TextSize = li_FontSize lst_Text.Weight = li_Weight lul_Handle = Handle( lst_Text ) lul_Hdc = GetDC( lul_Handle ) lul_hFont = Send( lul_Handle, li_WM_GETFONT, 0, 0 ) SelectObject( lul_Hdc, lul_hFont ) // Now the text object is set up, loop through the // data and figure out the largest size. li_Max = ldw_DW.RowCount() li_MaxWidth = 0 For li_i = 1 To li_Max ls_Text = String( ldw_DW.Object.Data[ li_i, li_Col ] ) + 'W' li_Len = LenA(ls_Text) GetTextExtentpoint32A(lul_Hdc, ls_Text, li_Len, lstr_Size ) If lstr_Size.l_x > li_MaxWidth Then li_MaxWidth = lstr_Size.l_x Next ReleaseDC(lul_Handle, lul_Hdc) This.ParentWindow().CloseUserObject( lst_Text ) // Now we have the max width, alter the column and header // widths occordingly. li_MaxWidth += UnitsToPixels( Long( ldw_DW.Describe( & is_ObjectNames[ li_Gap ] + '.X' ) ), XUnitsToPixels! ) ResizeColumns( li_MaxWidth, li_Gap ) End If End If End Subroutine Public Subroutine idw_parent (datawindow adw_dw); //==================================================================== // Function: nvo_dw_listview.idw_parent() //-------------------------------------------------------------------- // Description: This function overrides the ancestor function so that we // can interagate the datawindow and cache some values for // later use. This function is called automatically by the // datawindow manager. // // Function gets all the header text items, ending in _t // and check that they have matching columns. Load them // into an array then sort them in to ascending sequence. // Then calculate where the gaps are. NOTE THIS ROUTINE // ASSUMES THE DATAWINDOW UNITS ARE PIXELS! //-------------------------------------------------------------------- // Arguments: // datawindow adw_dw: Datawindow being processed by the manager. //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/27 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== idw_Parent = adw_dw Long ll_I, ll_Max, ll_Pos, ll_O, ll_J, ll_OM1 Long ll_X[], ll_Width[], ll_SX String ls_DWObjects, ls_ObjectNames[], ls_ObjectName, ls_Chk Boolean lb_Swap ls_DWObjects = adw_dw.Describe( 'datawindow.objects' ) + '~t' ll_Pos = PosA( ls_DWObjects, '~t' ) Do While ll_Pos > 0 ls_ObjectName = LeftA( ls_DWObjects, ll_Pos - 1 ) ls_DWObjects = MidA( ls_DWObjects, ll_Pos + 1 ) ll_Pos = PosA( ls_DWObjects, '~t' ) // Check to see if the object name ends in _t, it // is in the header and there is a matching column If RightA( ls_ObjectName, 2 ) <> '_t' Then Continue ls_Chk = adw_dw.Describe( ls_ObjectName + '.band' ) If ls_Chk <> 'header' Then Continue ls_Chk = adw_dw.Describe( LeftA( ls_ObjectName, LenA( ls_ObjectName ) - 2 ) + '.ColType' ) If ls_Chk = '!' Then Continue // Header is good so add it to the list ll_O++ ls_ObjectNames[ ll_O ] = ls_ObjectName ll_X[ ll_O ] = Long( adw_dw.Describe( ls_ObjectName + '.X' ) ) Loop // If we did not find any useable headers then quit! If ll_O = 0 Then Return // Sort the headers in order of X position. ll_OM1 = ll_O - 1 For ll_I = 1 To ll_O lb_Swap = False For ll_J = 1 To ll_OM1 If ll_X[ ll_J ] > ll_X[ ll_J + 1 ] Then lb_Swap = True ll_SX = ll_X[ ll_J ] ls_ObjectName = ls_ObjectNames[ ll_J ] ll_X[ ll_J ] = ll_X[ ll_J + 1 ] ls_ObjectNames[ ll_J ] = ls_ObjectNames[ ll_J + 1 ] ls_ObjectNames[ ll_J + 1 ] = ls_ObjectName ll_X[ ll_J + 1 ] = ll_SX End If Next If Not lb_Swap Then Exit Next // Therefore the gap for the resizing of the columns must be at the // X + width of all the number of text items. il_NGaps = ll_O For ll_I = 1 To il_NGaps ll_SX = Long( adw_dw.Describe( ls_ObjectNames[ ll_I ] + '.Width' ) ) // All coord calulations should be done in pixels... il_Gaps[ ll_I ] = UnitsToPixels( ll_X[ ll_I ], XUnitsToPixels! ) + UnitsToPixels( ll_SX, XUnitsToPixels! ) Next // Record the object/column names and the Height of the header is_ObjectNames = ls_ObjectNames For ll_I = 1 To ll_O is_ColumnNames[ ll_I ] = LeftA( ls_ObjectNames[ ll_I ], LenA( ls_ObjectNames[ ll_I ] ) - 2 ) Next il_HeaderHeight = UnitsToPixels( Long( adw_dw.Describe( 'datawindow.header.height' ) ), XUnitsToPixels! ) End Subroutine Public Subroutine setparentwindow (Window aw_w); iw_ParentWindow = aw_w End Subroutine Public Function datawindow idw_parent (); Return idw_Parent End Function On nvo_dw_listview.Create Call Super::Create TriggerEvent( This, "constructor" ) End On On nvo_dw_listview.Destroy TriggerEvent( This, "destructor" ) Call Super::Destroy End On Event Constructor; Call Super::Constructor; /******************************************************************** nc_sdw_listview: Make your DW control act like a list view. <OBJECT> This service allows the user to interact with the datawindow column headers of a tabular style datawindow as if the header was a listview control. Users can resize the column headers and double click the header to have it resize automatically to the maximum column width. The service also features a serialization type interface for recording the column widths and later restoring the column widths. This service monitors the event queue for the following event types: <LI>mousemove <LI>clicked or lbuttondown <LI>doubleclicked <LI>lbuttonup (must be mapped as pbm_lbuttonup) You may want to inherit this service and override the following functions to call the correct functions in your class library: <LI>GetSetting <LI>SetSetting <LI>TextWidth <LI>SetCapture <LI>GetCapture <LI>ParentWindow </OBJECT> <USAGE> Add the service to the datawindow manager.</USAGE> <ALSO> nc_service_datawindow</ALSO> Date Ref Author Comments 11/18/98 Ken Howe First Version 20/09/99 Ken Howe Add Column Serialization functions ********************************************************************/ End Event |
Object Window
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
Forward Global Type w_main From window End Type Type dw_1 From datawindow within w_main End Type End Forward Global Type w_main From window Integer Width = 2377 Integer Height = 1132 Boolean TitleBar = True String Title = "Resize Column" Boolean ControlMenu = True Boolean MinBox = True Boolean MaxBox = True Boolean Resizable = True Long BackColor = 67108864 String Icon = "AppIcon!" Boolean center = True dw_1 dw_1 End Type Global w_main w_main Type Variables nvo_dw_listview invo_dw_lv End Variables On w_main.Create This.dw_1 = Create dw_1 This.Control[] = {This.dw_1} End On On w_main.Destroy Destroy(This.dw_1) End On Event Open; invo_dw_lv = Create nvo_dw_listview invo_dw_lv.SetParentWindow( This ) invo_dw_lv.idw_Parent( dw_1 ) End Event Type dw_1 From datawindow within w_main Event MouseMove pbm_dwnmousemove Event lbuttonup pbm_dwnlbuttonup Integer Width = 2318 Integer Height = 964 Integer TabOrder = 10 String Title = "none" String DataObject = "d_example" Boolean HScrollBar = True Boolean VScrollBar = True Boolean LiveScroll = True BorderStyle BorderStyle = stylelowered! End Type Event MouseMove; Any la_Args[] la_Args[ 1 ] = xpos la_Args[ 2 ] = ypos la_Args[ 3 ] = row la_Args[ 4 ] = dwo invo_dw_lv.Perform( 'mousemove', la_Args ) End Event Event lbuttonup; Any la_Args[] la_Args[ 1 ] = xpos la_Args[ 2 ] = ypos la_Args[ 3 ] = row la_Args[ 4 ] = dwo invo_dw_lv.Perform( 'lbuttonup', la_Args ) End Event Event Clicked; Any la_Args[] la_Args[ 1 ] = xpos la_Args[ 2 ] = ypos la_Args[ 3 ] = row la_Args[ 4 ] = dwo invo_dw_lv.Perform( 'clicked', la_Args ) End Event Event DoubleClicked; Any la_Args[] la_Args[ 1 ] = xpos la_Args[ 2 ] = ypos la_Args[ 3 ] = row la_Args[ 4 ] = dwo invo_dw_lv.Perform( 'doubleclicked', la_Args ) End Event |
Find Projects On Github click here
Attachments Objects :
Good Luck!
Subscribe
Login
0 Comments
Oldest