|
I am writing a high-level automated integration test. I have some MenuCommands that update their checked state based on some criteria in their Update event handler. Is there any way I can force this event to happen programmatically so I can get the menu command to update so I can test it?
Thanks,
-- Rick
|
|
|
|
|
Hi there. Thanks for the control. It has been very useful so far. I am trying to use the menus I created on a form in a C# dll from within a MC++ client, but I have noticed that I cannot grab the MenuCommand from the control, I get a run-time error.
I tried making my C# code CLS compliant, thinking that would perhaps help, and I noticed that the only places where I had problems were when I used the MenuCommand.
Thanks for any help,
-- Rick
|
|
|
|
|
Rick Pingry wrote:
I am trying to use the menus I created on a form in a C# dll from within a MC++ client
This is a problem with marshalling across context boundaries. Do a simple search here at The Code Project on the word "Marshal."
You may also have to use the fixed C# keyword to "pin" the data in memory as the CLR moves memory around and only tracks its own internal use of memory objects. Again, a marshalling issue.
Rick Pingry wrote:
I tried making my C# code CLS compliant
Being CLS compliant is clearly not the issue. You simply cannot just willy-Nilly pass pointers to memory locations around within C#, much more so when you pass them across process boundaries to other applications or AppDomains.
-Doug
|
|
|
|
|
I am not going between managed/unmanaged code boundaries, so I do not see why marshalling is the issue. What I have is a C# dll which provides the base classes, interfaces, and top level application form that have these MenuCommands from the MagicLibrary. Then there are plug-ins can be written in the various managed languages. Then there is the application itself, which simply calls a function in the base dll that loads any available plug-ins and starts the main form.
I can write plug-ins in C# and VB that can use the MenuCommands without any problem (plug-ins can add menu items to the main menu). I can write a plug-in in managed C++ also, I just start to have problems when I try to access the MenuCommands.
The reason that I think this is a CLS compliance issue is that when I add the CSL compliant attribute to the base DLL, the only place that it fails is where I am exposing the MenuCommand in my public interface. I made a little wrapper class that has a MenuCommand as a member which forwards the member functions I am interested in. When I did that, everything worked fine. The managed C++ plug-in was able to use my wrapper without any problems at all.
I was able to get this work-around going ok. I was just wondering if I could get a CLS compliant version of the MenuCommand so I wouldn't have to.
-- Rick
|
|
|
|
|
Rick Pingry wrote:
The managed C++ plug-in was able to. . .
This is my point regarding marshalling. Managed C++ is not fully CLR compliant and it never will be. C# is unless you use the unsafe keyword. Even then it may still be unless something really unusual is happening within the unsafe section. Managed C++ on the otherhand, merely has a garbage collector and some other special features added, but it does not produce fully compliant CLR.
That is why Managed C++ will not run on Windows CE, Pocket PCs, Windows Mobile Phones, Linux, or Macs. Only fully CLR compliant languages will compile and run on all these platforms with no changes. Managed C++ uses too much native code to be fully CLR compliant. Managed C++ is not meant to be fully CLR compliant, and if it were, there would be no reason to use it over C# or VB.NET, because it would loose its special features that fully CLR compliant languages simply cannot posses. It is just too low level.
Visual Basic insulates users by performing most marshalling functionality transparently. So it does not suprise me that VB was able to use your dll. Managed C++, or any other C++ derivative, requires you to personally deal with marshalling issues.
-- Doug
|
|
|
|
|
Ah, thanks for the insight.
-- Rick
|
|
|
|
|
Hi,
I am Tushar,
I wnat to know about your GUI Windows controls.
Is these control free for use.
Is your control gives XP like look n feel.
If yes can you give me your control for mY project.
Waiting for reply
Thank You
Tushar P.
|
|
|
|
|
I have a contextmenu which I dynamicly change from a click in the menu itself. It removes and adds items in a submenu. But after one change the submenu becomes "empty". But it isnt empty. The little arrow to the right at the item says that it is more items (means its a submenu). And if I make a temp. procedure which just checks items in the submenu, everyone is there.
If I use this contextmenu on my form instead it works just like it should! But when using it on my notifyIcon it doesnt work. If I for example first clicks on a item in the menu from the notifyIcon which changes the menu and then AFTER clicks on the form to popup the menu and then again go to the menu in the notifyIcon its properlly refreshed.
Anyone gets my problem!?
Some help would be nice. I have been googled a whole day not finding any solution.
|
|
|
|
|
Thanks for the great stuff, it has been very helpful.
Is there any way to programmatically click a menu item? In this case it is one of the top menu items that I would like to expand automatically on startup.
Thanks,
-- Rick
|
|
|
|
|
Hi
I have download the dotnetbar form devcomponents.com but i don't now how i can to do to install the *.dll into my VIsual Studio .NET. I try to execute the samples but always get an error like "FileNotFoundException' .
What can i do??
|
|
|
|
|
Hi,
When i create a menuitem and within this menuitem i create several sub menuitems
i get a object reference set.
Help how can i solve this problem
Klaasjan
Klaasjan
|
|
|
|
|
I have created a mdi form with File and Edit menu items in the Parent form. I have created one child of the MDI parent. On the child window l have placed a file menu. When the program starts the Parent Menu items are shown. Now I press File menu on the Parent form to show the child form in maximized at this instance l want the child's File menu be merged with Parents File menu.
Many thanks for your help in advance
Sunil.
|
|
|
|
|
Hello,
Is it possible to add "Popup menu" as context menu to a tool bar control. It would be be nice to have same look and feel of menu control, popupmenu. So please provide the interface to make use of this popup menu as context menu to a tool bar.
Thanx in Advance
Jayakarthik
|
|
|
|
|
What if for some strange reason (like I don't have VS.Net) I wanted to compile the demo on the command line (or using a response file). The response file I have is:
/target:winexe
/out:magictest.exe
/r:MagicLibrary.dll
SampleMenus.cs
AssemblyInfo.cs
/resource:MenuImages.bmp
/resource:SampleMenus.resx
This compiles fine, but the resultant exe gives a "Application has generated an exception that could not be handled." error. I'm sure there's something important I've left out of the response file.
______________ Marc Heiligers Not one shred of evidence supports the notion that life is serious
|
|
|
|
|
When you show a PopupMenu and it overlaps another control while the mouse is inside that control, the control no longer receives WM_MOUSELEAVE messages after the PopupMenu is dismissed. This is because the control still thinks the mouse is over it.
HOW TO REPRODUCE:
1. Start up the docking sample for MagicLibrary.
2. Choose Manager -> Create 3 in Column.
3. Hover the mouse over the maximize button of the Form 0 docking window, and leave the cursor there.
4. Activate and show the Settings menu via keyboard, and press ESC twice to deactivate it again.
5. Move the mouse outside of the maximize button and notice how the button is still in its hover state. Only restarting the application will fix it.
HOW TO FIX:
The solution is simple. Right before calling CreateHandle in CreateAndShowWindow for the PopupMenu, add a call to ReleaseMouse, and declare the function ReleaseMouse, as follows:
private void ReleaseMouse() <br />
{ <br />
<br />
IntPtr hWnd = User32.WindowFromPoint(Cursor.Position.X, Cursor.Position.Y); <br />
if(hWnd != IntPtr.Zero) <br />
{ <br />
User32.SendMessage(hWnd, Win32.Msgs.WM_NCMOUSELEAVE, 0, 0); <br />
User32.SendMessage(hWnd, Win32.Msgs.WM_MOUSELEAVE, 0, 0); <br />
} <br />
}
Declare the WindowFromPoint API function in User32 as follows:
[DllImport("User32.dll")] <br />
public static extern IntPtr WindowFromPoint(int xPoint, int yPoint);
You may also need to declare the WM_MOUSELEAVE and WM_NCMOUSELEAVE messages as per the Win32 API documentation.
I have a symbiotic relationship with my computer.
|
|
|
|
|
Tried it, but the correction doesn't work... Any idea ?
If I Right-Click on a control to display a Pop-Up menu, then I can Right-Click anywhere on the form and the same Pop-Up menu is always displayed, until I Left-Click on something, then the Right-Click works again.
|
|
|
|
|
Phil,
Good stuff. Why don't you grop me a line (namortaror@hotmail.com). There is a project you might be interested in.
Roman
|
|
|
|
|
Failed to download the source codes!!
|
|
|
|
|
According to the code followed
I do not know How can i add my own icon to the menu
can you help me!!!!
How can i to modify the code??
Protected Sub LoadResources()
' Create a strip of images by loading an embedded bitmap resource
_images = ResourceHelper.LoadBitmapStrip(Me.GetType(), _
"SampleMenus.MenuImages.bmp", _
New Size(16, 16), _
New Point(0, 0))
End Sub
Dim window1 As MenuCommand = New MenuCommand("&New Window", _images, 0, New EventHandler(AddressOf OnNewWindowSelected))
Dim window2 As MenuCommand = New MenuCommand("Cl&ose", _images, 1, New EventHandler(AddressOf OnCloseWindowSelected))
|
|
|
|
|
This is what I did in C#, so just do that same thing in vb and you'll get the menu bitmap to show up.
// Create my menu item.
MenuCommand mImport = new MenuCommand("&Import data", m_ImageListToolBar, 16, new EventHandler(OnImportData) );
mMenuCom3.MenuCommands.AddRange(new MenuCommand[]{mImport});
All you have to do is add all your images to a imagelist and then specify the proper imagelist index like I did above.
Hope this helps
|
|
|
|
|
when I did that as you said,
It caused some error as following:
'DefaultDomain': Loaded 'c:\winnt\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'UltEditPro': Loaded 'F:\Computer\EXE\Visual C#\myproject\UltEditPro\bin\Debug\UltEditPro.exe', Symbols loaded.
'UltEditPro.exe': Loaded 'c:\winnt\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded.
'UltEditPro.exe': Loaded 'c:\winnt\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded.
'UltEditPro.exe': Loaded 'c:\winnt\assembly\gac\magiclibrary\1.7.4.0__3a6eb82f876a49bc\magiclibrary.dll', No symbols loaded.
'UltEditPro.exe': Loaded 'c:\winnt\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.
An unhandled exception of type 'System.ArgumentException' occurred in system.drawing.dll
Additional information: 'null' is not a valid value for 'stream'.
Unhandled Exception: System.ArgumentException: 'null' is not a valid value for 'stream'.
at System.Drawing.Bitmap..ctor(Stream stream)
at Crownwood.Magic.Common.ResourceHelper.LoadBitmapStrip(Type assemblyType, String imageName, Size imageSize, Boolean makeTransparent, Point transparentPixel)
at Crownwood.Magic.Common.ResourceHelper.LoadBitmapStrip(Type assemblyType, String imageName, Size imageSize, Point transparentPixel)
at UltEditPro.UltEditPro.LoadResources() in f:\computer\exe\visual c#\myproject\ulteditpro\ulteditpro.cs:line 72
at UltEditPro.UltEditPro..ctor() in f:\computer\exe\visual c#\myproject\ulteditpro\ulteditpro.cs:line 45
at UltEditPro.UltEditPro.Main() in f:\computer\exe\visual c#\myproject\ulteditpro\ulteditpro.cs:line 455The program '[2384] UltEditPro.exe' has exited with code 0 (0x0).
|
|
|
|
|
when I did that as you said,
It caused some error as following, why? Would you like to explain it to me?
'DefaultDomain': Loaded 'c:\winnt\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'UltEditPro': Loaded 'F:\Computer\EXE\Visual C#\myproject\UltEditPro\bin\Debug\UltEditPro.exe', Symbols loaded.
'UltEditPro.exe': Loaded 'c:\winnt\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded.
'UltEditPro.exe': Loaded 'c:\winnt\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded.
'UltEditPro.exe': Loaded 'c:\winnt\assembly\gac\magiclibrary\1.7.4.0__3a6eb82f876a49bc\magiclibrary.dll', No symbols loaded.
'UltEditPro.exe': Loaded 'c:\winnt\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.
An unhandled exception of type 'System.ArgumentException' occurred in system.drawing.dll
Additional information: 'null' is not a valid value for 'stream'.
Unhandled Exception: System.ArgumentException: 'null' is not a valid value for 'stream'.
at System.Drawing.Bitmap..ctor(Stream stream)
at Crownwood.Magic.Common.ResourceHelper.LoadBitmapStrip(Type assemblyType, String imageName, Size imageSize, Boolean makeTransparent, Point transparentPixel)
at Crownwood.Magic.Common.ResourceHelper.LoadBitmapStrip(Type assemblyType, String imageName, Size imageSize, Point transparentPixel)
at UltEditPro.UltEditPro.LoadResources() in f:\computer\exe\visual c#\myproject\ulteditpro\ulteditpro.cs:line 72
at UltEditPro.UltEditPro..ctor() in f:\computer\exe\visual c#\myproject\ulteditpro\ulteditpro.cs:line 45
at UltEditPro.UltEditPro.Main() in f:\computer\exe\visual c#\myproject\ulteditpro\ulteditpro.cs:line 455The program '[2384] UltEditPro.exe' has exited with code 0 (0x0).
|
|
|
|
|
I know this is very old, but I thought I would post a response in case anyone else has had this problem, because I just did.
You have to make sure that the bitmap you are using is an embedded resource. If you look in the properties of your bitmap (click on the file in your Solution View, NOT the editor), you will see an option that says "Build Action". You need to change that to "Embedded Resource".
Hope this helps someone
-- Rick
|
|
|
|
|
Thanks a lot!!! It helped me to fix up the problem i was seeing.
regards,
-raghav
|
|
|
|
|
The properties of my bitmap have chosen the "embedded resource",but also have this error,why?
|
|
|
|
|