0x05 Programming/API / MFC
-
[MFC] 다른클래스에서 메인 다이얼로그의 포인터 얻어오기 (dialog based)0x05 Programming/API / MFC 2010. 10. 11. 21:59
다이얼로그 기반의 프로젝트로 작업을 하다보면 사용자가 임의로 여러가지 클래스들을 만들어 사용하는 경우가 있다. 일반적으로 프로젝트를 생성하던가 CView, CFormView등의 MFC에 정의되있는 클래스의 상속을 받아서 만들든 다양한 형태의 클래스가 만들어 질 것이다. 보통 사용자가 만든 클래스들은 메인 다이얼로그 클래스에 헤더파일을 인클루드하고 인스턴스로 만들어져 사용이 될텐데 경우에 따라 사용자가 만든 클래스에서 메인 다이얼로그의 변수나 함수들을 사용해야 할 경우가 생기게 된다. 이런 경우 메인 다이얼로그의 포인터를 얻는 방법에는 다음의 두 가지가 있다. 메인 다이얼로그 클래스 : CMainDlg 임의로 생성된 클래스 : CChild 라고 했을 때, 1. CMainDlg.h를 인클루드하고 다음과 같이..
-
[API] 11.13 수업0x05 Programming/API / MFC 2009. 11. 13. 11:48
#include "StdAfx.h" #include "my.h" #include "resource.h" #pragma comment(lib,"Msimg32.lib") HDC g_BackDC; HBITMAP g_BackBitmap; HDC g_BgDC; HBITMAP g_BgBitmap; HDC g_MyDC; HBITMAP g_MyBitmap; extern HINSTANCE hInst; int g_x = 100; int g_y = 100; int g_frame = 0 ; int g_time = 0; void MyIni(HWND hWnd, WPARAM wParam, LPARAM lParam) { HDC hdc; hdc = GetDC(hWnd); g_BackDC = CreateCompatibleDC(hdc);..
-
[API] 비트맵 적용 숫자퍼즐0x05 Programming/API / MFC 2009. 11. 2. 17:47
#include #include "resource.h" //비트맵을 사용할 수 있게 해주는 핸들 extern HINSTANCE hInst;//해당 hInst변수를 연결 HBITMAP g_hMyBitmap;//리소스 연결 HDC g_hMyDC;//dc에 연결 (이걸로 화면 출력ㅇㅇ) int g_data[3][3]= { {1,2,3}, {4,5,6}, {7,8,9} }; void MyIni(HWND hWnd, WPARAM wParam, LPARAM lParam) { HDC hdc; hdc = GetDC(hWnd);//화면제어권 획득 g_hMyDC = CreateCompatibleDC(hdc); //DC(제어권)에 호환되는 것을 만든다 //리소스에 있는 비트맵을 로드 g_hMyBitmap = LoadBitma..
-
[API] 늑대의 침공 기본형0x05 Programming/API / MFC 2009. 10. 30. 11:45
#include "stdafx.h" #include #include #include "my.h" #define MAX_LAMB_COUNT 10 struct S_MY { int x; int y; int w; int h; int life; char name[10]; }; S_MY g_lamb[MAX_LAMB_COUNT]; S_MY g_wolf = {100,100,20,20,10,"wolf"}; int g_score = 0; void MyIni(HWND hWnd, WPARAM wParam, LPARAM lParam) { int i; srand(time(NULL)); for(i=0;i
-
[API]늑대의 침공 가상키보드 적용 [미완성]0x05 Programming/API / MFC 2009. 10. 27. 10:31
#include "StdAfx.h" #include "my.h" #include #include #define U_LAMB_COUNT 20 #define U_WOLF_COUNT 2 #define U_W1_LEFT VK_LEFT #define U_W1_RIGHTVK_RIGHT #define U_W1_UPVK_UP #define U_W1_DOWNVK_DOWN #define U_W2_LEFT 65 #define U_W2_RIGHT 68 #define U_W2_UP 87 #define U_W2_DOWN 83 struct S_MY { int x; int y; int w; int h; int life; char name[10]; }; S_MY g_lamb[U_LAMB_COUNT]; S_MY g_wolf[U_WOLF..
-
[API]산성비 응용0x05 Programming/API / MFC 2009. 9. 29. 01:38
#include "stdafx.h" #include "my.h" char g_words[5][20]={"wParam","lParam","hdc","hWnd","test"}; int g_windex=0; char g_rain[20]; int g_xpos=0; int g_ypos=0; char g_key[20]; int g_kindex=0; int g_score=0; int GetNextWord() { if(g_windex < 5) { strcpy(g_rain,g_words[g_windex]); g_windex= rand()%5-1; g_xpos = rand()%500; g_ypos = 0; return 0; } return -1; } void MyIni(HWND hWnd, WPARAM wParam, LPA..
-
[API] 09월 25일 수업내용0x05 Programming/API / MFC 2009. 9. 25. 10:23
///////////////// 09월 25일 API 수업내용 ///////////////// 헤더를 따로 나누는방법 헤더파일을 하나 추가해주고 따로 cpp 파일을 추가한다. 헤더파일에는 함수의 원형을 선언해주고 cpp 파일에는 함수의 바디를 써준다. 그리고 WndProc 맨 위부분에 #include "My.h" 이런식으로 추가해주면 된다. 키제어방법 키를 누를때 메세지가 3개 온다. WM_KEYDOWN // 위치에 중심을 둔 메세지 WM_CHAR // 값에 중점을 둔 메세지 WM_KEYUP // 위치에 중심을 둔 메세지 #include "stdafx.h" #include "my.h" /////////////////////////////////////////// /* 간단한 산성비 게임 예제 */ /* ..
-
[API] 숫자퍼즐 게임체크 & 시간 & 스텝 구현0x05 Programming/API / MFC 2009. 9. 12. 14:15
#include "stdafx.h" #include #define OK 0 #define NO -1 #define LEVEL 10 int g_data[3][3]={ {1,2,3}, {4,5,6}, {7,8,9} }; int g_step = 0; int g_time = 0; int CanMove(int sx, int sy, int dx, int dy) { if(sx < 0 || sy < 0 || dx < 0 || dy < 0) { return NO; } if(2 < sx || 2 < sy || 2 < dx || 2 < dy) { return NO; } if(9 == g_data[dy][dx]) { g_data[dy][dx] = g_data[sy][sx]; g_data[sy][sx] = 9; return O..