|
|
how could i use the mschart in a c# code ,,,i simply need to give my chart 2 columns(coulmn 1 actual cost,coulmn 2 actual cost) ,i need axis y only with millions,and i 've the coulmn value in variables plz answer me quickly..
|
|
|
|
|
|
You must set ColumnNumber and RowNumber first. ColumnNumber is the number of kind of data ( in simple, total color that you see in chart ). The RowNumber is the total data that you want to show ( Default : R1, R2, R3 , ... ). To fill the data you can do this.
//Fill the first column, the second row
myChart.Column = 1;
myChart.Row = 2;
myChart.Data = 25;
NOTE : The property name may be wrong as I don't remember it precisely. But that is the main idea in using ActiveX MSChart.
|
|
|
|
|
Hello all,
I have a tab control which initially has one tab page. I want to dynamically create some more tab pages which should have the same controls as the first one.
To read the controls on the first page I am doing the following :
Control[] myObjArray = new Control[this.tabControl1.TabPages[2].Controls.Count];<br />
this.tabControl1.TabPages[2].Controls.CopyTo(myObjArray,0); The problem is, when I try to add the controls obtained using the above method, the controls are removed from the first page.
Control NewControl = new Control();<br />
NewControl = (Control)myObjArray[nCount];<br />
myTabPage.Controls.Add(NewControl);
This method however successfully puts the controls on the newly created page.
Any ideas how I can have the controls on both the pages ?
Thanks in advance.
Regards,
Amit
|
|
|
|
|
Control objects are reference types, and by they can only belong to one parent (typical in a window manager). You're not actually cloning these controls so they are getting re-parented in the new TabPage .
Perhaps a better - more object-oriented - approach would be to subclass TabPage and initialize all the controls in the constructor (like VS.NET does when you add controls to a Form , UserControl , etc.). Then you simply need to instantiate and add your custom TabPage class. New instances of all the controls in each separate instance of this custom TabPage class will already be there, just like instantiating multiple instances of some Form you created.
-----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'm converting my idl file to a tlb file, which now works fine. I have the base classes for Drag and Drop in the file, but when I convert it to a dll via tlbimp, i get a lot of errors, that leads me to believe that I am missing out on a large number of type definitions.
Where do I go to import these?
Aditionaly, when comparing my DLL with the windows form DragDrop methods, a lot of my int32's are replaced with UInt32. Why is this the case?
All my return values are void, wheras, in the IoleDataObject, they are almost all exclusively int.
Looking at the reflector decompilation, some of the objects that my version tries to interpret and convert but fails to, are all stored as object , i.e. IEnumStatData and IAdviceSink. How would I set up tlbimp to set it up this way?
Also, many of my types now come with & appended after them when they are used in method descriptions. Why is this?
My compiled version seems to have added object's for all the base types, Bitmap, clip format, metafile, pallete, and a whole heap of IWinTypes and IAdviseSink.
I don't know where these are actualy coming from. Do they exist in the .NET run time assembly already? I thought they did.
my IDL file I compiled looked like this:
<br />
import "oaidl.idl";<br />
import "ocidl.idl";<br />
<br />
<br />
[<br />
uuid(01020304-0506-0708-9010-011012013014)<br />
]<br />
library DragDrop{<br />
import "objidl.idl";<br />
<br />
enum tagADVF;<br />
enum tagDATADIR;<br />
enum tagTYMED;<br />
enum tagCLIPFORMAT;<br />
<br />
struct tagFORMATETC;<br />
struct tagSTGMEDIUM;<br />
struct tagSTATDATA;<br />
<br />
interface IEnumFORMATETC;<br />
interface IEnumSTATDATA;<br />
interface IDataObject;<br />
};
Any advice would be welcome on this issue.
Cheers
Cata
|
|
|
|
|
By default, tlbimp.exe transforms any method signatures with an [out, retval] parameter such that it because the return type of the method. Since Microsoft developers also typed these methods, you can sometimes get away with returning an int to represent the HRESULT (so it would seem), but you can still return various HRESULT codes by throwing the COMException with an appropriate errorCode parameter value - even success codes like S_FALSE .
As far as all the interfaces that were imported, these interfaces, structs, etc., are used by the interfaces you imported so they must be imported too, being that they are dependend types of the interfaces' methods that you imported (or struct member types, etc.).
If you want more control over the method signatures, you should type them yourself.
-----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-----
|
|
|
|
|
So what I have will still work? i'll just have to handle the Uints and IntPtr's differently?
What about deffining the classes that didn't get ported properly?
STGMEDIUM failed completely, and is handled as an intptr. I can define one myself, but I'm curious as to why it failed. I'm not sure where it's declared, as there are many STGMEDIUM type classes declared through the SDK import IDL's, though none actualy follow the name STGMEDIUM or tagSTGMEDIUM directly.
Many of the other interfaces, structs etc, failed to be marshaled, I got a lot of errors that looked like they failed down to a base system type.
Clipformat and STGMEDIUM in particular are my two biggest concerns, and another problem is with a Byte array that used an equation to determine the size.
I will have a crack at porting some of these to C# manualy if the whole tlbimp failes, but i'd like to go back to it due to the fact that I only had a slight brush with it.
(As opposed to MIDL which works fine now I have figured out how things work, but it took long enough)
Regards, and a happy new year
Cata
TO THE PUB! AND PARTIES!
|
|
|
|
|
If you are ready to lose some of your hair, then you can edit the interop assembly (ildasm) by hand and then recompile it with a proper marshalling (ilasm).
Things to know about tlbimp.exe :
- it's a great tool but it doesn't export all of the content of IDL files.
- you need an actual tlb file (embedded or not), if not tlbimp.exe will fail miserably
- The .NET IntPtr type is the lowest common denominator for some struct. It shouldn't be a surprise that tlbimp exports an IDL-defined struct to a mere IntPtr when either 1) the struct is not defined as tlbimp.exe expects it to be 2) the structure is overly complex. Resulting in an IntPtr means that you have to marshal the struct back and forth yourself, that's not a big deal though since the Marshal class in the InteropServices namespace provides the API for just that.
RSS feed
|
|
|
|
|
hi,
i want to know which API to set a button to be the default button of a Form. so, that button will be invoked when press Enter for that Form.
i remember i have seen b4 in msdn but not able to get it now!
any help?
thanks,
jim
|
|
|
|
|
Why do you want to use API? This feature exist in .NET.
this.AcceptButton = yourbutton;
Mazy
No sig. available now.
|
|
|
|
|
Dear memebers,
I would like to create a string bitmap and that string should be able to customized by user.
I know I can use Graphics.DrawString() to draw a string over the window, but phycially, I want to generate a bitmap for that. Futhermore, I would like to collect the memory bits of that bitmap, because I need to do some calculations or adjusting its colors .
Could somebody help me, or give me some example??
Many thanks for your help.!!
|
|
|
|
|
azusakt wrote:
I would like to collect the memory bits of that bitmap, because I need to do some calculations or adjusting its colors .
When you have your Bitmap object with Bitmap.GetPixel() you can get each pixel of bitmap. Also take look at BitmapData class.
Is that what you want?
Mazy
No sig. available now.
|
|
|
|
|
Thanks Mazy,
Do you mean I can Use Bitmap.GetPixel() to get a buffer? I'm going to try this.
because I want to collect a data buffer of that bitmap.
but one thing, how can I create a string bitmap at first??
Thank you for your help..
|
|
|
|
|
azusakt wrote:
Do you mean I can Use Bitmap.GetPixel() to get a buffer?
No,this one will give you colors.For getting bufer you can use this one:
System.IO.FileStream stream = new System.IO.FileStream("somefile.bmp", System.IO.FileMode.Open, System.IO.FileAccess.Read);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, (int)stream.Length);
stream.Close();
Now buffer contain data of bitmap. You can put in a string like this.
string str="";
for(int i=0;i < buffer.Length;i++)
str += buffer[i].ToString()+ " ";
Mazy
No sig. available now.
|
|
|
|
|
To actually create a bitmap, do something like the following (and read the documentation for the Bitmap and Graphics classes):
private void CreateBitmap(string text, Font font)
{
Bitmap bmp = new Bitmap(200, 80, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bmp);
RectangleF rect = new RectangleF(0f, 0f, 200f, 80f);
g.FillRectangle(Brushes.White, rect);
SizeF size = g.MessageString(text, font, rect.Size);
StringFormat format = new StringFormat(StringFormatFlags.FitBlackBox);
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
RectangleF posRect = new RectangleF(
(rect.Width - size.Width) / 2,
(rect.Height - size.Height / 2,
size.Width,
size.Height);
g.DrawString(text, font, Brushes.Black, posRect, format);
g.Dispose();
bmp.Save("c:\file.bmp", ImageFormat.Bmp);
}
-----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-----
|
|
|
|
|
Thank you so much for your reply, Heath~
It works well, but I just got one more question; is it possible to scale down the bitmap and the rewrite it to new bitmap?
I have 2 ideas;
1. I hope the saving of string bitmap is proportioned to the resoultion that I entered.
2. I want to let user to import a bitmap, and then I will get the bitmap and scale it to fit the resoultion, and finally save it to new bitmap.
Is it possible to the scaling?
Thanks for help~
|
|
|
|
|
Yeah, just see the documentation for the System.Drawing.Graphics class and related classes. Through transformations and a few other means you can scale it and much, much more.
-----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 am devloping a window form to List the files under a specific folder. I am using FolderBrowserDialog class for user to select a specific folder. Once a specific folder is selected I list all the files under that folder.
My problem is when Folder Browser window opens It does not show the tree view of Directory structure. Just a blank area instead. At the bottom of the window, it shows
three button " Create new folder ", "OK" & "Cancel". Appreciate any help to resolve this problem.
Code for Folder Browser:
========================
FolderBrowserDialog folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
folderBrowserDialog1.SelectedPath = Directory.GetCurrentDirectory();
DialogResult result = folderBrowserDialog1.ShowDialog();
if( result == DialogResult.OK )
{
directoryPath = folderBrowserDialog1.SelectedPath;
}
....
...
Thanks
|
|
|
|
|
Everything looks right, so you should try debugging. See what the value of folderBrowserDialog1.SelectedPath is after assigning the return value of Directory.GetCurrentDirectory . If you are setting a RootPath (assuming you didn't copy and paste the code fragment directly), make sure Directory.GetCurrentDirectory is a child of that RootPath .
-----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-----
|
|
|
|
|
Hi,
folderBrowserDialog1.SelectedPath returns the same value as Directory.GetCurrentDirectory() if I click on the OK button.
But still the tree view is not able to render. It just shows
the blank area..
|
|
|
|
|
Does someone knows how to print on windows xp pr 2000 on a custom size paper. I have tried and it prints what the default papersize the printer has. Thanks
Carlos Eduardo Hernandez P.
|
|
|
|
|
|
|