|
You could put a panel inside the form that would be your effective client area. The panel would be set to allow scrolling, but not the form. The panel would leave enough room for the OK\Cancel buttons, which would be on the form, not the panel.
Brian
|
|
|
|
|
Thanks Brian! I should have thought of that.
Mark
|
|
|
|
|
reference: http://msdn.microsoft.com/library/en-us/gdi/monitor_4mr7.asp?frame=true
========================================================================
SETUP:
I have two monitors using a dual video output NVIDIA Quadro NVS. One of them is the primary. The other is NOT part of the VIRTUAL DESKTOP.
APPLICATION:
One monitor will be for the cashier running her program and the other Independent Monitor will be for WEB, FLASH and VIDEO CONTENT to be played on, plus a section of the monitor for the running itemize total. I don't want the cashier to be able to move the mouse or window accidently over to the other monitor.
QUESTION:
How do I accomplish this? The Microsoft hyerlink above is quite cryptic for a C# guy learning C++. If anyone has another solution or a way to impliment this idea or can tell me some books to read, I would highly grateful, since I am on a very TIGHT SCHEDULE. THANK YOU ADVANCE.
Peter B.
|
|
|
|
|
Dunno if this helps, but this is how I place a form over the second monitor:
Screen [] screens = Screen.AllScreens;<br />
<br />
if (screens.GetUpperBound(0) > 0)<br />
{<br />
Screen secondary = screens[1];<br />
secondMonitor.Bounds = secondary.Bounds;<br />
secondMonitor.MinimumSize = secondary.Bounds.Size;<br />
}<br />
else<br />
{<br />
secondMonitor.Visible = false;<br />
}
My second monitor is part of the virtual desktop tho. Why isn't yours ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi,
I want to send to SQL server a query I want to get randomly generated 100 rows where they are no generated before. I made my query like below:
mySqlCommand.CommandText = "SELECT name,rand(name) FROM people LIMIT 100 WHERE generated_before IS NULL";
Gives system error???
Thank you,
Cem Louis
|
|
|
|
|
You want to generate 100 rows, or get back 100 rows at random ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I'm not sure when you get the LIMIT keyword from, it doesn't appear to be a valid T-SQL keyword.
Try
SELECT TOP 100 ....
Also, the RAND() function only accepts interger types. I am assuming that name is a string of some kind. I am not sure what you are trying to do with RAND()
If you can explain more about what you are trying to do I might be able to help more.
Do you want to know more?
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Anyway I did it like below:
"SELECT TOP 100 name FROM people ORDER BY NEWID()"
Cem
|
|
|
|
|
I have a project with several Forms open at the same time. Is there a way I can keep certain ones always on top? At runtime, each time the user clicks a form it gets focus and hides an overlapping forms.
Thanks!
Mark
|
|
|
|
|
Set the TopMost property of the form to true .
|
|
|
|
|
Waaaaaaaaaaahhhh
Have the same problem, to lazy to research and test code.
Please help the weaklings and the lazy ones...
Thank you very much for your help
|
|
|
|
|
hi all,
i would like to write C# code that would allow a user to upload images to a file on a remote server any ideas or solutions for me pleez. this would require ftp access and i am uncertain how i am going to integrate this into the app. the idea is the to upload new images when the need arises...
many thanks
butchzn
|
|
|
|
|
Uploading files greatly depends on what the server protocol is. If you're using HTTP, for example, the HttpWebRequest already supports this. Since you're requiring FTP, realize that the current .NET BCL has no FTP support - but don't let that stop you.
Some articles on this site and others have simply wrapped the ftp.exe application in a class library. This is dodgy and not very well designed. A proper design - like HttpWebRequest and HttpWebResponse - would extend WebRequest and WebResponse , classes for pluggable protocols.
It just so happens that there's a good example in the Microsoft Knowledge Base: http://support.microsoft.com/default.aspx?scid=kb%3BEN-US%3B812409[^]. It has a link at the bottom to GotDotNet (a Microsoft developer community site) with the full source.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Is there a simple way to paint in a colour inverse to the current image?
(I'm implementing a mouse-drag selection box, and want to just draw a rectangle on screen where each pixel is the inverse of whatever's already there)
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
The inverse colors are easy to calculate. Subtract the red, green, or blue (RGB) component from 255:
Color Invert(Color c)
{
int r = 255 - c.R;
int g = 255 - c.G;
int b = 255 - c.B;
return Color.FromArgb((int)c.A, r, g, b);
} But there's a easier way, and it's a little faster since the Color structure stores the ARGB (alpha, red, green, blue) as a single 64-bit number (though most members reflect a 32-bit number):
Color Invert(Color c)
{
Color c2 = Color.FromArgb(0xffffff - c.ToArgb());
return Color.FromArgb((int)c.A, c2);
} All this is assuming you keep the same alpha value, which is typically want you want to do.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
|
Microsoft, I noticed, doesn't use a lot of unsigned types, even when private or internal (since unsigned types are not CLS-compliant, but for private and internal members I don't see why it matters). If they used a signed int , solid black would be -1, something that may pose a problem for those using reflection. Maybe Microsoft plans on supporting CMYK along with an alpha channel in the future (requiring more than 32 bits).
It's all just speculation, though. I really don't know.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks, I was figuring I was going to have to do something like that - but was hoping I'd just be able to set my pen colour to some magic constant that'd tell the gdi functions to draw in an inversed colour
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
I'm programming a GUI in C# with the objective to interface with a program written in C++ (MS-DOS). The MS-DOS program reads some information from a text file and then writes the results to a binary file. Depending on the initial information, the program can run for several hours and write large information to the binary file.
For now I can read the text file, write the information to several windows in the GUI, run the MS-DOS program in the background, retrieve the results in real time as the program runs and show it to the user (in real time).
What I want to ask is there any other way to communicate between the C++ program and the C# GUI?
Thanks in advance for any answers.
Filipe Delgado
|
|
|
|
|
Yes, but define "C++". Are you talking about managed or "unmanaged" (formerly just known as C++) C++? If you're speaking of unmanaged C++, then you're stuck with the ways of doing it between two native applications. That includes DDE, RPC, and the like - all of thich are not supported in the current .NET releases (IPC is supported in .NET 2.0 - at least last time I checked). If you want to some IPC mechanism you'll have to P/Invoke the necessary functions or find a library that already does it (there are a couple here on CodeProject; just search).
The other option is an oldie but a goodie: HWND s. The use of FindWindow , FindWindowEx , SendMessage , PostMessage , and the like is supported because Windows Forms encapsulates the Windows APIs (among other APIs, like GDI in some cases). Most of the controls (sans DataGrid ) encapsulates the Windows Common Controls, and every control - by nature on Windows - is tied to an HWND .
Using Spy++ can help you realize the classes used by the controls, although you'll find most use the same classes as the Common Controls because they are the same window classes.
This has been discussed here on this forum before, and there are articles about this on CodeProject. A quick search should find you the answers you need if you don't have them already.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Heath Stewart wrote:
Are you talking about managed or "unmanaged" (formerly just known as C++) C++?
Grrr. When people say C++, surely they mean proper C++, not this 'managed' crap.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
You're preaching to the choir. However, this is the C# forum - a managed language - so the distinction between native (is that better ?) and managed C++ is necessary.
In as many cases as possible, I refer to it only as "C++".
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi everyone,
I've been stuck with this problem for several days already. My code extensively uses asynchronous delegate invocation using the Delegate.BeginInvoke method. The general pattern is as follows:
Scheduler or UI thread:
1) BeginInvoke function 1
First function:
1) prepare data
2) BeginInvoke data processing passing CurrentThread (see below)
3) CurrentThread.Suspend
4) (after resume) go to step 1 with new data processing command, if all commands are executed, exit
Data processing:
0) get calling thread (passed in parameters)
1) process data
2) set result
3) resume calling thread
Several data processing commands (Command pattern) require asynchronous calls, too. That is that BeginInvoke method is called from inside another method which was called using BeginInvoke, too. What I've noticed so far is that sometimes the delegate being BeginInvoke'd is NOT CALLED AT ALL! To give more evidence, I have a special Logger class which sends messages to a text box. Apparently, it uses Control.BeginInvoke to correctly dispatch Text property changes. Sometimes again the function specified in MethodInvoker delegate is also NOT CALLED AT ALL!
What could be the problem? I honestly hope it is not a bug in the framework, as the project is (and has been for the last month) in the final stage.
Regards,
Serge (Logic Software, Easy Projects .NET site)
|
|
|
|
|
hello guys
i have a problems with the following code but i can't identify any on having idea please help me
the problems are:
1 when activate and deactivate it doesn't paint NCArea
2 it flickers
3 it doesn't give the feel like windows default title
//NCButton class
using System;
namespace WindowsApplication1
{
///
/// Summary description for NCButton.
///
public class NCButton
{
System.Drawing.Image nBitmap,fBitmap,pBitmap;
System.Drawing.Rectangle buttonRectangle;
public NCButton()
{
//
// TODO: Add constructor logic here
//
nBitmap = null;
fBitmap = null;
pBitmap = null;
}
public System.Drawing.Image NormalButtonImage
{
get
{
return nBitmap;
}
set
{
nBitmap = value;
}
}
public System.Drawing.Image FocusedButtonImage
{
get
{
return fBitmap;
}
set
{
fBitmap = value;
}
}
public System.Drawing.Image PressedButtonImage
{
get
{
return pBitmap;
}
set
{
pBitmap = value;
}
}
public System.Drawing.Rectangle ButtonRectangle
{
get
{
return buttonRectangle;
}
set
{
buttonRectangle = value;
}
}
}
}
//form1 class
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
///
/// Summary description for Form1.
///
///
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.IContainer components;
///
/// Required designer variable.
///
///
private ArrayList ncButtons;
[Category("Custom Mouse Events")]
private event System.Windows.Forms.MouseEventHandler NonClientMouseMove;
private event System.Windows.Forms.MouseEventHandler NonClientMouseDown;
private event System.Windows.Forms.MouseEventHandler NonClientMouseUp;
System.Drawing.Bitmap imgTitle,imgLRBorder,imgBBorder,imgButtons;
Rectangle bt1,bt2,bt3;
private System.Windows.Forms.ImageList imageList1;
private System.Drawing.Graphics graphics;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
ncButtons = new ArrayList();
NCButton bt = new NCButton();
bt.FocusedButtonImage = new Bitmap(@"C:\btimages\fmin.bmp");
bt.NormalButtonImage = new Bitmap(@"C:\btimages\nmin.bmp");
bt.PressedButtonImage = new Bitmap(@"C:\btimages\pmin.bmp");
Rectangle rect = new Rectangle(0,0,bt.NormalButtonImage.Width,bt.NormalButtonImage.Height);
bt.ButtonRectangle = rect;
ncButtons.Add(bt);
bt = new NCButton();
bt.FocusedButtonImage = new Bitmap(@"C:\btimages\fmax.bmp");
bt.NormalButtonImage = new Bitmap(@"C:\btimages\nmax.bmp");
bt.PressedButtonImage = new Bitmap(@"C:\btimages\pmax.bmp");
rect = new Rectangle(0,0,bt.NormalButtonImage.Width,bt.NormalButtonImage.Height);
bt.ButtonRectangle = rect;
ncButtons.Add(bt);
bt = new NCButton();
bt.FocusedButtonImage = new Bitmap(@"C:\btimages\fclose.bmp");
bt.NormalButtonImage = new Bitmap(@"C:\btimages\nclose.bmp");
bt.PressedButtonImage = new Bitmap(@"C:\btimages\pclose.bmp");
rect = new Rectangle(0,0,bt.NormalButtonImage.Width,bt.NormalButtonImage.Height);
bt.ButtonRectangle = rect;
ncButtons.Add(bt);
imgTitle = new Bitmap(@"C:\Skin Images\title.bmp");
imgLRBorder = new System.Drawing.Bitmap(@"C:\Skin Images\LRF.bmp");
imgBBorder = new System.Drawing.Bitmap(@"C:\Skin Images\BottomF.bmp");
imgButtons = new System.Drawing.Bitmap(@"C:\Skin Images\Button.bmp");
//graphics = new System.Drawing.Graphics();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
protected override void WndProc(ref Message m)
{
if(m.Msg == 0x1)//once when application starts
{
}
else if(m.Msg == 0x85 || m.Msg == 0x86)//nc_paint //nc_activate
{
IntPtr regn = m.WParam;
IntPtr hdc = Form1.GetDCEx(m.HWnd,regn,0x1 | 0x30);
if(hdc != IntPtr.Zero)
{
graphics = Graphics.FromHdc(hdc);
}
RepaintTheNCArea();
}
else if(m.Msg == 0xA0 )//nc mouse move
{
if( MouseMoveHandling(FindMousePosition()))
return;
}
else if(m.Msg == 0xA1 )//nc mouse button down
{
if( MouseDownHandling(FindMousePosition()) )
return;
}
else if(m.Msg == 0xA2 )//nc mouse button up
{
if (MouseUpHandling(FindMousePosition()))
return;
}
label1.Text = m.Msg.ToString();
base.WndProc (ref m);
}
[DllImport("User32.DLL", EntryPoint="GetDCEx", SetLastError=true,
CharSet=CharSet.Ansi, ExactSpelling=true,
CallingConvention=CallingConvention.Winapi)]
public static extern IntPtr GetDCEx(
IntPtr hWnd, // handle to window
IntPtr hrgnClip, // handle to clipping region
int flags // creation options
);
[DllImport("User32.DLL", EntryPoint="GetWindowDC", SetLastError=true,
CharSet=CharSet.Ansi, ExactSpelling=true,
CallingConvention=CallingConvention.Winapi)]
public static extern IntPtr GetWindowDC(
IntPtr hWnd // handle to window
);
private bool MouseMoveHandling(Point mousePosition)
{
Rectangle rect = ((NCButton)this.ncButtons[0]).ButtonRectangle;
if(rect.Contains(mousePosition))
{
RepaintTheNCArea();
graphics.DrawImage( ((NCButton)ncButtons[0]).FocusedButtonImage,((NCButton)ncButtons[0]).ButtonRectangle);
return true;
}
rect = ((NCButton)this.ncButtons[1]).ButtonRectangle;
if(rect.Contains(mousePosition))
{
RepaintTheNCArea();
graphics.DrawImage( ((NCButton)ncButtons[1]).FocusedButtonImage,((NCButton)ncButtons[1]).ButtonRectangle);
return true;
}
rect = ((NCButton)this.ncButtons[2]).ButtonRectangle;
if(rect.Contains(mousePosition))
{
RepaintTheNCArea();
graphics.DrawImage( ((NCButton)ncButtons[2]).FocusedButtonImage,((NCButton)ncButtons[2]).ButtonRectangle);
return true;
}
RepaintTheNCArea();
return false;
}
private bool MouseDownHandling(Point mousePosition)
{
Rectangle rect = ((NCButton)this.ncButtons[0]).ButtonRectangle;
if(rect.Contains(mousePosition))
{
RepaintTheNCArea();
graphics.DrawImage( ((NCButton)ncButtons[0]).PressedButtonImage,((NCButton)ncButtons[0]).ButtonRectangle);
return true;
}
rect = ((NCButton)this.ncButtons[1]).ButtonRectangle;
if(rect.Contains(mousePosition))
{
RepaintTheNCArea();
graphics.DrawImage( ((NCButton)ncButtons[1]).PressedButtonImage,((NCButton)ncButtons[1]).ButtonRectangle);
return true;
}
rect = ((NCButton)this.ncButtons[2]).ButtonRectangle;
if(rect.Contains(mousePosition))
{
RepaintTheNCArea();
graphics.DrawImage( ((NCButton)ncButtons[2]).PressedButtonImage,((NCButton)ncButtons[2]).ButtonRectangle);
return true;
}
RepaintTheNCArea();
return false;
}
private bool MouseUpHandling(Point mousePosition)
{
Rectangle rect = ((NCButton)this.ncButtons[0]).ButtonRectangle;
if(rect.Contains(mousePosition))
{
RepaintTheNCArea();
graphics.DrawImage( ((NCButton)ncButtons[0]).NormalButtonImage,((NCButton)ncButtons[0]).ButtonRectangle);
return true;
}
rect = ((NCButton)this.ncButtons[1]).ButtonRectangle;
if(rect.Contains(mousePosition))
{
RepaintTheNCArea();
graphics.DrawImage( ((NCButton)ncButtons[1]).NormalButtonImage,((NCButton)ncButtons[1]).ButtonRectangle);
return true;
}
rect = ((NCButton)this.ncButtons[2]).ButtonRectangle;
if(rect.Contains(mousePosition))
{
RepaintTheNCArea();
graphics.DrawImage( ((NCButton)ncButtons[2]).NormalButtonImage,((NCButton)ncButtons[2]).ButtonRectangle);
return true;
}
RepaintTheNCArea();
return false;
}
private Point FindMousePosition()
{
/*int l = (int)m.LParam;
int x = l & 0xffff;
int y = (int)((l & 0xffff0000) >> 16);
label1.Text = x.ToString();
label2.Text = y.ToString();*/
Point pt = System.Windows.Forms.Cursor.Position;
Point ptScreen = Cursor.Position;
Point ptClient = PointToClient(ptScreen);
ptClient.Y += 30;
//label1.Text = ptClient.X.ToString();
//label2.Text = ptClient.Y.ToString();
return ptClient;
}
private void RepaintTheNCArea()
{
if(graphics != null)
{
graphics.DrawImage(imgTitle,0,0,this.Width,30);
graphics.DrawImage( ((NCButton)ncButtons[0]).NormalButtonImage,((NCButton)ncButtons[0]).ButtonRectangle);
graphics.DrawImage( ((NCButton)ncButtons[1]).NormalButtonImage,((NCButton)ncButtons[1]).ButtonRectangle);
graphics.DrawImage( ((NCButton)ncButtons[2]).NormalButtonImage,((NCButton)ncButtons[2]).ButtonRectangle);
}
}
private void Form1_Resize(object sender, System.EventArgs e)
{
int totalButtonsWidth = 0;
int x = 0, y = 0 , w = 0, h = 0;
int space = 5;//space b/w the buttons;
for(int i = 0 ; i < ncButtons.Count ; i++)
{
totalButtonsWidth += ((NCButton)ncButtons[i]).NormalButtonImage.Width;
}
x = this.Width - ( (space * 2) + totalButtonsWidth) ;
y = 0;
w = ((NCButton)ncButtons[0]).NormalButtonImage.Width;
h = ((NCButton)ncButtons[0]).NormalButtonImage.Height;
Rectangle rect = new Rectangle(x,y,w,h);
((NCButton)ncButtons[0]).ButtonRectangle = rect;
x += (space + w) ;
y = 0;
w = ((NCButton)ncButtons[1]).NormalButtonImage.Width;
h = ((NCButton)ncButtons[1]).NormalButtonImage.Height;
rect = new Rectangle(x,y,w,h);
((NCButton)ncButtons[1]).ButtonRectangle = rect;
x += (space + w) ;
y = 0;
w = ((NCButton)ncButtons[2]).NormalButtonImage.Width;
h = ((NCButton)ncButtons[2]).NormalButtonImage.Height;
rect = new Rectangle(x,y,w,h);
((NCButton)ncButtons[2]).ButtonRectangle = rect;
}
}
}
|
|
|
|
|
hi,
Is it possible to explain your little more specific. What i mean is, what is your real requirement and where you fond problem. And what is your problem. When your form flickering. And what you mean by activate and deactivate. Is it forms activate and deactivate or something else
Sreejith Nair
|
|
|
|
|