yangakw yangakw

c++ 显示图片【隐藏鼠标】

in 记录read (52) 文章转载请注明来源!
    #include <stdlib.h>
    #include <conio.h>
    #include <windows.h>
    #include <atlimage.h>


    HWND WINAPI GetConsoleWindow();
    void HideTheCursor() {
        CONSOLE_CURSOR_INFO cciCursor;
        HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
        if (GetConsoleCursorInfo(hStdOut, &cciCursor)) {
            cciCursor.bVisible = FALSE;
            SetConsoleCursorInfo(hStdOut, &cciCursor);
        }
    }
    void ShowTheCursor() {
        CONSOLE_CURSOR_INFO cciCursor;
        HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
        if (GetConsoleCursorInfo(hStdOut, &cciCursor)) {
            cciCursor.bVisible = TRUE;
            SetConsoleCursorInfo(hStdOut, &cciCursor);
        }
    }
    int main() {
        HWND  hwnd;
        HDC   hdc;
        HFONT hfont;
        HBITMAP hbm;
        HDC hdcBits;
        BITMAP bm;
    CImage Image;


        system("color F0");
        system("cls");
        HideTheCursor();
        hwnd  = GetConsoleWindow();
        hdc   = GetDC(hwnd);


    Image.Load(L"1.jpg");
    hbm=Image.Detach();


    //hbm=LoadImage(0,"C:\\Windows\\1.jpg",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
        if (hbm) {
            hdcBits = CreateCompatibleDC(hdc);
            GetObject (hbm, sizeof(BITMAP), &bm);
            SelectObject(hdcBits,hbm);
            BitBlt(hdc,20,10,bm.bmWidth, bm.bmHeight,hdcBits,0,0,SRCCOPY);
    BitBlt(hdc,20,10,bm.bmWidth, bm.bmHeight,hdcBits,0,0,SRCCOPY);
            DeleteDC(hdcBits);
            DeleteObject(hbm);
        }
        hfont = CreateFont(24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L"华文楷体");
        SelectObject(hdc,hfont);
        SetTextColor(hdc,RGB(255,255,255));
        SetBkMode(hdc,TRANSPARENT);
        TextOut(hdc,210,30,L"这个背景是泡泡",14);
        DeleteObject(hfont);
        ReleaseDC(hwnd,hdc);
        getch();
        system("color 07");
        system("cls");
        ShowTheCursor();
        return 0;
    }
jrotty WeChat Pay

微信打赏

jrotty Alipay

支付宝打赏

文章二维码

扫描二维码,在手机上阅读!

发表新评论
博客已运行
© 2018 yangakw
PREVIOUS NEXT
雷姆
拉姆