|
the sample says:
Bitmap bmp = new Bitmap();
my questions is : can i create a bmp instance with 256 color depth ?
can i use the system 256 color table ( if it exists )directly ?
i do not want to get a 24 bits bmp and then transfer it into 256 color one.
i want to get a 256 color bmp directly. but HOW ?
and How to display the 256 color bmp after its creation ?
|
|
|
|
|
I think you have to set Image.PixelFormat property, but I'm not sure. One of Bitmap enumeration get this parameter.
fu0 wrote:
How to display the 256 color bmp after its creation ?
What do you mean by display?
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
my meaning is How to draw this 256 color bitmap on a form.
can i use this codes?
Graphics c = this.CreateGraphics();
c.DrawImage(256bmp,xCoordinary,yCoordinary);
can the Graphic instance draw the 256 color bitmap use the code above ?
|
|
|
|
|
Instantiate your Bitmap using the Bitmap(int, int, PixelFormat) overload like so:
Bitmap bmp = new Bitmap(32, 32, PixelFormat.Format8bppIndexed); To load a specific palette, you'll need to load it from serialized data. One easy way would be to create a 256-color bitmap in mspaint.exe or something then save it. Open that with a simple program to get the Image.Palette and serialize that to some form you can work with (runtime serialization would probably work). Just deserialize that into a ColorPalette and set that as your Bitmap.Palette (inheritted from the Image ) class.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have a custom dll in C++ which exports a class with certain member functions. I want to call the methods from a c# application. I am able to call the member functions seperately using the DllImports[....]. Is it possible to instantiate an object of the exported class from the C# tester application? Kindly help. Is there any link which would give me this detail.
Is the source code of the DLL necessary for this.
Thanks,
Regards,
Vini
|
|
|
|
|
If it where me, I would create a wrapper in Managed C++, then call that from c#. That way you could totally avoid DllImports. DllImports is fine and dandy for most functions, especially win32, but once you hit a function with some off the wall data structure it turns into a pain real quick.
-Sam
|
|
|
|
|
|
now, i have a problem in programed a network application. Have anyone can help me? The problem is that I need to open a powerpoint file in my program and send it to everyone in my network. Someone talk me that you can't embedded a powerpoint file in your program. Is it right? So, I think it may have another way like open an powerpoint than share the powerpoint to everyone in my network. But I don't how to share an application in C#. Please tell me. Thanks a lot...
|
|
|
|
|
|
PowerPoint is an application required to view PowerPoint presentations. Even if you embed it in a .NET application (written in C# or whatever other mangaged language), PowerPoint is still required to be installed on the client's machine. The installation source can be located on a network share, but it still needs to be installed on the client machine.
And, yes, actually you can embed the PowerPoint Viewer in a .NET application, but that too would need to be installed on the client's machine. This is how COM works (basically).
If you don't have PowerPoint available to all your clients on a network, you can download and install on each of their machines the PowerPoint 2003 Viewer[^], which can display PowerPoint slides from version '97 and newer (up till at least 2003).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi all,
I am trying to build OfficePlanSample (a VISIO SDK sample found at:
C:\Program Files\Microsoft Office\Visio11\SDK\Samples\Office Plan\CSharp. )
I get the error:
Microsoft.Interop.Visio.Application does not contain a definition for 'Name'
???
I have added all needed references as far as I know.
|
|
|
|
|
I already answered this one, presumably from you (get an account already). See http://www.codeproject.com/script/comments/forums.asp?msg=787915&forumid=1649&Page=1&userid=46969&mode=all#xx787915xx[^].
If you are the same person, you need to create the ActiveX interop assembly by customizing your toolbox (right click, select "Customize...") and selecting the COM control from the COM tab. Drag that into your project.
The Office 2003 PIAs for VS.NET 2003 are for the various object models, not the ActiveX controls. The ActiveX control wrappers (which inherit from System.Windows.Forms.AxHost ) will be created when you drop a COM control on your form or other container control.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok, I did that.
Is that suppose to fix it so it compiles?
I do have the control on the toolbox.
It doesn't compile!
Sorry if this is a newbie question, but I still can't make it compile....
|
|
|
|
|
The problem is that you need to use the Office PIAs (Primary Interop Assemblies) and DO NOT generate these yourself. If you need to import an ActiveX control, once you get the right COM control on your toolbox, drag it to a form or other container control in your project. This will create a different kind of interop assembly - the only kind you should generate.
If it doesn't compile, you should provide more information about the exact error. There's an infinite number of reasons why something might not compile.
Also, please register for an account. It's quick and it's free and there's many people who go by the name "Anonymous" so it's difficult to know if I'm talking to the same person all the time.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thank you very much.
I have fixed it tho', and it was the version of office and visio I had on my laptop! I had Office 2002. Just by installing Office 2003 and Visio 2003 the compilation is perfect, with no changes on my part.
Thank anyway.
I hope this information is useful to other people.
|
|
|
|
|
I have Microsoft Visio 11.0 Drawing Control in my toolbox, but how do I get Visio controls there????
I mean, the elements to draw a UML graph, for example....
|
|
|
|
|
You'll need to read about the object model on MSDN[^]. There's also several articles on working with the Visio control.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
As I suspected, you were trying to use the new PIAs more than likely. If you use the Office XP PIAs, you should be able to work with both Office 2002 and Office 2003 since following COM guidelines can help ensure then COM interfaces are backward compatible, which Microsoft does a pretty good job of doing (since they wrote the specs).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok,
got it.
Using a vss file as a container of the controls.
Thanks for baering with me!
|
|
|
|
|
I'm working with DataGrid in winforms application. I need to set focus() to a specific cell in the DataGrid.
I used the CurrentCell property to set the cell focus:
private void ColumnChangingHandler(object sender, DataColumnChangeEventArgs args)
{
switch (args.Column.ColumnName)
{
case "acsID":
{
string value = args.ProposedValue.ToString();
if (!IsNumber(value))
{
SetCellWithFocus(this.dataGrid2);
dataGrid2_GotFocus(sender, args);
}
break;
}
}
}
private void SetCellWithFocus(DataGrid myGrid)
{
myGrid.CurrentCell = new DataGridCell(1,1);
}
private void dataGrid1_GotFocus(object sender, EventArgs e)
{
MessageBox.Show(dataGrid1.CurrentCell.ColumnNumber +
" " + dataGrid1.CurrentCell.RowNumber);
}
but the focus was returned in the next cell.
Please help me.
Thanks
Mr Duc Linh Nguyen
|
|
|
|
|
I don't have VS.NET to test it now but it seems it is zero based.
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
How do we get the current path of the application?
|
|
|
|
|
Use the static property StartupPath of the Application class.
|
|
|
|
|
Simply: Environment.CurrentDirectory . Its a string so you can feed this to other objects like DirectoryInfo and Directory .
|
|
|
|
|
While I'm sure you probably mean what the other reply suggested (Application.StartupPath ), "current path" is not always the same directory as the application. It is the current working directory, and can be set on shortcuts to something different, or if you are in a command prompt in a different directory and type the path to the application. The directory you're in is the currenty working directory. It's important to be mindful of this fact.
To get the current working directory, you can get the Environment.CurrentDirectory . If you want the application directory to be the current working directory anytime your application starts, set this property like so:
Environment.CurrentDirectory = Application.StartupPath;
Microsoft MVP, Visual C#
My Articles
|
|
|
|