|
Try ShowDialog() instead.
--
Andrew.
|
|
|
|
|
when i click the window form's minimize box!
how to minimize it to tray icon(when the app is started,the app tray icon is displayed)!
and then how to display it again!
is the notifyicon's contextmenu event click-form1.show() enough!
the vs.net and c# is all new to me!
so if anyone knows,please tell me.thanks!
|
|
|
|
|
I'm trying to add a preview to my screensaver, but no matter what I do to the string coming in ( which should be a HWND ), I cannot get a graphics object that I can draw to - the preview window stays black. Any suggestions ?
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
|
|
|
|
|
In this mode, you should be drawing using screen coordinates.
I would check that...
|
|
|
|
|
That was weird, I tested that this morning and now it wants client coordinates???
|
|
|
|
|
I was using Graphics.Clear, and also FillRectangle to fill a HUGE rectangle so that my problem was not related to coordinates, because the screensaver preview window is pretty small.
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
|
|
|
|
|
What I have working is this:
I am getting the HWND and the Graphics object with something a little more robust but equivalent to:
IntPtr hWnd = (IntPtr) uint.Parse(args[1]);
.
.
.
Graphics g = Graphics.FromHwnd(hWnd);
.
.
.
I call GetClientRect on the hWnd, and use that for all of my drawing...
|
|
|
|
|
How do I call GetClientRect in C# ?
This does not work for me:
if (args[0] == "/p")
{
IntPtr hWnd = (System.IntPtr)uint.Parse(args[1]);
Graphics g = Graphics.FromHwnd(hWnd);
g.Clear(Color.Orange);
}
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
|
|
|
|
|
If you create a Control from the hWnd you can use that.
Control previewWindow = Control.FromHwnd(hWnd);<br />
Rectangle rect = previewWindow.ClientRectangle;
BTW, just picked up a Radeon 7500 (dual-head) so I can use dual monitors now
James
Simplicity Rules!
|
|
|
|
|
James T. Johnson wrote:
BTW, just picked up a Radeon 7500 (dual-head) so I can use dual monitors now
Yummy - looks like I got the dual monitor support into the screen saver just in time.....
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
|
|
|
|
|
This code:
IntPtr hWnd = (System.IntPtr)uint.Parse(args[1]);
Graphics g = Graphics.FromHwnd(hWnd);
Control previewWindow = Control.FromHandle(hWnd);
Rectangle rect = previewWindow.ClientRectangle;
SolidBrush brush = new SolidBrush(Color.Orange);
g.FillRectangle(brush, rect);
Gives me a Null reference error, leading me back to the belief that I am unable to parse the hWnd in a meaningful manner.
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
|
|
|
|
|
Christian Graus wrote:
leading me back to the belief that I am unable to parse the hWnd in a meaningful manner
If this statement was true, my code wouldn't be running...
Take a look at the API definition I posted to the other part of this thread.
Regards
|
|
|
|
|
It's obviously working for you, but are you doing it in the context of the screensaver preview ? If you are, then I have no idea why I cannot get it to work for me. If I have a valid HWND in my variable, why can't I use the code I posted to get it into a control ?
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
|
|
|
|
|
Yes, I am drawing in the context of the preview from the screen saver tab of the desktop properties.
I am not using a control, you don't need it in the preview mode.
|
|
|
|
|
Well, in that case, you're obviously a better man than I am. Could you please zip the project and mail it to me so I can have a look at it and figure out what I am missing ?
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
|
|
|
|
|
You have mail...
Just a quick app made from pieces I gutted from mine, and enough to show the steps involved to draw in the property sheets preview.
I would suggest separating your drawing code from your form and calling it from both the preview mode and your full display mode.
Regards
|
|
|
|
|
Christian Graus wrote:
why can't I use the code I posted to get it into a control ?
The Control was just used to get away from making a direct call into unmanaged land. I forgot to say that in my original post though
James
Simplicity Rules!
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("user32.dll")]
private static extern int GetClientRect(IntPtr hWnd, ref RECT rect);
|
|
|
|
|
In the course of recent enlightenment I have a better solution that will reuse your form as is…
In the preview mode (/p) do this:
if (IntPtr.Zero != hWnd)
{
Application.Run(new MainForm(hWnd));
}
In your form class do this:
private IntPtr parentWindow;
public MainForm(IntPtr parent)
{
parentWindow = parent;
if (IntPtr.Zero != parent)
this.TopLevel = false;
.
.
.
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Parent = parentWindow;
return cp;
}
}
Works like a champ!
|
|
|
|
|
Use the DllImport attribute found in the System.Runtime.InteropServices namespace.
You may also have to use the StructLayout and MarshalAs attributes if you need to pass structures around.
HTH,
James
Simplicity Rules!
|
|
|
|
|
Is C# using the same pseudo generator to generete random numbers like Visuial C?
thanx
|
|
|
|
|
No it doesn't; I can't post the code but you can compare it yourself to verify. The rand function in the CRT doesn't use an array while the .NET version does.
James
Simplicity Rules!
|
|
|
|
|
Hi,
I want to use the ICatInformation Interface in a C# project, but am having a little difficulty.
The header file is comcat.h in the SDK and you can compile the comcat.idl using the MIDL compiler to produce the type libuary msclus.tlb, but i can not import this as a refernece because it is not registered in the registry, so I thought use the msclus.dll but this does not containt the definition or Implementation for ICatInformation.....
So how do i get this interface into C#?
Cheers
Ollie
|
|
|
|
|
Hi all - I've been looking around for a way to disable the "x" (close button) at the top right of every Form. I'd like a way to "gray" (disable) it or, even better, a way to remove it completely. I'd like to keep the minimize/maximize buttons however.
I realize I could use the Closing event to make it so a user can't close a window until certain conditions are met, but that isn't satisfactory.
Any help would be appreciated. Thanks.
- Sabran
|
|
|
|
|
DISCLAIMER: Like most workarounds, This is going outside the .NET Framework "Box", so it may break in the future....
Set the ControlBox property to false and then add this code to your form derived class.
const int WS_SYSMENU = 0x00080000;
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style |= WS_SYSMENU;
return cp;
}
}
|
|
|
|