gdi

Calculating the positions of glyphs in Windows

人走茶凉 提交于 2021-02-17 06:25:10
问题 Is there any simple and compatible GDI or .NET accessible subsystem of Windows that will give glyph position characters. The task here is the combining symbols such as those in Arabic which sometimes have chains of multiple combining symbols stacking on top of each others such as Arabic Fatha + Arabic Letter Superscript Alef + Arabic Maddah Above. The trouble is that though the X positions can be determined precisely with GDI GetCharacterPlacement, the Y position calculations which are

C++ winapi Taking Screenshot and Making It Background of Window

你说的曾经没有我的故事 提交于 2021-02-11 12:42:34
问题 I'm trying to make the snippingtool in c++. I managed to create a borderless, fullscreen window via this code; WindProc: LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { switch (message) { case WM_CHAR: //this is just for a program exit besides window's borders/taskbar if (wparam==VK_ESCAPE) { DestroyWindow(hwnd); } case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wparam, lparam); } } Creating the window; WNDCLASS

How to draw RGB bitmap to window using GDI?

我是研究僧i 提交于 2021-02-11 12:32:19
问题 I have an image in memory with the following byte layout blue, green, red, alpha (32 bits per pixel) The alpha is not used. I want to draw it to a window using GDI. Later I may want to draw only a smaller part of it to the window. But the bitmap in memory is always fixed at a certain width & height. How can this bitmap drawing operation be done? 回答1: SetDIBitsToDevice and/or StretchDIBits can be used to draw pixel data directly to a HDC if the pixel data is in a format that can be specified

Why do I need to save handle to an old bitmap while drawing with Win32 GDI?

大城市里の小女人 提交于 2021-02-10 11:53:58
问题 Here is the code from switch in WndProc function I've been given as an example: case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // Create a system memory device context. bmHDC = CreateCompatibleDC(hdc); // Hook up the bitmap to the bmHDC. oldBM = (HBITMAP)SelectObject(bmHDC, ghBitMap); // Now copy the pixels from the bitmap bmHDC has selected // to the pixels from the client area hdc has selected. BitBlt( hdc, // Destination DC. 0, // 'left' coordinate of destination rectangle. 0, // 'top'

Why are my programs's tab controls rendering their background in a blocky way, but the standard Window dialogs are not?

我们两清 提交于 2021-02-08 03:30:24
问题 tl;dr for those who read the old question: new circumstances have caused me to look a little deeper and I've found that this affects bare Tab controls on their own; I've adjusted the question to compensate. If I should remove the old question text entirely, please let me know. Here is a screenshot from a program I'm working on to test a wrapper library I'm also working on: If you look closely, the window on the right appears blocky, while the window on the left (the standard Windows Explorer

Graphics.MeasureString allowing too much whitespace

徘徊边缘 提交于 2021-02-07 04:17:17
问题 I'm using a function to call for a piece of text to be rendered within an area. The basic working of the function is: Dim measureSize as Size Do myFont = new Font(myFont.Name, myFont.Size - 1, FontStyle.Regular, GraphicsUnit.Document) 'Initial font size is set insanely high for the moment, during testing. 'Low initial font size is not the problem. measureSize = g.MeasureString(myString, myFont) Loop until (measuredSize.width < desiredSize.width AND measuredSize.height < desiredSize.height)

Graphics.MeasureString allowing too much whitespace

血红的双手。 提交于 2021-02-07 04:15:18
问题 I'm using a function to call for a piece of text to be rendered within an area. The basic working of the function is: Dim measureSize as Size Do myFont = new Font(myFont.Name, myFont.Size - 1, FontStyle.Regular, GraphicsUnit.Document) 'Initial font size is set insanely high for the moment, during testing. 'Low initial font size is not the problem. measureSize = g.MeasureString(myString, myFont) Loop until (measuredSize.width < desiredSize.width AND measuredSize.height < desiredSize.height)

What happens if you release an unclean device context?

送分小仙女□ 提交于 2021-02-07 04:08:03
问题 Normally, if a program selects an object into a device context, or changes its properties, it should change them back before releasing the device context. What happens if it doesn't? Let's say I do this: HDC hdc = GetDC(some_window); SelectObject(hdc, some_font); SetTextColor(hdc, 0x123456); SetBkColor(hdc, 0xFEDCBA); SetROP2(hdc, R2_XORPEN); ReleaseDC(some_window, hdc); and some_window 's window class does not have the CS_OWNDC or CS_CLASSDC flag. What happens? 回答1: Of the functions you

Move a bitmap around a window quickly in C++

眉间皱痕 提交于 2021-01-28 10:00:06
问题 I'm looking for some C++ code to let me quickly move a bitmap around a window, restoring the background as it moves. At present I capture the Window contents to a bitmap during the app initialization and in the OnPaint() I draw the this bitmap and then I draw my overlayed bitmap. I am double buffering the paint. The overlayed bitmap position moves with the mouse which invalidates the Window. This works fine except it is too slow when the background window is large (think Windows Desktop) and

Screen capture of specific window c++

人盡茶涼 提交于 2021-01-01 08:57:53
问题 I want to take a screenshot of some specific window (e.g calculator). Here is the code I have written according to this discussion: // Get the window handle of calculator application. HWND hWnd = ::FindWindow(0, _T("Calculator")); RECT r; GetWindowRect(hWnd, &r); int x[2]; int y[2]; x[0] = r.top; x[1] = r.bottom; y[0] = r.left; y[1] = r.right; HDC hScreen = GetWindowDC(hWnd); HDC hDC = CreateCompatibleDC(hScreen); HBITMAP hBitmap = CreateCompatibleBitmap(hScreen, y[1] - y[0], x[1] - x[0]);