gdi

How to draw a single line using MouseMove Event

爱⌒轻易说出口 提交于 2019-12-04 15:10:49
I'm trying to draw a single line using OnMouseMove() event. My Problem is that everytime I move the mouse It leaves a trail. I tried to use the refresh method, but when I stop moving the mouse the line is gone. I don't want the line to be drawn OnPaint(); , Just want to draw it OnMouseMove() . EDIT: I'm using a transparent panel(cp.ExStyle |= 0x20;), so I cant use the graphics.Clear() and BackColor() Here's a Sample Image without the Refresh() : Here's my code: private void panel1_MouseMove(object sender, MouseEventArgs e) { Graphics g = panel1.CreateGraphics(); g.SmoothingMode = System

Convert CFF fonts into OpenType fonts programmatically

旧城冷巷雨未停 提交于 2019-12-04 15:06:39
Does anyone have any pointers where I can find extra information on how to create an opentype wrapper around a CFF font? Currently I have a parser for CFF files so I can get all sorts of information out of it (cmap, glyph names, widths, names etc etc). Given this information I am unable to create an Opentype (truetype format like) wrapper so I can use the font on Windows using GDI; GDI will not load the Opentype font and the only thing I know is that it fails to load the font. Does anyone know any additional information, validation applications, example code, get additional information why the

Any good tutorials / resources to learn Win32 GDI? [closed]

一笑奈何 提交于 2019-12-04 13:56:04
So far i have been searching on google and haven't fount a single good tutorial which is comprehensive. Does any one know of any good site or book which teaches Win32 GDI? Petzold (Programming Windows, now in its >=5th edition) has good coverage. GDI has been replaced by Direct2D and DirectWrite, which are available down to Vista, and substantially more performant and flexible. You might want to double-check that you really need to support XP, which is already past end-of-life. Martyn I found bobobobo's blog to be quite helpful for getting started with Win32 and related concepts. 来源: https:/

Problem with drawing custom Windows controls

筅森魡賤 提交于 2019-12-04 13:31:51
I'm playing around with drawing my own custom controls using the uxTheme library in Windows, and I can't work out why my control doesn't look like the regular Windows control that (supposedly) uses the same theme I'm using: The above image shows a standard Windows ComboBox (top) and my custom control drawn using the ComboBox theme (bottom). What I can't work out is why the border from my control is a different shape and colour to the standard control. In my class constructor I open the theme data: mComboTheme = OpenThemeData( hwnd, L"COMBOBOX" ); And then in the handler for WM_PAINT I'm just

Calculate ideal font size, based on the paper size and maximum allowed text length

和自甴很熟 提交于 2019-12-04 13:14:06
I have printing code that draws grid on the paper. Grid has 4 columns, and they have equal horizontal length. Height of the cell is tenth of the paper size. Total number of rows is unknown but I know for a fact that there will be at least one row. Each cell has same physical size-> width is quarter of the paper width, and height is one tenth of the paper height. Maximum number of characters that can fit into cell is 50. The problem I face is choosing proper font size so text of maximum length can fit into cell. Browsing through MSDN documentation and WinAPI examples, I saw that they use

How to draw 2d contour plot in c#?

本小妞迷上赌 提交于 2019-12-04 12:42:14
I'm mainly interested in algorithm which would enable me to convert Point3D[] into drawable gdi lines? Thanks to @Anders Gustafsson I was able to build something: public partial class FunctionGraph : UserControl { private Rectangle _area = new Rectangle(-10, -10, 20, 20); private Func<float, float, float> _func; public FunctionGraph() { SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); this.Padding.All=20; InitializeComponent(); } public Rectangle Area { get { return

D3D11: How to draw GDI Text to a GXDI Surface? (Without D2D)

若如初见. 提交于 2019-12-04 10:52:45
问题 I need some help with drawing a text to a texture with GDI and D3D11. I tried using D2D/DirectWrite, but it supports just D3D10 and not D3D11 as I need. Everything I tried failed so far... Now I want to use GDI methodes to write in the texture. So I created a texture with this params: Usage = D3D11_USAGE_DEFAULT; Format = DXGI_FORMAT_B8G8R8A8_UNORM; BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; CPUAccessFlags = 0; MiscFlags = D3D11_RESOURCE_MISC_GDI_COMPATIBLE Then I

Alphablend and TransparentBlt

时间秒杀一切 提交于 2019-12-04 09:40:24
This question is related to my earlier question on SO. I want to combine two layers with alpha applied only to a specific portion of the source layer. One way I tried was to set SourceConstantAlpha to $ff (and have the function use the alpha channel in the source layer). This kind of works - although slow (I guess I can speed it up by using ScanLines), the kind of part is that I cannot figure out what to set the alpha channel to. The documentation suggests that the calculation is: st.Red = Src.Red + (1 - Src.Alpha) * Dst.Red I have tried a few different values by guess work, but my first

Double buffering in WPF?

时光怂恿深爱的人放手 提交于 2019-12-04 08:38:02
I'm developing a graph control in WPF. I have previously developed it using GDI and C#. i've used double buffering in previous control to avoid some issues related to redrawing of the graph control. Now when i've developed the Graph Control in WPF i have a problem, when i use my Graph Control as a user control in a windows form,anchoring it to the form,and when running it and resizing it i can clearly see two black lines horizontal one and a vertical one in the right and bottom corners of the graph control... i think when i am resizing the graph, to occupy the resized area graph control is

Clickthrough to desktop on a transparent form

北城余情 提交于 2019-12-04 07:49:55
I have a screen capturing utility on which I can rubber band an area on the desktop. I've done this is a fairly easy manner, I have a form which is the same size as the screen on which I draw a screenshot of the desktop transformed into grayscale. When the user holds down the left mouse button he/she can select an area on the form. The rectangle which the user draws is filled with TransparentColor. Once the users lifts up his/her mouse the transparent rectangle is left in place and the actual desktop is visible. Here comes my problem: On my dev PC I can actually click through this transparent