[MFC] GDI( Graphics Device Interface )

DC( Device Context )
GDI is supported by Windows OS to process the problem from compatibility with new Graphic Cards. If u use GDI, u don't need to care about a kind of devices.
Create DC to choose a device which u r going to use. After creating DC, GDI returns the handler of the DC. Then, u are able to use the device via the handler. U must release DC, after using the DC. Or else, Memory Leak occurs.

MFC DC( Device Context )
The below illustration is MFC Class Table.

CObject--
              |-- CDC
                 |-- CClientDC
                 |-- CMetaFileDC
                 |-- CPaintDC
                 |-- CWindowDC

1) CDC Class
CDC Class is the base class of other DC classes. In MFC Application, CWnd::GetDC Func returns CDC class pointer. After painting via the CDC pointer, u must release the DC using CWnd::ReleaseDC Func.

2) CWindowDC Class
It's for the entire region of Window. It contains Caption Bar, Menu Bar, Tool Bar, State Bar and so on... ,and besides Client region, that is, the entire region of Window.
GetWindowDC Func returns DC and ReleaseDC Func releases DC.

3) CClientDC Class
It's for client region in a Window. ClientDC Func returns DC and ReleaseDC FUnc releases DC or U could use delete with the pointer for DC.
ex ) CClientDC* pClientDC = new CClientDC( this );
       delete pClientDC;

4) CPaintDC Class
It's used in OnPaint Member Func which is WM_PAINT Message handler Func, when a window is being redrawed by WM_PAINT message. CPaintDC dc(this)  Func gets a pointer of Paint DC.

5) CMetaFileDC Class
It manages DC which are related with MetaFile( WMF, EMF ). MetaFile is a file of a group of GDI commands.

'Programming > Windows Programming' 카테고리의 다른 글

라디오 버튼 그룹지정 하기  (0) 2009.08.22
IP HELP API 설정하기  (0) 2009.08.22
[MFC] 더블 버퍼링  (0) 2009.06.22
[MFC] Bitmap Object  (0) 2009.06.07
[MFC] FileOpen  (0) 2009.06.04

설정

트랙백

댓글

[MFC] FileOpen

1. 이 두 파일을 프로젝트에 추가한다. "MyFileDialog.cpp", "MyFileDialog.h"

2. 파일 열기 때 사용할 다이얼로그를 하나 만들고 옵션을 수정한다.
    -> Clip Siblings : True, Style : Child, Control : True, System Menu : False
   그리고, 창의 길이를 옆으로 늘인다( 실제 파일 오픈 할 때 열리는 다이얼로그 보다 크게... 그렇지 않으면 이 다이얼로그의 테두리가 파일 열기 다이얼로그에 보이게 된다).

3. 리소스에 메뉴를 추가하고, 이벤트 핸들러를 추가한다.
    -> Message Type : COMMAND,  Function Handler Name : OnFileOpen, Class List : 이벤트 핸들러를 추가할 다이얼로그.( A Dialog )

4. A Dialog 의 옵션에 있는 Menu 에 이 새로 만든 Menu를 등록시킨다.

5. 메뉴 이벤트 핸들러에 아래의 소스를 붙여 넣고 수정하여 사용한다.

멀티바이트 용

char szFilter[] = "Text File|*.txt|All Files (*.*)|*.*||";
 CMyFileDialog Dlg( TRUE, "txt", NULL, NULL, szFilter );
 Dlg.m_ofn.lpstrTitle = "KnapsackProblem : Open File";
 if( Dlg.DoModal() == IDOK )
 {
 
 }

