Many times while working on complex environment like opening sessions on multiple companies, taking multiple login on same systems, etc results in confusion of the present window refers to login or company.
And for this we always wanted some indication on each baan session to let us know the server, company and the user.
How we can achieve it?
One answer to it is by marking each session by a small color window displaying the server, company and the user.
And here is the way to get it.
*) First on all it is needed to identify the processes which are alive or running. It can be done using the pstat(...) funtion. And to dynamically update the running processes it has to be looped at regular interval.
e.g.
while true
temp.proc.id = pstat( proc.id, progname, info )
proc.id = temp.proc.id
endwhile
It will give us all the running processes one by one.
**) Secondly, to draw the indicator(Color object) for the processes the main window id related to that process is needed. It can be fetched by using function ps.mwin(info) for the specific process used in pstat(process, program name, information).
Once the main window id is fetched, we need to inherit its properties to be able to draw additional object on it. To inherit use function inherit.object(process, window id). After this draw a small graphical object using create.object(....) and the text object of it using create.sub.object(...).
Repeat it for all the processes and the required will be done.
e.g.
mwin = ps.mwin(info)
inherit.object(proc.id, mwin)
get.object (mwin, DsNwidth, width, 1024)
text.string = toupper$(hostname$())&"("&edit$(get.compnr(), "999")&")-"&logname$
obj.id(procid) = create.object(DsCgwindow,mwin,
DsNx, width-text.leng*8, DsNy, 0,
DsNheight, 10, DsNwidth, text.leng*8,
DsNbackground, color.id, DsNborderColor,color.id ) subobj.id(procid) = create.sub.object(obj.id(procid), DsCgpText ,
DsNx, 0, DsNy, 9,
DsNwidth, text.leng*8,
DsNstring, text.string,
DsNgcForeground, RGB.WHITE)
update.object(obj.id(procid))
***) When we do this it happens that the main and child windows are not destroyed when we exit the session so for that we need to kill / destroy the main window. It is done using destroy.object(...).
e.g.
if mwin <> 0 then
destroy.object(mwin)
endif
if cwin <> 0 then
destroy.object(cwin)
endif
:) Just do these and enjoy!!!!!!!
No comments:
Post a Comment