gdi

how to fill gradient for roundrect in pure gdi (not gdi+)

时光怂恿深爱的人放手 提交于 2019-12-21 01:48:39
问题 just in pure gdi. thoughts or code are all welcome. 回答1: Create a rounded rect as a path, select the path as the clipping path, then do a gradient fill of the same rectangle. Code with MFC would look like this: int top = 10; int left = 10; int right = 200; int bottom = 200; int radius = 20; pDC->BeginPath(); pDC->RoundRect(left, top, right, bottom, radius, radius); pDC->EndPath(); pDC->SelectClipPath(RGN_COPY); TRIVERTEX vertices[2]; vertices[0].x = left; vertices[0].y = top; vertices[0].Red

About GDI/GDI+ coordinate compatibility?

大兔子大兔子 提交于 2019-12-20 10:28:52
问题 I have a problem while drawing with both GDI and GDI+ interchangeably. The page transformation—in particular scaling—seems to be a little bit off between the two. Which properties of the GDI context affects the scaling of the output other than SetViewportExt and SetWindowExt ? The code uses almost exclusively GDI for its drawing, but uses GDI+ in a few cases where its features (semitransparency) are needed. It uses SetViewportExt , SetWindowExt and SetViewportOrg to enable zooming and

Sharing GDI handles between processes in Windows CE 6.0

旧巷老猫 提交于 2019-12-20 06:36:57
问题 I know that GDI handles are unique and process specific in 'Big Windows' but do they work the same way in Windows CE 6.0? For example: I've got a font management service that several other services and applications will be using. This service has a list of valid fonts and configurations for printing and displaying; CreateFontIndirect() has been called on each of them. When one of these client applications requests a particular font (and configuration), can I return it the appropriate HFONT?

MeasureString always thinks whitespace will fit

心已入冬 提交于 2019-12-20 04:26:07
问题 I'm trying to do some hit testing on strings (I want to get the char index from the x offset), but I'm hitting issues with measure string. This is essentially the code I am using StringFormat sf = new StringFormat(StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.NoWrap | StringFormatFlags.LineLimit); e.Graphics.MeasureString("test string", this.Font, new SizeF(xHitTestPosition, this.Font.Height), sf, out charFitted, out linesFilled); The value of charFitted should be set to the

Creating a .NET app that “docks” to the side of the screen and limits other windows' sizes when maximized

痞子三分冷 提交于 2019-12-20 03:31:11
问题 I got an interesting request from the higher ups. They want a simple app that will show on users' computers to display the time in multiple time zones. That, in itself, is trivial; a simple window with a timer that will get the current UTC time and convert it to any number of time zones they want to see to update some labels' text. Here's the rub, though; to meet requirements all around, the window can never obscure nor be obscured by anything else on the desktop. The user will be running

Creating a .NET app that “docks” to the side of the screen and limits other windows' sizes when maximized

时间秒杀一切 提交于 2019-12-20 03:31:10
问题 I got an interesting request from the higher ups. They want a simple app that will show on users' computers to display the time in multiple time zones. That, in itself, is trivial; a simple window with a timer that will get the current UTC time and convert it to any number of time zones they want to see to update some labels' text. Here's the rub, though; to meet requirements all around, the window can never obscure nor be obscured by anything else on the desktop. The user will be running

How to make my game engine faster (GDI+, C#)

廉价感情. 提交于 2019-12-20 02:38:10
问题 I'm currently building a 2D Game Engine in C#, using GDI. I do know that there are better alternatives to GDI but I'm also so deep into the project I can't turn back now. So, I currently have a graphics engine, that renders a portion of a bitmap, depending on what my cameras position and windows size is, which has given me a great performance boost. Great! However, I've noticed that if I place a bunch of game objects, in the same position, I get the same frame rate compared to if I placed the

How to avoid flicker while handling WM_ERASEBKGND in Windows dialog

半腔热情 提交于 2019-12-19 15:41:32
问题 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 the flickering I enumerate all child windows and add them to the clipping region. That seems to help a little -- now the flickering is mostly evident in all of the child controls as they repaint. How can I make the dialog flicker-free while resizing? I

Generic text-only printer driver doesn't work

时光怂恿深爱的人放手 提交于 2019-12-19 10:33:20
问题 I am using Generic text-only printer driver, provided as a sample in WDK(Windows driver toolkit). But it works with some applications and doesn't work with others. Like it works with Notepad and Microsoft word, but doesn't work with chrome browser or FloreantPOS. I tried using this driver to print to a file or a thermal printer with following 4 applications:- 1)Simple text on Notepad: Works successfully. 2)Text + graphics(word art) on Microsoft Word: Works successfully i.e. prints text and

Setting the Line End Styles for Canvas.LineTo

大憨熊 提交于 2019-12-19 08:01:14
问题 Is there any way to set the style for the lineends for the TCanvas.LineTo method? It seems to default to rounded ends, which looks very bad for several lines in a row of different colours when Pen.Width is set to a large value (e.g. 9). It looks like this (rounded ends): ********........****** **********........****** **********........****** ********........****** (where * is e.g. blue and . is yellow) It is even worse if the two outer lines are drawn after the middle line: ********........*