Questions tagged [gdi]

Graphics Device Interface (GDI) is a device-independent, pure software graphics API under the Windows operating system for drawing graphic primitives and text. It is the underlying base used to render the Windows GUI elements.

Graphics Device Interface (GDI) is a device-independent, pure software graphics API under the Windows operating system for drawing graphic primitives and text. It is the underlying base used to render the Windows GUI elements.

More information at http://en.wikipedia.org/wiki/Graphics_Device_Interface

2158 questions
10
votes
1 answer

Is it possible to determine the fonts Windows chooses for font-linking?

Suppose you have a string with text in two or more scripts. When you use a GDI function like TextOut, (modern versions of) Windows will do "font-linking". That is, GDI will draw what it can with your selected font and draw the rest in an…
Adrian McCarthy
  • 45,555
  • 16
  • 123
  • 175
10
votes
3 answers

Win32: Does a window have the same HDC for its entire lifetime?

Am i allowed to use a DC outside of a paint cycle? Is my window's DC guaranteed to be valid forever? i'm trying to figure out how long my control's Device Context (DC) is valid. i know that i can call: GetDC(hWnd); to get the device context of my…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
10
votes
1 answer

Why are functions duplicated between opengl32.dll and gdi32.dll?

The following functions are duplicated between opengl32.dll and gdi32.dll: [opengl32.dll] / [gdi32.dll] wglChoosePixelFormat / ChoosePixelFormat wglDescribePixelFormat / DescribePixelFormat wglGetPixelFormat /…
The Fiddler
  • 2,726
  • 22
  • 28
10
votes
5 answers

How to measure the pixel width of a digit in a given font / size (C#)

I am trying to calculate the pixel width of Excel columns, as described in this post, using the official formula from the OpenXML specification. However, in order to apply this formula, I need to know the Maximum Digit Width of the Normal font,…
Tim Coulter
  • 8,705
  • 11
  • 64
  • 95
10
votes
6 answers

How to avoid flicker while handling WM_ERASEBKGND in Windows dialog

I have a dialog that resizes. It also has a custom background which I paint in response to a WM_ERASEBKGND call (currently a simple call to FillSolidRect). When the dialog is resized, there is tremendous flickering going on. To try and reduce…
DougN
  • 4,407
  • 11
  • 56
  • 81
10
votes
1 answer

Double Buffering? Win32 c++

I am trying to implement double buffering but it doesn't seem to work i.e. the graphic still flickers. The WM_PAINT gets called everytime when the mouse moves. (WM_MOUSEMOVE) Pasted WM_PAINT below: case WM_PAINT: { hdc =…
user1788175
  • 1,518
  • 4
  • 16
  • 20
10
votes
4 answers

Letting the mouse pass through Windows C++

I am working on an Win32 C++ application where I want to ignore the mouse events and let is pass through to the window beneath my window. Basically the window below mine will handle the mouse event. I would prefer not to send the mouse message using…
JoderCoder
  • 111
  • 1
  • 5
9
votes
3 answers

Is there something special about using BeginPaint/EndPain and not GetDC/ReleaseDC in response to WM_PAINT message?

One can use GetDC/ReleaseDC to draw in client area of window. But in response to WM_PAINT message one have to use BeginPaint/EndPaint. Is there something special about this?
Vadim
  • 1,223
  • 2
  • 17
  • 26
9
votes
4 answers

Switching from OpenGL to GDI

We have an application where we use both GDI and OpenGL to draw to the same HWND, but exclusively. Example: initially we are in 2d mode, so we draw on it using GDI then we switch to 3d mode and we draw on it using OpenGL then we switch back to 2d…
myavuzselim
  • 365
  • 5
  • 8
9
votes
2 answers

Is there a faster alternative to GDI GetPixel()?

I'm using GetPixel() from gdi32.dll in a .NET app to sample the colour of a pixel anywhere on the screen. It works ok but it is a major performance bottleneck for me. Is there a faster way of doing it?
stucampbell
  • 6,383
  • 5
  • 26
  • 25
9
votes
1 answer

Invert Text Color depending on BackColor

I have a ProgressBar control like the following two: The first is painted properly. As you can see, the second only has one 0, it's supposed to have two but the other cannot be seen because ProgressBar's ForeColor is the same as the TextColor. Is…
Asad Ali
  • 684
  • 6
  • 17
9
votes
1 answer

Why would FillRect not draw when LineTo succeeds?

I am trying to change the background color of a DateTimePicker, but my question is unrelated to what i'm trying to do. I am catching a window's WM_PAINT message, letting the default drawing implementation happen (i.e. the one inside ComCtrl.dll),…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
9
votes
1 answer

multiple screen capture with MSDN library

I am working on screen capture with multiple display units. As GetDesktopWindow() only gets the handle to primary monitors, I tried to use EnumDisplayMonitors() to do the job. After reading the MSDN website, I wrote these in the main(): HDC hdc =…
Samuel
  • 113
  • 2
  • 8
9
votes
2 answers

Understanding Device Contexts

As a relative newcomer to MFC, I see Device Contexts (DCs) a lot. I vaguely understand that it's something to do with drawing, but the specifics are not very well explained anywhere that I can find. What does creating a "compatible Device Context"…
Smashery
  • 57,848
  • 30
  • 97
  • 128
9
votes
2 answers

Font in 'GraphicsPath.AddString' is smaller than usual font

For some reason if I add a string to GraphicsPath using AddString the font is going to be smaller than it looks like in the Font Dialog. SizeF sz = g.MeasureString(Text, new Font(Font.FontFamily, (int)(Font.Size - (Font.Size / 7)), Font.Style),…
Kristina
  • 15,859
  • 29
  • 111
  • 181