How can I hide Cursor in Windows? (delphi) - windows

I want my program to work sort of like Team Player. Multi mice, multi cursor but only one focus. But the problem is I can't hide the default cursor. I only want it to be invisible.
So far this works inside my application only.
ShowCursor(false);
and
Screen.Cursor:=crNone;
Is there a way to hide the cursor for the entire system (just until I close my application)?
EDIT:
This doesn't work:
procedure myShowCursor(Show :boolean);
var cursor1, cursor2: HCursor;
begin
cursor1 :=CopyIcon(Screen.Cursors[crDefault]);
cursor2 := LoadCursorFromFile('blank\blank.cur');
if Show then
SetSystemCursor(cursor1, OCR_NORMAL)
else
SetSystemCursor(cursor2, OCR_NORMAL);
end;
This works: (but I can't exactly use this)
procedure myShowCursor;
var cursor1, cursor2: HCursor;
begin
cursor1 :=CopyIcon(Screen.Cursors[crDefault]);
cursor2 := LoadCursorFromFile('blank\blank.cur');
SetSystemCursor(cursor2, OCR_NORMAL);
SetSystemCursor(cursor1, OCR_NORMAL)
end;
SOLVED: restored system cursors by SystemParametersInfo
procedure TForm1.myShowCursor(Show :boolean);
var cursor1: HCursor;
begin
cursor1 := LoadCursorFromFile('blank\blank.cur');
if Show then
SystemParametersInfo(SPI_SETCURSORS,0,0,WM_SETTINGCHANGE or SPIF_UPDATEINIFILE )
else
SetSystemCursor(cursor1, OCR_NORMAL);
end;

first download a blank cursor, you can get it from many places,i downloaded it from
http://pc.autons.net/stuff/blanks/blank.zip
,extact blank.zip then copy and paste blank.cur to a desired location(i am saving it to 'c:\blank.cur' for this example)
then try this code:
var cursor1, cursor2: HCursor;
begin
cursor1 := CopyIcon(Screen.Cursors[crDefault]);
cursor2 := LoadCursorFromFile('c:\blank.cur');
SetSystemCursor(cursor2, OCR_NORMAL);//to hide cursor
Sleep(2000);
SetSystemCursor(cursor1, OCR_NORMAL);//to show cursor again
end;
hope this helps

Related

Get Ref Cursor from dbms_sql.open_cursor

I have been asked to try to fix some existing PL/SQL code at work and I am new to PL/SQL. I am sorry if this is a stupid question.
Is there a way to take the cursor id returned by dbms_sql.open_cursor and get a REF CURSOR? Something like this:
procedure DoSomething (po_cursor out REF CURSOR) is
lv_cursorid integer;
begin
lv_cursorid := DBMS_SQL.open_cursor;
po_cursor := get_cursor_by_id(lv_cursorid);
end;
Per the docs, dbms_sql.to_refcursor(lv_cursorid) should do it

How to call a stored procedure in pl/sql developer

I am new at this and have a simple question.
I have created a procedure like so in pl/sql developer
CREATE OR REPLACE PROCEDURE myproc2 AS
BEGIN
SELECT cd_desc des, cd_value cd FROM v_codes WHERE cd_type='CVS02'
END;
Now I want to call the procedure and see the output however when I run this
BEGIN
myproc2;
END;
in Pl/sql I am getting an error saying object myproc2 is invalid
How do I call a stored procedure in PL/SQL?
You're calling it right, but the procedure is wrong. If you check its status, it is invalid.
In PL/SQL, a SELECT requires INTO:
CREATE OR REPLACE PROCEDURE myproc2 AS
l_cd_desc v_codes.cd_desc%type;
l_cd_value v_codes.cd_value%type;
BEGIN
SELECT v.cd_desc, v.cd_value
INTO l_cd_desc, l_cd_value
FROM v_codes v
WHERE v.cd_type = 'CVS02';
END;
Beware of possible NO_DATA_FOUND or TOO_MANY_ROWS exception.
Also, although it'll now run OK (I guess), you won't see anything because it is unknown what you'll do next. You could, for example, choose to display values you fetched. In that case, add
<snip>
WHERE v.cd_type = 'CVS02';
dbms_output.put_line(l_cd_desc ||', '|| l_cd_value);
END;
Don't forget to enable serveroutput.
As you commented, you got too_many_rows. How to handle it? It depends on what you want to do. One option is to switch to a cursor FOR loop; now you don't need local variables and - as there's no SELECT statement itself - no INTO clause either:
CREATE OR REPLACE PROCEDURE myproc2
AS
BEGIN
FOR cur_r IN (SELECT v.cd_desc, v.cd_value
FROM v_codes v
WHERE v.cd_type = 'CVS02')
LOOP
DBMS_OUTPUT.put_line (cur_r.cd_desc || ', ' || cur_r.cd_value);
END LOOP;
END;
One great thing about Oracle SQL Developer is the GUI and that it does things for you.
You can open a sheet and run it the traditional way:
BEGIN
PROCEDURENAME(PARAM);
END;
or you can use the GUI, find the object with the (View->) Find DB object, find it, click on it and use the green arrow in the toolbar. It will open a UI for any parameters you used within the procedure.
In SQL Developer, if you want to see the output then you can return a cursor:
CREATE OR REPLACE PROCEDURE myproc2(
o_cursor OUT SYS_REFCURSOR
)
AS
BEGIN
OPEN o_cursor FOR
SELECT cd_desc AS des,
cd_value AS cd
FROM v_codes
WHERE cd_type='CVS02'; -- You need a ; statement terminator here.
END;
/
Then you can use:
-- Declare a cursor bind variable
VARIABLE cur SYS_REFCURSOR;
BEGIN
-- Call the cursor outputting into the bind variable.
myproc2(:cur);
END;
/
-- Print the cursor
PRINT :cur;
And run it as a script (using F5).

Edit File on Click of a button in Lazarus

Like I posted in a previous thread I want to create a little program which edits one line in a .ini file. Now I have implemented a button but don't further. I basically want to implement the following scenario:
1) Click Button
2) Because of button click, program opens .txt/.ini file (in background) the file is located in the same folder
3) One word in text file is changed with new word
4) file gets saved
5) message pops up
procedure TLauncher.ButtonClick(Sender: TObject);
var
begin
ShowMessage('.Ini-File was edited')
end;
That's simple to do, if you split what you want to do into procedures that only
do one thing each.
Assume your form has a string variable IniFileName which you initialize however
you want, e.g. using a TOpenDialog. Then you can have
procedure TForm1.LoadIni;
begin
Memo1.Lines.LoadfromFile(IniFileName);
end;
procedure TForm1.SaveIni;
begin
Memo1.Lines.SaveToFile(IniFileName);
end;
procedure TForm1.Button1Click;
begin
if OpenDialog1.Execute then begin
IniFileName := OpenDialog1.FileName;
LoadIni;
end;
end;
procedure TForm1.Button2Click;
begin
SaveIni;
ShowMessage(IniFileName + ' saved to disk');
end;

