กระทู้เก่าบอร์ด อ.Yeadram
2,035 11
URL.หัวข้อ /
URL
โค้ดการแก้ไขฟอร์ม
ผมต้องการจะปิด ตัวที่ย่อ ขยาย และปิดโปรแกรม ของaccess คือผมสร้างปุ่มปิดไว้แล้วนะครับ แต่มีปุ่มปิดของโปรแกรมaccessอยู่แล้วแต่ผมไม่ต้องการผมทำการสร้างปุ่มขึ้นมาใหม่แล้วนะครับจะลบปุ่มเก่าอย่างไงดีครับ ขอบคุณครับ
11 Reply in this Topic. Dispaly 1 pages and you are on page number 1
1 @R22076
ไม่ทราบว่า ใช่ตัวที่ต้องการหรือเปล่าครับ ตามรูป ด้านล่าง

2 @R22077
รูปที่อัพไม่ขึ้นครับ งั้นลองตามนี้ครับ ไม่ทราบว่าตรงตามที่ผมเข้าใจคำถามไหม ผมมือใหม่น๊ะครับ ถ้าไม่ใช่ คงรอให้อาจารย์ ท่านอืนๆมาตอบน๊ะครับ
1.เปิด Form ในโหมด Design view
2. property sheet ---> Form ---> Format
3.ที่ close Button เลือก no
4. ที่ Min Max Button เลือก None
อื่นๆอีก ลองเลือกดูครับ
1.เปิด Form ในโหมด Design view
2. property sheet ---> Form ---> Format
3.ที่ close Button เลือก no
4. ที่ Min Max Button เลือก None
อื่นๆอีก ลองเลือกดูครับ
3 @R22078
อ่า ไม่ใช้ครับตัวนั่นผมทำแล้ว
ตรงนี้อะครับผมอยากทำให้หายไปผมทำไม่เป็นอะครับ
ตรงนี้อะครับผมอยากทำให้หายไปผมทำไม่เป็นอะครับ
4 @R22079

