▶ 뭉충닷컴
 
mungchung.com login
Site Search
My Space
주절주절...
공부방
쥔장소개
Board
자유게시판
유용한 정보
자료실
Programming
강좌 & Articles
Spring 3.0
프로그래밍 Tip
   -ASP
   -PHP
   -JavaScript
   -HTML
   -Java/JSP
   -Database
   -Crystal Report
   -Visual Basic
   -이클립스
   -리눅스
   -기타
Windows API (VB)
Spread Sheet 7.0
컴퓨터활용 Tip
Other things
StarCraft 전략
StarCraft 문서
김용(金庸)
Son Q & Dieda

폼 제목표시줄(타이틀바)의 최소화, 최대화 버튼을 없애거나 추가하거나 하는 방법이다.

출처 : http://www.andreavb.com/tip050002.html

API Declarations
Option Explicit

Private Declare Function DeleteMenu Lib "user32.dll" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetSystemMenu Lib "user32.dll" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nindex As Long, ByVal dwnewlong As Long) As Long
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nindex As Long) As Long

Public Const MF_BYCOMMAND = &H0&
Public Const MF_BYPOSITION = &H400&
Public Const SC_ARRANGE = &HF110
Public Const SC_CLOSE = &HF060
Public Const SC_HOTKEY = &HF150
Public Const SC_HSCROLL = &HF080
Public Const SC_KEYMENU = &HF100
Public Const SC_MAXIMIZE = &HF030
Public Const SC_MINIMIZE = &HF020
Public Const SC_MOVE = &HF010
Public Const SC_NEXTWINDOW = &HF040
Public Const SC_PREVWINDOW = &HF050
Public Const SC_RESTORE = &HF120
Public Const SC_SIZE = &HF000
Public Const SC_VSCROLL = &HF070
Public Const SC_TASKLIST = &HF130
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const HWND_TOP = 0
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Public Const GWL_STYLE = (-16)

Public Enum T_WindowStyle
    WS_BORDER = &H800000
    WS_CAPTION = &HC00000
    WS_CHILD = &H40000000
    WS_CHILDWINDOW = (WS_CHILD)
    WS_CLIPCHILDREN = &H2000000
    WS_CLIPSIBLINGS = &H4000000
    WS_DISABLED = &H8000000
    WS_DLGFRAME = &H400000
    WS_EX_ACCEPTFILES = &H10&
    WS_EX_DLGMODALFRAME = &H1&
    WS_EX_NOPARENTNOTIFY = &H4&
    WS_EX_TOPMOST = &H8&
    WS_EX_TRANSPARENT = &H20&
    WS_GROUP = &H20000
    WS_HSCROLL = &H100000
    WS_MAXIMIZE = &H1000000
    WS_MAXIMIZEBOX = &H10000
    WS_MINIMIZE = &H20000000
    WS_MINIMIZEBOX = &H20000
    WS_OVERLAPPED = &H0&
    WS_ICONIC = WS_MINIMIZE
    WS_POPUP = &H80000000
    WS_VISIBLE = &H10000000
    WS_VSCROLL = &H200000
    WS_SYSMENU = &H80000
    WS_TABSTOP = &H10000
    WS_THICKFRAME = &H40000
    WS_TILED = WS_OVERLAPPED
    WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or          WS_MAXIMIZEBOX)
    WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)
    WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW
    WS_SIZEBOX = WS_THICKFRAME
End Enum



Module
'Brings the specified form in the top most position, it will be over all other
'forms in the screen, even if they will receive the focus
Public Sub FormTopMost(hWnd As Long)
    SetWindowPos hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE
End Sub

'Brings the form in his standard Z-Order
Public Sub FormNoTopMost(hWnd As Long)
    SetWindowPos hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE
End Sub

'Brings the form in the top position of the Z-Order, if another form takes the
'focus it will become the new top form
Public Sub FormTop(hWnd As Long)
    SetWindowPos hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE
End Sub