유니코드 용
CString szFilter = _T( "HTML 파일|*.htm|All Files (*.*)|*.*||" );
 CMyFileDialog Dlg( TRUE, (LPCTSTR)("txt"), NULL, NULL, szFilter );
 Dlg.m_ofn.lpstrTitle = _T("파일 열기");
 if( Dlg.DoModal() == IDOK )
 {

'Programming > Windows Programming' 카테고리의 다른 글

라디오 버튼 그룹지정 하기  (0) 2009.08.22
IP HELP API 설정하기  (0) 2009.08.22
[MFC] 더블 버퍼링  (0) 2009.06.22
[MFC] Bitmap Object  (0) 2009.06.07
[MFC] GDI( Graphics Device Interface )  (0) 2009.06.07

설정

트랙백

댓글

Static Member

Programming/C++ Language 2009. 5. 31. 22:59
Static Data Member has Class Scope. Static Member could be defined as Public, Protected, Private. It must to be defined once in File Scope, such as "CGameUnit* CGameUnit::aUserUnit[2] = {NULL, NULL};". Because If you don't, Compiler makes "error LNK2001", "fatal error LNK1120: 1개의 확인할 수 없는 외부 참조입니다.", "외부 기호를 확인할 수 없습니다.".
The case of Public static, U can use this with Binary Scope resolution operator( :: ) and a name of Class, such as "Martian::martiancount".
The case of Private or Protected static, Public static Member function must be exist. This Public Static Function must be called with a name of Class and "::".

When it's inherited, If it's Public or Protected, U could use it w/out Public Static Function in inherited Class. Buf if it's Private, U must use it via Public Static Function in inherited Class.


'Programming > C++ Language' 카테고리의 다른 글

namespace  (0) 2010.03.19
연산자 오버로딩  (0) 2009.09.30
순수 가상 함수  (0) 2009.09.26
가상 함수의 활용  (0) 2009.09.25
가상 함수에 대한 이해  (0) 2009.09.25

설정

트랙백

댓글

하드 디스크 드라이버 ( Hard Disk Driver )

Programming/OS Development 2009. 5. 29. 23:38
Hard Disk Driver is the program to control Hard Disk.



As the upper picture, Hard Disk is consist of "Platter". Platters' circle is called "Track". The invariable part of Track is called Sector. This is the smallest unit of Writting in Disk which is usually 512 Bytes.
There are two modes to access Hard Disk. The first one is called "CSH Mode", the another one is called "LBA Mode( Logical Block Address )".
The former one has the limitation of capacity( 528 MB ). Controlling Hard Disk using Sector 6-bit, Head 4-bit, Track 10-bit and one sector is 512-byte. Therefore, The max capacity which is capable of being controlled is 528MB( = 2^20 * 512-byte ). But the latter one is not. It sees Hard Disk as a group of linear sector. it could be controlled as long as knowing the total number of sector of Hard Disk.

'Programming > OS Development' 카테고리의 다른 글

NASM - 2  (0) 2009.06.29
VGA 관련  (0) 2009.06.19
OS 제작의 원리 그리고 Codes - Ch 6. Memory Management  (1) 2009.05.19
메모리 주소별 용량.  (0) 2009.05.15
어셈블러에서 16진수 입력  (0) 2009.05.15

설정

트랙백

댓글

OS 개발 - 4월 5째주 ( 26 ~ 30 )

etc/Work Diary 2009. 5. 28. 18:40
만들면서 배우는 OS 커널의 구조와 원리

Boot Strap
Kernel Load
Protected Mode 전환
   GDT
Interrupt & Exception
  IDT, PIC, Timer Int, KeyBoard Int, Exception

'etc > Work Diary' 카테고리의 다른 글

OS 개발 - 5월 3째주 ( 18 ~ 24 )  (0) 2009.05.28
OS 개발 - 5월 2째주 ( 11 ~ 17 )  (0) 2009.05.28
OS 개발 - 5월 1째주 작업일지 ( 1 ~ 10 )  (0) 2009.05.28

설정

트랙백

댓글

OS 개발 - 5월 3째주 ( 18 ~ 24 )

etc/Work Diary 2009. 5. 28. 18:37
"OS 제작의 원리 그리고 Codes" 책 공부

Memory Management
  Paging의 장점, 기능 활성화, Paging시에 사용 되는 Page Directory, Page Table
  물리 메모리 크기 구하기
  Buddy Algorithm
    Physical Memory Management Table( Free Memory Block을 관리하기 위한 Table )
    Memory Pool, Memory Block, Shared Memory.

'etc > Work Diary' 카테고리의 다른 글

OS 개발 - 4월 5째주 ( 26 ~ 30 )  (0) 2009.05.28
OS 개발 - 5월 2째주 ( 11 ~ 17 )  (0) 2009.05.28
OS 개발 - 5월 1째주 작업일지 ( 1 ~ 10 )  (0) 2009.05.28

설정

트랙백

댓글

OS 개발 - 5월 2째주 ( 11 ~ 17 )

etc/Work Diary 2009. 5. 28. 18:34
"만들면서 배우는 OS 커널의 구조와 원리" 책 공부

A20 Gate Setting, Paging

"OS 제작의 원리 그리고 Codes" 책 공부

Kernel Image 공부, Boot Image, Boot Loader, PE 파일

'etc > Work Diary' 카테고리의 다른 글

OS 개발 - 4월 5째주 ( 26 ~ 30 )  (0) 2009.05.28
OS 개발 - 5월 3째주 ( 18 ~ 24 )  (0) 2009.05.28
OS 개발 - 5월 1째주 작업일지 ( 1 ~ 10 )  (0) 2009.05.28

설정

트랙백

댓글

OS 개발 - 5월 1째주 작업일지 ( 1 ~ 10 )

etc/Work Diary 2009. 5. 28. 18:30
"만들면서 배우는 OS 커널의 구조와 원리" 책 공부
Task Switching
  TSS 설정, CALL, JMP에 의한 Task Switching
UserMode Task Switching
  User Mode Segment 설정, Call Gate 설정, User Mode 로의 Task Switching
  Call Gate를 사용한 System Call, 여러개의 User Mode Task 실행,
  스택 영역을 사용한 Task Switching 수행

'etc > Work Diary' 카테고리의 다른 글

OS 개발 - 4월 5째주 ( 26 ~ 30 )  (0) 2009.05.28
OS 개발 - 5월 3째주 ( 18 ~ 24 )  (0) 2009.05.28
OS 개발 - 5월 2째주 ( 11 ~ 17 )  (0) 2009.05.28

설정

트랙백

댓글

[Computer Tip] 네이버 카페 가입시 익스프로러에 오류 뜨는 현상.

etc 2009. 5. 23. 09:31
익스프로러의 도구->인터넷 옵션 에서 보안 탭 클릭

사용자 지정 수준 버튼을 클릭 하고, 아래의 화면 처럼 하위 프레임 탐색, 데이터 소스 엑세스 를 사용 으로 체크해 줍니다.

그리고 확인을 누르고, 익스프로러를 닫고 다시 시작해 주면 카페 가입이 정상적으로 됩니다.

'etc' 카테고리의 다른 글

티스토리 마우스 오른쪽 방지  (0) 2009.09.23
사랑, 결혼에 대한 명언들  (0) 2009.09.21
신발 세탁법!  (0) 2009.09.04

설정

트랙백

댓글

OS 제작의 원리 그리고 Codes - Ch 6. Memory Management

Programming/OS Development 2009. 5. 19. 02:29

To calculate the size of physical memory

We could calculate in a simple way to check data. Writting data from the certain address then read it. Comparing that two data. If it's the same, there is memory. If not, there is no memory.
 

 // 실메모리의 크기를 구한다.
int nGetPhysMemSize()
{
 int  nI, nSize;
 UCHAR *pX, byTe;;

 // 실메모리의 크기를 구한다.
    
 // 메모리는 512메가부터 2기가 바이트까지 뒤진다.
 for( nSize = nI = 512; nI < 2048; nI++ )
 {
  pX = (UCHAR*)( nI * (ULONG)0x100000 );  //  nl * 1MB
  

  byTe = pX[0];         // The start address of the memory.
  byTe++;                 // Increasing the value of the start address.
  pX[0] = byTe;        // Writting the value on the start address.
  if( byTe != pX[0] )  // Comparing between the increased data and the value of the start address.
   break;                  // If it's not the same, there is no memory on that address.
  else
   nSize++;              // If it's the same, there is memory. Keep calculating.
        
        pX[0] -= 1;     // Restoring to the previous value
 }

 return( nSize * 0x100000 );  // 바이트 단위로 리턴한다.
}



Physical Memory Management Table

Assigning 1byte to save the status of physical memory. It's like Reference Counter.
When it's zero, it's not used and is available. When it's five, five processors are using it by mapping.

Each page has 1024 entries, which is 4 byte. It means 4 KB allocate to each page.
There are 256 pages In 1 MB Memory. That's why needing 256 byte per 1MB.

To save the counter for 1024MB Memory, 1024 * 256 bytes ( 256 KB ) are required.
Putting P.M.M.T right after kernel image. But, it is no matter where you put P.M.M.T.

Caution ) There is the space for ROM BIOS on 0xF0000. You must not write any data on that.

