117.C language realization Desktop output picture, desktop output text, desktop draw line

Source: Internet
Author: User
Tags drawtext set background

By getting the window handle, then getting the window DC, and then drawing

1#include <Windows.h>2#include <stdio.h>3 4 //Desktop Drawing Line5 voidDrawLine ()6 {7     //get the console window8     //hwnd hwnd = Getconsolewindow ();9     //Get OutputTen     //HDC hdc = GetDC (hwnd); One     //Get Desktop Window AHWND hwnd =GetDesktopWindow (); -     //Get Output -HDC HDC =GETWINDOWDC (HWND); theHpen Hpen = CreatePen (Ps_solid,2, RGB (255,255,255)); -SelectObject (hdc, hpen);//Select Pen -      while(1) -     { +LineTo (HDC,Ten,Ten); -Sleep ( -); +LineTo (HDC, -, -); ASleep ( -); atLineTo (HDC, -, -); -Sleep ( -); -LineTo (HDC, -, -); -Sleep ( -); -LineTo (HDC, the, -); -Sleep ( -); inLineTo (HDC, the, the); -     } to      +  -System"Pause"); the } *  $ //display pictures on the desktop or consolePanax Notoginseng voiddrawpic () - { the     //get the console window +     //hwnd hwnd = Getconsolewindow (); A     //Get Output the     //HDC hdc = GetDC (hwnd); +     //Get Desktop Window -HWND hwnd =GetDesktopWindow (); $     //Get Output $HDC HDC =GETWINDOWDC (HWND); -Hbrush brush = CreateSolidBrush (RGB (255,0,0)); -SelectObject (hdc, brush);//Select Pen the      while(1) -     {WuyiRectangle (HDC, -, -, -, -); theSleep ( -); -     } WuSystem"Pause"); -  About } $  - //Desktop Output Text - voidDrawText () - { AHWND hwnd =GetDesktopWindow (); +HDC HDC =GETWINDOWDC (HWND); theSetTextColor (HDC, RGB (0,0,255)); -     //Set Background $SetBkColor (HDC, RGB (255,0,0)); the  the      while(1) the     { the Hfont Hfont, hfontold; -Hfont =Createfonta ( in              the, the              $, the             0, About             0, the Fw_regular, the FALSE, the FALSE, + FALSE, - Gb2312_charset, the Out_default_precis,Bayi Clip_default_precis, the proof_quality, theFixed_pitch |Ff_modern, -             "Official Script" -         ); the          the         //Select Font theHfontold =SelectObject (hdc, hfont); the         //output text in area -         /*RECT Rctext; the rctext.left = ten; the rctext.top = ten; the rctext.right = n;94 rctext.bottom = n; the Drawtexta (hdc, "Desktop text output test", strlen ("Desktop text output test"), &rctext, dt_center);*/ theTextouta (HDC,0,0,"Desktop text output test", strlen ("Desktop text output test")); the SelectObject (hdc, hfontold);98Sleep ( -); About     } - }101 102 voidMain ()103 {104     //drawpic (); the     //drawLine ();106 DrawText ();107System"Pause");108}

117.C language realization Desktop output picture, desktop output text, desktop draw line

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.