Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

winform fails to set size correctly!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MeteoBFG - 25 Apr 2005 15:27 GMT
There must be something happening behind the scenes to "help" me, but I've
got a real problem.

I've embedded an AxWebBrowser directly onto a form, and I'm trying to set
the size of the form to accomodate the contents.  The width sets to a
predefined number of pixels (816) correctly, but I can't get the height to
work.  The code setting the height is below.

You can see what I'm doing is trying to set the form to be so tall that
there's no vertical scrollbar.  I do that by asking for the size of the
scrollHeight, and growing the form so the client area is as large as the
value of scrollHeight.  But this code fails.  The value of desiredHeight
comes back with 7409, and the currentHeight is 293, for a delta of 7116 and
a targetHeight of 7436.  But when I set "this.Height = 7436" the form only
grows to to 1036.  That number is always the same.

My screen resolution is 1280 * 1024.  Does that affect the maximum possible
size of a winform?  Would I get the growth I need if I rendered this
offscreen?  The real reason I'm trying to work this out anyway is to do a
screen capture and turn HTML into TIFFs, so doing it offscreen (or in
memory) is the real target here, anyway.

private void FitVertical()

{

MSHTML.HTMLDocumentClass doc =
(MSHTML.HTMLDocumentClass)AxWebBrowser.Document;

MSHTML.HTMLBodyClass body = (MSHTML.HTMLBodyClass)doc.body;

int desiredHeight = body.scrollHeight;

int currentHeight = this.ClientSize.Height;

int delta = desiredHeight - currentHeight;

int targetHeight = this.Height + delta;

this.Height = targetHeight;

}
Stoitcho Goutsev \(100\) [C# MVP] - 30 Apr 2005 02:07 GMT
Hi MeteoBFG,

Yes, this size of the form is limited to the size of the desktop (more
specifcally SystemInformation.MaxWindowTrackSize).
This is done in the Form.SetBoundsCore protected virtual method. This
behaviour cannot be changes or at least without a great deal of work and
using PInvoke.

Signature

Stoitcho Goutsev (100) [C# MVP]

> There must be something happening behind the scenes to "help" me, but I've
> got a real problem.
[quoted text clipped - 38 lines]
>
> }

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.