PLS-00221: 'C1'(cursor) is not a procedure or is undefined

I am creating a package to use with Jasper reports where I learnt that I need SYS_REFCURSOR but I cannot seem to be able to Loop my cursors:eg
create or replace PACKAGE BODY fin_statement_spool
AS
PROCEDURE fin_main_spool(vacid in VARCHAR2, vfromdate in date, vtodate in date,c1 out SYS_REFCURSOR,c2 out SYS_REFCURSOR)
AS
cramount NUMBER;
dramount NUMBER;
countcr NUMBER;
countdr NUMBER;
BEGIN
OPEN c1 FOR
SELECT
.......;
OPEN c2 FOR
SELECT ........;
BEGIN
FOR i IN c1--Error is here
LOOP
rnum := 0;
cramount := 0;
dramount := 0;
countdr := 0;
countcr := 0;
..........
Isn't this the right way?
You appear to have confused explicit cursors, e.g.:
declare
cursor cur is
select dummy from dual;
begin
for rec in cur
loop
dbms_output.put_line(rec.dummy);
end loop;
end;
/
with a ref cursor - which is a pointer to an open cursor.
You would typically use a ref cursor to open a cursor in the db and pass it back to the calling app for it to loop through.
The way you have declared the ref cursors as out parameters and then tried to loop through them in the same procedure does not make sense - once you have fetched a record from a cursor, you cannot re-fetch it.
If you absolutely must loop through a ref cursor, you'd use this sort of syntax:
declare
cur sys_refcursor;
rec dual%rowtype;
begin
open cur for select dummy from dual;
loop
fetch cur into rec;
exit when cur%notfound;
dbms_output.put_line(rec.dummy);
end loop;
end;
/
but as I said, in general, you wouldn't be looping through ref cursors in the db, you'd be doing that in the calling code.
Perhaps if you updated your question with the requirements you're trying to fulfil, we could suggest a better way of doing it.