'Remove the form's system menu, if RemoveClose is true the Close command inside the
'menu is removed too, in this case even the X key in the right upper cornet of the
'form will be removed
Public Sub RemoveSystemMenu(hWnd As Long, RemoveClose As Boolean)
    Dim hMenu As Long

    hMenu = GetSystemMenu(hWnd, False)
    DeleteMenu hMenu, SC_MAXIMIZE, MF_BYCOMMAND
    DeleteMenu hMenu, SC_MINIMIZE, MF_BYCOMMAND
    DeleteMenu hMenu, SC_SIZE, MF_BYCOMMAND
    DeleteMenu hMenu, SC_MOVE, MF_BYCOMMAND
    DeleteMenu hMenu, SC_RESTORE, MF_BYCOMMAND
    DeleteMenu hMenu, SC_NEXTWINDOW, MF_BYCOMMAND
    If RemoveClose Then
        DeleteMenu hMenu, SC_CLOSE, MF_BYCOMMAND
        DeleteMenu hMenu, 0, MF_BYPOSITION
    End If
End Sub

'Hides the upper right keys Maximize and minimize
Public Sub RemoveMaxMinButtons(hWnd As Long)
    Dim x As Long

    x = GetWindowLong(hWnd, GWL_STYLE)
    x = x And Not WS_MINIMIZEBOX
    x = x And Not WS_MAXIMIZEBOX
    SetWindowLong hWnd, GWL_STYLE, x
End Sub

'Shows the upper right keys Maximize and minimize
Public Sub AddMaxMinButtons(hWnd As Long)
    Dim x As Long

    x = GetWindowLong(hWnd, GWL_STYLE)
    x = x Or WS_MINIMIZEBOX
    x = x Or WS_MAXIMIZEBOX
    SetWindowLong hWnd, GWL_STYLE, x
End Sub

'Set the attribute of a window: the module has a public enum type that contains
'all the constants to define a window style (used by others Subs)
Public Sub SetWindowStyle(hWnd As Long, mAttribute As T_WindowStyle, Enable As Boolean)
    Dim x As Long

    x = GetWindowLong(hWnd, GWL_STYLE)
    If Enable Then
        x = x Or mAttribute
    Else
        x = x And Not mAttribute
    End If
    SetWindowLong hWnd, GWL_STYLE, x
End Sub

문서 첨부 제한 : 0Byte/ 2.00MB
파일 크기 제한 : 2.00MB (허용 확장자 : *.*)
List of Articles
번호 제목 글쓴이 날짜 조회 수
» VB 폼의 제목표시줄 최소화, 최대화버튼 다루기 뭉충닷컴 2009-06-16 14981
65 VB VB의 Choose 함수 뭉충닷컴 2007-10-10 9423
64 VB VB에서 HTML의 스크립트 함수 호출및 Active X 호출 [1] 뭉충닷컴 2007-05-21 15413
63 VB 영문만 입력되어있는지 검사 뭉충닷컴 2007-02-18 9573
62 VB 엑셀 다루는 몇가지 명령어들 모음 뭉충닷컴 2007-02-13 11500
61 VB VB로 엑셀 종료시 "기존의 RESUME.XLW이 있습니다" 라고 나올경우 뭉충닷컴 2007-01-27 13170
60 VB SAP와 VB 연동하는 간단한 예제파일 file [1] 뭉충닷컴 2006-12-06 15677
59 VB 배열이 몇차원인지 알아내는 방법 뭉충닷컴 2006-12-02 6943
58 VB vbMHWB 컨트롤을 이용해 VB로 HTML , Script 제어하기 file 뭉충닷컴 2006-12-01 17901
57 VB 유니코드 관련 사이트 뭉충닷컴 2006-10-25 7766
56 VB Form 모양 꾸며주는 컨트롤 jcForms 뭉충닷컴 2006-10-12 7862
55 VB 텍스트박스 안의 텍스트 선택하기 뭉충닷컴 2006-10-12 8539
54 VB DAO에서 이용하던 sp가 ADO에서 안될때 뭉충닷컴 2006-10-10 7655
53 VB VB에서 동적배열 사용하기 뭉충닷컴 2006-10-08 12898
52 VB 폼 안의 컨트롤들 개수와 접근하기 뭉충닷컴 2006-09-25 7321
51 VB VB 개발을 편리하게 해주는 Add-In 프로그램들 file 뭉충닷컴 2006-09-21 9161
50 VB 가로(or 세로)로 인쇄하기 뭉충닷컴 2006-09-21 9793
49 VB 열려진 모든폼 한꺼번에 닫기 뭉충닷컴 2006-09-21 8121
48 VB MDIForm의 자식창중 사용중(활성화중)인 자식창 찾기 뭉충닷컴 2006-09-21 8269
47 VB 동적으로 컨트롤 추가하기 (텍스트박스, 레이블, 콤보..등등) 뭉충닷컴 2006-08-01 11808