|
Hello I am working on a gamma adjustment program in c# and I have imported the gdi32.dll file as follows,
[DllImport("gdi32.dll")]
and have then declared getDeviceGammaRamp with
private static extern bool getDeviceGammaRamp(HDC hDC, LPVOID lpRamp);
But I get errors such as HDC could not be found etc. I have tried reading up on threads such as creating screenshots for some help as they are similar in nature to my program. I can't seem to get things going.
Could somebody please explain to me how import getDeviceGammaRamp and setDeviceGammaRamp correctly in c# to adjust gamma or possibly write a small tute just like the create screenshot bitmaps one except on how to adjust monitor gamma?
Thanks for your time people
|
|
|
|
|
You need to "translate" the Win32 data types, HDC & LPVOID, into CLR data types. You can use the System.IntPtr type in both cases.
private static extern bool GetDeviceGammaRamp(IntPtr hDC, IntPtr lpRamp)
Hope this helps!
Paul Lyons, CCPL Certified Code Project Lurker
|
|
|
|
|
Hi!Paul,
Thank you very much! It do me a big favour^_^
Thank you again!!!
Best regards!
momer
|
|
|
|
|
Yes thank you for the help Paul, now I just need to convert some c++ classes to c#. It is harder than I expected.
If somebody could write up a tutorial on gdi32 and setting gamma in c# then this would help me out alot, it seems that there is almost nothing on the subect at all.
I have been searching for days
|
|
|
|
|
I wanna this happen:Within a TabControl,when I click the "OK" button on the
tabpage "OPTIONS",it automatically turn into the
tabpage "SETTINGREPORT". In other words,when I click the "OK" button on one tabpage it automatically turn into another tabpage in the same TabControl.
What code should I write with C#?
|
|
|
|
|
momer wrote:
What code should I write with C#?
If you know the index value of the tab page, you can simple use the SelectedIndex property of the TabControl . If your clicking a button, your code might look something like this:
private void button_Click(object sender, System.EventArgs e)
{
this.tabControl1.SelectedIndex = 3;
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Im creating a custom control ,which has no gui but only functionalities , i want this control to be displayed in the bar below the form designer (vs.net 2003) just like menu or OpenFileDialog do (right now its displayed like a blank square on the form)
How could I accomplish this? (A [ ] tag for vs.net ide?)
Any link with info or direct answer will be greatly appreciated.
|
|
|
|
|
you should create a "component" not a "control"
components go in the component tray below the form designer.
easiest is to add a class an just inherit from system.componentmodel.component
//Roger
|
|
|
|
|
I'm working with VS.NET 2003 and .NET 1.1 (not SP1) on Windows XP SP1. My application is using the Windows Installer Bootstrap. (I may have also installed a module which detects requirements (.NET 1.1 -> MsiNetAssembly Support.) I have a few issues and questions regarding the MSI and its properties.
* This may be my biggest annoyance at the moment. When the installer creates the target directory, it's setting them as read-only. When the application is uninstalled, the target directory is not deleted, although it's empty. I presume this is because the target directory is read-only and the installer doesn't try to force the removal, but I'm not positive. Why is this happening, anyway, and how can I correct it. I'm not certain if this has always been a problem for me with this project, but it's also not a recently new problem.
* When the user opts to install for "Everyone," I need to modify the registry for all users. I'm not sure there's a reasonable way to do this within VS.NET's IDE (or otherwise?). The User/Machine Hive is an alias for HKLM when "Everyone" is selected, so that's no help. HKEY_USERS only seems useful (ever) for setting within the .DEFAULT tree, but that doesn't handle current users. I've seen a reference to HKEY_PER_USER, which seems like what I'd want, but I don't know how to access it, and there's almost zero documentation online, so maybe it's vaporware. I suppose I could handle this programmatically, in a custom action, but it seems like a common enough need, and I'd rather have the installer handle as much as possible, anyhow! Plus, how can the custom action know that it's supposed to set keys for all users? Can the custom actions access the MSI's runtime properties?
* For that matter, I'm not sure there's a good way for users' configurations to be retained during an upgrade, and possibly my real problem here is that I have RemovePreviousVersions set to True. But if an installer is supposed to remove its files and registry keys it created, and if the installer is supposed to first uninstall previous versions (which makes sense in my case), then how are previous configurations supposed to migrate forward?
* There doesn't seem to be a good way for defining deployment projects in terms of solution configurations. For instance, I can configure the project within a certain solution configuration (e.g. Debug) to add some conditional compilation constants (e.g. TRACE, DEBUG), and I can use those constants in my code within #if blocks. How can I do something similar within a deployment project? One solution I've heard is to create a different deployment project for each solution configuration that has its own needs. That seems like a management nightmare beyond the simple case!
Thanks for any comments or answers you might provide.
Arun
|
|
|
|
|
Ok, here's the deal. I have an Active-X control on a form. I call a function off that control and get an object. This object I get does NOT have a typelib that I can create a RCW from, but I do know that functions and properties it has.
So, right now I created a class that just thunks down using the InvokeMethod stuff. However, I'd like to use standard .NET interfaces instead. The problem is that I can't seem to get the object to cast to the interface, nor do I know the GUID for the object.
Is there any way of forcing the COM object to route thru a interface I've created?
Thanks.
--
Joel Lucsy
|
|
|
|
|
What you could do is use Ole View (go to Run, type oleview and hit enter). Select File -> View TypeLib... and select you ActiveX control. Once you have the control open in the ITypeLib Viewer select File -> Save As. This will allow you to save the contents to a .idl file (Interface Definition Language). You can now use the MIDL compiler to generate a type library from the .idl. Once you have a .tlb file you can use one of the .NET command line tools to generate the appropriate interop assemblies. Use tlbimp.exe to generate an output assembly based on the COM-based type library you just generated. Use the newly generated assemblies in your .NET project. HTH
- Nick Parker My Blog | My Articles
|
|
|
|
|
Nope, can't do that. The Active-X control doesn't provide a typelib interface for the internal api I'm trying to access. The control itself has a typelib for interacting with the visible component, but the internal api you can get to.
For further information, I'm interacting with Adobe's SVG control. You can retrieve the internal DOM document from the COM interface, but Adobe doesn't provide a typelib for interacting with it. The functions and properties available are identical to the Javascript calls you can make from the browser, so I know the interface it provides. I just can't apply a .NET interface to the objects I get back.
Any ideas? Is there a way to get the guid from the COM object I get? It seems in order to apply an interface I need a guid.
--
Joel Lucsy
|
|
|
|
|
I have read the "DataGridColumnStyle Class" page from MSDN 2003 and built my own column style.
but i have a problem.
only when i click on a dataGrid 's cell the corresponding columnStyle appears.
but i want all the cells have their column style after AddData() Method.
for example all the cells that have the ComboBoxColumnStyle have combo appearance at first and user can select a combo.
what shoud i do .
please mail me a C# sipmle code to explain your solve.
arbuston@yahoo.com
|
|
|
|
|
|
I'm having a hardtime understanding interfaces. What is the purpose of having an interface that is a property of a class? I may not be asking this correctly because I don't know much about interfaces yet... see below
<br />
<br />
public interface IpropInt<br />
{<br />
}<br />
<br />
public interface Isomeinterface<br />
{<br />
IpropInt propertyInterface<br />
{<br />
get;<br />
}<br />
}<br />
<br />
<br />
class someclass : Isomeinterface<br />
{<br />
<br />
public IpropInt propertyInterface;<br />
{<br />
}<br />
}<br />
<br />
"...practice safe hex when IM'ing"
--Shawn L. Morrissey, Managing Editor, MSDN Online ( MSDN Flash; Volume 8, Number 20, 10/4/2004)
|
|
|
|
|
An interface allows you to define methods that a class must impiment, but you can also create an instance of an interface. So you can have all sorts of classes, with all sorts of base classes, but so long as they impliment IEnumerable, they can be cast to an instance of IEnumerable, and those methods only will be visible to the code that makes for each work, for instance.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
but you can also create an instance of an interface
Not really, they can really only be assigned by object that implement them, they can't be new'ed (the interface). I know you know what it means, I just don't want to confuse him.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Yes, you're totally right. *blush* You're right, I knew what I meant, but I didn't explain it as well as I could have.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
ok, but when I make a call to the interface that is a property of that class... I can get data out of it. What instance is it pulling that data from? How can something like that be populated with data... More info for you... the instance of my class is added to another instance of another class... the data that is inside of that interface is the same data I would expect from the "another class". I just am having a hard time seeing the relationship here.
"...practice safe hex when IM'ing"
--Shawn L. Morrissey, Managing Editor, MSDN Online ( MSDN Flash; Volume 8, Number 20, 10/4/2004)
|
|
|
|
|
If you have a class called MyClass, and it defines an interface, MyInterface, the only way to build an instance of MyInterface is from an instance of MyClass ( or another class that impliments the interface ). So the instance you're pulling data from is the instance you used to create an instance of the interface.
Have you done any C++ ? Interfaces is how C# gets around the lack of multiple inheritance.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
The interface itself can be used to call methods or supply properties, does the following example help clear it up?
interface IProcess
{
void Process();
}
class Example : IProcess
{
public void Process()
{
Console.WriteLine("Hello Example.");
}
}
class Test
{
[STAThread]
static void Main()
{
Test t = new Test();
IProcess p = new Example();
t.Fun(p);
}
public void Fun(IProcess p)
{
p.Process();
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
I'm not quite sure how to load or reference this dll as I need ntohl function.
What I need to do is to convert hex to int then switch the bytes to get other value.
I.e.
ABCD = 43981
switch byte and convert to int...
CDAB = 52651
|
|
|
|
|
I have a C++ application that I want to have interface with a C# Web Service application.
What are the different ways that I can go about this?
Thanks
|
|
|
|
|
One way that I know of:
Download the Microsoft SOAP Toolkit. It has COM object which you can use for your purpose. Use MSSOAP.SoapClient30 to invoke methods such as mssoapinit(), InvokeHelper() which let you communicate with a Web Service with most of the transport details (http/soap) hidden from you.
This will work just great for you…
I read that, Microsoft has now stopped supporting SOAP Toolkit (don't worry you will still be able to find soapsdk.exe somewhere), but what are the alternatives, is a question for me too.
Salil Khedkar [^]
|
|
|
|
|
HI all,
How can i incorporate the ability for a user to select an ROI by pressing his left mouse button and dragging it on the displayed image and also i want to set the max boundaries for dragging as the image resolution.
For this how can i implement my MouseDown event for left button.
anyideas or suggestions please...
thanks in advance,
Suman
|
|
|
|