Click here to Skip to main content
15,884,388 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to Serialize object's property by its Category Pin
Stefan Troschuetz2-Jul-04 1:19
Stefan Troschuetz2-Jul-04 1:19 
GeneralRe: How to Serialize object's property by its Category Pin
nakey_yang2-Jul-04 1:53
nakey_yang2-Jul-04 1:53 
GeneralRe: How to Serialize object's property by its Category [EDITED] Pin
Stefan Troschuetz2-Jul-04 2:12
Stefan Troschuetz2-Jul-04 2:12 
GeneralRe: How to Serialize object's property by its Category Pin
Heath Stewart2-Jul-04 3:02
protectorHeath Stewart2-Jul-04 3:02 
AnswerRe: How to Serialize object's property by its Category Pin
nakey_yang2-Jul-04 4:33
nakey_yang2-Jul-04 4:33 
GeneralTCP/IP Pin
Melanius2-Jul-04 1:05
Melanius2-Jul-04 1:05 
GeneralRe: TCP/IP Pin
Colin Angus Mackay2-Jul-04 2:12
Colin Angus Mackay2-Jul-04 2:12 
Generalpositioning a popup window correctly when large fonts are used... Pin
misterbear1-Jul-04 23:33
misterbear1-Jul-04 23:33 
I'm creating a button that opens a popup window when clicked, to display further options. I locate the topleft corner of the control at same location as button itself, by using mybutton.PointToScreen. No problem.

When the button is too close to the bottom of screen I locate the popup at location
mybutton.PointToScreen.Y - popup.Height + mybutton.height (i.e. open it upwards instead of downwards in a sence...)

This all works fine, if I use normal fonts. However when using larger font size in windows it becomes a problem for me.
the code looks like this:

<br />
Popup popup = new Popup();<br />
<br />
// Get bounds of the screen on which this Application is located<br />
Rectangle screenBounds = Screen.GetBounds(this.Location);<br />
<br />
// Get scaling factor for font used (will be 1 if using small fonts, 96 fpi)<br />
float scaleY = Form.GetAutoScaleSize(this.Font).Height / 13.0f;<br />
float scaleX = Form.GetAutoScaleSize(this.Font).Width / 5.0f;<br />
<br />
// Get screen coordinates of button that opens popup<br />
Point ButtonLocation = ((Control)sender).PointToScreen(Point.Empty);<br />
int x = ButtonLocation.X;<br />
int y = ButtonLocation.Y;<br />
<br />
if( screenBounds.Bottom < (y+popup.Height) )	//Open popup up instead of down<br />
{<br />
        //make sure the whole of the popup fits on screen<br />
	if( eventButtonLocation.Y < popup.Height )<br />
		popup.Height = eventButtonLocation.Y;	<br />
<br />
	y = (eventButtonLocation.Y - popup.Height + eventLabel.Height);<br />
}<br />
<br />
if(screenBounds.Right < (x + popup.Width) )	//Open to left instead of right<br />
	x = x - popup.Width + ((Control)sender).Width;<br />
<br />
// Set location of popup<br />
popup.Location = new Point(x,y);<br />
<br />
// Add event handler<br />
popup.Closed += PopupClosedEventHandler;<br />
<br />
// Display it<br />
popup.Show();<br />


now what happens internally is that the popup window is scaled using the Control.Scale()
method, since I have the AutoScale property of the popup form set to true.
This won't take effect until the call to Show() however, which means that my control
will be misplaced cause it will also scale the location of the form.
I can calculate the desired location after the call to the Show() method,
but this will first bring up the popup in the wrong location and
THEN move it, and the whole thing won't look very good...

Any ideas? I've tried to use the calculated scaleX and scaleY values to account for the
scaling done by the System, but can't quite get it right. The scale values I calculate
are the exact same the system uses, that I've concluded through testing. So I should be able
to fix it...

Can anyone help me? Or maybe give me a good briefing of how exactly the autoscale works? What I could
find out from the documentation is that the scaling should be performed in the constructor but that
is not the case from what i've found out (displaying a message before the constructor, after the constructor,
and inside an overridden scalecore() method in the popup (which is called from the Scale method)
the scale message shows up last, i.e. long after the constructor has finished.
GeneralRe: positioning a popup window correctly when large fonts are used... Pin
Heath Stewart2-Jul-04 3:01
protectorHeath Stewart2-Jul-04 3:01 
GeneralMultiple problems related to PrinPreviewControl Pin
sachinkalse1-Jul-04 23:00
sachinkalse1-Jul-04 23:00 
GeneralRe: Multiple problems related to PrinPreviewControl Pin
Heath Stewart2-Jul-04 2:58
protectorHeath Stewart2-Jul-04 2:58 
QuestionHow to Serialize object's property by its Category Pin
Anonymous1-Jul-04 23:00
Anonymous1-Jul-04 23:00 
AnswerRe: How to Serialize object's property by its Category Pin
Heath Stewart2-Jul-04 2:47
protectorHeath Stewart2-Jul-04 2:47 
GeneralResizing a Form Pin
Anonymous1-Jul-04 14:03
Anonymous1-Jul-04 14:03 
GeneralRe: Resizing a Form Pin
Anonymous1-Jul-04 14:04
Anonymous1-Jul-04 14:04 
GeneralC# Print Driver Pin
cobyjone1-Jul-04 12:45
cobyjone1-Jul-04 12:45 
GeneralRe: C# Print Driver Pin
cobyjone1-Jul-04 13:14
cobyjone1-Jul-04 13:14 
GeneralRe: C# Print Driver Pin
WillemM2-Jul-04 1:26
WillemM2-Jul-04 1:26 
GeneralRe: C# Print Driver Pin
cobyjone2-Jul-04 2:17
cobyjone2-Jul-04 2:17 
GeneralRe: C# Print Driver Pin
Dave Kreskowiak2-Jul-04 3:25
mveDave Kreskowiak2-Jul-04 3:25 
QuestionPocket PC database access ? Pin
Christian Graus1-Jul-04 12:31
protectorChristian Graus1-Jul-04 12:31 
AnswerRe: Pocket PC database access ? Pin
Anders Molin1-Jul-04 13:54
professionalAnders Molin1-Jul-04 13:54 
GeneralRe: Pocket PC database access ? Pin
Christian Graus1-Jul-04 13:58
protectorChristian Graus1-Jul-04 13:58 
GeneralRe: Pocket PC database access ? Pin
Anders Molin1-Jul-04 13:59
professionalAnders Molin1-Jul-04 13:59 
GeneralRe: Pocket PC database access ? Pin
Heath Stewart2-Jul-04 2:18
protectorHeath Stewart2-Jul-04 2:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.