| View previous topic :: View next topic |
| Author |
Message |
Cold_Burn Power User


Joined: 21 Apr 2008 Posts: 62
|
Posted: Wed Jun 04, 2008 7:53 am Post subject: How to get document window status? |
|
|
Cheers,
I'm setting the document window status to maximize and minimize through showwindow function provided by the system.
Then i went to do the opposite - Getting the status of an active document window - and searched the developerguide pdf, the online html api project repository and the forum and didnt found anything like that ( or i didnt searched well possibly).
There's a way to get the status of a document window?
I think that it will be something like a function that recieves the window handle of the document and returns the status, where minimize would be a number and maximize another number.
Best regards,
Cold_Burn
PS: Another doubt that i have is: Is it possible to define a status NORMAL to a document window? I'm already supporting the MAXIMIZE and MINIMIZE status. |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Sun Jun 08, 2008 4:29 am Post subject: |
|
|
To get the maximize status, there is no OO API. Use the system GetWindowPlacement function http://msdn.microsoft.com/en-us/library/ms633518(VS.85).aspx
The SW_SHOWNORMAL should allow for resize to normal
Good luck,
ms777 |
|
| Back to top |
|
 |
Cold_Burn Power User


Joined: 21 Apr 2008 Posts: 62
|
Posted: Tue Jul 08, 2008 3:10 am Post subject: |
|
|
I followed your advice and i use the GetWindowPlacement system function.
But there is a problem.
When i pass from Maximize to Minimize the GetWindowPlacement returns that the window is still maximized.
When i pass from Minimize to Maximize returns the right status: Maximized.
Another thing that is odd is that the Showcmd of the window structure parameter doesn't differs from the Normal status from the Minimize status returning the same integer value.
Does anyone knows why this happens?
The code:
| Code: | integer li_windowstate
String ls_dimarray[]
unsignedlong ul_whandle
windowplacement window
Integer li_showcmd,li_tamanho
Boolean lb_status
Long ll_status
if Not IsValid(ioo_obj) then return -1
if ioo_obj.of_isalive() = FALSE then return -1
ul_whandle = ioo_objDesktop.getactiveframe().getcontainerwindow().getwindowhandle(ls_dimarray,1)
//window.length= len(string(window))
//li_tamanho=window.length
//window.length = 44
ll_status=getwindowplacement(ul_whandle,window)
li_showcmd=window.showcmd
//DEBUG
if li_showcmd = 2 then
messagebox("Maximized!","")
elseif li_showcmd = 0 then
messagebox("Minimized or Normal","")
elseif li_showcmd <> 0 and li_showcmd <> 2 then
messagebox("Another status!","")
end if
//DEBUG
RETURN li_showcmd |
|
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Tue Jul 08, 2008 10:07 am Post subject: |
|
|
can you share the DECLARE statements you use ?
Also OO and OS version would be helpful |
|
| Back to top |
|
 |
Cold_Burn Power User


Joined: 21 Apr 2008 Posts: 62
|
Posted: Tue Jul 08, 2008 10:13 am Post subject: |
|
|
| ms777 wrote: | can you share the DECLARE statements you use ?
Also OO and OS version would be helpful |
That is the full and rather abnormally working code. I code in Powerbuilder. Dont know what DECLARE statements is.
OO version 2.3.1
OS WinXP Professional SP2 |
|
| Back to top |
|
 |
Cold_Burn Power User


Joined: 21 Apr 2008 Posts: 62
|
Posted: Tue Jul 29, 2008 2:42 am Post subject: Still unsolved |
|
|
I continue with this issue. I've been working on integration of my project with applications while searching for a working solution for this issue.
Anyone familiar with this subject can give me some help? Thanks |
|
| Back to top |
|
 |
DVezina OOo Advocate

Joined: 29 Sep 2006 Posts: 248 Location: Orlando
|
Posted: Wed Jul 30, 2008 12:14 pm Post subject: |
|
|
Ok don't laugh but this is how I do it in Basic.
Basically if the width of the window is equal to the screen resolution, then it's maximized.
When there is a will there is a way.
| Code: |
Sub doit
setCurrentFrame(1, 1024)
End Sub
Declare Function ShowWindow Lib "user32" (ByVal lHwnd As Long, ByVal lCmdShow As Long) As Boolean
sub setCurrentFrame(iState as Long, iRes as Integer)
' 1 = Normal, 2 = Minimized, 3 = Maximized
aFrame = ThisComponent.getCurrentController.getFrame()
window = aframe.getContainerWindow()
handle = window.getWindowHandle(dimarray(), 1)
ShowWindow( handle, iState )
Select Case window.PosSize.Width
case 0:
MsgBox("Minimized")
case iRes:
MsgBox("Maximized")
case else:
MsgBox("Normal")
End Select
end sub
|
|
|
| Back to top |
|
 |
Cold_Burn Power User


Joined: 21 Apr 2008 Posts: 62
|
Posted: Wed Jul 30, 2008 1:58 pm Post subject: |
|
|
I will try this in the morning. Thanks for the input.
I will come back with news. |
|
| Back to top |
|
 |
Cold_Burn Power User


Joined: 21 Apr 2008 Posts: 62
|
Posted: Thu Jul 31, 2008 2:50 am Post subject: |
|
|
Why do you set the state of the window and then get that state?
That's not what this function is ment to do, right?
You post was very helpful in this single bit:
| Quote: | | window.PosSize.Width |
I then adapted your code to see if the window is maximized,normal or maximized to the actual window without setting the state before.
So, imagine, if some windows are open for some time how would you know what the state it has a specific window without setting it (as you do)?
As this function is related to the active document this captures the window, sees what is the resolution (using your code ) and then decides which state is without setting it.
Thanks |
|
| Back to top |
|
 |
DVezina OOo Advocate

Joined: 29 Sep 2006 Posts: 248 Location: Orlando
|
Posted: Thu Jul 31, 2008 5:55 am Post subject: |
|
|
I was setting the state for testing purposes only. That way I could tell if the rest of the macro was working.
I'm glad you were able to adapt to your needs. |
|
| Back to top |
|
 |
|