bb.donnay-software.com

Donnay Software Web Forums
It is currently Sun Jun 07, 2020 2:15 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sun Mar 25, 2018 1:12 am 
Offline
User avatar

Joined: Wed Feb 24, 2010 3:44 pm
Posts: 1185
i can find out which Apps are running and get Pos/Size on Desktop.

now i want to open new Windows, any Size, and find a Position of a "free" (not Overlapped) Space on Desktop.

i do not want try/error like this ( too slow )
Code:
      FOR x := 1 TO aDesk[1]-aNewSize[1] STEP nXstep
         FOR y := 1 TO aDesk[2]-aNewSize[2] STEP nYstep
            aNewPos := {x,y}

            FOR i := 1 TO LEN(aFenster)
               aPos[1]  := aFenster[i][xPos ]
               aPos[2]  := aFenster[i][yPos ]
               aSize[1] := aFenster[i][xSize]
               aSize[2] := aFenster[i][ySize]

               IF HitWindow(aNewPos,aNewSize, aPos,aSize)

i wonder if i can use some sort of Delone Triangulation to find (best) free place on Desktop :?:

_________________
greetings by OHR
Jimmy


Top
 Profile  
 
PostPosted: Sun Mar 25, 2018 8:57 am 
Offline
Site Admin
User avatar

Joined: Wed Jan 27, 2010 6:58 pm
Posts: 4128
Location: Boise, Idaho USA
Quote:
i can find out which Apps are running and get Pos/Size on Desktop.


How are you getting the pos/size of those apps?

_________________
The eXpress train is coming - and it has more cars.


Top
 Profile  
 
PostPosted: Sun Mar 25, 2018 10:46 am 
Offline
User avatar

Joined: Wed Feb 24, 2010 3:44 pm
Posts: 1185
rdonnay wrote:
Quote:
i can find out which Apps are running and get Pos/Size on Desktop.

How are you getting the pos/size of those apps?
using Tasklist and this
Code:
FUNCTION GetaPosaSize(obj,aPos,aRefSize)
LOCAL nLeft   := 0
LOCAL nTop    := 0                                          // aPos == aRefSize == {nil,nil}
LOCAL nRight  := 0                                          // passed by reference
LOCAL nBottom := 0
LOCAL cBuffer := SPACE(16)

   // Get the absolute position and size of the Object (relative to DeskTop)
   DllCall("User32.DLL",DLL_STDCALL,"GetWindowRect",obj:GetHWND(),@cBuffer)

   nLeft   := Bin2U(SUBSTR(cBuffer,1,4))
   nTop    := Bin2U(SUBSTR(cBuffer,5,4))
   nRight  := Bin2U(SUBSTR(cBuffer,9,4))
   nBottom := Bin2U(SUBSTR(cBuffer,13,4))

   aRefSize[ 1 ] := nRight - nLeft
   aRefSize[ 2 ] := nBottom - nTop
   aPos[ 1 ]     := nLeft
   aPos[ 2 ]     := nTop

   // For Xbase++ Coordinates, Bottom Left == 0,0  use.....
   * aPos[2]  := aRefSize[2] - nBottom

RETURN NIL

_________________
greetings by OHR
Jimmy


Top
 Profile  
 
PostPosted: Sun Mar 25, 2018 11:06 am 
Offline
Site Admin
User avatar

Joined: Wed Jan 27, 2010 6:58 pm
Posts: 4128
Location: Boise, Idaho USA
I get that part. I wrote a program that gets the PID and Window Title of all running tasks, but how do you get an Xbase++ object from that info?

_________________
The eXpress train is coming - and it has more cars.


Top
 Profile  
 
PostPosted: Sun Mar 25, 2018 12:32 pm 
Offline
User avatar

Joined: Wed Feb 24, 2010 3:44 pm
Posts: 1185
you are right :
i´m not using oDlg Object from Tasklist, i use oDlg:GethWnd() Handle for "GetWindowRect"

Code:
FUNCTION gettasklist( hWnd )
LOCAL aList := {}
LOCAL cWindowName
LOCAL nVisible
   DO WHILE hWnd != 0
      cWindowname := SPACE( 100 )
      IF ( getwindowtexta( hWnd, @cWindowName, LEN( cWindowName ) ) <> 0 )
         nVisible := IsWindowVisible( hWnd )
         IF nVisible == 1
            AADD( aList, STR( hWnd, 8 ) + cWindowname )
         ENDIF
      ENDIF
      hWnd = GetWindow( hWnd, GW_HWNDNEXT )
   ENDDO
RETURN aList

FUNCTION GetWindow( hWnd, uCmd )
LOCAL nDll := DllLoad( "USER32.DLL" )
LOCAL xRet := DllCall( nDll, DLL_STDCALL, "GetWindow", hWnd, uCmd )
   DllUnLoad( nDll )
RETURN xRet

FUNCTION GetWindowTextA( hWnd, lPstring, nMax )
LOCAL nDll := DllLoad( "USER32.DLL" )
LOCAL xRet := DllCall( nDll, DLL_STDCALL, "GetWindowTextA", hWnd, @lPstring, nMax )
   DllUnLoad( nDll )
RETURN xRet

FUNCTION IsWindowVisible( hWnd )
LOCAL nDll := DllLoad( "USER32.DLL" )
LOCAL xRet := DllCall( nDll, DLL_STDCALL, "IsWindowVisible", hWnd )
   DllUnLoad( nDll )
RETURN xRet

_________________
greetings by OHR
Jimmy


Top
 Profile  
 
PostPosted: Sun Mar 25, 2018 1:28 pm 
Offline
Site Admin
User avatar

Joined: Wed Jan 27, 2010 6:58 pm
Posts: 4128
Location: Boise, Idaho USA
Quote:
FUNCTION gettasklist( hWnd )


What is hWnd? It is obviously a window handle but from where?

Is it from AppDeskTop():getHwnd() ?

_________________
The eXpress train is coming - and it has more cars.


Top
 Profile  
 
PostPosted: Sun Mar 25, 2018 2:58 pm 
Offline
User avatar

Joined: Wed Feb 24, 2010 3:44 pm
Posts: 1185
Code:
LOCAL oDlg
LOCAL aTasklist
LOCAL aSize     := { 0, 0 }
LOCAL aPos      := { 0, 0 }

   oDlg := XBPDIALOG() :new( APPDESKTOP(),, aPos, aSize,, .F. )
   oDlg:clipSiblings := .T.
   oDlg:drawingArea:ClipChildren := .T.
   oDlg:create()
   SETAPPFOCUS( oDlg )

   aTasklist := GetTaskList( oDlg:gethWnd() )
   FOR i := 1 TO LEN( aTasklist )

_________________
greetings by OHR
Jimmy


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group