Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralTroubles with Owner-draw TextBox... Pin
Mike0108-Feb-04 7:55
Mike0108-Feb-04 7:55 
GeneralRe: Troubles with Owner-draw TextBox... Pin
leppie8-Feb-04 8:28
leppie8-Feb-04 8:28 
GeneralRe: Troubles with Owner-draw TextBox... Pin
Mike0108-Feb-04 9:29
Mike0108-Feb-04 9:29 
GeneralRe: Troubles with Owner-draw TextBox... Pin
Heath Stewart8-Feb-04 18:13
protectorHeath Stewart8-Feb-04 18:13 
GeneralRe: Troubles with Owner-draw TextBox... Pin
Mike0109-Feb-04 4:43
Mike0109-Feb-04 4:43 
GeneralAdapt forms to screen resolution Pin
haezeban8-Feb-04 7:55
haezeban8-Feb-04 7:55 
GeneralRe: Adapt forms to screen resolution Pin
Mazdak8-Feb-04 8:24
Mazdak8-Feb-04 8:24 
GeneralRe: Adapt forms to screen resolution Pin
Heath Stewart8-Feb-04 18:07
protectorHeath Stewart8-Feb-04 18:07 
Subclassing is not the way to solve this. You'll end up with more problems than solutions because of an overly-complex architecture.

You could simply get - as part of a static call (it really only needs to be obtained once) - the dpi of the screen (or any graphical output device for that matter) and either initially size your controls accordingly (hence not relying on the designers to do the dirty work and re-arrange your code for optimal execution) or call Scale or ScaleCore (inherited from Control, and the last is virtual so you can override its behavior).

To get the dpi (logical pixels), you'll need to P/Invoke GetDeviceCaps since .NET doesn't expose these properties in the base class library:
[DllImport("gdi32.dll")]
private static extern int GetDeviceCaps(IntPtr hdc, int index);
 
private const int LOGPIXELSX = 88;
private const int LOGPIXELSY = 90;
Once you have the dpi (should normally be the same for the X and Y axis) you can do the appropriate calculations and scale your controls accordingly.

 

Microsoft MVP, Visual C#
My Articles
Questionminimize to tray? Pin
visiontec8-Feb-04 7:43
visiontec8-Feb-04 7:43 
AnswerRe: minimize to tray? Pin
OmegaSupreme8-Feb-04 10:18
OmegaSupreme8-Feb-04 10:18 
GeneralRe: minimize to tray? Pin
visiontec9-Feb-04 11:34
visiontec9-Feb-04 11:34 
GeneralRe: minimize to tray? Pin
OmegaSupreme9-Feb-04 15:25
OmegaSupreme9-Feb-04 15:25 
GeneralAdding parameters to a table Pin
Andrlage8-Feb-04 5:30
Andrlage8-Feb-04 5:30 
GeneralRe: Adding parameters to a table Pin
Nick Parker8-Feb-04 6:02
protectorNick Parker8-Feb-04 6:02 
QuestionMost efficient way of doing this? Pin
Alex Korchemniy7-Feb-04 22:31
Alex Korchemniy7-Feb-04 22:31 
GeneralZooming approach Pin
Meysam Mahfouzi7-Feb-04 18:08
Meysam Mahfouzi7-Feb-04 18:08 
GeneralRe: Zooming approach Pin
Heath Stewart7-Feb-04 19:00
protectorHeath Stewart7-Feb-04 19:00 
GeneralCombo Box problem... Pin
je_gonzalez7-Feb-04 17:27
je_gonzalez7-Feb-04 17:27 
GeneralDatabase Pin
ASGill7-Feb-04 17:16
ASGill7-Feb-04 17:16 
GeneralRe: Database Pin
Heath Stewart7-Feb-04 18:50
protectorHeath Stewart7-Feb-04 18:50 
GeneralMore Thread Troubles; not sure if it's deadlock Pin
Peter Mills7-Feb-04 14:41
Peter Mills7-Feb-04 14:41 
GeneralRe: More Thread Troubles; not sure if it's deadlock Pin
Heath Stewart7-Feb-04 18:58
protectorHeath Stewart7-Feb-04 18:58 
GeneralWell it's got me stumped Pin
Rob Manderson7-Feb-04 14:08
protectorRob Manderson7-Feb-04 14:08 
GeneralRe: Well it's got me stumped Pin
Rob Manderson7-Feb-04 16:25
protectorRob Manderson7-Feb-04 16:25 
GeneralRe: Well it's got me stumped Pin
Heath Stewart7-Feb-04 19:08
protectorHeath Stewart7-Feb-04 19:08 

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.