473,394 Members | 1,737 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,394 software developers and data experts.

Context menu handler code, from C++

Hi, i'm having a little problem with my context menu handler.
Basically if i select multiple files and right-click OPEN or EDIT, it
uses my context menu to open it. It is because i am missing this line
of code of C++ in my C# code.
-------------------------
// If lpVerb really points to a string, ignore this function call and
bail out.

if ( 0 != HIWORD( pInfo->lpVerb ))
return E_INVALIDARG;
---------------------------
Here is the C++ example code to bring up a mesage box:

HRESULT CDLLRegShlExt::InvokeCommand ( LPCMINVOKECOMMANDINFO pInfo )
{
// If lpVerb really points to a string, ignore this function call
and bail out.

if ( 0 != HIWORD( pInfo->lpVerb ))
return E_INVALIDARG;

// Check that lpVerb is one of our commands (0 or 1)

switch ( LOWORD( pInfo->lpVerb ))
{
case 0:
case 1:
{
CProgressDlg dlg ( &m_lsFiles, pInfo );

dlg.DoModal();
return S_OK;
}
break;

default:
ATLASSERT(0); // should never get here
return E_INVALIDARG;
break;
}
}
------------------------
HERE is my C# code to call a custom app:

void IContextMenu.InvokeCommand(IntPtr pici)
{
try
{
//fileList
StringBuilder fileList = new StringBuilder();
StringBuilder sb = new StringBuilder(1024);
uint i = 0;

//Get number of files
uint uNumFiles = 0;
uNumFiles = DllImports.DragQueryFile(m_hDrop, 0xFFFFFFFF, null,
0);
//make file name
while (i < uNumFiles)
{
DllImports.DragQueryFile(m_hDrop, i, sb, sb.Capacity + 1);
fileList.Append(sb + ",");
i++;
}

// Determine which of the context menus was clicked
Type t = Type.GetType("ShellExt.INVOKECOMMANDINFO");
INVOKECOMMANDINFO ici;
ici = (INVOKECOMMANDINFO)Marshal.PtrToStructure(pici, t);

switch (ici.verb - 1)
{
case 0:
// Send File(s) to CheapFTP client
Process.Start("c:\\CheapFTP.exe", "\"" +
fileList.ToString() + "\"");
break;

case 1:
// Send File(s) to CheapFTP client with QuickSend Flag
enabled
fileList.Append("QuickSend,");
Process.Start("c:\\CheapFTP.exe", "\"" +
fileList.ToString() + "\"");
break;

default:

break;
}

}

How can i get

if ( 0 != HIWORD( pInfo->lpVerb ))
return E_INVALIDARG;

into C#, as i know the "pInfo" of the C++ is the equivalent to the
"ici" in my C# code so it "bails out" and returns the E_INVALID arg so
it will OPEN or EDIT the file with the proper program?

Mar 27 '06 #1
0 3231

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

Similar topics

0
by: VP | last post by:
G'day folks, well i am attempting to get an understanding on how to create the menuitems in a context menu on the fly. So far I have managed to actually achieve the menu items being created for...
4
by: Don Peters | last post by:
I can't seem to find an answer to this problem in spite of many searches. I have a VB.NET program that has a context menu popup event. In it I associate some menu items with their events, as...
3
by: jcrouse | last post by:
Is it possible more multiple controls (labels) to share the code from one context menu. I have 32 labels on a form and don't want to add 32 context menu controls. Where might I find information on...
1
by: Chris Murphy via DotNetMonster.com | last post by:
Hi all, I'm just wondering if any one can help me with this development issue I'm having. I've created a customized treeview control to handle the particular tasks to which I'll be using it. Within...
2
by: Paul E Collins | last post by:
A context menu is created in the scope of the RightClick event, but it continues to be displayed after that event handler terminates - i.e. after it has gone out of scope. The code works correctly,...
5
by: james | last post by:
Hello, I am having a little trouble creating an event handler for a context menu toolstripmenuitem. I've seen various tutorials and so on, but I keep getting a bit stuck! So far I have a second...
2
by: Ron M. Newman | last post by:
Hi, Just need a little advice. Id like to build *dynamic* context menus for tree nodes. I'm pretty versed in building context menus and attaching them to tree nodes. My question is, what...
2
by: MCM | last post by:
I'm working on a plotting control. The plotting control will have a context menu with basic commands for "scaling", "zooming", etc. Is there a way that, from the parent form, I can add more...
1
by: paragpdoke | last post by:
Hello Everyone. I am new to Windows programming / registry settings and I need help regarding setting a context menu. Allow me to provide details. - There is a DLL written in C++ which somehow is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.