// allocate one physical page
 DWORD dwAllocPhysPage()
{
 int  nI;
 UCHAR *pTbl;

 pTbl = bell.pPhysRefTbl; // Physical Memory Management Table

 // search after 64K
 for( nI = 16; nI < bell.nPhysRefSize; nI++ )
 {
  // if the address is video memory then next search is started at 1.5M( = 0x180000 ) area
  if( nI == ( (int)0xA0000 / 4096 ) ) // Skipping the space of ROM BIOS.
   nI = ( (int)0x180000 / 4096 );

  if( pTbl[nI] == 0 )
  {
   pTbl[nI]++;  // increase counter
   return( (DWORD)( (DWORD)nI * (DWORD)4096 ) );
  }
 }
 return( 0 ); // allocation failed
}


 int nFreePage( DWORD dwPhysAddr )
{
 DWORD dwI;
 UCHAR *pTbl;

 dwI = (DWORD)( dwPhysAddr / (DWORD)4096 );

 pTbl = bell.pPhysRefTbl;
 if( pTbl[dwI] == 0 )
  return( -1 );   // 할당되지 않은 메모리이다.

 pTbl[dwI]--;  // Decreasing the counter value with 1

 return( 1 );
}


'Programming > OS Development' 카테고리의 다른 글

VGA 관련  (0) 2009.06.19
하드 디스크 드라이버 ( Hard Disk Driver )  (0) 2009.05.29
메모리 주소별 용량.  (0) 2009.05.15
어셈블러에서 16진수 입력  (0) 2009.05.15
naked 함수  (0) 2009.05.11

설정

트랙백

댓글