|
Christian Graus wrote:
So how do I get my hands on it in C# ?
P/Invoke I'm still recovering from shock though, the DEVMODE structure is HUGE. I remember seeing a tool that created P/Invoke code from the vb6 win32api.txt file, I'll see if I can find it again.
James
Simplicity Rules!
|
|
|
|
|
public const int CCHDEVICENAME = 32;
public const int CCHFORMNAME = 32;
[StructLayout(LayoutKind.Sequential)]
public struct DEVMODE{
[MarshalAs(UnmanagedType.ByValTStr,SizeConst:= CCHDEVICENAME)]
public string dmDeviceName;
public int dmSpecVersion;
public int dmDriverVersion;
public int dmSize;
public int dmDriverExtra;
public int dmFields;
public int dmOrientation;
public int dmPaperSize;
public int dmPaperLength;
public int dmPaperWidth;
public int dmScale;
public int dmCopies;
public int dmDefaultSource;
public int dmPrintQuality;
public int dmColor;
public int dmDuplex;
public int dmYResolution;
public int dmTTOption;
public int dmCollate;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst:= CCHFORMNAME)]
public string dmFormName;
public int dmUnusedPadding;
public int dmBitsPerPel;
public int dmPelsWidth;
public int dmPelsHeight;
public int dmDisplayFlags;
public int dmDisplayFrequency;
}
[DllImport("user32.dll")]
public static int ChangeDisplaySettingsEx(
[MarshalAs(UnmangagedType.LPTStr)] string lpszDeviceName,
ref DEVMODE lpDevMode, IntPtr hwnd, int flags,
IntPtr lParam); This should work, but of course its untested and may need some tweaking here and there
James
Simplicity Rules!
|
|
|
|
|
Wow - that IS a monster....
What do I need to be using for it to work ? How do I get my hands on my hwnd to pass in ? What is lParam ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
The hWnd is stored in the Handle property of the Control (Form derives from Control).
lParam can be NULL (IntPtr.Zero) or it can be a pointer to a VIDEOPARAMETERS structure, which I didn't see the first time I looked at the docs.
Here's the help link I used in MSDN when looking up what was there (yes the Platform SDK still has a purpose )
ms-help://MS.VSCC/MS.MSDNVS/gdi/devcons_3tfc.htm
Here is the API Viewer tool which generated the structure me, you'll need the win32api.txt file from the common/tools/apiviewer directory on the VB6 CD.
Unfortunately the API Viewer doesn't have information about the VIDEOPARAMETERS structure, which means lots of fun On second look, I don't think you'll need the structure, its declared in tvout.h
James
Simplicity Rules!
|
|
|
|
|
I took a look at implementing what was required to change the display resolution *correctly* in C#. I ended up reverting to C++, and writing a set of helper classes in MC++. This was much, much easier and has much cleaner interface for other .NET languages.
I will post it when I have finished cleaning it up and testing it if you’re interested.
Regards
|
|
|
|
|
Ok, this is the scoop...
First you need to call "EnumDisplayDevices" to track down which displays you are interested in.
You then need to call "EnumDisplaySettings" for each device of interest to get a list of supported "modes" (X, Y Resolution, Frequency and color depth).
From those lists you can then perform a "ChangeDisplaySettingsEx" to change the actual settings.
Considering you most likely want to make the changes temporary, you can get the current settings for each device by calling "EnumDisplaySettings" with an iModeNum of ENUM_CURRENT_SETTINGS, before you change them.
Regards
|
|
|
|
|
I need to do this in MC++ right ? I've never used MC++ before - could be interesting...
Thanks
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Don't need to, I already coded up a set of classes to do this.
I used MC++ because, I am very familiar with C++ and it was allot faster than attempting to translate all of the API calls and structures involved to C#. As an added benefit, the MC++ classes are a seamless interface to C# or the *other* .NET languages.
Shoot me your e-mail address at vannote@netaxs.com and I will drop the project off as soon as I feel that it's ready...
Regards
|
|
|
|
|
Anyone know how to change the available client area of a .NET Framework Form ?
I have tried intercepting the WM_NCCALCSIZE message, but this doesn't
do what was expected.
Anyone got any suggestions, or even working examples of WM_NCCALCSIZE ?
|
|
|
|
|
Just set the ClientSize property on the form to the desired size
Much easier than standard win32
James
Simplicity Rules!
|
|
|
|
|
I was playing around last night and had done something like this:
protected override void WndProc(ref Message m)
{
MessageBox.Show(m.Msg.ToString());
}
I got a series of messageboxes (about 2 or 3) and then I received an error stating that it was able to create a handle, that, did I just need something like this to still allow it to call the base constructor?
protected override void WndProc(ref Message m)
{
MessageBox.Show(m.Msg.ToString());
base.WndProc(ref m);
}
I'm just playing with this anyone, so it doesn't really matter, just curious.
Nick Parker
|
|
|
|
|
.Net framework class library Control.WndProc method
Notes to Inheritors: Inheriting control should call the base class's WndProc method to process any messages that they don't handle.
I guess they say so.
- Gile
|
|
|
|
|
You know sometimes it is so damn clear that it doesn't make sense right away, why should I have thought that it would just fall though and continue on its merry way. Thanks.
Nick Parker
|
|
|
|
|
Hi,
I wanna customize the draw method of Datagrid, for example inorder to show the records which have a field (i.e. Salary) More then 50,000 in red BackColor and the others in white.
I don't know if you are familiar with delphi It use to have a OnCustom Draw Event that would deal with it. Do we have sth like that here?
thanks
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
It looks like what you need to do is create a class that inherits from DataGridColumnStyle (or better System.Windows.Forms.DataGridTextBoxColumn) and override the Paint methods.
HTH,
James
Simplicity Rules!
|
|
|
|
|
hi,
all
In c#, how can I get an running instance of a com object
instead of creating a new instance.
Can System.Activator implement it??
thx.
Regards.
Marion
|
|
|
|
|
|
when i am using msflexgrid component in vs.net in windows2000 server enviroment,i can not even put the control to the designing form.it display "you have not the activex control license"!or "The ActiveX control cound not be instantiated because it requires a design-time license "。
why?
how can i register the activex control?
i am a novice,i think to many people here,it's not a difficult question!so please help me !thanks!!
|
|
|
|
|
zhoujun wrote:
when i am using msflexgrid component
I wasn't aware that Microsoft still keep the msflexgrid in the Visual Studio.NET package, or are you adding it in another way?
Nick Parker
This is a non-Calculus course as long as you know things like line integrals and surface integrals...
|
|
|
|
|
at first i am also a bit confused,but i think of it for a while and i know it is because i install sql2000 server,and it add the msflexgrid run-time license!but have not install the design-time license!
|
|
|
|
|
i have 2 datagrid binded to 2 different part of the same table in access. now when i scroll the 1st grid i want the 2nd datagrid to scroll proportionately to the 1st datagrid....which is not happening. i tried to use a scrollbar control but couldnt do it...
if anybody has an idea about this problem......any solution as to how to go about doing it then.....please reply.
bye
|
|
|
|
|
Under Datagrid.scroll
Have you looked at:
public void scroll( int cols, int rows )
You could then assign both of your Datagrids to this method call.
Nick Parker
|
|
|
|
|
Hi,
all
I come accross a problem again.
Firstly,I make a ActiveX Dll(myDll.dll) in Visual Basic 6.0. And in myDll.dll there is only one function as follow:
Public Function show ( )
MsgBox ( "Hello world!" )
End Function
Then, I type this command in dos:
TlbImp mydll.dll /out: my.Dll
According the reference ,then I can invoke the method "show" in my C# console apllication.
My C# application(try.cs) as follows:
using my ;
using System ;
namespace Hello
{
public class Activex
{
public static void Main ( )
{
Class1 s = new Class1 ( ) ;
s.show ( ) ;
}
}
}
Finally,I type such command :
csc /r:my.dll try.cs
But errors ocurres, and details are showed as follows:
Try.cs(10,25): error CS0246: The type or namespace name 'Class1' could not
be found (are you missing a using directive or an assembly reference?)
Try.cs(11,25): error CS0246: The type or namespace name 's' could not be
found (are you missing a using directive or an assembly reference?)
who can tell me why ?
regards.
|
|
|
|
|
AM i being stupid how do you search in a message board, i am in C# board there is a search box but no 'go' but.....
|
|
|
|
|
Click the "Set Options" button next to it, not the most intuitive label.
James
Simplicity Rules!
|
|
|
|