in vb in user32
the vb . bas file
Attribute VB_Name = "modCloseBtn"
Option Explicit
Private Const SC_CLOSE As Long = &HF060&
Private Const MIIM_STATE As Long = &H1&
Private Const MIIM_ID As Long = &H2&
Private Const MFS_GRAYED As Long = &H3&
Private Const WM_NCACTIVATE As Long = &H86
Private Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Private Declare Function GetSystemMenu Lib "user32" ( _
ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemInfo Lib "user32" Alias _
"GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, _
ByVal b As Boolean, lpMenuItemInfo As MENUITEMINFO) As Long
Private Declare Function SetMenuItemInfo Lib "user32" Alias _
"SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, _
ByVal bool As Boolean, lpcMenuItemInfo As MENUITEMINFO) As Long
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Private Declare Function IsWindow Lib "user32" _
(ByVal hWnd As Long) As Long
'*******************************************************************************
' Enables / Disables the close button on the titlebar and in the system menu
' of the form window passed.
'-------------------------------------------------------------------------------
' Return Values:
'
' 0 Close button state changed succesfully / nothing to do.
' -1 Invalid Window Handle (hWnd argument) Passed to the function
' -2 Failed to switch command ID of Close menu item in system menu
' -3 Failed to switch enabled state of Close menu item in system menu
'
'-------------------------------------------------------------------------------
' Parameters:
'
' hWnd The window handle of the form whose close button is to be enabled/
' disabled / greyed out.
'
' Enable True if the close button is to be enabled, or False if it is to
' be disabled / greyed out.
'
'-------------------------------------------------------------------------------
' Example:
'
' Add a form window to your project, and place a button on the form. Add the
' following in the form's code window:
'
' Option Explicit
'
' Private m_blnCloseEnabled As Boolean
'
' Private Sub Form_Load()
' m_blnCloseEnabled = True
' Command1.Caption = "Disable"
' End Sub
'
' Private Sub Command1_Click()
' m_blnCloseEnabled = Not m_blnCloseEnabled
' EnableCloseButton Me.hwnd, m_blnCloseEnabled
'
' If m_blnCloseEnabled Then
' Command1.Caption = "Disable"
' Else
' Command1.Caption = "Enable"
' End If
' End Sub
'
'-------------------------------------------------------------------------------
Public Function EnableCloseButton(ByVal hWnd As Long, Enable As Boolean) _
As Integer
Const xSC_CLOSE As Long = -10
' Check that the window handle passed is valid
EnableCloseButton = -1
If IsWindow(hWnd) = 0 Then Exit Function
' Retrieve a handle to the window's system menu
Dim hMenu As Long
hMenu = GetSystemMenu(hWnd, 0)
' Retrieve the menu item information for the close menu item/button
Dim MII As MENUITEMINFO
MII.cbSize = Len(MII)
MII.dwTypeData = String(80, 0)
MII.cch = Len(MII.dwTypeData)
MII.fMask = MIIM_STATE
If Enable Then
MII.wID = xSC_CLOSE
Else
MII.wID = SC_CLOSE
End If
EnableCloseButton = -0
If GetMenuItemInfo(hMenu, MII.wID, False, MII) = 0 Then Exit Function
' Switch the ID of the menu item so that VB can not undo the action itself
Dim lngMenuID As Long
lngMenuID = MII.wID
If Enable Then
MII.wID = SC_CLOSE
Else
MII.wID = xSC_CLOSE
End If
MII.fMask = MIIM_ID
EnableCloseButton = -2
If SetMenuItemInfo(hMenu, lngMenuID, False, MII) = 0 Then Exit Function
' Set the enabled / disabled state of the menu item
If Enable Then
MII.fState = (MII.fState Or MFS_GRAYED)
MII.fState = MII.fState - MFS_GRAYED
Else
MII.fState = (MII.fState Or MFS_GRAYED)
End If
MII.fMask = MIIM_STATE
EnableCloseButton = -3
If SetMenuItemInfo(hMenu, MII.wID, False, MII) = 0 Then Exit Function
' Activate the non-client area of the window to update the titlebar, and
' draw the close button in its new state.
SendMessage hWnd, WM_NCACTIVATE, True, 0
EnableCloseButton = 0
End Function
'*******************************************************************************
'
'-------------------------------------------------------------------------------
the .frm file
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 3 'Fixed Dialog
Caption = "Enable / Disable Close Button ->"
ClientHeight = 1650
ClientLeft = 45
ClientTop = 330
ClientWidth = 3600
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1650
ScaleWidth = 3600
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton Command1
Caption = "Toggle"
BeginProperty Font
Name = "Comic Sans MS"
Size = 36
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1455
Left = 120
TabIndex = 0
Top = 120
Width = 3375
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private m_blnCloseEnabled As Boolean
Private Sub Form_Load()
m_blnCloseEnabled = True
Command1.Caption = "Disable"
End Sub
Private Sub Command1_Click()
m_blnCloseEnabled = Not m_blnCloseEnabled
EnableCloseButton Me.hWnd, m_blnCloseEnabled
If m_blnCloseEnabled Then
Command1.Caption = "Disable"
Else
Command1.Caption = "Enable"
End If
End Sub
in c no close ok
#include <windows.h>
int InitWindow (HINSTANCE);
long CALLBACK wndproc (HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInst,
HINSTANCE hPrev,
LPSTR cmd,
int show)
{
MSG msg;
InitWindow(hInst);
while (GetMessage(&msg, 0, 0, 0 ))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
int InitWindow (HINSTANCE hinst)
{
WNDCLASS wc;
POINT scr;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = CreateSolidBrush(0x00ffffff);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hIcon = LoadIcon(0, IDI_EXCLAMATION);
wc.hInstance = hinst;
wc.lpfnWndProc = wndproc;
wc.lpszClassName = "ScreenWin";
wc.lpszMenuName = 0;
wc.style = CS_NOCLOSE;
if (!RegisterClass(&wc))
{
MessageBox(0,"RegisterClass failed !", "Error", MB_OK);
return 1;
}
scr.x = GetSystemMetrics(SM_CXSCREEN);
scr.y = GetSystemMetrics(SM_CYSCREEN);
HWND hwnd = CreateWindow("ScreenWin","ScreenWin",
WS_POPUP,0,0,scr.x,scr.y,0,0,hinst,0);
if (!hwnd)
{
MessageBox(0,"CreateWindow failed !", "Error", MB_OK);
return 1;
}
ShowWindow(hwnd, SW_SHOW);
return 0;
}
long CALLBACK wndproc (HWND hwnd,
UINT msg,
WPARAM wpar,
LPARAM lpar)
{
return DefWindowProc(hwnd,msg,wpar,lpar);
}
help!!! in dbpro!!!! disable a x button
help disable a close windows
plese help
download a exe in c mode compiled whit dev c++
full screen + no close( in dbpro ? )
hello,attend news
Anxiously awaiting BlueGUI v2
it informs to me when and ended BlueGUI v2