| Powerbuilder - Bring Window to the Foreground |
//external function declarations
> FUNCTION uint GetDesktopWindow() LIBRARY "user32"
> FUNCTION uint GetWindow(uint hwnd, int wflags) LIBRARY
> "user32"
> FUNCTION int GetWindowTextA(uint hwnd, ref string wintext,
> int textlength) LIBRARY "user32"
>
> // PB code, this is cut and paste from a function that
> accepts ls_search as an inputparameter
>
> string ls_windowtitle
> boolean lb_found, lb_done
> integer li_child, li_frame
> ulong iu_apphandle
>
> /* Get the desktop window */
> iu_apphandle = GetDesktopWindow()
> IF iu_apphandle <= 0 THEN
> messagebox("Error","Failed getting handle to desktop")
> return(0)
> End If
>
> /* Locate the first child of the Desktop */
> li_child = GetWindow(iu_apphandle, 5)
> IF li_child <= 0 THEN lb_done = TRUE
>
> /* Loop through each main window */
> DO UNTIL lb_found OR lb_done
> ls_windowtitle = Space(80)
> GetWindowTextA(li_child, ls_windowtitle, 80)
> //messagebox("TEXT",ls_windowtitle + " " +
> string(li_child))
> IF Pos(Upper(ls_windowtitle), Upper(ls_search)) > 0 AND
> li_child <> li_frame THEN
> lb_found = TRUE
> //li_child : handle to window
> End If
> /*Locate the next child of the Desktop (2) */
> li_child = GetWindow(li_child, 2)
> IF li_child <= 0 THEN
> lb_done = TRUE
> End If
> LOOP
I ran into some curious results when attempt to generate a whole, random number within a range.
Common_func NumTable is just PL/SQL table of number indexed by binary integer.
Source :
clear;
set serveroutput on;
declare
i integer;
nt common_func.NUM_TABLE := common_func.EMPTY_NUM_TABLE;
begin
common_func.display_output(' ');
for j IN 1..11 loop
nt(j) := 0;
end loop;
FOR j IN 1..10000 LOOP
i := DBMS_RANDOM.VALUE(1,10);
nt(i) := nt(i) + 1;
END LOOP;
FOR j IN 1..nt.count LOOP
common_func.display_output(lpad(to_char(j),2,' ')||' : '||nt(j));
END LOOP;
common_func.display_output(' ');
for j IN 1..11 loop
nt(j) := 0;
end loop;
FOR j IN 1..10000 LOOP
i := trunc(DBMS_RANDOM.VALUE(1,10+1));
nt(i) := nt(i) + 1;
END LOOP;
FOR j IN 1..nt.count LOOP
common_func.display_output(lpad(to_char(j),2,' ')||' : '||nt(j));
END LOOP;
end;
/
Results :
Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0 Connected as jvogel 1 : 5513 2 : 11276 3 : 11013 4 : 11150 5 : 11227 6 : 11249 7 : 10918 8 : 11192 9 : 10937 10 : 5525 11 : 0 1 : 10064 2 : 10001 3 : 10001 4 : 9856 5 : 9948 6 : 10021 7 : 10025 8 : 10055 9 : 10040 10 : 9989 11 : 0 PL/SQL procedure successfully completed