How can i capture screenshot and assign to a static control? Winapi

I am trying to capture a screen and assign it to some sort of control so I can click the picture and retrieve the coordinates at which the picture was clicked. How would I go about doing this? Im trying to assign a bitmap to a static control, and when the user clicks on the image, i retrieve mouse coordinates and subtract the offsetted borders. Im using a static control since it has SS_Notify.

But here the picture isnt even to be able to be displayed on the frame? What would i do to fix this code?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
          static HDC handle_MemoryDC;
    static HDC handle_ScreenDC;
    //BITMAP bitmap;
    static HBITMAP handle_Bitmap;
    static int x, y;


    case WM_CREATE:{

    CreateWindowEx(NULL, "STATIC", "", SS_BITMAP|WS_VISIBLE|WS_CHILD, 500,300, 640 ,360 , hwnd, HMENU(IDCSTATIC_BITMAP), GetModuleHandle(NULL), NULL);

    handle_ScreenDC = GetDC(NULL);
    handle_MemoryDC = CreateCompatibleDC(handle_ScreenDC);



     x = GetDeviceCaps(handle_ScreenDC, HORZRES);
     y = GetDeviceCaps(handle_ScreenDC, VERTRES);

    handle_Bitmap = CreateCompatibleBitmap(handle_ScreenDC, 640, 360);

    SelectObject(handle_MemoryDC, handle_Bitmap);
    StretchBlt(handle_MemoryDC, 0, 0, 640, 360, handle_ScreenDC, 0, 0, x, y, SRCCOPY);



    SendDlgItemMessage(hwnd, IDCSTATIC_BITMAP, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)handle_Bitmap);
Topic archived. No new replies allowed.