gdi

Get DeviceContext of Entire Screen with Multiple Montiors

时光总嘲笑我的痴心妄想 提交于 2019-12-07 14:31:17
问题 I need to draw a line (with the mouse) over everything with C#. I can get a Graphics object of the desktop window by using P/Invoke: DesktopGraphics = Graphics.FromHdc(GetDC(IntPtr.Zero)); However, anything I draw using this graphics object is only showing on the left monitor, and nothing on the right monitor. It doesn't fail or anything, it just doesn't show. After I create the Graphics object, it shows the visible clip region to be 1680 x 1050 which is the resolution of my left monitor. I

Is there a way to add my own button inside the edit common control?

断了今生、忘了曾经 提交于 2019-12-07 12:37:26
Say, if I have a default EDIT common control in my MFC-based dialog window: I'm looking for a way to add a small "X" (or delete) button inside of it (here's my Photoshop rendering of what I need): Is there a way to do it by modifying the default edit control? Please consider using new class CMFCEditBrowseCtrl . It does have method CMFCEditBrowseCtrl::EnableBrowseButton() to do exactly what you need. If I wanted more than one button, I would investigate alternatives: See the CMFCEditBrowseCtrl class' code. Then decide if derive a class from it and extend; or else derive from CEdit, copy

How would I draw a PNG image using LoadImage and StretchDIBits?

坚强是说给别人听的谎言 提交于 2019-12-07 12:16:45
问题 (This is related to the question on How would I load a PNG image using Win32/GDI (no GDI+ if possible)?.) Hi all, I was wondering, given that you have a PNG resource embedded in a binary file with the ID IDB_PNG1 , and an LPDRAWITEMSTRUCT to draw into (so that means you have the HDC and the rectangle for your target), how do you draw that image onto the screen using StretchDIBits ? I've worked with BitBlt and TransparentBlt before, but StretchDIBits seems to work differently, and LoadImage

Get exact window region size - CreateWindow window size isn't correct size of window

房东的猫 提交于 2019-12-07 09:30:45
问题 I've noticed something very annoying while trying to create a window in C++ and draw Rectangles that the window size doesn't match the size I set. For example, If I set the 480x240 window and try to Draw rectangles from top to bottom, left to right by getting GetWindowRect(hwnd, &rect) and calculate the width and height: rectangle_width = (rect.right - rect.left) / amountRectangleX; rectangle_height = (rect.bottom - rect.top) / amountRectangleY; if amountRectangleX = 2 and Y = 2 it draw 4

GDI rendering to direct2D ID2D1BitmapRenderTarget is always transparent

倖福魔咒の 提交于 2019-12-07 08:18:40
问题 I want to port my movie rendering software from DirectDraw to Direct2D. Because of compatibility issues, GDI rendering needs to be done on top of the image. To optimize performance I want to implement some kind of backbuffer mechanism, but there seems to be a problem with the alpha channel information, all GDI drawing appears somehow transparent . I create a ID2D1HwndRenderTarget for my window handle and and a ID2D1Bitmap to copy the images to. The pixelformat of the bitmap is DXGI_FORMAT

Screen capture fails to capture whole screen using C++ and GDI

寵の児 提交于 2019-12-07 07:17:58
问题 I made some research through the web, and found some useful code. I changed it a bit, in attempt to capture the whole screen and generate a buffer that I can send through udp packets: #include <iostream> #include <Windows.h> #include <fstream> void CapruteScreenAndSaveToFile() { uint16_t BitsPerPixel = 24; uint32_t Width = GetSystemMetrics(SM_CXSCREEN); uint32_t Height = GetSystemMetrics(SM_CYSCREEN); // Create Header BITMAPFILEHEADER Header; memset(&Header, 0, sizeof(Header)); Header.bfType

Static controls slightly flicker when main window is resized

久未见 提交于 2019-12-07 06:07:24
问题 INTRODUCTION AND RELEVANT INFORMATION: I have a complex painting to implement in my main window’s WM_PAINT handler. I have submitted a picture bellow to illustrate it: Main window has static controls, instead of buttons, which have style SS_NOTIFY . When user clicks on them, certain actions occur in program. The following picture shows where static controls in the main window are: Map on the orange panel is an EMF file ,top left and right logos are PNG files, and other pictures are bitmaps.

Letting the mouse pass through Windows C++

為{幸葍}努か 提交于 2019-12-07 05:53:55
问题 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 SendMessage to the window beneath mine or use SetCapture. Is there a way basically to ignore the mouse event and let it pass through with Windows APIs or with styles? Note that my window is not transparent. Thanks in advance for the help. 回答1: So

Direct2D interface and blurry text issue

一世执手 提交于 2019-12-07 04:53:18
问题 My new application will feature a rich interface which should be resizable on-the-fly uses transparent icons/images etc. For this application I'm trying to decide on using the new Direct2D API against the good old GDI. One of the downsides is of course it does not run on XP, although I've found a bit nastier issues to decide upon: I noticed that outputting text in a Direct2D environment seems a bit blurry (although marketed as a feature). Just look at the text in Firefox 4 with hardware

What's the fastest way to repeatedly fill a window with RGB data from an array?

做~自己de王妃 提交于 2019-12-07 04:24:56
问题 I'm currently writing a simple game. My graphics code runs once per frame (approximately 30 times per second), and writes RGB data to an array with 640 * 480 = 307200 entries. I have created a Win32 window with a client area exactly 640 x 480 pixels in size. What's the fastest way to get my RGB data displayed within the otherwise-empty window? The window will need to be updated every frame, so I need to avoid flickering. Should I use GDI for this? Or is there a faster approach using a