c# only draws on partially of the screen
up vote
0
down vote
favorite
I'm trying to draw on my screen with c# but it only seems to draw e few pixels. Also when I log
Console.WriteLine(Screen.PrimaryScreen.Bounds.Width);
Console.WriteLine(Screen.PrimaryScreen.Bounds.Height);
It loggs: 1620, 1080 which is half my screen size...
Here is my code with which I'm trying to draw:
[DllImport("User32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("User32.dll")]
public static extern void ReleaseDC(IntPtr hwnd, IntPtr dc);
static void Main(string args) {
Console.WriteLine(Screen.PrimaryScreen.Bounds.Width);
Console.WriteLine(Screen.PrimaryScreen.Bounds.Height);
IntPtr desktopPtr = GetDC(IntPtr.Zero);
Graphics g = Graphics.FromHdc(desktopPtr);
SolidBrush b = new SolidBrush(Color.White);
g.FillRectangle(b, new Rectangle(0, 0, 16000, 16000));
}
Hope someone can help me, Elias :)
c#
|
show 2 more comments
up vote
0
down vote
favorite
I'm trying to draw on my screen with c# but it only seems to draw e few pixels. Also when I log
Console.WriteLine(Screen.PrimaryScreen.Bounds.Width);
Console.WriteLine(Screen.PrimaryScreen.Bounds.Height);
It loggs: 1620, 1080 which is half my screen size...
Here is my code with which I'm trying to draw:
[DllImport("User32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("User32.dll")]
public static extern void ReleaseDC(IntPtr hwnd, IntPtr dc);
static void Main(string args) {
Console.WriteLine(Screen.PrimaryScreen.Bounds.Width);
Console.WriteLine(Screen.PrimaryScreen.Bounds.Height);
IntPtr desktopPtr = GetDC(IntPtr.Zero);
Graphics g = Graphics.FromHdc(desktopPtr);
SolidBrush b = new SolidBrush(Color.White);
g.FillRectangle(b, new Rectangle(0, 0, 16000, 16000));
}
Hope someone can help me, Elias :)
c#
Are you possibly using display scaling (HiDPI) in Windows? This sounds like your program isn't HiDPI aware and gets confused there.
– AKX
Nov 22 at 8:57
Yes, my scaling was set to 200% by default which would exactly fit the 1/2 of the resolution... and how am I going to fix that now?
– Elias
Nov 22 at 9:05
stackoverflow.com/questions/23551112/… seems relevant. (There's also stackoverflow.com/questions/4075802/… if that doesn't do the trick.)
– AKX
Nov 22 at 10:33
@AKX Hm I've already seen those but I don't have any forms... just themain
function and some threads... I'm not sure what to do :(
– Elias
Nov 22 at 11:54
The first linked answer should be relevant even without threads, as you're using GDI/GDIplus to draw.
– AKX
Nov 22 at 11:55
|
show 2 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to draw on my screen with c# but it only seems to draw e few pixels. Also when I log
Console.WriteLine(Screen.PrimaryScreen.Bounds.Width);
Console.WriteLine(Screen.PrimaryScreen.Bounds.Height);
It loggs: 1620, 1080 which is half my screen size...
Here is my code with which I'm trying to draw:
[DllImport("User32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("User32.dll")]
public static extern void ReleaseDC(IntPtr hwnd, IntPtr dc);
static void Main(string args) {
Console.WriteLine(Screen.PrimaryScreen.Bounds.Width);
Console.WriteLine(Screen.PrimaryScreen.Bounds.Height);
IntPtr desktopPtr = GetDC(IntPtr.Zero);
Graphics g = Graphics.FromHdc(desktopPtr);
SolidBrush b = new SolidBrush(Color.White);
g.FillRectangle(b, new Rectangle(0, 0, 16000, 16000));
}
Hope someone can help me, Elias :)
c#
I'm trying to draw on my screen with c# but it only seems to draw e few pixels. Also when I log
Console.WriteLine(Screen.PrimaryScreen.Bounds.Width);
Console.WriteLine(Screen.PrimaryScreen.Bounds.Height);
It loggs: 1620, 1080 which is half my screen size...
Here is my code with which I'm trying to draw:
[DllImport("User32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("User32.dll")]
public static extern void ReleaseDC(IntPtr hwnd, IntPtr dc);
static void Main(string args) {
Console.WriteLine(Screen.PrimaryScreen.Bounds.Width);
Console.WriteLine(Screen.PrimaryScreen.Bounds.Height);
IntPtr desktopPtr = GetDC(IntPtr.Zero);
Graphics g = Graphics.FromHdc(desktopPtr);
SolidBrush b = new SolidBrush(Color.White);
g.FillRectangle(b, new Rectangle(0, 0, 16000, 16000));
}
Hope someone can help me, Elias :)
c#
c#
asked Nov 22 at 8:56
Elias
1
1
Are you possibly using display scaling (HiDPI) in Windows? This sounds like your program isn't HiDPI aware and gets confused there.
– AKX
Nov 22 at 8:57
Yes, my scaling was set to 200% by default which would exactly fit the 1/2 of the resolution... and how am I going to fix that now?
– Elias
Nov 22 at 9:05
stackoverflow.com/questions/23551112/… seems relevant. (There's also stackoverflow.com/questions/4075802/… if that doesn't do the trick.)
– AKX
Nov 22 at 10:33
@AKX Hm I've already seen those but I don't have any forms... just themain
function and some threads... I'm not sure what to do :(
– Elias
Nov 22 at 11:54
The first linked answer should be relevant even without threads, as you're using GDI/GDIplus to draw.
– AKX
Nov 22 at 11:55
|
show 2 more comments
Are you possibly using display scaling (HiDPI) in Windows? This sounds like your program isn't HiDPI aware and gets confused there.
– AKX
Nov 22 at 8:57
Yes, my scaling was set to 200% by default which would exactly fit the 1/2 of the resolution... and how am I going to fix that now?
– Elias
Nov 22 at 9:05
stackoverflow.com/questions/23551112/… seems relevant. (There's also stackoverflow.com/questions/4075802/… if that doesn't do the trick.)
– AKX
Nov 22 at 10:33
@AKX Hm I've already seen those but I don't have any forms... just themain
function and some threads... I'm not sure what to do :(
– Elias
Nov 22 at 11:54
The first linked answer should be relevant even without threads, as you're using GDI/GDIplus to draw.
– AKX
Nov 22 at 11:55
Are you possibly using display scaling (HiDPI) in Windows? This sounds like your program isn't HiDPI aware and gets confused there.
– AKX
Nov 22 at 8:57
Are you possibly using display scaling (HiDPI) in Windows? This sounds like your program isn't HiDPI aware and gets confused there.
– AKX
Nov 22 at 8:57
Yes, my scaling was set to 200% by default which would exactly fit the 1/2 of the resolution... and how am I going to fix that now?
– Elias
Nov 22 at 9:05
Yes, my scaling was set to 200% by default which would exactly fit the 1/2 of the resolution... and how am I going to fix that now?
– Elias
Nov 22 at 9:05
stackoverflow.com/questions/23551112/… seems relevant. (There's also stackoverflow.com/questions/4075802/… if that doesn't do the trick.)
– AKX
Nov 22 at 10:33
stackoverflow.com/questions/23551112/… seems relevant. (There's also stackoverflow.com/questions/4075802/… if that doesn't do the trick.)
– AKX
Nov 22 at 10:33
@AKX Hm I've already seen those but I don't have any forms... just the
main
function and some threads... I'm not sure what to do :(– Elias
Nov 22 at 11:54
@AKX Hm I've already seen those but I don't have any forms... just the
main
function and some threads... I'm not sure what to do :(– Elias
Nov 22 at 11:54
The first linked answer should be relevant even without threads, as you're using GDI/GDIplus to draw.
– AKX
Nov 22 at 11:55
The first linked answer should be relevant even without threads, as you're using GDI/GDIplus to draw.
– AKX
Nov 22 at 11:55
|
show 2 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427104%2fc-sharp-only-draws-on-partially-of-the-screen%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you possibly using display scaling (HiDPI) in Windows? This sounds like your program isn't HiDPI aware and gets confused there.
– AKX
Nov 22 at 8:57
Yes, my scaling was set to 200% by default which would exactly fit the 1/2 of the resolution... and how am I going to fix that now?
– Elias
Nov 22 at 9:05
stackoverflow.com/questions/23551112/… seems relevant. (There's also stackoverflow.com/questions/4075802/… if that doesn't do the trick.)
– AKX
Nov 22 at 10:33
@AKX Hm I've already seen those but I don't have any forms... just the
main
function and some threads... I'm not sure what to do :(– Elias
Nov 22 at 11:54
The first linked answer should be relevant even without threads, as you're using GDI/GDIplus to draw.
– AKX
Nov 22 at 11:55