 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
NoMercy Master Cheater
Reputation: 1
Joined: 09 Feb 2009 Posts: 289
|
Posted: Wed Jul 28, 2010 7:09 am Post subject: C++ PopUpMenu |
|
|
Hello,
I'm trying to create a PopUpMenu, I'm not sure that's the real name. I mean the window that appears when u right click at this site for example. I want to have such a thing, which API should I use?
And I want to create 2 seperates things, one when u right click in the ListView, and one when u click at another ListView.
Thanks,
NM
|
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
|
Back to top |
|
 |
NoMercy Master Cheater
Reputation: 1
Joined: 09 Feb 2009 Posts: 289
|
Posted: Wed Jul 28, 2010 7:58 am Post subject: |
|
|
Code: | case WM_CREATE:
hmenu = CreatePopupMenu();
x = GetLastError();
memset(&emii, 0, sizeof(MENUITEMINFO));
emii.cbSize = sizeof(MENUITEMINFO);
emii.fMask = MIIM_STRING | MIIM_FTYPE;
emii.fType = MIIM_STRING;
emii.dwTypeData = TEXT("Copy");
emii.cch = 4;
InsertMenuItem(hmenu, 0, TRUE, (LPCMENUITEMINFO) &emii); |
Code: |
if(wParam == IDC_BLOCK)
{
TrackPopupMenu(hmenu,TPM_LEFTBUTTON,100,100,0,hWnd,0); |
if i use GetLasterror at the second code, error 1401:Invalid menu handle.
|
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Wed Jul 28, 2010 2:14 pm Post subject: |
|
|
btw if you post more code more people are likely to try to help. preferably a completely compilable version. then people can just copy and test. also you could well be screwing it up elsewhere.
|
|
Back to top |
|
 |
NoMercy Master Cheater
Reputation: 1
Joined: 09 Feb 2009 Posts: 289
|
Posted: Wed Jul 28, 2010 5:16 pm Post subject: |
|
|
Code: | HINSTANCE hInstance = NULL;
LPCWSTR g_szClassName = TEXT("myWindowClassPEsend");
LPCWSTR g_szClassName1 = TEXT("myWindowClassPErecv");
HWND hWnd = 0;
HWND RecvListView,hHookBut,hSendButton,hSendEdit,hIngBloc,hClean,hBlocIng,hBlock,hIngore,hBlcEd,hIngEd,hBlorIg;
HWND RecvListView2,hHookBut2,hSendButton2,hSendEdit2,hUnhook2,hClean2;
#define IDC_HOOK 101
#define IDC_SEND 102
#define IDC_EDITSEND 103
#define IDC_INBL 106
#define IDC_CLEAN 105
#define IDC_LIST 107
#define IDC_IGNOR 108
#define IDC_BLIN 109
#define IDC_BLOCK 110
#define IDC_INGORE 111
#define IDC_INGED 112
#define IDC_BLCED 113
#define IDC_HOOK2 101
#define IDC_SEND2 102
#define IDC_EDITSEND2 103
#define IDC_UNHOOK2 106
#define IDC_CLEAN2 105
#define IDC_LIST2 107
wchar_t szIgnored[MAX_PACKET_LEN], szBlocked[MAX_PACKET_LEN];
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HFONT HhFont = CreateFont(20, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_STRING_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Calibri"));
HFONT hFont = CreateFont(15, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_STRING_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Calibri"));
HFONT sFont = CreateFont(12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_STRING_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Calibri"));
InitCommonControls();
OleInitialize(0);
LV_COLUMN* lvc = new LV_COLUMN;
HMENU hmenu;
MENUITEMINFO emii;
int x = 0;
switch(msg)
{
case WM_CREATE:
hmenu = CreatePopupMenu();
x = GetLastError();
memset(&emii, 0, sizeof(MENUITEMINFO));
emii.cbSize = sizeof(MENUITEMINFO);
emii.fMask = MIIM_STRING | MIIM_FTYPE;
emii.fType = MIIM_STRING;
emii.dwTypeData = TEXT("Copy");
emii.cch = 4;
InsertMenuItem(hmenu, 0, TRUE, (LPCMENUITEMINFO) &emii);
RecvListView = CreateWindowEx(WS_EX_STATICEDGE,WC_LISTVIEW,NULL,WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT ,75, 10, 455, 200,hWnd,(HMENU)IDC_LIST,hInstance,NULL);
hHookBut = CreateWindowEx(WS_EX_LEFT, TEXT("Button"), TEXT("Hook"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 9, 10, 55, 22, hWnd, (HMENU)IDC_HOOK, hInstance, NULL);
hSendButton = CreateWindowEx(WS_EX_LEFT, TEXT("Button"), TEXT("Send"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 455, 213, 75, 26, hWnd, (HMENU)IDC_SEND, hInstance, NULL);
hClean = CreateWindowEx(WS_EX_LEFT, TEXT("Button"), TEXT("Clean"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 9, 32, 55, 22, hWnd, (HMENU)IDC_CLEAN, hInstance, NULL);
hIngBloc = CreateWindowEx(WS_EX_STATICEDGE,WC_LISTVIEW,NULL,WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT ,37, 160, 35, 86,hWnd,(HMENU)IDC_INBL, hInstance, NULL);
hBlocIng = CreateWindowEx(WS_EX_STATICEDGE,WC_LISTVIEW,NULL,WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT ,2, 160, 35, 86,hWnd, (HMENU)IDC_BLIN, hInstance, NULL);
hBlock = CreateWindowEx(WS_EX_LEFT, TEXT("Button"), TEXT("Block"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 9, 54, 55, 22, hWnd, (HMENU)IDC_BLOCK, hInstance, NULL);
hIngore = CreateWindowEx(WS_EX_LEFT, TEXT("Button"), TEXT("Ingore"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 9, 97, 55, 22, hWnd, (HMENU)IDC_INGORE, hInstance, NULL);
hSendEdit = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("Edit"), TEXT("//Packet"), WS_TILED | WS_VISIBLE | WS_CHILD | ES_UPPERCASE, 76, 216, 365, 20, hWnd, (HMENU)IDC_EDITSEND, hInstance, NULL);
hBlcEd = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("Edit"), TEXT("00"), WS_TILED | WS_VISIBLE | WS_CHILD | ES_UPPERCASE, 9, 77, 55, 18, hWnd, (HMENU)IDC_BLCED, hInstance, NULL);
hIngEd = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("Edit"), TEXT("00"), WS_TILED | WS_VISIBLE | WS_CHILD | ES_UPPERCASE, 9, 120, 55, 18, hWnd, (HMENU)IDC_INGED, hInstance, NULL);
hBlorIg = CreateWindowEx(WS_EX_LEFT, TEXT("Button"), TEXT("ShowBlocked"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 9, 140, 55, 26, hWnd, (HMENU)IDC_IGNOR, hInstance, NULL);
SendMessage(hIngEd, WM_SETFONT, (WPARAM)hFont, TRUE);
SendMessage(hBlcEd, WM_SETFONT, (WPARAM)hFont, TRUE);
SendMessage(hBlock, WM_SETFONT, (WPARAM)hFont, TRUE);
SendMessage(hIngore, WM_SETFONT, (WPARAM)hFont, TRUE);
SendMessage(RecvListView, WM_SETFONT, (WPARAM)hFont, TRUE);
SendMessage(hHookBut, WM_SETFONT, (WPARAM)hFont, TRUE);
SendMessage(hSendEdit, WM_SETFONT, (WPARAM)hFont, TRUE);
SendMessage(hSendButton, WM_SETFONT, (WPARAM)HhFont, TRUE);
SendMessage(hClean, WM_SETFONT, (WPARAM)hFont, TRUE);
SendMessage(hBlocIng, WM_SETFONT, (WPARAM)sFont, TRUE);
SendMessage(hIngBloc, WM_SETFONT, (WPARAM)sFont, TRUE);
ListView_SetExtendedListViewStyle(RecvListView, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | 0x01000000 | LVS_EX_DOUBLEBUFFER | LVS_EX_TWOCLICKACTIVATE );
ListView_SetExtendedListViewStyle(hIngBloc, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | 0x01000000 | LVS_EX_DOUBLEBUFFER | LVS_EX_TWOCLICKACTIVATE );
ListView_SetExtendedListViewStyle(hBlocIng, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | 0x01000000 | LVS_EX_DOUBLEBUFFER | LVS_EX_TWOCLICKACTIVATE );
for (int i = 1; i <= 4; i++)
{
InsertLVColumn(RecvListView, i, i, szColumnHeadings[i - 1], iColumnWidths[i - 1], (i == 4 ? false : true));
}
InsertLVColumn(hBlocIng, 1, 1, TEXT("Blc"), 31, true);
InsertLVColumn(hIngBloc, 1, 1, TEXT("Ign"), 31, true);
SecureZeroMemory(szIgnored, MAX_PACKET_LEN * sizeof(wchar_t));
SecureZeroMemory(szBlocked, MAX_PACKET_LEN * sizeof(wchar_t));
break;
case WM_COMMAND:
if(wParam == IDC_HOOK)
{
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&InstallSendHook, 0, 0, 0);
SetDlgItemTextA(hWnd,IDC_HOOK,"Unhook");
}
if(wParam == IDC_SEND)
{
char buffer[5000];
GetDlgItemTextA(hWnd,IDC_EDITSEND ,buffer,5000);
eraseAllBlanks(buffer);
msSendPacketA(buffer);
}
if(wParam == IDC_BLOCK)
{
TrackPopupMenu(hmenu,TPM_LEFTBUTTON,100,100,0,hWnd,0);
GetDlgItemText(hWnd, IDC_BLCED,szBlocked, MAX_PACKET_LEN);
LVITEM lvi;
ZeroMemory(&lvi, sizeof(lvi));
lvi.mask = LVIF_TEXT;
lvi.iItem = SendMessage(RecvListView, LVM_GETITEMCOUNT, 0, 0); /* or set to 0 for testing */
lvi.iSubItem = 0;
lvi.pszText = szBlocked;
lvi.cchTextMax = lstrlen(lvi.pszText) + 1;
ListView_InsertItem(hBlocIng, &lvi);
} |
this is a few more code, thanks all ready
|
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Jul 29, 2010 4:05 pm Post subject: |
|
|
i'm honestly pretty busy right now and don't have time to fix something if you can't even give me code that compiles. i'm looking for something i can just copy and paste straight into vc++ and hit compile and it'll at least compile with no errors.
there's code right here though :
http://msdn.microsoft.com/en-us/library/ms647558
|
|
Back to top |
|
 |
NoMercy Master Cheater
Reputation: 1
Joined: 09 Feb 2009 Posts: 289
|
Posted: Fri Jul 30, 2010 3:04 am Post subject: |
|
|
I managed to fix it
HEMNU hmenu has to be a global variable, and the rest I just uses the hwnd from wParam to see if the HWND is from a listview, else the pop up menu doesnt show up.
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|