|
I think Leon was looking for a way to generate a random collection of images in memory based on images already stored on a CD. You are simply creating a thumbnail image from an existing file, not the collection of images needed.
- Nick Parker My Blog
|
|
|
|
|
The aswers you gave me where great, I was able to make my first little program.
So Cheers, and happy coding =)
|
|
|
|
|
I need to Get the List of computers connected in the server
.
I am working in 2000 prof and my server is 2000 Advanced server. Any one having idea in c#
Aravind.S
|
|
|
|
|
check sample at .NET SKD : \Samples\Technologies\Interop\Basic\ActiveDS\
or namespace System.DirectoryServices
Wiizi
|
|
|
|
|
Hi,
I would like to fill subitems on the fly of a ContextMenu. But it seems like the dot net menuItem class does not support this. The Popup event is never fired.
I fill my contextmenu with menuitems, which only has one dummy sub menuitem. Now i need an event to remove the dummy and populate the real items.
Any hints?
.:[Greetz from Jerry Maguire]:.
|
|
|
|
|
Try this :
<br />
this.ContextMenu.Popup += new EventHandler(ContextMenu_Popup);<br />
<br />
...<br />
<br />
private void ContextMenu_Popup(object sender, EventArgs e) {<br />
this.ContextMenu.MenuItems.Add(new MenuItem("ContextMenuPopup"));<br />
}<br />
I tried and it worked.
|
|
|
|
|
Hi
thanks, i will try it, but it only works for me if the sub menuitems also fire this event.
.:[Greetz from Jerry Maguire]:.
|
|
|
|
|
If not (I don't think it does, either), then learn a lesson from COM and have your objects that need to customize the context menu implement an interface of your design. Override the context menu nature (like preventing it from popping up automatically), check for the interface of the object that's being activated, and - for example - pass the ContextMenu to an interface method in order for the implementation to customize it. Then show the popup. There's many ways you can accomplish this, but basically take the approach that the active object will modify it's own ContextMenu based on its state or the state of objects to which it's related.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
This is how I do it:
- create a ContextMenuPopup in the application (I do this in the base form, but use it for multiple forms in the same application). I think that I used the GUI designer originally:
this.contextMenuPopup = new System.Windows.Forms.ContextMenu();
- the GUI designer threw this code in; how much is actually used? dunno!
this.contextMenuPopup.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemTitle,
this.menuItemSep1,
this.menuItemOpt1,
this.menuItemOpt2,
this.menuItemOpt3});
this.contextMenuPopup.Popup += new System.EventHandler(this.contextMenuPopup_Popup);
- In the form you want it to apply to, add:
newWindowL.GraphicControl.ContextMenu = contextMenuPopup;
- Write a menu builder
This is tricky; you need to remember that:
- each MenuItem has to be a clone, not an original, if you are "mix'n'match"ing a menu. Well, I found that it helped 'cos some items are duplicated.
- each MenuItem needs an event handler. I use a recursive method to allow multi-level context menus
-MenuItemCommand is derived from MenuItem & does a few fancy things like storing a command object (cf "Command Patterns")
The code has just been copied & pasted. Use it more for ideas/principles than 'as is'; here goes:
#region ContextMenuPopup stuff
private void contextMenuPopup_Popup(object sender, System.EventArgs e)
{
ContextMenu ctxMenu = sender as ContextMenu;
if(ctxMenu == null)
return;
Control ctl = ctxMenu.SourceControl;
if(ctl == null)
return;
// blah blah
contextMenuBuilder.SetContextOptionNames(GarageSystem.Garage, hitStruct4ContextMenu, mEditingMenus, contextMenuPopup);
}
public void SetContextOptionNames(SEComponentMaster topLevel, Structure hitStruct, Menu.MenuItemCollection theMenuCollection,
ContextMenu theContextMenu)//, MenuClicker theEventHandler)
{
MenuClicker theEventHandler = new ContextMenuBuilder.MenuClicker(menuItemDynamicContextEntry_Click);
theContextMenu.MenuItems.Clear();
MenuPlusCommand theFilteredMenu = null;
if(mHitStructure.Owner is IWall)
{
theFilteredMenu = MenuBuilderFromXML.ReturnFirstMenuItemOwnerLike(theMenuCollection[0].MenuItems, "Wall");
}
theContextMenu.MenuItems.Add(mHitStructure.Name);
theContextMenu.MenuItems.Add("-");
if(theFilteredMenu != null)
{
MenuPlusCommand theFilteredMenuCopy = theFilteredMenu;
foreach(MenuItem I in theFilteredMenuCopy.MenuItems)
theContextMenu.MenuItems.Add(I.CloneMenu());
RecursiveSetContextMenuClickEventHandler(theContextMenu.MenuItems, theContextMenu, theEventHandler);
}
}
public static void RecursiveSetContextMenuClickEventHandler(Menu.MenuItemCollection theMenuItems, ContextMenu theContextMenu, MenuClicker theEventHandler)
{
if(theMenuItems != null)
{
foreach(MenuItem I in theMenuItems)
{
MenuPlusCommand thisSubItem = I as MenuPlusCommand;
if(thisSubItem != null)
{
if(thisSubItem.Command.ToString().Length > 1)
{
thisSubItem.Click += new System.EventHandler(theEventHandler);
}
else
{
if(thisSubItem.MenuItems.Count > 0)
{
RecursiveSetContextMenuClickEventHandler(thisSubItem.MenuItems, theContextMenu, theEventHandler);
}
}
}
}
}
}
Hope this helps
Regards
Brewman
|
|
|
|
|
I've been trawling the web for days now, looking for advanced information and source code explanation on C# and COM, and have come up almost completely empty handed.
This is extreemly frustrating, and I guess I'm close to giving up on this as there seems to be no chance of me ever managaging to implement this drag'n'drop problem I have.
If anyone could direct me to any decent resources that go deep into explaining the COM and C# interface, (the COM forums seem to be practicaly dead), I would be most appreciative.
Grats all
Cata
|
|
|
|
|
Where exactly are you stuck, I know Heath has been working with you on this recently.
- Nick Parker My Blog
Last time I checked, all programmers have selective ignorance. I know nothing about 3D graphics. I know a lot about COM. VB gets under people's skin because one can be ignorant of computer architecture and ASM and still get a lot done. - Don Box
|
|
|
|
|
The translation part.
I understand marshaling etc, and creating structures, enumerations and classes that can be interpreted by C and C++, however, there are a number of strange things in the decompilation that don't make sense to what I already know.
for instance, in EnumFormatEtc the output is changed from HRESULT (translates to int), into IEnumFormatEtc. And the HREESULT is remvoed all together.
In FormatEtc class, there is an int16 variable called "dummy", and I don't know why it is there, or what it does.
So basicaly, I'd like to find the translation guide.
Will it work if I do direct translations as well? Are these things just microsoft standards?
It's all bugging me.
Your help is appreciated, as I'd really not like to give up.
Cata
|
|
|
|
|
The Catalyst wrote:
So basicaly, I'd like to find the translation guide.
There is no "translation guide". Translation is done by knowing the Win32 APIs and the .NET SDK well. For example, why are the HRESULT s translated to void when interoping? Because most COM error codes are thrown using a COMException in .NET, specifying the result code (these can even be used for success codes, like S_FALSE ). If you need that HRESULT , you have to attribute your method with the PreserveSigAttribute(true) , or specify PreserveSig=true in any DllImportAttribute attributed methods.
I'm talking about knowing what marshaling means and what it does, I'm talking about knowing how to use the MarshalAsAttribute , the DllImportAttribute , the StructLayoutAttribute , the PreserveSigAttribute , and the various COM-related attributes (where appropriate) effectively. You must read about these and understand them well.
Knowing which managed type to use for a native type is simply understanding the bit-length and matter of the two types. A native char is 8 bits and and unsigned char is 8 bits unsigned, just like a System.Byte .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I use net send to send messages around a LAN. The message content i pull from the TextBox. But when the textBox contains two lines more. The net send only send the first line.
I know the net send end when it see the "\n".
But don't know how to solve. Is there anyone can help?
Thanks
|
|
|
|
|
what about trying \r, seeing windows is dumb!
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I tried to change "\n" and "\r" but it not work.
Here my code
string txtToSend = txtBox.Text.Replace("\n", "\r")
I tested with the message:
aaaaaaa
bbbbbbb
I returned aaaaaaaabbbbbbb.
C# is a gun, Windows is a hole.
Without gun. How can you make love?
|
|
|
|
|
I dunno dude, the answer will be somewhere in the Win2k resource kit docs, but I dont have that installed. Try searching MSDN if you are brave.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I dont have it, either. Anyway Thank for your help leppie
|
|
|
|
|
bookwormXP wrote:
I tried to change "\n" and "\r" but it not work.
Here my code
string txtToSend = txtBox.Text.Replace("\n", "\r")
I tested with the message:
aaaaaaa
bbbbbbb
I returned aaaaaaaabbbbbbb.
Try using Sytem.Environment.NewLine for your CRLF.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
This has been answered before. Search the comments (using the link above the messages box).
Also, if you create a multi-line text box and send the content as a single string, you may, in fact, be able to do this. I answered a previous question witha programmatic way that worked similar to this but I don't remember it.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Try "\n\r" or "\r\n". As much as I remember "\n\r" is correct.
Mazy
No sig. available now.
|
|
|
|
|
I tried to create a method to open a document, but I got "The file isn't specified" error message. I debugged and saw the FileName contained like "C:\MyProject\Documents\my.doc", and it seems to be ok. Here is the code:
public void OpenDoc(string myDocumentsPath,
string fileName)
{
Process myProcess = new Process();
try
{
myProcess.StartInfo.FileName = myDocumentsPath + fileName;
myProcess.StartInfo.Verb = "Open";
myProcess.StartInfo.UseShellExecute = true;
myProcess.StartInfo.RedirectStandardOutput = false;
myProcess.Start();
}
catch (Win32Exception e)
{
if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
Console.WriteLine(e.Message + ". Check the path.");
}
else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
{
Console.WriteLine(e.Message +
". You do not have permission to open this file.");
}
}
If you find something is wrong, please let me know.
Thank you for your help,
|
|
|
|
|
um... I might be able to help...
What exactly are you sending as the arguments?
(string myDocumentsPath, string fileName)
/\ |_ E X E GG
|
|
|
|
|
For example, the arguments are:
string myDocumentsPath = "C:\MyProject\Documents\"
strin fileName = "My.doc"
I hope this helps. Thanks,
|
|
|
|
|
Um... If it still dosn't work after what Heath Stewart said....
Add a @ to myDocumentsPath ... like this...
string myDocumentsPath = @"C:\MyProject\Documents\";
does it work?
|
|
|
|