Jump to content

Popup Menü Yapımı


DivaneTR
 Share

Recommended Posts

[center][img]http://i.imgur.com/8SG06.png[/img]

Biliyorsunuz ki her objenin contextmenu veya right click eventi yok. Dolayısıyla bu objelere popup menü (sağ tık menü) yapamıyorduk. Memory plugini bu noktada bize yardımcı oluyor. Kodlarımızı inceleyelim.

Öncelikle Global Functions kısmına kodlarımızı yazıyoruz ;[/center]

[codebox]
WM_LBUTTONDOWN = 513
WM_LBUTTONUP = 514
WM_RBUTTONDOWN = 516

function SelectItem(hWnd, wParam, lParam)
LeftButtonDown(hWnd, wParam, lParam)
LeftButtonUp(hWnd, wParam, lParam)
end

function LeftButtonUp(hWnd, wParam, lParam)
va_args = string.format("%d,%d,%d,%d",hWnd, WM_LBUTTONUP, wParam, lParam)
DLL.CallFunction("User32.dll", "SendMessageA", va_args, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
end
function LeftButtonDown(hWnd, wParam, lParam)
va_args = string.format("%d,%d,%d,%d",hWnd, WM_LBUTTONDOWN, wParam, lParam)
DLL.CallFunction("User32.dll", "SendMessageA", va_args, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
end

function LOWORD(value)
return Memory.BitAND(value, 65535)
end

function HIWORD(value)
return Memory.BitAND(Memory.ShiftRight(value, 16), 65535)
end

---------- Menü kodlarımız ------------
function ShowPopUpMenu()
tblMenu = {};
tblMenu[1] ={};
tblMenu[1].Text = "ExtremitySoft";
tblMenu[1].ID = 100;
tblMenu[1].IconID = 0;
tblMenu[1].Checked = false;
tblMenu[1].Enabled = true;
tblMenu[2] ={};
tblMenu[2].Text = "Divane ©";
tblMenu[2].ID = 200;
tblMenu[2].IconID = 0;
tblMenu[2].Checked = false;
tblMenu[2].Enabled = true;

Mouse = System.GetMousePosition(true, nil);
nRes = Application.ShowPopupMenu(Mouse.X, Mouse.Y, tblMenu, TPM_LEFTALIGN, TPM_TOPALIGN, true, true);
end
[/codebox]

Globale kodlarımızı yazdık, aynı zamanda menümüzü de oluşturduk. Şimdi sıra obje ile ilişkilendirmede. Kodları inceleyelim ;

On show eventine kodlarımızı yazıyoruz.
[code]
function CallBack(hWnd, uMsg, wParam, lParam)

if uMsg == WM_RBUTTONDOWN then

SelectItem(hWnd,wParam, lParam)
ShowPopUpMenu()

end

end

LBHandle = ListBox.GetProperties("ListBox1").WindowHandle;
Memory.CreateWindowSubClass(LBHandle, 0, "CallBack");
[/code]

İşlem tamamdır. Listbox objemize sağ tık menüsü oluşturmuş olduk. Bu kodlarla tüm objelere menü ekleyebilirsiniz.

[code]LBHandle = ListBox.GetProperties("ListBox1").WindowHandle;[/code]

Sayfamızın on show evresine yazdığımız yukarıdaki kod Listbox'un handle değerini alıyordu. Bu satırda istediğiniz objenin handle değerini alarak popup menü göstermiş olacaksınız. Kolay gelsin.
Link to comment
Share on other sites

bu örnek reteset ( Serkan ) tarafından hazırlanmıştır bunu konuda belirtmen gerekiyor

[img]http://www.amsplugins.com/screenshots/LBRightClick.jpg[/img]

[code]http://www.amsplugins.com/details.asp?id=114[/code]

Edited by milano88
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...