| Dart Home | PowerTCP Emulation for .NET | Custom Development | Reply | PowerTCP Emulation for .NET Topics | Forums |
| Author | Forum: PowerTCP Emulation for .NET Topic: Window Resizing |
| TrentLawrence From: Pekin, IL USA Posts: 3 Member Since: 12/05/06 |
posted December 5, 2006 12:16 PM Ok the next tough task we have migrating from the Emulator components in VS6 to .NET is window resizing. In the old system I had a nifty function that, upon a window resize, would "step up" the size of the font, check the emulator window size, and if it was larger by height or width than the window size it'd shrink the font size back down. Then, it'd center the VT control on the screen. I also added in "+" and "-" buttons on the toolbar to upsize the font *and* window size to the next largest size, unless the window was larger than the screen... etc. I could go on longer - there was more built on this relating to the handling of XP's wider "themed" borders - but there's little to gain in doing so. My question is - and I dug around for a long time, maybe I'm blind - what's the equivalent (if any) for the auto resize property that was in VB6? On a form resize event, I need to resize the text on the VT control to the largest "font" which will fit in the screen, resize the control (with no annoying scrollbars) to fit the new 80x24 screen / font size appropriately, then center the control within the container it's placed in. Thanks in advance! |
K M Drake![]() From: Utica, NY USA Posts: 3406 Member Since: 07/14/00 |
posted December 5, 2006 4:20 PM Hi Trent, Well, the equivalent of AutoResize would be the DoResize() code included in the External Client sample app. This adjusts window size based on font size. But it sounds like you want to adjust the font size based on window size. You could add code similar to this: Private Sub ResizeFont() 'Calculate new Font Size Dim newSize As Single = (vt1.Size.Height / vt1.ScreenSize.Height) 'CharacterSize.Height Dim widthAllowed = Math.Floor(vt1.Size.Width - vt1.Margin.Width - SystemInformation.VerticalScrollBarWidth) / (vt1.ScreenSize.Width) newSize = Math.Floor((newSize * 7.3) / 10) 'Must adjust for character "padding" newSize = Math.Min(newSize, (1.6 * widthAllowed)) 'Set FontEx to use new Font Size Dim f As Dart.PowerTCP.Emulation.Font = New Dart.PowerTCP.Emulation.Font(vt1.FontEx.Name, newSize, GetFontStyle(vt1.FontEx.Bold, vt1.FontEx.Italic)) vt1.FontEx = f End Sub Private Function GetFontStyle(ByVal bold As Boolean, ByVal italic As Boolean) As FontStyle 'Return FontStyle with specified attributes Dim style As FontStyle = FontStyle.Regular If (bold) Then style = style + FontStyle.Bold If (italic) Then style = style + FontStyle.Italic Return style End Function You may have to play with the percentages to get it exactly right for each font. Hope it helps, -ken |
| Reply | PowerTCP Emulation for .NET Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|