Drawing a rectangle outside of the task

Discussions related to Visual Prolog
User avatar
Tonton Luc
VIP Member
Posts: 500
Joined: 16 Oct 2001 23:01

Drawing a rectangle outside of the task

Unread post by Tonton Luc » 26 Dec 2012 14:05

Hi,

When the cursor move everywhere outside of the task of my application (VP 7.3), I would like to draw a rectangle (or an invisible window with border) from the cursor position on my screen : how to do it ?
I already look at gui_native but without succes.

User avatar
Thomas Linder Puls
VIP Member
Posts: 1622
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 26 Dec 2012 20:34

I believe you do it in a tool-tip window.
Regards Thomas Linder Puls
PDC

User avatar
Tonton Luc
VIP Member
Posts: 500
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 27 Dec 2012 7:52

What do you mean by a tool-type window ?
An invisible window that have the same size of the desktop ? somethink like :

Code: Select all

facts mem_win_virtuel:windowHandle:=erroneous.   predicates     onTraceCadreOutside : window::menuItemListener. clauses     onTraceCadreOutside(_Source, _MenuTag):-         NULLWIN=uncheckedConvert(vpiDomains::windowHandle,0),         DW = uncheckedConvert(vpiDomains::windowHandle,vpi::winGetAttrVal(NULLWIN,attr_screen_window)),         mem_win_virtuel := vpi::winCreate(w_Child ,vpi::winGetOuterRect(DW),"",noMenu,DW,[wsf_Transparent,wsf_NoBorder],action_fenetre,0)         .   predicates action_fenetre:eHandler. clauses action_fenetre(_,e_MouseMove(Point, _ShiftControlAlt, _Buttons))=0:-     _ = gui_native::getcursorpos(pnt(XX,YY)),settext(string::format("% - %",Point,pnt(XX,YY))),     !. action_fenetre(_,_)=0.

User avatar
Thomas Linder Puls
VIP Member
Posts: 1622
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 27 Dec 2012 11:16

Well, I think I was wrong anyway (tool tip windows are the help/hint windows that appear when you place the mouse over something).

Anyway, I think you will have to draw in some kind of top level window that has the screen as parent.
Regards Thomas Linder Puls
PDC

User avatar
Tonton Luc
VIP Member
Posts: 500
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 27 Dec 2012 13:42

Hi,

Using this following code, I obtein the result (in JPEG enclosed) :

Code: Select all

facts mem_win_virtuel:windowHandle:=erroneous. mem_win_cadre:windowHandle:=erroneous. largeur_cadre:integer:= 600. hauteur_cadre:integer:= 30.   predicates     onTraceCadreOutside : window::menuItemListener. clauses     onTraceCadreOutside(_Source, _MenuTag):-         Largeur_ecrans = systemInformation_native::getSystemMetrics(systemInformation_native::sm_cxvirtualscreen),         Hauteur_ecrans = systemInformation_native::getSystemMetrics(systemInformation_native::sm_cyvirtualscreen),                 DW = uncheckedConvert(vpiDomains::windowHandle,gui_native::getDesktopWindow()),         mem_win_virtuel := vpi::winCreate(w_TopLevel ,rct(0,0,Largeur_ecrans,Hauteur_ecrans),"",noMenu,DW,[wsf_Transparent,wsf_NoBorder],action_fenetre,0),         _ = gui_native::getCursorPos(pnt(X,Y)),         if not(isErroneous(mem_win_virtuel)) then             mem_win_cadre := vpi::winCreate(w_Child ,rct(X,Y,X+largeur_cadre,Y+hauteur_cadre),"",noMenu,mem_win_virtuel,[wsf_Transparent,wsf_DlgBorder],action_cadre,0)         end if         .   predicates action_fenetre:eHandler. clauses action_fenetre(Win,e_KeyUp(k_f9, _ShiftControlAlt))=0:-     vpi::winDestroy(Win),     mem_win_virtuel := erroneous,     !. action_fenetre(_Win,e_MouseMove(_ , _, _))=0:-     move_rectangle(),     !. action_fenetre(_,_)=0.   predicates action_cadre:eHandler. clauses action_cadre(Win,e_MouseMove(_ , _, _))=0:-     move_rectangle(),     !. action_cadre(_,_)=0.     predicates move_rectangle:(). clauses move_rectangle():-     if not(isErroneous(mem_win_virtuel)) and not(isErroneous(mem_win_cadre)) then         _ = gui_native::getCursorPos(pnt(X,Y)),         vpi::winMove(mem_win_cadre,rct(X,Y,X+largeur_cadre,Y+hauteur_cadre)),         vpi::wininvalidate(mem_win_virtuel),         vpi::wininvalidate(mem_win_cadre)     end if.
How to solve this ?
I've the same result using vpi::processEvents.
Attachments
tmp.JPG
print-screen when user move his mouse :
tmp.JPG (42.33 KiB) Viewed 2017 times

dominique f pannier
VIP Member
Posts: 98
Joined: 23 Sep 2002 23:01

Unread post by dominique f pannier » 31 Dec 2012 13:41

Hi Tonton,

I suppose your problem is the residual position of the moving window.
If yes, you have to clear it.

You can do it before redrawing. The clear instruction is a method of the windowGDI attached to a window.

I thik the best way is to create a window to which you add a paint responder (setpaintresponder); its last argument is the GDIObject; You take the client rectangle that you can clear before redrawing with the new coordinates.
Regards
Dominique Pannier

User avatar
Tonton Luc
VIP Member
Posts: 500
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 2 Jan 2013 12:51

and is it possible to set a paint responder to a window created by vpi::winCreate ?

dominique f pannier
VIP Member
Posts: 98
Joined: 23 Sep 2002 23:01

Unread post by dominique f pannier » 5 Jan 2013 16:24

I'm afraid no...

paintResponder is attached to a drawWindow, built by a class in the GUI package.
Instead of usin vpi::winCreate, you have to add in your project a new object form, setState with the flags you want, and to which you add the paintResponder.
Regards
Dominique Pannier

Post Reply