473,320 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem with rendering clipboard contents in popup menu

I have an mfc dialog application that sets a dll as a global keyboard
hook. The dll looks for the correct key press, grabs the mouse coords
and then sends a message back to the dialog app. I am trying to get
the dialog app to set focus on the windows under the cursor, issue a
control-c keyboard event to copy the underlying text and then read
from the clipboard and display in a popup menu. I have not been able
to get this to work. The text under the cursor is copied the first
time and display in the popup, but subsequent keyboard presses over
different text results in the initial text to be display in the menu.
I am attaching the method in the dialog app that handles the message
coming from the dll hook. Thanks for any help you can offer.

LRESULT CInSideDlg::processKeyboardClick(WPARAM wParam, LPARAM lParam)
{

POINT pt;
pt.x = wParam;
pt.y = lParam;

HWND hwnd = ::WindowFromPoint(pt);

::ShowWindow(hwnd, SW_SHOW);
::SetForegroundWindow(hwnd);
::SetFocus(hwnd);

keybd_event(VK_CONTROL,0x45,KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(0x43,0x45,KEYEVENTF_EXTENDEDKEY | 0,0);
keybd_event(0x43,0x45,KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);

CMenu mainMenu;
VERIFY(mainMenu.LoadMenu(IDR_MENU2));

CMenu* popupMenu = mainMenu.GetSubMenu(0);

int iCount = popupMenu->GetMenuItemCount();

while (iCount > 0) {
popupMenu->DeleteMenu(0, MF_BYPOSITION);
iCount = popupMenu->GetMenuItemCount();
}

if (OpenClipboard()) {
HANDLE hClipboardData = GetClipboardData(CF_TEXT);
char *pchData = (char*)GlobalLock(hClipboardData);

CString strFromClipboard = pchData;
popupMenu->InsertMenu(0, MF_BYPOSITION | MF_POPUP,
ID_INSIDE_DUMMYITEM, strFromClipboard);
popupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, wParam,
lParam, AfxGetMainWnd());

GlobalUnlock(hClipboardData);
CloseClipboard();
}

return 0L;
}
Jul 22 '05 #1
1 1955
twinfire wrote:
I have an mfc dialog application


This group is for standard C++ language only, not for MFC or dialogs,
try this group instead:

microsoft.public.vc.mfc
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: xyz | last post by:
I have a menu item to handle clipboard actions (cut, copy, paste). When I paste text that I copied from a Hungarian web page, the display looks normal on my RichTextBox, but the text retrieved from...
8
by: LG | last post by:
Just have a question with regards to the clipboard, and how to read what other applications (Adobe InDesignCS) place in the clipboard. I am currently in the process of creating a booklet from a...
0
by: vikram.cvk | last post by:
Hello Experts, Im trying to design a CSS vertical drop down menu which should have the following functionality. Home About Us | -->Overview
4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
3
by: Tyrone Slothrop | last post by:
The first question, is this even possible? What I need to do is pass the contents of a PHP web page from a textarea using window.open method to a new browser window and display it. The page has...
16
by: DataBard007 | last post by:
I have an Access97 application whose form contains many text boxes. What do I have to do in order to copy the contents of one of these text boxes to the clipboard? I want to do this so I can then...
16
by: ad | last post by:
Hi, How can we get the content of clipboard with program?
1
by: Al | last post by:
I'm looking for a sample to save File from clipboard into specified folder on HD. I found many samples for copying text, image etc. But no file copying code so far. Thank you Al
6
by: Adam Sandler | last post by:
Hello, I have a richtextbox and a method which copies the contents of the richtextbox to the clipboard -- like so: Clipboard.SetText(this.richTextBox1.Text); The problem is if there are any...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.