How to draw over second monitor with GDIPLUS

I'm want to draw some text and lines over the desktop.
I'm using gdiplus.h for print texts with the function DrawString.
But its only print text on a primary screen monitor.
If has in presentation mode, with 2 monitors I need to print text in a second monitor.
#define _WIN32_WINNT 0x500
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")
int main() {
HWND desktop = GetDesktopWindow();
HDC hdc = GetWindowDC(desktop);
ULONG_PTR m_gdiplusToken;
// Initialize GDI+
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
while (true)
HPEN newpen;
LPPOINT point = NULL;
newpen = CreatePen(PS_COSMETIC, 20, RGB(255, 0, 0));
SelectObject(hdc, newpen);
MoveToEx(hdc, 1500, 500, point);
LineTo(hdc, 1600, 550 );
//this block works for draw line in second monitor
TextOut(hdc, 1500, 300, TEXT("Text of text out"), 17); // this works too
//But if I'm use gdiplus only print things on the primary screen
Gdiplus::Graphics g(hdc);
Pen pen(Gdiplus::Color(0, 0, 255), 2);
g.DrawLine(&pen, 1500, 0, 1700, 600);// dont work
g.DrawLine(&pen, 0, 0, 1200, 600);// work, but is in the primary screen
FontFamily fontFamily(L"Times New Roman");
Font font(&fontFamily, 24, FontStyleRegular, UnitPixel);
SolidBrush brush(Color(255, 0, 0, 255));
g.DrawString(TEXT("test of GDI+"), 13, &font, PointF(1600.0f, 300.0f), &brush); // dont work
g.DrawString(TEXT("test of GDI+"), 13, &font, PointF(500.0f, 300.0f), &brush); // work, but is in the primary screen
Gdiplus::GdiplusShutdown(m_gdiplusToken);
return 0;

Hi Bhash, Thanks for help.
You can show to me an code example?
I'm tryied with this way: 
#include
#define _WIN32_WINNT 0x500
#include
#include
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")
HDC hdc;
BOOL CALLBACK MonitorEnumProcCallback(_In_ HMONITOR hMonitor, _In_ HDC DevC, _In_ LPRECT lprcMonitor, _In_ LPARAM dwData) {
MONITORINFOEX info;
info.cbSize = sizeof(MONITORINFO);
BOOL monitorInfo = GetMonitorInfo(hMonitor, &info);
cout << "info szDevice" << info.szDevice << endl;
if (monitorInfo) {
hdc = CreateDC(NULL, info.szDevice, NULL, NULL);
return TRUE;
int main() {
HWND desktop = GetDesktopWindow();
HDC DevC = GetDC(desktop);
BOOL b = EnumDisplayMonitors(DevC, NULL, MonitorEnumProcCallback, 0);
ULONG_PTR m_gdiplusToken;
// Initialize GDI+
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
while (true)
HPEN newpen;
LPPOINT point = NULL;
newpen = CreatePen(PS_COSMETIC, 20, RGB(255, 0, 0));
SelectObject(hdc, newpen);
MoveToEx(hdc, 1500, 500, point);
LineTo(hdc, 1600, 550);
//this block works for draw line in second monitor
TextOut(hdc, 1500, 300, TEXT("Text of text out"), 17); // this works too
//But if I'm use gdiplus only print things on the primary screen
Gdiplus::Graphics g(hdc);
Pen pen(Gdiplus::Color(0, 0, 255), 2);
g.DrawLine(&pen, 1500, 0, 1700, 600);// dont work
g.DrawLine(&pen, 0, 0, 1200, 600);// work, but is in the primary screen
FontFamily fontFamily(L"Times New Roman");
Font font(&fontFamily, 24, FontStyleRegular, UnitPixel);
SolidBrush brush(Color(255, 0, 0, 255));
g.DrawString(TEXT("test of GDI+"), 13, &font, PointF(1600.0f, 300.0f), &brush); // dont work
g.DrawString(TEXT("test of GDI+"), 13, &font, PointF(500.0f, 300.0f), &brush); // work, but is in the primary screen
Gdiplus::GdiplusShutdown(m_gdiplusToken);
return 0;
and I'm tryied too with
BOOL b = EnumDisplayMonitors(NULL, NULL, MonitorEnumProcCallback, 0);
and dosent work for any case, dont print anything in the any monitors
I'm tryied too with this mode: 
#include <iostream>
#define _WIN32_WINNT 0x500
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")
HDC hdc;
int main() {
DISPLAY_DEVICE dd;
ZeroMemory(&dd, sizeof(dd));
dd.cb = sizeof(dd);
for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); i++)
DEVMODE lpDevMode;
hdc = CreateDC(dd.DeviceName, dd.DeviceString, NULL, &lpDevMode);
ULONG_PTR m_gdiplusToken;
// Initialize GDI+
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
std::cout << "hdc: " << hdc << std::endl; //this print 00000000000000000000
while (true)
HPEN newpen;
LPPOINT point = NULL;
newpen = CreatePen(PS_COSMETIC, 20, RGB(255, 0, 0));
SelectObject(hdc, newpen);
MoveToEx(hdc, 200, 500, point);
LineTo(hdc, 300, 550);
//this block dont work
TextOut(hdc, 600, 300, TEXT("Text of text out"), 17); // dont work
//But if I'm use gdiplus only print things on the primary screen
Gdiplus::Graphics g(hdc);
Pen pen(Gdiplus::Color(0, 0, 255), 2);
g.DrawLine(&pen, 1500, 0, 1700, 600);// dont work
g.DrawLine(&pen, 0, 0, 100, 600);// dont work
FontFamily fontFamily(L"Times New Roman");
Font font(&fontFamily, 24, FontStyleRegular, UnitPixel);
SolidBrush brush(Color(255, 0, 0, 255));
g.DrawString(TEXT("test of GDI+"), 13, &font, PointF(1600.0f, 300.0f), &brush); // dont work
g.DrawString(TEXT("test of GDI+"), 13, &font, PointF(500.0f, 300.0f), &brush); // dont work
Gdiplus::GdiplusShutdown(m_gdiplusToken);
return 0;
ando Not was printed, dont print anything in the any monitors.

Similar Messages

  • Can I use the HDMI out on a HP ALL IN ONE TOUCHSCREEN Desktop to connect a second monitor with HDMI

    Can I use the HDMI out on a HP ALL IN ONE TOUCHSCREEN Desktop to connect a second monitor with HDMI  in without any additional  software or graphics adaptor.  I have a 520-1070
    HP - 23" Touch-Screen TouchSmart All-In-One Computer - 8GB Memory - 2TB Hard Drive ? I used a HDMI to HDMI cable and the monitor was not  recognized.

    Here are the specs for your HP TouchSmart 520-1070 Desktop Computer. As previously stated your computer Doesn't have a HDMI output, instead it has a HDMI input. This is designed to let you connect a game console, a DVD/Bluray player, etc. to use as a monitor.
    If you wish to conect a second monitor to your computer, you will need to use a USB-to-video adapter such as the EVGA UV Plus+ UV39 or EVGA UV Plus+ UV19. Using an adapter like these with the touch feature of your computer may cause issues with pointer control and you may need to disable the touch feature to use "extended desktop".
    Frank
    {------------ Please click the "White Kudos" Thumbs Up to say THANKS for helping.
    Please click the "Accept As Solution" on my post, if my assistance has solved your issue. ------------V
    This is a user supported forum. I am a volunteer and I don't work for HP.
    HP 15t-j100 (on loan from HP)
    HP 13 Split x2 (on loan from HP)
    HP Slate8 Pro (on loan from HP)
    HP a1632x - Windows 7, 4GB RAM, AMD Radeon HD 6450
    HP p6130y - Windows 7, 8GB RAM, AMD Radeon HD 6450
    HP p6320y - Windows 7, 8GB RAM, NVIDIA GT 240
    HP p7-1026 - Windows 7, 6GB RAM, AMD Radeon HD 6450
    HP p6787c - Windows 7, 8GB RAM, NVIDIA GT 240

  • How do I Add second monitor to ALL in One ENVY23 that has a HDMI port

    How do I Add second monitor to my ALL in One ENVY23 that has a HDMI port the computer has Win 8  Model #: 23se-d494
    Product #: F3D93AA#ABA
    Serial #: [edited Serial Number by Moderator]
    Software Build #: 14AM1HRA601#SABA#DABA
    Service ID #: 20140521
    PCBRAND #: HP

    Here are the specs for your HP ENVY TouchSmart 23se-d494 All-in-One Desktop Computer. Based the specs, the HDMI port on the side of your computer is an INPUT only. This model doesn't have a video output of any kind.
    1 - Controls           2 - HDMI In port (model dependent)
    You will need to purchase and use a USB-to-video adapter such as the EVGA UV Plus+ UV39 (or any of the many other adapters on the market) to connect an external display to your computer. I personally use and recommend the EVGA UV Plus+ UV39.
    If you have any further questions, please don't hesitate to ask.
    Please click the White KUDOS "Thumbs Up" to show your appreciation
    Frank
    {------------ Please click the "White Kudos" Thumbs Up to say THANKS for helping.
    Please click the "Accept As Solution" on my post, if my assistance has solved your issue. ------------V
    This is a user supported forum. I am a volunteer and I don't work for HP.
    HP 15t-j100 (on loan from HP)
    HP 13 Split x2 (on loan from HP)
    HP Slate8 Pro (on loan from HP)
    HP a1632x - Windows 7, 4GB RAM, AMD Radeon HD 6450
    HP p6130y - Windows 7, 8GB RAM, AMD Radeon HD 6450
    HP p6320y - Windows 7, 8GB RAM, NVIDIA GT 240
    HP p7-1026 - Windows 7, 6GB RAM, AMD Radeon HD 6450
    HP p6787c - Windows 7, 8GB RAM, NVIDIA GT 240

  • How to use a second monitor in I movie 11

    How can I use a second monitor in i movie.  I could use it under preference in imovie 9, but in the new imovie 11 i can't find any advanced  prefernces let alone how to use a second monitor

    I too got the same. Both monitors went portrait. Then I unchecked the 'Mirror Display' option in the Arrangment tab of iMac display and voila. Got what I wanted.

  • How to run an external monitor with lid closed

    how to use an external monitor with the "lid" closed

    You can use your MacBook in Clamshell Mode with a wired or Bluetooth keyboard and mouse.  http://support.apple.com/kb/HT3131

  • How to use an iPad as a second monitor with Bluetooth?

    I know there are several apps that will allow me to use my iPad as a second monitor over my wifi connection. But is there a way to us it over blue tooth or with a special cord?
    Thanks!

    I use a projector as a second monitor for a desk top. When the shutter is closed it is hard to minimize or exit a window. I would like to use my iPad as an additional second monitor so I can tell what I am doing.

  • Use 23" apple monitor as second monitor with 27" imac

    I've just bought a 27" imac, and I want to connect the 23" apple monitor from my old system to it as a second monitor.
    The 23" has a huge cable with firewire and usb connectors as well as a multipin connector. How can I link it up?

    Hello,
    I have seen people use the expensive DVI-ADC converter with an MDP-> DVI cable.
    http://www.ebay.com/itm/Apple-Mac-A1006-DVI-to-ADC-Converter-LCD-Display-Adapter -w-Power-Cord-/330799049978?
    Cheaper ADC to DVI converter won't work.
    Then you need an MDP to DVI adapter...
    http://store.apple.com/us/product/MB570Z/B/mini-displayport-to-dvi-adapter
    DVI single link 60-Hz LCD can display a resolution of 1920 x 1200.

  • How to attach a second monitor

    I would like to attach a second monitor to my TouchSmart Envy 23 PC.  It will not work with a HDMI Cable.  Can anyone please help me with how to do it. 

    Hi, The HDMI port on your machine is an IN port, you can't attache a monitor to it. If you wish to connect to a second computer, please try      http://www.startech.com/AV/USB-Video-Adapters/ Regards.

  • Premiere 5.5 taking over Second Monitor when minimized

    I am using a second monitor as an HD Fullscreen preview for Premiere 5.5. It has this annoying habit of taking over the second monitor (whatever frame I happened to be parked on) while the program is minimized. The only way to get back cotnrol of the monitor is to maximize then send to the background again. This is very annoying when you are operating back and forth between Pr and Ae or trying to do anything else on the second monitor.
    It seems to happen when it auto saves (which I have set at 5 minutes.. Yeah, I'm paranoid). I have the "Disable video output when in background" button selected, so what gives? This is the second Premiere 5.5 set-up I've had with this issue.
    Thanks for any feedback!
    And yes, the fullscreen video preview popped up THREE times while I was composing this message.

    Then download this Intel driver and install first. Then run the Nvidia driver after restart.
    https://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&ProdId=3319&DwnldID=23377&ProductF amily=Graphics&ProductLine=Laptop+graphics+drivers&ProductProduct=2nd+Generation+Intel%c2% ae+Core%e2%84%a2+Processors+with+Intel%c2%ae+HD+Graphics+3000%2f2000&DownloadType=Drivers& OSFullname=Windows+7+(64-bit)*&lang=eng
    Once you have that done open the Nvidia control panel on Restart. Select manage 3D settings. See if you see a Preferred GPU or Graphics card drop down on the right. If so select the Nvidia or performance option. I forget what is exactly said there. That is the Optimus control and will make sure the Nvidia GPU is used most often. That keeps the anomalies you are getting now when the video is switching to the Intel Adapter when you minimize Adobe. If that doesnt work then there may not be a fix for this beyond disabling the Intel adapter.
    Eric
    ADK

  • Best way to set up a second monitor with a Touchsmart

    What's the best way to set up a second monitor for the Touchsmart IQ506?  Is a USB to VGA cable the only way and how well does that work (I've read that they can be buggy)?  
    Are they any recommendations for products and setting it up?

    Leopard wont be out befor the second half of this year, sofar i cannot tell you what options you are going to have with the new system. Seems like with time machine is going to be a perfect backup for your whole system.
    10.4.x:
    Software RAID you can do 0 -1:
    To setup a RAID of your system you have to format the drive and setup the RAID type you want from the disk utility.
    To have some security i suggest the "mirror" options but you are going to lose some perfomance, depending you want is your main job it mighn't be noticed.
    RAID 5:
    This would be the nicest option but you need to buy an additional RAID controller. This is mostly used on servers and not on client computers.

  • I want to be able to draw on the monitor with a stylus

    I have a 24" iMac now but often I want to be able to add a drawing or a plan in an email using a stylus on the monitor. I know that this writing on the monitor with an iPad2 is possible but is it also possible on a MacBook PRO?
    I do not want something that plugs into the Mac to work. I want a little simple application that will run and can accept drawings done by a stylus.
    Then I want to be able to attach that file into an Apple Mail email.
    Is it possible on the MacBook PRO? Or should I get an iPad 2 to be able to do it?
    -L

    Lorna from Hawaii wrote:
    I do not want something that plugs into the Mac to work. I want a little simple application that will run and can accept drawings done by a stylus.
    Sorry, Mac's don't have the touchscreen technology installed to do that like the iPad does.
    The closest you can do is Walcom tablet on the low end
    http://www.wacom.com/en/Products.aspx
    and one of these bad babies on the high end (out of stock)
    http://www.wacom.com/en/Products/Cintiq/Cintiq24HD.aspx
    A Mac can't do this yet and would add a fortune to a already expensive machine to cater to artists, thus it's a external add-on device.
    Then I want to be able to attach that file into an Apple Mail email.
    Any file can be attached to a email provided it's not larger than the email service will accept, then there's DropBox for large files.
    Or should I get an iPad 2 to be able to do it?
    A iPad 2 will do that and allow you to draw on the screen, but it's smaller screen and there isn't the fine control like a add-on tablet provides. So your constantly zooming in and out to get the detail you need.
    It can work, it's just more work to get the same results.
    I don't know how email attachments are handled on a iPad, you need to ask that in the iPad forums.

  • Second Monitor with new iMac

    I'm confused.  I'm getting various answers in 'searching' what I need to know.
    I just bought a new iMac... very happy.  BUT... how does a second monitor connnect to a 'thunderbolt' only iMac.
    I read, "Thunderbolt accepts DVI"... then I read no, "You need the adapter".
    I also read... a DVI is on the new iMacs... but I can't see one.  I've looked at the jpg's.  I've read that a DVI and Thunderbolt connection is one and the same... as far as the physical characteristics of the input -  insinuating that a DVI, mini, will work with Thunderbolt... true?
    Also...
    Firewire to USB.  Confused here as well.  "Apple sells one"... that's one response. Also:  "They're available, don't always work".  My camcorder only has Fireware. 
    Hoping to hear some 'definitive' answers, if any exist. - JamesJM

    Your kind of Stuck. You will need a TB to DVI adapter and a TB to FW adapter. Apple sells both of those and I think the newest iMac's have 2 TB ports. So you will be using both for your 2 devices.

  • How to set up dual monitors with a Mac Mini

    The Mac Mini has only one video output port. I very nearly didn't buy a Mac Mini system because I need to work with two monitors. I use the second monitor to display information in Web pages, PDFs, and Word documents while I am working in the main window.
    However, I discovered after quite a bit of Googling that it is possible to set up dual monitors using an inexpensive USB video adapter (about $70).
    So I bought my Mini (1.83Ghz, 2GB RAM, 200GB 7200rpm Seagate Momentus), and I also bought a USB video adapter called the EVGA Plus.
    I've installed this system and used it now for a week, and I am quite pleased with it. So I thought I'd pass this information along to anyone who's interested. Please note that, although this is my first post to this forum, this isn't spam -- I have no financial relationship with any of the companies mentioned here, other than as a customer.
    LINKS
    EVGA Plus:
    http://www.evga.com/articles/409.asp
    Their literature does not mention Mac OS X compatibility. However, the underlying technology is made by Display Link. You can download beta Mac OS X drivers from their site:
    Go to Display Link to download the beta Mac OS support -- see
    http://www.displaylink.com/macbetadrivers.html
    The disk image includes a very well written PDF document that explains the driver's status and limitations.
    PICS
    My Mac Mini setup, with dual monitors:
    http://lh5.ggpht.com/BPfaffenberger/SGV5A7lA2QI/AAAAAAAABMI/CBuR4m3uGRA/IMG_0144 .JPG?imgmax=800
    The EVGA+ USB display unit - a tiny little thing - driven by Mac OS beta drivers from Display Link:
    http://lh3.ggpht.com/BPfaffenberger/SGV49qpHuQI/AAAAAAAABME/b9wo9TZPJdE/IMG_0143 .JPG?imgmax=800
    *MORE INFO*
    A thread at 123macmini.com on the same topic, including another user's experiences and MUCH better pictures:
    http://www.123macmini.com/forums/viewtopic.php?t=19126&postdays=0&postorder=asc& start=0&sid=5a05cb75b90cab5bbc7dfd16b02632c1
    NOTES
    * The DisplayLink driver is beta. It doesn't support 2D or 3D accelerated graphics. You can't use it to display iPhoto slide shows, for example. However, I need to be able to display a Web page, document, or PDF in the second monitor while I am working in the first. I've found this solution to be quite acceptable for this purpose.
    * Several other companies make USB video units that use the same DisplayLink support, so they should work, too. However, they are more expensive -- largely because they're set up to function as port expanders, I believe. The EVGA Plus was the only unit priced under $100 when I did my search.
    * USB does not have very much bandwidth, so you might be surprised that to hear that it's possible to use USB to drive a monitor! You'll find that the display isn't as fast as DVI, but for my purposes, I've found it quite acceptable.
    * The EVGA Plus comes with a terrible USB to mini USB cable that will cause all sorts of display problems. Replace it with the type of cable that is used to hook up digital cameras to a USB port.
    * Once everything is installed, you can use the Displays in System Preferences (or just click the icon on the menu bar) to adjust the second monitor. You can choose display resolutions (depending on your monitor's ability, of course). Rotation works. You can also right-click the second monitor and choose a different background color or graphic.
    Don't expect miracles. Don't go this route if you want to run videos or games in the second monitor. And if you get an EVGA Plus, replace that horrible cable!
    I hope this information is helpful.
    Bryan

    There has been quite a lot of discussion here about driving twin displays with the mini, and more recently about the potential for USB video adapters to facilitate this, particularly in the light of several vendors claiming they have suitable MacOS devices and drivers 'almost ready'.
    The DisplayLink solution seems to be the one most suggested as viable, though it's a pity they have not yet been able to move their drivers from beta - I suspect that puts a few people off. It's therefore good to hear of a real-world experience that should help others decide whether or not to go this route!

  • How to stop my second monitor from dimming (connected on a mbp)?

    Hello
    I have a MBP 13" late 2011, I have a second monitor connected to it (LG 24EN43VS), and it doesn't stop from dimming. For me it seems that as soon as I have movements in the second screen it dims, then come back full brightness, but it's annoying I feel like having a stroboscope lol.
    Thanks for helping.
    PS: I even did a fresh install of Yosemite + Reset SMC & RPAM

    I would also very much like to know this.Multiscreen as default is less convenient for me. Please advice on how to disable this M

  • Blurry picture on second monitor with MB Pro 13"

    My wife has a brand new MB Pro 13". When we attach an external monitor to it (with a digital DVI cable), we have the following problem: When the computer's lid is closed, everything is fine, the picture is crisp. However, when we open the lid and both displays are turned on, the picture on the second monitor gets slightly blurred.
    When I do the same setup with my 15" MB Pro, both computers have a crisp picture.

    A blurry picture means that the resolution is incorrect. Go to the Display preference pane and make sure that the two monitors have the native resolution set properly. If the two monitors have different native resolutions, one will always be blurry in mirrored mode. If the displays are not mirrored, it's possible that one will reset to the wrong resolution on opening/closing the lid.

Maybe you are looking for

  • Converting Date Column to format MM/DD/YYYY in RPD

    Hi all, I have a requirement like converting a Date column to format MM/DD/YYYY in RPD. Any help as we are not supposed to use the BI Answers Data Fomat for showing this format. Thankyou, Edited by: [email protected] on May 10, 2010 11:49 PM

  • Reinstalling from backup - Windows

    My hard drive was replaced, but I had a backup so I copied the adobe files from the following folders: Program files, Program files 86X, Users (desktop). I can see the files there, including the installation instructions and my reciept from adobe wit

  • CRM complaints with item details

    Hi all, We currently use the basic complaints extraction from CRM and that's working fine. Now we would like to report on a more detailed level for complaints, showing the item details for the complaint. Basicly the analysis tab in the item details s

  • XPS error when configuring microblaze

    Hi, I am working in spartan 6 XC6SLX45. I want to configure microblaze in it and is using xilinx XPS for same. But I am getting following error and duont know to solve it . Kindly make some suggestions. EDK:3900 - issued from TCL procedure "check_err

  • Safari 5 load fails, then you refresh and it works!

    Ummm... Im pretty descriptive in my title. I click on a link or TopSite and the progress bar will just freeze. After some time it would bring up the error page, and then, if I refresh it it will load it with no problem (really fast by the way, safari