5 @R22080
อ่ารูปไม่ขึ้น เอาเป็นว่าไม่ใช่ตรงฟอมอะครับแต่เป็นปุ่มที่ปิดและย่อขยายของaccessเองเลยอะครับ
6 @R22081
งั้นต้องรอ อาจารย์ท่านมาตอบหละครับ ผมมือใหม่จริงๆครับ แต่ผมไปเห็น Link ข้างล่างนี้ ไม่รูว่าทำได้ไหมครับ
https://www.fmsinc.com/microsoftaccess/startup/preventclose.asp
https://www.fmsinc.com/microsoftaccess/startup/preventclose.asp
7 @R22082
ทำได้ครับ
สร้าง module ใหม่ แล้ว copy ข้อความนี้ ลงไป
Option Compare Database
'Windows API Calls
'There are two Windows API calls to use. Add these to the declarations section of your module:
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal wRevert As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
'Procedure to Disable and Enable the Close Button
Public Sub AccessCloseButtonEnabled(pfEnabled As Boolean)
' Comments: Control the Access close button.
' Disabling it forces the user to exit within the application
' Params : pfEnabled TRUE enables the close button, FALSE disabled it
' Owner : Copyright (c) FMS, Inc.
' Source : Total Visual SourceBook
' Usage : Permission granted to subscribers of the FMS Newsletter
On Error Resume Next
Const clngMF_ByCommand As Long = &H0&
Const clngMF_Grayed As Long = &H1&
Const clngSC_Close As Long = &HF060&
Dim lngWindow As Long
Dim lngMenu As Long
Dim lngFlags As Long
lngWindow = Application.hWndAccessApp
lngMenu = GetSystemMenu(lngWindow, 0)
If pfEnabled Then
lngFlags = clngMF_ByCommand And Not clngMF_Grayed
Else
lngFlags = clngMF_ByCommand Or clngMF_Grayed
End If
Call EnableMenuItem(lngMenu, clngSC_Close, lngFlags)
End Sub
ที่ ฟอร์ม ที่ต้องการ เปิด มา แล้ว บังคับ ให้ enable ปุ่ม access window ให้ใส่ code นี้ ลงไป
Private Sub Form_Load()
'Disabling the Close Button
'When your application starts, simply call this to disable the close button:
Call AccessCloseButtonEnabled(False)
End sub
เค้าเตือนไว้ว่า คุณต้องแน่ใจนะครับ ว่า ถ้าปิดปุ่มนี้ แล้ว มีทางออกจาก access
นะ
ลองทดสอบดูครับ
สร้าง module ใหม่ แล้ว copy ข้อความนี้ ลงไป
Option Compare Database
'Windows API Calls
'There are two Windows API calls to use. Add these to the declarations section of your module:
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal wRevert As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
'Procedure to Disable and Enable the Close Button
Public Sub AccessCloseButtonEnabled(pfEnabled As Boolean)
' Comments: Control the Access close button.
' Disabling it forces the user to exit within the application
' Params : pfEnabled TRUE enables the close button, FALSE disabled it
' Owner : Copyright (c) FMS, Inc.
' Source : Total Visual SourceBook
' Usage : Permission granted to subscribers of the FMS Newsletter
On Error Resume Next
Const clngMF_ByCommand As Long = &H0&
Const clngMF_Grayed As Long = &H1&
Const clngSC_Close As Long = &HF060&
Dim lngWindow As Long
Dim lngMenu As Long
Dim lngFlags As Long
lngWindow = Application.hWndAccessApp
lngMenu = GetSystemMenu(lngWindow, 0)
If pfEnabled Then
lngFlags = clngMF_ByCommand And Not clngMF_Grayed
Else
lngFlags = clngMF_ByCommand Or clngMF_Grayed
End If
Call EnableMenuItem(lngMenu, clngSC_Close, lngFlags)
End Sub
ที่ ฟอร์ม ที่ต้องการ เปิด มา แล้ว บังคับ ให้ enable ปุ่ม access window ให้ใส่ code นี้ ลงไป
Private Sub Form_Load()
'Disabling the Close Button
'When your application starts, simply call this to disable the close button:
Call AccessCloseButtonEnabled(False)
End sub
เค้าเตือนไว้ว่า คุณต้องแน่ใจนะครับ ว่า ถ้าปิดปุ่มนี้ แล้ว มีทางออกจาก access
นะ
ลองทดสอบดูครับ
8 @R22083
Option Compare Database
'Windows API Calls
'There are two Windows API calls to use. Add these to the declarations section of your module:
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal wRevert As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
'Procedure to Disable and Enable the Close Button
Public Sub AccessCloseButtonEnabled(pfEnabled As Boolean)
' Comments: Control the Access close button.
' Disabling it forces the user to exit within the application
' Params : pfEnabled TRUE enables the close button, FALSE disabled it
' Owner : Copyright (c) FMS, Inc.
' Source : Total Visual SourceBook
' Usage : Permission granted to subscribers of the FMS Newsletter
On Error Resume Next
Const clngMF_ByCommand As Long = &H0&
Const clngMF_Grayed As Long = &H1&
Const clngSC_Close As Long = &HF060&
Dim lngWindow As Long
Dim lngMenu As Long
Dim lngFlags As Long
lngWindow = Application.hWndAccessApp
lngMenu = GetSystemMenu(lngWindow, 0)
If pfEnabled Then
lngFlags = clngMF_ByCommand And Not clngMF_Grayed
Else
lngFlags = clngMF_ByCommand Or clngMF_Grayed
End If
Call EnableMenuItem(lngMenu, clngSC_Close, lngFlags)
End Sub
โค้ดนี่ผมสร้างมอดูล
Private Sub Form_Open(Cancel As Integer)
DoCmd.ShowToolbar "Ribbon", acToolbarNo
DoCmd.MoveSize 3000, 400, 15000, 9000 '
End Sub
Private Sub Form_Load()
'Disabling the Close Button
'When your application starts, simply call this to disable the close button:
Call AccessCloseButtonEnabled(True)
Dim i As Integer
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.RunCommand acCmdWindowHide
DoCmd.ShowToolbar "Ribbon", acToolbarNo '???? Ribbon'
DoCmd.LockNavigationPane True '????NavigationPane'
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False '????NavigationPane'
Next i
End Sub
โค้ดนี่ผมสร้างหน้าHome ถูกแล้วใช่ไมครับ
คือผมสร้างแล้วไม่มีอะไรเกิดขึ้นอะครับมี ตัวปิดโปรแกรมAccessและย่อขยายเหมือนเดิมครับ
'Windows API Calls
'There are two Windows API calls to use. Add these to the declarations section of your module:
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal wRevert As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
'Procedure to Disable and Enable the Close Button
Public Sub AccessCloseButtonEnabled(pfEnabled As Boolean)
' Comments: Control the Access close button.
' Disabling it forces the user to exit within the application
' Params : pfEnabled TRUE enables the close button, FALSE disabled it
' Owner : Copyright (c) FMS, Inc.
' Source : Total Visual SourceBook
' Usage : Permission granted to subscribers of the FMS Newsletter
On Error Resume Next
Const clngMF_ByCommand As Long = &H0&
Const clngMF_Grayed As Long = &H1&
Const clngSC_Close As Long = &HF060&
Dim lngWindow As Long
Dim lngMenu As Long
Dim lngFlags As Long
lngWindow = Application.hWndAccessApp
lngMenu = GetSystemMenu(lngWindow, 0)
If pfEnabled Then
lngFlags = clngMF_ByCommand And Not clngMF_Grayed
Else
lngFlags = clngMF_ByCommand Or clngMF_Grayed
End If
Call EnableMenuItem(lngMenu, clngSC_Close, lngFlags)
End Sub
โค้ดนี่ผมสร้างมอดูล
Private Sub Form_Open(Cancel As Integer)
DoCmd.ShowToolbar "Ribbon", acToolbarNo
DoCmd.MoveSize 3000, 400, 15000, 9000 '
End Sub
Private Sub Form_Load()
'Disabling the Close Button
'When your application starts, simply call this to disable the close button:
Call AccessCloseButtonEnabled(True)
Dim i As Integer
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.RunCommand acCmdWindowHide
DoCmd.ShowToolbar "Ribbon", acToolbarNo '???? Ribbon'
DoCmd.LockNavigationPane True '????NavigationPane'
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False '????NavigationPane'
Next i
End Sub
โค้ดนี่ผมสร้างหน้าHome ถูกแล้วใช่ไมครับ
คือผมสร้างแล้วไม่มีอะไรเกิดขึ้นอะครับมี ตัวปิดโปรแกรมAccessและย่อขยายเหมือนเดิมครับ
9 @R22085
ลองกด ดูรึยังครับ ว่า ปุ่มปิด ทำงานรึเปล่า
10 @R22086
หรือ เข้าไปดู link นี้ ครับhttp://www.thai-access.com/yeadram_view.php?topic_id=1736&page=1
11 @R22089
ใช้ได้แล้วครับ
ขอบคุณครับอาจารย์
ผมถามอีกนิดนะครับบนหัวโปรแกรมของผมมันโชว์ลิงค์ที่เก็บโปรแกรมผมสามารถเเก้ไขมันได้ไหมครับ ให้โชว์อย่างอื่นแทนนะครับ
Private Const GWL_EXSTYLE = (-20)
Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000
Private Const HWND_TOP = 0
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) _
As Long
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowPos Lib "user32" _
(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
Sub HideAccessCloseButton()
Dim lngStyle As Long
lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle And Not WS_SYSMENU
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME)
End Sub
Sub UnHideAccessCloseButton()
Dim lngStyle As Long
lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle Or WS_SYSMENU
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME)
End Sub
ขอบคุณครับอาจารย์
ผมถามอีกนิดนะครับบนหัวโปรแกรมของผมมันโชว์ลิงค์ที่เก็บโปรแกรมผมสามารถเเก้ไขมันได้ไหมครับ ให้โชว์อย่างอื่นแทนนะครับ
Private Const GWL_EXSTYLE = (-20)
Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000
Private Const HWND_TOP = 0
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) _
As Long
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowPos Lib "user32" _
(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
Sub HideAccessCloseButton()
Dim lngStyle As Long
lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle And Not WS_SYSMENU
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME)
End Sub
Sub UnHideAccessCloseButton()
Dim lngStyle As Long
lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle Or WS_SYSMENU
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME)
End Sub
Time: 0.3254s