User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive
 

Here is an easy to implement service geared towards developers who are working on complex, many layered applications. In its basic form it shows the current window object, which pbl it is located in, all the various ancestors of the window, their pbl locations, all datawindows and datawindow objects on the window, and the sql statements for those datawindow objects.

The only dependency in the window is the pfc resize service. This can easily be stripped out if needed.

To implement the service, add the following to the window/ancestor window event (rbuttondown for example):

openwithparm(w_window_info,THIS)


The screenshot is an example output.

Window Information Service Window

 

Here are the export files for the window and datawindow.

-------------- window export

$PBExportHeader$w_window_info.srw
forward
global type w_window_info from window
end type
type cb_1 from commandbutton within w_window_info
end type
type dw_1 from datawindow within w_window_info
end type
end forward

global type w_window_info from window
integer width = 1198
integer height = 1288
boolean titlebar = true
string title = "Window Info"
boolean controlmenu = true
boolean minbox = true
boolean resizable = true
windowtype windowtype = popup!
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cb_1 cb_1
dw_1 dw_1
end type
global w_window_info w_window_info

type variables
window iw
n_cst_resize inv_resize //remove if not needed
end variables

on w_window_info.create
this.cb_1=create cb_1
this.dw_1=create dw_1
this.Control[]={this.cb_1,&
this.dw_1}
end on

on w_window_info.destroy
destroy(this.cb_1)
destroy(this.dw_1)
end on

event close;close(this)
end event

event open;iw = message.powerobjectparm

boolean lb_found
long ll_i, ll_j, ll_k
classdefinition lcd
datawindow ldw
string ls_msg, ls_liblist, ls_dwlist, ls_lib, ls_libarray[]
string ls_dwval
long ll_curpos, ll_newpos, ll_row
inv_resize =  CREATE n_cst_resize //remove if not needed
ll_curpos = 1
ll_i = 1

//Set the original size
inv_resize.of_SetOrigSize(1161, 1184) //remove if not needed

inv_resize.of_register(dw_1, 'SCALETORIGHT&BOTTOM')
inv_resize.of_register(cb_1, 'FIXEDTOBOTTOM')

// build array of libraries so we can search through them
// for the specified datawindow object
ls_liblist = getlibrarylist()
// add final comma to define last entry in list
ls_liblist += ','
// build librarylist array
ll_newpos = pos(ls_liblist,',',ll_curpos)
DO UNTIL ll_newpos = 0
    ls_lib = Mid(ls_liblist,ll_curpos, ll_newpos - ll_curpos)
    ll_curpos = ll_newpos + 1
    ls_libarray[ll_i] = ls_lib
    ll_i++
    ll_newpos = pos(ls_liblist,',',ll_curpos)
LOOP
// reset position vars
ll_curpos = 1
ll_newpos = 0
// window
lcd = iw.classdefinition
do while IsNull(lcd) = FALSE
    IF ll_j = 1 THEN
        ls_msg = 'Ancestors'
        ll_row = dw_1.insertrow(0)
        dw_1.setitem(ll_row,'info',ls_msg)

    END IF
    ll_j ++
    ls_msg = lcd.libraryname + '  ' + lcd.name 
    ll_row = dw_1.insertrow(0)
    dw_1.setitem(ll_row,'info',ls_msg)

    lcd = lcd.ancestor
    IF IsNull(lcd) THEN CONTINUE
    IF lcd.issystemtype THEN EXIT
