کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی
کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی

نمایش Bitmap کنار منو ( پیوند BitMap مشخص شده به آیتم منو )

Type: HBITMAP

A handle to the bitmap to be displayed, or it can be one of the values in the following table. It is used when the MIIM_BITMAP flag is set in the fMask member


uflags: MF_BYCOMMAND

hBitmap:LoadBitmap,LoadIcon,LoadImage







Dim mim As MENUITEMINFOA

(mim.cbSize = Len(mim

   mim.fMask = MIIM_BITMAP

mim.hbmpitem=1

SetMenuItemInfoA hSysMenu, 6, 1, mim


Use the GetSystemMetrics function with the CXMENUCHECK and CYMENUCHECK values to retrieve the bitmap dimensions.


تصویر بالا با استفاده از تابع زیر ( foo هندلی برای Bitmap ) و   loadimagea ( در آرگومان Type حتما IMAGE_BITMAP  استفاده شود ) بدست آمده  ضمنا  Bitmap ها در Shell32  در اینترنت وجود دارد و می توانید در سیستم خود لود نمایید و مانند زیر استفاده کنید .


windows_7_shell32_dll.shtml


SetMenuItemBitmaps hMenu, 1,MF_BYPOSITION, foo, foo


گرفتن استرینگ آیتم های SystemMenu


در تصویر بالا تعداد آیتم ها عدد 6 است 


szItem As String*100
((szItem=String$(100,Chr(0
(hSysMenu=GetSystemMenu(hwnd
(hSysMenuItmCount=GetMenuItemCount(hSysMenu,0
For i=0 To hSysMenuItmCount
(ItemId=GetMenuItemId(hSysMenu,i
(Length=GetMenuString(hSysMenu,i,szItem,Len(szItem)+1,MF_BYPOSITION
(txt=Left$(szItem,Length
Debug.Print txt,ItemId,i
Next

درباره ی تابع GetMenuString 

If the function succeeds, the return value specifies the number of characters copied to the buffer, not including the terminating null character.

If the function fails, the return value is zero.

If the specified item is not of type MIIM_STRING or MFT_STRING, then the return value is zero.

Remarks

The nMaxCount parameter must be one larger than the number of characters in the text string to accommodate the terminating null character.

If nMaxCount is 0, the function returns the length of the menu string.



درباره تابع  GetMenuItemCount 


Return Value

Type: int

اگر عملکرد موفقیت آمیزباشدمقداربرگشتی تعداد آیتم های منو خواهدبود.

If the function succeeds, the return value specifies the number of items in the menu.

If the function fails, the return value is -1


درباره  تابع  GetMenuItemId


Return Value

Type: UINT

مقدار برگشتی شناسه ی آیتم منوی مشخص شده خواهد بود اگر شناسه ی آیتم منو نال یا شامل ساب منو باشد عدد برگشتی 1- است که اثبات و تست شده.  

The return value is the identifier of the specified menu item. If the menu item identifier is NULL or if the specified item opens a submenu, the return value is -1.


درباره تابع ModifyMenu



(idItem=GetMenuItemID(hmenu, uItemPos

ModifyMenu hmenu,idItem,MF_BYCOMMAND+MF_STRING,idItem, szItem


Return Value

Type: BOOL

اگر تابع ( عملکرد ) موفقیت آمیز باشد مقدار برگشتی عددی غیرصفر است خواه مثبت یا منفی  و در صورت عدم موفقیت صفر را برخواهد گرداند.

If the function succeeds, the return value is nonzero

If the function fails, the return value is zero

MENUINFO گرفتن اطلاعات منوبار



Public Const MIM_BACKGROUND As Long = &H2
Public Const MIM_APPLYTOSUBMENUS As Long
&H80000000=
Pubkic Type MENUINFO
cbSize As Long
hbrBack As Long
fMask As Long
dwStyle As Long
cyMax As Long
End Type



.fMask=MIM_BACKGROUND
.hbrBack=CreateSolidBrush(vbYellow)
SetMenuInfo GetMenu(Me.hwnd),mi
.fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS
.hbrBack=CreateSolidBrush(vbCyan)
SetMenuInfo GetSubMenu(GetMenu(Me.hwnd),0),mi
.hbrBack=CreateSolidBrush(vbGreen)
SetMenuInfo GetSubMenu(GetMenu(Me.hwnd),1),mi
.hbrBack=CreateSolidBrush(vbRed)
SetMenuInfo GetSubMenu(GetMenu(Me.hwnd),2),mi









tagMENUITEMINFOA { UINT cbSize; UINT fMask; UINT fType; UINT fState; UINT wID; HMENU hSubMenu; HBITMAP hbmpChecked; HBITMAP hbmpUnchecked; ULONG_PTR dwItemData; LPSTR dwTypeData; UINT cch; HBITMAP hbmpItem;


fMask

MIIM_FTYPE
0x00000100
Retrieves or sets thefType member.
MIIM_ID
0x00000002
Retrieves or sets thewID member.
MIIM_STATE
0x00000001
Retrieves or sets thefState member.
MIIM_STRING
0x00000040
Retrieves or sets thedwTypeDatamember.



fType


MFT_RIGHTJUSTIFY
0x00004000L
Right-justifies the menu item and any subsequent items. This value is valid only if the menu item is in a menu bar.
MFT_RIGHTORDER
0x00002000L
Specifies that menus cascade right-to-left (the default is left-to-right). This is used to support right-to-left languages, such as Arabic and Hebrew.
MFT_SEPARATOR
0x00000800L
Specifies that the menu item is a separator. A menu item separator appears as a horizontal dividing line. ThedwTypeData andcch members are ignored. This value is valid only in a drop-down menu, submenu, or shortcut menu.
MFT_STRING
0x00000000L
Displays the menu item using a text string. ThedwTypeDatamember is the pointer to a null-terminated string, and the cchmember is the length of the string.

MFT_STRING is replaced by MIIM_STRING.



Public Sub SetMenuBackground()
MenuHandle = GetSystemMenu(form.Handle,0)
Dim brush
Brush=CreateSolidBrush(RGB(200,100,200))
Dim mi As MenuInfo
mi.cbSize=Len(MenuInfo)
mi.fMask=&H2
mi.hbrBack=brush
SetMenuInfo(MenuHandle,mi)
End Sub




Private Sub Form_Load()
Dim ret As Long
Dim hMenu As Long
Dim hBrush As Long
Dim lbBrushInfo As LOGBRUSH
Dim miMenuInfo As tagMENUINFO
lbBrushInfo.lbStyle=BS_SOLID
lbBrushInfo.lbColor=RGB(155, 100, 200)
lbBrushInfo.lbHatch = 0
hBrush=CreateBrushIndirect(lbBrushInfo)
hMenu = GetMenu(Me.hwnd)
miMenuInfo.cbSize = Len(miMenuInfo)
ret=GetMenuInfo(hMenu, miMenuInfo) ' 0 means failure
miMenuInfo.fMask =MIM_BACKGROUND
'MIM_APPLYTOSUBMENUS  use this to apply to submenus as well
miMenuInfo.hbrBack=hBrush
ret=SetMenuInfo(hMenu,miMenuInfo) '0 means failure
End Sub

پیام WM_INITMENU برای چک مارک منو آیم



The following example has three menu items and moves the check mark of the menu item each time the menu is opened.



Public Function WndProc (HWND hWnd, UINT iMessage

( WPARAM wParam, LPARAM lParam,

 HDC hdc

PAINTSTRUCT ps

 static int count = 0

 Mes="Checks menu items in order every time the menu is

" opened

 Select Case iMessage

 case WM_INITMENU

  CheckMenuItem (HMENU) wParam

(IDM_MENU1,MF_BYCOMMAND | MF_UNCHECKED , 

,CheckMenuItem (HMENU) wParam, IDM_MENU2,m

( MF_BYCOMMAND | MF_UNCHECKED

CheckMenuItem ((HMENU) wParam, IDM_MENU3, MF_BYCOMMAND | MF_UNCHECKED)

count = (count +1)% 3

CheckMenuItem (HMENU) wParam, IDM_MENU1 + count, MF_BYCOMMAND | MF_CHECKED)

Wndproc=False

case WM_PAINT

(hdc = BeginPaint (hWnd, ps

(TextOut hdc, 10, 10, Mes,len(Mes

  (EndPaint (hWnd,ps

 WndProc=False

case WM_DESTROY

 PostQuitMessage (0

 WndProc=False

Case Else

(Wndproc=DefWindowProc (hWnd, iMessage, wParm,lParam

End Select

Exit Function




ShowPopup در اکسس



Private Sub Song_List_MouseUp(Button As Integer, Shift As Integer, X As Single,
(Y As Single
ساخت شورتکات منو توسط تابع با پوزیشن msoBarPopup
SetUpContextMenu
If Button = acRightButton Then
CommandBars("MyListControlContextMenu").ShowPopup
End If
End Sub


منابع


اعتراف می نمایم که پست های بنده در حد تجربی   و نه تئوریکالی و دانشگاهی است بنابراین تمامی اطلاعات به اشتراک گذاشته ۱۰ درصد تجربی بوده و حدود ۹۰ درصد آن از داکیومنت آفیس یا سایر فروم های خارجی استخراج شده لذا در صورت اشتباه در پاره ای از موارد ، اصلاح شده یا باصطلاح تست شده ی آن را در نظرها به اشتراک بگذارید تا سایرین نیز استفاده بنمایند.

اضافه کردن منو



hMenu=GetMenu(Me.Handle)
menuItemCount=GetMenuItemCount(hMenu) 
hSubMenu=GetSubMenu(hMenu, 0) 
subMenuItemCount=GetMenuItemCount(hSubMenu) 
Dimmii As MENUITEMINFO 
With mii 
.cbSize=Len(mii) 
.fMask=MIIM_FTYPE Or MIIM_STATE Or MIIM_ID Or MIIM_STRING 
.fType=MFT_STRING 
.fState=MFS_ENABLED 
.wID = 0
.hSubMenu=0
.hbmpChecked=0
.hbmpUnchecked=0 
.dwItemData=9 
.dwTypeData="My Menu Item" 
' the name of your custom menu item End With

 InsertMenuItem(hSubMenu, subMenuItemCount + 1, True, mii) 
DrawMenuBar(Me.Handle)

غیرفعال کردن آیدی منو

WM_INITMENUPOPUP=&H117
WM_RBUTTONDOWN=&H204


TPM_LEFTBUTTON = 0
TPM_RIGHTBUTTON = 2
TPM_LEFTALIGN = 0
TPM_CENTERALIGN = 4
TPM_RIGHTALIGN = 8
TPM_TOPALIGN = 0
TPM_VCENTERALIGN = 16
TPM_BOTTOMALIGN = 32
TPM_HORIZONTAL = 0
TPM_VERTICAL = 64

MF_BYCOMMAND = 0
MF_BYPOSITION = 1024
MF_SEPARATOR = 2048
MF_ENABLED = 0
MF_GRAYED = 1
MF_DISABLED = 2
MF_STRING = 0
MF_BITMAP = 4
MF_POPUP = 16
MF_UNHILITE = 0
MF_HILITE = 128
MF_SYSMENU = 8192
MF_HELP = 16384
MF_RIGHTJUSTIFY = 16384

Public Function WndProc

   Case WM_RBUTTONDOWN

hMenuPopUp = CreatePopupMenu

             "AppendMenuA hMenuPopUp, MF_STRING, IDM_CONTEXT_LINE, "Line

             "AppendMenuA hMenuPopUp, MF_STRING, IDM_CONTEXT_RECTAN, "Rectangle

            " AppendMenuA hMenuPopUp, MF_STRING, IDM_CONTEXT_CIRCLE, "Circle

             AppendMenuA hMenuPopUp, MF_SEPARATOR, 0, vbNullString

             "AppendMenuA hMenuPopUp, MF_STRING, IDM_CONTEXT_HELP, "Help

&EnableMenuItem hMenuPopUp, 1000, 1

TrackPopupMenu hMenuPopUp, TPM_RIGHTALIGN + TPM_RIGHTBUTTON, pt.x, pt.y, 0, lhwnd, rc



برای تغییر LayOut  پاپ آپ منو  باید از مسیج   WM_INITMENUPOPUP و  کلاس آن  که 32768# است و با تابع FindWindowA میتوان هندل آن را بدست آورد استفاده کرد ، برای اینکه درجایی که کرسر هست بازشود باید از تابع GetCursorPos بهره برد و x و y آنرا در Track گذاشت .

case WM_RBUTTONDOWN:
HMENU hPopupMenu = CreatePopupMenu();
InsertMenu(hPopupMenu, 0, MF_BYPOSITION + MF_STRING, ID_CLOSE, L"Exit");
InsertMenu(hPopupMenu, 0, MF_BYPOSITION + MF_STRING, ID_EXIT, L"Play");
SetForegroundWindow(hWnd);
TrackPopupMenu(hPopupMenu, TPM_BOTTOMALIGN + TPM_LEFTALIGN, 0, 0, 0, hWnd, NULL);



EnableMenuItem در VB



(WndProc(ref Message m
    if  m.Msg = WM_INITMENUPOPUP
  (((int)m.LParam & 0x10000) != 0) 
   (EnableMenuItem(WParam,SC_MOVE,MF_DISABLED
End If

   

   

Handle Menu در VB


Private Const windowsMenuClassName As String= "#32768

(externalMenu=FindWindowEx(GetDesktopWindow,0,windowsMenuClassName,VbNullString
(PostMessage(externalMenu,WM_CLOSE, 0,0
End If 
End Sub

()Private Sub Timer1_Timer


Dim hMenuWnd As Long
(hMenuWnd = FindWindow ("# 32768", vbNullString
If hMenuWnd <> 0 Then
(( Me.Caption = CStr (SendMessage
(hMenuWnd, MN_GETHMENU, 0, 0
End If
End Sub

Ribbon



                                                            

                                                           office_standards/ms-customui


iribbonui-members-office







File Tab And BackStage

Visible=False/True


customize-ribbon-to-suppress-backstage-with-access-2013










</ribbon>

  <backstage>

    <tab  id="btab1" label="Tab Label 1. ">

      <firstColumn>

        <taskGroup id="MytskGroup1"






ماکرو Before Change و SetLocalVar




ساخت   متغیر ( Variable ) موقتی  و تنظیم آن به مقدار مشخص شده  





Remarks

The SetField action cannot be used outside of an CreateRecord or EditRecord data block


The CreateRecord data block can only be used in the After InsertAfter Update, and After Update data macro events




ساخت رکورد Create Record



EVENT MACRO


بعد از تغییر رکورد اتفاق می افتد طبق گفته از Update در If میشود استفاده کرد برای اینکه تعیین کند آیا فیلد موردنظر ( داخل پرانتز و دابل کوتیشن )  تغییر نموده  . در مثال بیان شده 








درمثال بالا اگر فیلد Meter_Value در جدول اول تغییر کرد یوزری که باعث این عمل شده به جدول دوم اضافه میشود و یوزر در فیلد And_User قرار خواهد گرفت ... تابع ENVIRON را سرچ کنید البته در شبکه باید سرچ کنید میشود با این تابع گرفت یا خیر .


:environment variables
LLUSERSPROFILE
APPDATA
AVENGINE
CLIENTNAME
CommonProgramFiles
COMPUTERNAME
ComSpec
FP_NO_HOST_CHECK
HOMEDRIVE
HOMEPATH
INCLUDE
INOCULAN
LIB
LOGONSERVER
NUMBER_OF_PROCESSORS
OS
Path
PATHEXT
PROCESSOR_ARCHITECTURE
PROCESSOR_IDENTIFIER
PROCESSOR_LEVEL
PROCESSOR_REVISION
ProgramFiles
SESSIONNAME
SystemDrive
SystemRoot
TEMP
TMP
USERDOMAIN
USERNAME
USERPROFILE
VS71COMNTOOLS
WecVersionForRosebud.FF0

Device Context


















BMP_file_format

 Picture Property Doffice.11

stdole.SavePicture


The IDispatch interface ID is defined as a GUID with the value of {00020400-00000000-C000-000000000046}

H20400&

HC0&

H46&


GUID.htm&id

نوشتن ولیو در رجیستری




Set the registry flag to display Hidden and System files in Windows Explorer


WScript.Shell


 _"myKey="HKCU\Software\Microsoft\Windows

"\CurrentVersion\Explorer\Advanced\Hidden\"

"WshShell.RegWrite myKey,1,"REG_DWORD




"WScript.Shell"
Methods
   .AppActivate      'Activate running command.
   .Run              'Run an application
   .TileVertically   'Tile app windows
   .RegRead          'Read from registry
   .RegDelete        'Delete from registry
   .RegWrite         'Write to the registry


"Shell.Application"

Methods
   .CanStartStopService("ServiceName")   'Can the current user start/stop the named service?
   .CascadeWindows      'Arrange app windows
   .EjectPC             'Eject PC from a docking station
   .Explore(FolderPath) 'Open a folder
   .FileRun             'Open the File-run dialogue
   .GetSystemInformation("PhysicalMemoryInstalled")  'Physical memory installed, in bytes.
   .IsServiceRunning("ServiceName")  'Check if a Windows service is running
   .MinimizeAll         'Minimize everything
   .NameSpace("C:\\")   'Create an object reference to a folder
   .ServiceStart("ServiceName", true)  'Start a windows service
   .ServiceStop("ServiceName", true)   'Stop a windows service
   .SetTime             'Open the set time GUI
   .ShellExecute        'Run a script or application
   .ShutdownWindows
   .TileHorizontally   'Tile app windows
   .TileVertically     'Tile app windows
   .ToggleDesktop      'Show/Hide Desktop
   .TrayProperties     'Display the Taskbar/Start Menu Properties
   .UndoMinimizeAll    'Un-Minimize everything