|
-
Mar 19th, 2009, 02:45 AM
#1
Get Height of a window
Friends,
I just need to print screen the full height of a window that has scroll bar.
normally getWindowRect only returns the visible portion of the window. not the hidden part. i just want to print screen the full height .
any advise
-
Mar 19th, 2009, 07:20 AM
#2
Re: Get Height of a window
Is it your window or third party?
-
Mar 19th, 2009, 07:30 AM
#3
Re: Get Height of a window
 Originally Posted by RhinoBull
Is it your window or third party?
RhinoBull, 3rd Party. but it can be any window out there opened in a windows session with a scroll bar. ex. part of windows explore, browser window etc.
-
Mar 19th, 2009, 08:02 AM
#4
Re: Get Height of a window
Well, you can try doing something as simple as this:
Code:
Option Explicit
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Declare Sub SetWindowPos Lib "User32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Sub Command1_Click()
Dim ret As Long
Dim wnd As Long
wnd = FindWindow(vbNullString, "My Documents") '<<< I had Windows Explorer sized down
'get actual window size here using GetWindowRect
'and use values after you're done to restore it original size
SetWindowPos wnd, HWND_NOTOPMOST, 0, 0, _
Screen.Width * Screen.TwipsPerPixelX, Screen.Height * Screen.TwipsPerPixelY, _
SWP_NOACTIVATE Or SWP_SHOWWINDOW
'do whatever
'restore window to its original size here
End Sub
However, you may as well want to explore some other api functions like GetWindowPlacement and SetWindowPlacement.
-
Mar 21st, 2009, 07:27 AM
#5
Re: Get Height of a window
RhinoBulls
I am confused with your code

scren.height and screen.width i dont thik will work in most situation. coz if you take a webpage, that is heigher than the screen
How to get the full height of this winodw including the hidden part top and bottom?
coz i want to get a snap shot of the full list.
BTW, I think if i can get the Scroll height of the window, then also ok. how to do that?
Last edited by Fazi; Mar 21st, 2009 at 07:52 AM.
-
Mar 21st, 2009, 12:32 PM
#6
Re: Get Height of a window
 Originally Posted by Fazi
i dont thik will work in most situation. coz if you take a webpage, that is heigher than the screen 
Actually you can take a snap shot of a web page that is taller then the height of your screen using the webbrowser control..
http://www.vbforums.com/showpost.php...3&postcount=32
http://www.vbforums.com/showpost.php...4&postcount=29
Now if you can do the same with an external app that's something I'd like to see, I have no clue how you'd go about doing that.
-
Mar 21st, 2009, 01:42 PM
#7
Re: Get Height of a window
 Originally Posted by Edgemeal
yes, already i saw those great codes. but unfortunetly, i need it for what ever the window in what ever the program that have scrollbar
-
Mar 21st, 2009, 03:18 PM
#8
Re: Get Height of a window
Fazi, I doubt seriously you will be able to do what you want without manipulating the other window. Using listings for example, many list windows don't try to cache the entire "list" to a DC, because if the list had 1,000s of items in it the bitmap in that DC would be massive in size and probably errors if tried to be created. Most will simply redraw only the items that can be shown on the visible dc.
So, I think the answer would be to literally scroll the window remotely. Scroll it to the top, take snap shot, scroll it a page, take another snap shot, etc. And after you are done, it would be probably a good idea to set the window back to the original scroll position. I think you'd be able to use SendMessage and fire off some WM_VScroll/WM_HScroll messages. Or maybe use the Get/SetScrollPos APIs?
Another option, which probably wouldn't please anyone, would be to SetParent the target window (if possible) to the desktop, maximize it, then send scroll messages as mentioned above. The idea, if it works, would be far less screenshots, but obviously much larger screenshots. Of course, you'd have to put it back (SetParent) and resize it to original size once done. Just thinking off the top of my head.
Last edited by LaVolpe; Mar 21st, 2009 at 04:09 PM.
-
Mar 22nd, 2009, 12:23 AM
#9
Re: Get Height of a window
 Originally Posted by LaVolpe
Fazi, I doubt seriously you will be able to do what you want without manipulating the other window. Using listings for example, many list windows don't try to cache the entire "list" to a DC, because if the list had 1,000s of items in it the bitmap in that DC would be massive in size and probably errors if tried to be created. Most will simply redraw only the items that can be shown on the visible dc.
So, I think the answer would be to literally scroll the window remotely. Scroll it to the top, take snap shot, scroll it a page, take another snap shot, etc. And after you are done, it would be probably a good idea to set the window back to the original scroll position. I think you'd be able to use SendMessage and fire off some WM_VScroll/WM_HScroll messages. Or maybe use the Get/SetScrollPos APIs?
Another option, which probably wouldn't please anyone, would be to SetParent the target window (if possible) to the desktop, maximize it, then send scroll messages as mentioned above. The idea, if it works, would be far less screenshots, but obviously much larger screenshots. Of course, you'd have to put it back (SetParent) and resize it to original size once done. Just thinking off the top of my head.
Thank you
The first solution is what really in my mind. but i am not sure how decided the amount of scroll on each snap. i think for this we need the total scroll height + top & bottom arrow button height is it? if so , how to get that?
2nd solution. yah i think this is the solution rino bull also gave it seems.
first ill try this solution and see how it work
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|