프로그래밍/API 프로그래밍

프로그램 사이드 및 캡션 조절

CokeBell 2008. 10. 17. 21:04


#include <windows.h>
#include <stdio.h>

// 잘 보관해 두세요..
void ModifyStyle( HWND hwnd, UINT remove, UINT add )
{
 // Window Object 에서 기존 style을 얻는다.
 UINT style = GetWindowLong( hwnd, GWL_STYLE);
 style = style & ~remove; // 제거할 스타일
 style = style | add;  // 추가
 // 변경된 style 을 다시 Window Object 에 넣는다.
 SetWindowLong( hwnd, GWL_STYLE, style);

 // style 변경한 경우.. 현재 윈도우를 다시 그리게 한다.
 SetWindowPos( hwnd, 0, 0, 0, 0, 0,
     SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_DRAWFRAME);
}

void main()
{
 HWND hwnd = FindWindow( 0, "계산기");
 if ( hwnd == 0 )
 {
  printf("계산기를 먼저 실행하세요\n");
  return ;
 }
 ModifyStyle( hwnd, WS_CAPTION,  // 캡션바를 제거하고
        WS_THICKFRAME ); // size 조절이 가능하게 한다.
}