일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 28 | 29 | 30 | 31 |
Tags
- TensorFlow
- findContours
- 완전탐색
- #1일1영어
- 이미지 생성
- 영어
- #opencv
- Convolution Neural Network
- c언어
- 딥러닝
- #프로젝트
- python list
- #일상영어
- #English
- keras
- 영어명언
- opencv SURF
- #실생활 영어
- tensorflow update
- tokenizing
- python __init__
- object detection
- text2img
- #영어 명언
- python 알고리즘
- #Android
- #영어
- word embedding
- convexhull
- #실생활영어
Archives
- Today
- Total
When will you grow up?
[Win32 API] 오른쪽버튼 누르면 좌표값 나오기 본문
화면 위에처럼 이런식으로 나오네요^~^
아래는 소스코드
// //////////////////////////////////////////////////////////////////////////////// #pragma warning( disable : 4996) #include#include #include #include char m_sCls[128] ; HINSTANCE m_hInst = NULL; HWND m_hWnd = NULL; DWORD m_dWinStyle = WS_OVERLAPPEDWINDOW| WS_VISIBLE; DWORD m_dScnX = 800; // Screen Width DWORD m_dScnY = 600; // Screen Height BOOL m_bShowCusor= TRUE; // Show Cusor //Window+Device관련 함수들 INT Create(HINSTANCE hInst); INT Run(); void Cleanup(); LRESULT MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); LRESULT WINAPI WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); class NODE { public: int x,y; NODE* next; public: NODE(int _x=0,int _y=0) { x=_x; y=_y; this->next=NULL; } void AddNode(int _x,int _y) { this->next = new NODE(_x,_y); } }; NODE Head; NODE* Tail=&Head; INT Create( HINSTANCE hInst) { m_hInst = hInst; strcpy(m_sCls, "D3D Tutorial"); WNDCLASS wc = // Register the window class { CS_CLASSDC , WndProc , 0L , 0L , m_hInst , NULL , LoadCursor(NULL,IDC_ARROW) , (HBRUSH)GetStockObject(WHITE_BRUSH) , NULL , m_sCls }; RegisterClass( &wc ); RECT rc; //Create the application's window SetRect( &rc, 0, 0, m_dScnX, m_dScnY); AdjustWindowRect( &rc, m_dWinStyle, FALSE ); int iScnSysW = ::GetSystemMetrics(SM_CXSCREEN); int iScnSysH = ::GetSystemMetrics(SM_CYSCREEN); m_hWnd = CreateWindow( m_sCls , m_sCls , m_dWinStyle , (iScnSysW - (rc.right - rc.left))/2 , (iScnSysH - (rc.bottom - rc.top))/2 , (rc.right - rc.left) , (rc.bottom - rc.top) , GetDesktopWindow() , NULL , m_hInst , NULL ); ShowWindow( m_hWnd, SW_SHOW ); UpdateWindow( m_hWnd ); ::ShowCursor(m_bShowCusor); //////////////////////////////////////////////////////////////////////////// // // 여기에 DX를 초기화 할 것임 // //////////////////////////////////////////////////////////////////////////// return 0; } void Cleanup() { //////////////////////////////////////////////////////////////////////////// // // 게임 데이터 + DX 해제 // //////////////////////////////////////////////////////////////////////////// } LRESULT MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch( msg ) { case WM_PAINT: { HDC hdc; PAINTSTRUCT ps; NODE* temp=Head.next; char* Message="Beautiful Korea"; char RMessage[100]; hdc=BeginPaint(hWnd,&ps); TextOut(hdc,100,100,Message,strlen(Message)); while(temp!=NULL) { sprintf(RMessage,"Right Button is down at %d, %d",(int)temp->x,(int)temp->y); TextOut(hdc,temp->x,temp->y,RMessage,strlen(RMessage)); temp=temp->next; } EndPaint(hWnd,&ps); } break; case WM_RBUTTONDOWN: { Tail->AddNode(LOWORD(lParam),HIWORD(lParam)); Tail=Tail->next; InvalidateRect(hWnd,NULL,true); } break; case WM_KEYDOWN: { switch(wParam) { case VK_ESCAPE: { SendMessage(hWnd, WM_DESTROY, 0,0); break; } } return 0; } case WM_DESTROY: { Cleanup(); PostQuitMessage( 0 ); NODE* del=Head.next; NODE* temp=del->next; while(del!=Tail) { delete del; del=temp; temp=del->next; } return 0; } } return DefWindowProc( hWnd, msg, wParam, lParam ); } INT Run() { // Enter the message loop MSG msg; memset( &msg, 0, sizeof(msg) ); while( msg.message!=WM_QUIT ) { if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else { //////////////////////////////////////////////////////////////////// // // 게임 루프 // //////////////////////////////////////////////////////////////////// } } UnregisterClass( m_sCls, m_hInst); return 0; }
'02. Study > API' 카테고리의 다른 글
BardAPI를 이용한 ChatBot 만들기 (0) | 2023.06.01 |
---|---|
[Win32 API] GetMessage() , PeekMessage() (0) | 2016.03.17 |
Comments