티스토리 뷰




prjCapture.exe

#define WINVER 0x0500 
#include <windows.h> 

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); 
HINSTANCE g_hInst; 
HWND hWndMain; 
LPCTSTR lpszClass=TEXT("Capture"); 

int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance ,LPSTR lpszCmdParam,int nCmdShow) { 
    HWND hWnd; 
    MSG Message; 
    WNDCLASS WndClass; 
    g_hInst=hInstance; 

    WndClass.cbClsExtra=0; 
    WndClass.cbWndExtra=0; 
    WndClass.hbrBackground=(HBRUSH)(COLOR_WINDOW+1); 
    WndClass.hCursor=LoadCursor(NULL,IDC_ARROW); 
    WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION); 
    WndClass.hInstance=hInstance; 
    WndClass.lpfnWndProc=WndProc; 
    WndClass.lpszClassName=lpszClass; 
    WndClass.lpszMenuName=NULL; 
    WndClass.style=CS_HREDRAW | CS_VREDRAW; 
    RegisterClass(&WndClass); 

    hWnd=CreateWindow(lpszClass,lpszClass,WS_OVERLAPPEDWINDOW, 
        CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, 
        NULL,(HMENU)NULL,hInstance,NULL); 
    ShowWindow(hWnd,nCmdShow); 

    while (GetMessage(&Message,NULL,0,0)) { 
        TranslateMessage(&Message); 
        DispatchMessage(&Message); 
    } 
    return (int)Message.wParam;
} 

int y; 
BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
    TCHAR sInfo[256]; 
    MONITORINFOEX mi; 

    mi.cbSize = sizeof(MONITORINFOEX); 
    GetMonitorInfo(hMonitor, &mi); 
    wsprintf(sInfo, TEXT("모니터 핸들 = %x, 좌표=(%d,%d)-(%d,%d) %s"), hMonitor, lprcMonitor->left, lprcMonitor->top, lprcMonitor->right, lprcMonitor->bottom, (mi.dwFlags & MONITORINFOF_PRIMARY)==0 ? TEXT(""):TEXT(":주 모니터")); 

TextOut((HDC) dwData, 10, y, sInfo, lstrlen(sInfo)); y+=20; return TRUE; } LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; TCHAR Mes[256]; int cMon; RECT rcVirt; switch (iMessage) { case WM_CREATE: hWndMain=hWnd; return 0; case WM_DISPLAYCHANGE: InvalidateRect(hWnd, NULL, TRUE); UpdateWindow(hWnd); return 0; case WM_PAINT: hdc=BeginPaint(hWnd, &ps); cMon = GetSystemMetrics(SM_CMONITORS); if (cMon == 0) { // Win 95/NT 에서는 다중 모니터를 지원하지 않아 0으로 Return한다. lstrcpy(Mes, TEXT("다중 모니터를 지원하지 않는 시스템입니다.")); TextOut(hdc, 10, 10, Mes, lstrlen(Mes)); } else { // 모니터 갯수와 색상 포멧이 모두 동일한지 출력한다. wsprintf(Mes, TEXT("모니터 개수 = %d, 색상 포멧=%s"), cMon, GetSystemMetrics(SM_SAMEDISPLAYFORMAT) ? TEXT("모두 동일"):TEXT("다름")); TextOut(hdc, 10, 10, Mes, lstrlen(Mes)); // 가상 모니터의 좌표를 출력한다. rcVirt.left = GetSystemMetrics(SM_XVIRTUALSCREEN); rcVirt.top = GetSystemMetrics(SM_YVIRTUALSCREEN); rcVirt.right = GetSystemMetrics(SM_CXVIRTUALSCREEN); rcVirt.bottom = GetSystemMetrics(SM_CYVIRTUALSCREEN); wsprintf(Mes, TEXT("가상 화면=(%d,%d)-(%d,%d)"), rcVirt.left, rcVirt.top, rcVirt.right, rcVirt.bottom); TextOut(hdc, 10, 30, Mes, lstrlen(Mes)); // 다중 모니터에 대한 정보를 출력한다. y = 50; EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM) hdc); } EndPaint(hWnd, &ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return(DefWindowProc(hWnd,iMessage,wParam,lParam)); }

댓글

파트너스 활동을 통해 일정액의 수수료를 제공받을 수 있음



Total
Today
Yesterday
최근에 달린 댓글