loop
ll_j = 0
// controls on window
FOR ll_k = 1 TO upperbound(iw.control)
    lcd = iw.control[ll_k].classdefinition

   DO WHILE IsNull(lcd) = FALSE
        // datawindow controls
        // is_control limits the search to a single dw control, this could be
        // changed to show the information for all dw controls
        IF iw.control[ll_k].typeof() = Datawindow! THEN
            IF ll_j = 0 THEN
                ls_msg = 'Datawindow object'
                ll_row = dw_1.insertrow(0)
                dw_1.setitem(ll_row,'info',ls_msg)
                ll_j ++
            END IF
             ls_msg += lcd.libraryname + '  ' + lcd.name + '~r'
            // if looking at all controls, need to do a typeof to verify it is a datawindow
            // prior to the following assignment
            ldw =  iw.control[ll_k]
            ls_msg =  ldw.dataobject
            ll_row = dw_1.insertrow(0)
            dw_1.setitem(ll_row,'info',ls_msg)

            FOR ll_i = 1 TO upperbound(ls_libarray) // loop through libraries to find datawindow object
                ll_curpos = 1
                ls_dwlist = LibraryDirectoryEx(ls_libarray[ll_i],DirDataWindow!)
                // Look through list of dw objects to find one associated with the dw control
                ll_newpos = pos(ls_dwlist,'~n',ll_curpos)
                DO UNTIL ll_newpos = 0
                    ls_lib = Mid(ls_dwlist,ll_curpos, ll_newpos - ll_curpos)
                    ls_dwval = ls_lib
                    ls_dwval = Left(ls_dwval, POS(ls_dwval, '~t') - 1)
                    IF ls_dwval = ldw.dataobject THEN
                        ls_msg = 'Library: ' + ls_libarray[ll_i]
                        ll_row = dw_1.insertrow(0)
                        dw_1.setitem(ll_row,'info',ls_msg)

                        // sql statement
                        IF ldw.object.datawindow.table.SQLselect <> '' THEN
                            ls_msg = 'Last SQL:~r ' + ldw.object.datawindow.table.SQLselect     
                        ELSE
                            ls_msg = 'DWO SQL:~r ' + ldw.object.datawindow.table.select
                        END IF
                        ll_row = dw_1.insertrow(0)
                        dw_1.setitem(ll_row,'info',ls_msg)
                        lb_found = TRUE
                        EXIT
                    END IF
                    ll_curpos = ll_newpos + 1
                    ll_newpos = pos(ls_dwlist,'~n',ll_curpos)
                LOOP
                // found what we are looking for so no more need to search libraries
                IF lb_found then 
                    lb_found = FALSE
                    EXIT
                END IF
            NEXT
        END IF
        lcd = lcd.ancestor
        IF IsNull(lcd) THEN CONTINUE
        IF lcd.issystemtype THEN EXIT
    LOOP // valid classdefinition
NEXT // controls on window
end event

event resize;if IsValid(inv_resize) then  //remove if not needed
    inv_resize.Event pfc_Resize (sizetype, This.WorkSpaceWidth(), This.WorkSpaceHeight())
end if

end event

type cb_1 from commandbutton within w_window_info
integer x = 786
integer y = 1044
integer width = 325
integer height = 92
integer taborder = 20
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "Close"
end type

event clicked;parent.event post close()
end event

type dw_1 from datawindow within w_window_info
integer x = 27
integer y = 24
integer width = 1102
integer height = 956
integer taborder = 10
string title = "none"
string dataobject = "d_window_info"
boolean hscrollbar = true
boolean vscrollbar = true
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

-------------- datawindow export

$PBExportHeader$d_window_info.srd
release 11.5;
datawindow(units=0 timer_interval=0 color=1073741824 brushmode=0 transparency=0 gradient.angle=0 gradient.color=8421504 gradient.focus=0 gradient.repetition.count=0 gradient.repetition.length=100 gradient.repetition.mode=0 gradient.scale=100 gradient.spread=100 gradient.transparency=0 picture.blur=0 picture.clip.bottom=0 picture.clip.left=0 picture.clip.right=0 picture.clip.top=0 picture.mode=0 picture.scale.x=100 picture.scale.y=100 picture.transparency=0 processing=1 HTMLDW=no print.printername="" print.documentname="" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes print.background=no print.preview.background=no print.preview.outline=yes hidegrayline=no showbackcoloronxp=no picture.file="" grid.lines=0 )
header(height=68 color="0" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )
summary(height=0 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )
footer(height=0 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )
detail(height=72 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" height.autosize=yes )
table(column=(type=char(8000) updatewhereclause=yes name=info dbname="info" )
 )
column(band=detail id=1 alignment="0" tabsequence=10 border="0" color="33554432" x="14" y="8" height="60" width="2807" format="[general]" html.valueishtml="0"  name=info visible="1"  resizeable=1 height.autosize=yes edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes  font.face="MS Sans Serif" font.height="-8" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )
text(band=header alignment="0" text="Window Information" border="0" color="16777215" x="5" y="12" height="52" width="2816" html.valueishtml="0"  name=t_1 visible="1"  font.face="MS Sans Serif" font.height="-8" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="553648127" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )
htmltable(border="1" )
htmlgen(clientevents="1" clientvalidation="1" clientcomputedfields="1" clientformatting="0" clientscriptable="0" generatejavascript="1" encodeselflinkargs="1" netscapelayers="0" pagingmethod=0 generatedddwframes="1" )
xhtmlgen() cssgen(sessionspecific="0" )
xmlgen(inline="0" )
xsltgen()
jsgen()
export.xml(headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0 )
import.xml()
export.pdf(method=0 distill.custompostscript="0" xslfop.print="0" )
export.xhtml()
 

Comments (0)

There are no comments posted here yet