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 :)










share|improve this question






















  • 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















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 :)










share|improve this question






















  • 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













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 :)










share|improve this question













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#






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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


















  • 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
















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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

How to ignore python UserWarning in pytest?

Alexandru Averescu