Oracle SQL Developer: how to view results from a ref cursor?

If I have a function which returns a reference cursor for a query, how can I view the result set of this in SQL Developer? Toad has a special tab for viewing the results of a reference cursor, this is the functionality I would like to find.
SET SERVEROUTPUT ON;
VARIABLE X REFCURSOR;
EXEC PROCEDURE_WITH_OUTPUT_SYS_REFCURSOR(:X);
PRINT X;
Double click the cursor fields in your result record. On the right side there is a "..." icon. Click this and you'll see the contents
Hi I know this was asked a while ago but I've just figured this out and it might help someone else. Not sure if this is exactly what you're looking for but this is how I call a stored proc and view the output in SQL Developer.
In SQL Developer when viewing the proc, right click and choose 'Run' or select Ctrl+F11 to bring up the Run PL/SQL window. This creates a template with the input and output params which you need to modify. To return the results of a sys_refcursor you then need to declare a row type that is exactly equivalent to the select stmt / sys_refcursor being returned by the proc. Below I declare "type t_row" which matches my output fields, then loop through the returned sys_refcursor. If t_row matches my sys_refcursor then it gets populated with each row of the sys_refcursor:
DECLARE
P_CAE_SEC_ID_N NUMBER;
P_FM_SEC_CODE_C VARCHAR2(200);
P_PAGE_INDEX NUMBER;
P_PAGE_SIZE NUMBER;
v_Return sys_refcursor;
type t_row is record (CAE_SEC_ID NUMBER,FM_SEC_CODE VARCHAR2(7),rownum number, v_total_count number);
v_rec t_row;
BEGIN
P_CAE_SEC_ID_N := NULL;
P_FM_SEC_CODE_C := NULL;
P_PAGE_INDEX := 0;
P_PAGE_SIZE := 25;
CAE_FOF_SECURITY_PKG.GET_LIST_FOF_SECURITY(
P_CAE_SEC_ID_N => P_CAE_SEC_ID_N,
P_FM_SEC_CODE_C => P_FM_SEC_CODE_C,
P_PAGE_INDEX => P_PAGE_INDEX,
P_PAGE_SIZE => P_PAGE_SIZE,
P_FOF_SEC_REFCUR => v_Return
);
-- Modify the code to output the variable
-- DBMS_OUTPUT.PUT_LINE('P_FOF_SEC_REFCUR = ');
loop
fetch v_Return into v_rec;
exit when v_Return%notfound;
DBMS_OUTPUT.PUT_LINE('sec_id = ' || v_rec.CAE_SEC_ID || 'sec code = ' ||v_rec.FM_SEC_CODE);
end loop;
END;
there are no way to display a refcursor in datagrid in sqldeveloper.
we can define a refcursor,call SP,then print refcursor,then data will be printed in Script output window in a plane text mode,but not in Query Result window.

Resources