|
i am a newbie at c#, but have a good amount of time with vc++ development.. can someone help me with some questions?
in vc++ my application could have variables and functions like:
CCompanyStore* myCompanyStore;
void ShowAboutDialog(); and i would call them throughout the program like:
CMyApp* pApp = (CMyApp*)AfxGetApp();
pApp->ShowAboutDialog(); i would use these types of functions for replacing views in my mainframe and such as well.. but i dont understand how to call a function from my base form without doing something stupid like calling this.Parent.Parent.SetStatusText("hello"); ..
is there an easy way to get a pointer or a handle onto the main form i have derived from System.Windows.Forms.Form to call its functions or get/set its variables?
thanks in advance for any pointers!
EDIT: just to clarify, i want to be able to call functions from anywhere in the program to set the status bar text, or to enable/disable a toolbar button, or to replace the form displayed in the background, etc.
|
|
|
|
|
Remember that everything in C# is defined in a class. So, check out the static [^] keyword. I believe that is what you want. Here[^] is another reference.
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
i guess the static variables would work for maintaining application variables, but i still dont understand how i would access the variable of that class type if it is a member variable of my main form..
basicly if i have a function which sets what is being displayed in my main form i would want to be able to call that function from another form..
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
The equivalent of AfxGetApp is the .NET Application class, which holds the ApplicationContext and the MainForm.
Unfortunately, the ApplicationContext member is not visible from your own code (it's protected).
|
|
|
|
|
so is there another way to get a handle on the main form?
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
dazinith wrote:
so is there another way to get a handle on the main form?
First of all, a form handle is a different thing. All forms expose the underlying WIN32 window handle through the this.Handle property, but that's a different matter.
Beside navigating the parent hierarchy (as you pointed out in your original post), the most straight forward way to let a main form method be called from a child form is to pass a this reference to it when the child form is created. Passing this passes a reference to it, not a copy.
|
|
|
|
|
I just finished porting my C++ classes over to C# and now I want to document everything. In other words, I want to put the usual /// comments on top of every class and public member. I've started doing it manually, but it seems to me like there ought to be an easier way. I mean, it's a pain to have to write out the opening and closing tags for the summary, params, remarks, etc. So I'm wondering if there's a tool out there that can scan a .cs file, list all the public classes and members in a tree pane (on the left) and allow me to fill in the appropriate doc sections (on the right). This would allow me finish my task sooner, more accurately, and with less typing.
Anyone know of something like this, of should I start thinking about creating one?
Thanks,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
Alvaro Mendez wrote:
should I start thinking about creating one?
You could do that and then post it as an article...it would be very nice to have. Meanwhile, I'll ask around.
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|
|
You can try doxygen. Its rather flexable.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hello,
I agree with you. Doxygen is great. But it will be also great to have some kind of tool as described working with the .NET documentation system.
Have a nice day,
R. LOPES
Just programmer.
|
|
|
|
|
Hello,
I don't know about any such tool but it could be really useful.
Feel free to create one. It will be greatly appreciated .
Have a nice day,
R. LOPES
Just programmer.
|
|
|
|
|
What about NDOC? You can then use the VSHK to convert the CHM into a .NET help project.
Jarrod
|
|
|
|
|
Hello,
I'm wondering if anybody managed to use the webbrowser
control in a multithreaded application.
I would like to have several browsers runnning in
parrallel in the same program, but when I create several
webbrowser controls and call the navigate() function of
each of them to load different sites, it seems that if one
of them is long or somewhat stuck it affects all the
others. If I increase the number of webbrowser I get even
more troubles. I'm doing my tests using C#.
Has anybody tried this kind of solution ? Any experience
will be welcome.
Thanks,
R. LOPES
Just programmer.
|
|
|
|
|
I believe that's because all web browser control instances are hosted by a unique ole control site.
I would try to write my own. Derive the AxHost class. (google!)
|
|
|
|
|
Hello Stephane,
Thank you for your help. Do you have any idea on how to test that with VS .NET easely (if the instances are hosted by the same control) ?
Thanks,
R. LOPES
Just programmer.
|
|
|
|
|
Hi,
I am trying to display a metafile as a background of a C# custom control.
I need the control allows to zoom the metafile without image degradation (the metafile contains only lines and arcs, no bitmaps).
The DrawImage method do not give me the desiree result since scaling yield a loose of details.
e.Graphics.ScaleTransform(100, -100);
e.Graphics.DrawImage(image, 0,0)
or
e.Graphics.DrawImage(image, Rectangle(0,0,100,100))
Using PlayRecord method of Metafile class the drawing process is too slow.
Any ideas?
Thank you
Alessandro
|
|
|
|
|
do any body knows a good reference on how to use DDE by C#
i tried to do that using DDEML (APIs) but am stucked with the getdata method, it takes a pointer paramenter to a data type that should be a string, and i don't think that we can make a pointer to a string in C#...ref and out gives a null reference exipition.
please help me...i will be very thankful
|
|
|
|
|
Hello,
I work on the same think. To make DDE working for C#. It is very difficult.
For getdata I use following declaration
[DllImport("user32.dll")]
public unsafe static extern int DdeGetData(IntPtr hData, sbyte *pDst, int cbMax, int cbOff);
and in the code I do
arry = new Byte[cb];
fixed(Byte result = arry)
{
User.DdeGetData(hData, result, cb, 0);
ppsz = new StringBuilder(new string(result));
}
Did you have some progress or did you gave up.
So far my class is working for some time, but fails later with a illegal memory access error, which is probably caused by the GC in C#.
Hope that helps,
Wolfram
wolfram.rinke@inode.at
|
|
|
|
|
look for http://www.codeplex.com/ndde.
jiugarte brasil
|
|
|
|
|
this one might be alittle easy....im just having a little trouble. I have a form..that has 2 tab pages embeded into (and tbcontrol) on the second tab .. i have a PictureBox (pbox1). Inside that picture box (pbox1)i have put other picture boxes (pbox2) that move to diffrent locations at diffrent times. i need to find a way to get (pbox2) to display its own tool tip. I cant seem to event get a OnMouseMove override to work on (pbox2). Is there something i need to do before hand to get the tooltip class to be noticed by (pbox2). Thanks alot for your time. I can make this work fine on the form its self. But as soon as i add the pictureBox(pbox1) to a tabpage all of the functions (i.e OnMouseOver) dont respond. Is there some kind of command i need to enable on the tabpage / tabcontrol to get it to show my tool tips or respond to mouse over events ? thanks alot
If you have any further questions reguarding this one...please post them here...i will get back to them ASAP.
Jesse M
The Code Project Is Your Friend...
|
|
|
|
|
It might be helpful if you included some code...maybe ftp the code somewhere so that we can all look at it. The form sounds like it's a mess.
[edit]Also, if you have MSN Messenger, e-mail me a response to this message and we can chat about this. Might help you get it done faster.[/edit]
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|
|
i can email it to. you its about 300+ lines... It is part of a project for school. The project is to create a traffic simulation with cars randomly generated...with random types....cars changing lanes , random speed and space buffers. I choose to use picture boxes because instead of using just drawing graphics i could assing the picture box its own tool tip. the text of the tool tip would reflect the speed,lane postion ect of thta car. It works as suspected. but as soon as i draw the "cars" on a tabcontrol/tabpage the tooltip of the "cars" dont work. But if i draw them onto the form itself. it works fine. Anyways give me your email and ill send you that class as well as the main class.
Jesse M
The Code Project Is Your Friend...
Actual on the other hand i set this thing up at yahoo..and i think it will work... http://briefcase.yahoo.com/bc/cuteone_97058/lst?.dir=/[^]
|
|
|
|
|
Is there a way to change the Title Bar font? I don't want to change the fonts from Display Properties cause it changes all the Windows Title Fonts. I am looking for a C# function or maybe a WinAPI to achieve this.
Thanks in advance
|
|
|
|
|
Hi. Is it possible to do something like this? :
res = Response;
res.Write("hello world");
|
|
|
|
|
Well, the Response class is of type HttpWebResponse. So what you would really do is this:
HttpWebResponse res = Response;
res.Write("hello world");
This works because HttpWebResponse is a reference type, so all you are doing is creating a new reference to the same Response type.
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|