|
Hi
how i can draw a control on somewhere (on a form say)
but NOTE that not placing the control on the form, Drawing
the form on it.
i want to draw a control 100 times on different palaces of
a form to seem that i have 100 controls on form.
i know that they are not controls and are the drawing of
a control.
|
|
|
|
|
Read the documentation for Control.OnPaint (inheritted by all controls). You override this method and use the Graphics property of the PaintEventArgs passed to it. Be sure to read the documentation for the Graphics class.
For example, to draw a rectangle just slightly smaller than the bounding rectangle for a control (remember that Form derives from Control , and thus inherits all its properties, methods, fields, and events (members)):
class Form1 : Form
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle rect = Bounds.Inflace(-5, -5);
e.Graphics.DrawRectangle(Pens.Black, rect);
}
} For more examples, search this site for "owner drawing" in the C# and .NET categories. There are many articles about this topics on this developer site.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
This is a big question, but how do you architect your application to centrally manage memory allocation/deallocation? To approve or deny allocation request from its child threads?
For instance, you can configure upper/lower memory limits for SQL Server. This implies a centrally managed memory allocation. Has anyone done this before? How's this done? References would be helpful.
Norman Fung
|
|
|
|
|
|
Anything, actually, Java, C++, C#, whatever. Just a question in general, I didn't run into any problem in specific actually.
Norman Fung
|
|
|
|
|
Well it all starts with asking the OS for memory with malloc() and friends.... i'm not clear what you really mean. Your program has to fit into memory, its up to you how you deal with that. Perhaps reading stuff on GC's (see boehm opensource), and C++'s autopointers.
You mentioned SQL. Those options are just for tuning SQL performance, eg the # and size of indices that are kept in memory cache etc etc.
There was a link to an article on memory management too on www.osnews.com the last week, I havent read it yet though.
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
Hello,
I am using Tri-state tree veiw (http://www.codeproject.com/cs/miscctrl/TriStateTreeViewSubmissio.asp) to make a small application.
When I add images to the treeview node, it get added to all nodes, but I do not want it in the root node.
Can anyone one guide how to remove the image from root node?
Even if I change the Imageindex and Selected InageIndex property to such a number that is not in the image list (say I have image 1, 2, and 3; and I make the Index Property =4) I can remove the image but not able to shift the node text towords left side, such that it should fill up the blank space of image. If some how i can shift the node text near to the node , that will do the job.
please guide
regards
|
|
|
|
|
Hi All,
I am converting a VB6 app to C# and have come across something that has raised a question.
What I want to do is to create a structure, populate the values for each member in the structure and write it to a file. I used to do this in a Binary access mode in VB6. This produced a file with no quotes around the text in the structure (in VB6 it is a type) and then I would write out a newline. I cannot find how to do this in C#. Structures I have found and that is fine, but writing the structure to a file so that the file has no quotes or other characters seperating the data has not been frutiful.
Can anyone point me into the right direction?
Thanks
Stephen
|
|
|
|
|
Here is a quick example:
using System;
using System.IO;
public class test
{
[STAThread]
public static void Main()
{
test t = new test();
t.Write();
}
private void Write()
{
using(StreamWriter sw = new StreamWriter(@"C:\test.txt"))
{
sw.WriteLine("Hello Nick");
}
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thanks Nick.
|
|
|
|
|
HI.
I have a question regarding Datagrid and its Templatecolumn.
I am trying to populate a crosstab query result in to a Datagrid. That works fine. Now I want to add hyperlinks to all the populated values in the Datagrid.
I want to pass (1) a Id (2) column-name of that fieldvalue displayed as querystring. So my idea is to pass two values in the query string.
Hyperlink column only allows one value in the querystring.
Read lot of articles about Templatecolumn.
I don’t know how to build the Templatecolumn dynamically and how to pass two values as querystring.
Please help me in solving this problem.
HOpe you all understand my problem.
|
|
|
|
|
Your question belongs in the ASP.NET forum, since only the ASP.NET DataGrid has a TemplateColumn . Please use the forum most appropriate for your questions.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I am having some trouble with this method that I want converted into c#, and being a c# novice it is taking me far longer than I would like.
At the moment it is written in c++ and its function is to set the DeviceGammaRamp given a certain int value (igamma).
Here it is...
void AdjustGamma( int iGamma )
{
HDC hDC = GetDC(GetDesktopWindow());
bool bMinus = iGamma < 0;
if( bMinus )
iGamma = -iGamma;
iGamma = min(max(iGamma, 0), 255);
if( hDC ) {
const int iNum = 256;
struct sRamp {
WORD wRed[iNum];
WORD wGreen[iNum];
WORD wBlue[iNum];
} wRamp;
if( GetDeviceGammaRamp(hDC, (LPVOID)&wRamp) ) {
for( int i = 0; i < iNum; i++ ) {
if( bMinus ) {
wRamp.wRed[i] = (255 - iGamma)*(i);
wRamp.wGreen[i] = (255 - iGamma)*(i);
wRamp.wBlue[i] = (255 - iGamma)*(i);
} else {
wRamp.wRed[i] = 65535 - (255 - iGamma)*(255 - i);
wRamp.wGreen[i] = 65535 - (255 - iGamma)*(255 - i);
wRamp.wBlue[i] = 65535 - (255 - iGamma)*(255 - i);
}
}
BOOL bRet = SetDeviceGammaRamp(hDC, (LPVOID)&wRamp);
}
ReleaseDC(GetDesktopWindow(), hDC);
}
}
There is some additional information as well, I have imported gdi32.dll sucessfully, and it looks like this...
[DllImport("gdi32.dll")]
private static extern bool SetDeviceGammaRamp(IntPtr hDC, IntPtr lpRamp);
If somebody could help me with this method then I could most certainly finish of another two that I have incompleted.
Thanks for your time
|
|
|
|
|
You may want to have a look at this[^] article by Christian Graus. The source code has an implementation of gamma correction written in C#.
Paul Lyons, CCPL Certified Code Project Lurker
|
|
|
|
|
Thanks! That was an awesome article! It really has helped me alot! I might consider implementing some other features in my program now!
Wow I'm so happy now!
|
|
|
|
|
SeaMonkey007 wrote:
That was an awesome article!
Yep! Christian is a God!
Paul Lyons, CCPL Certified Code Project Lurker
|
|
|
|
|
|
Good day all.
Using the Text property in the Form design. I created a text line with the Ampersand in the text. The designer does not display the symbol, nor does running the app.
Thank you in advance for any assistance on this problem.
Have a great coding day.
Regards,
Tony D. Abel
|
|
|
|
|
Tony D. Abel wrote:
Using the Text property in the Form design. I created a text line with the Ampersand in the text. The designer does not display the symbol, nor does running the app.
That is correct. What displays instead is an underline on the character after the ampersand indicating that is is used as part of a keyboard shortcut (like the underlines on single characters in a menu).
If you want to display an ampersand you need to type it twice.
This & That will display as This _That
This && That will display as This & That
Does this help?
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Just implemented the fix.
Thanks very much Colin.
Have a great evening.
Have a great coding day.
Regards,
Tony D. Abel
|
|
|
|
|
This must have a really easy answer. I have created a tabcontrol and added five pages to it. I added an 'click' event handler to each page. But the event only fires when I click on the main part of the page, not on the tabs (labels) themselves! (The graphical representation of the tabs changes with each click, but my Click handler is never called).
Since most of each page is covered with other controls this makes it almost impossible to use.
What am I doing wrong? Is there a different click event for the labels?
|
|
|
|
|
The TabPage does not include the tab itself; that is painted and otherwise handled by the TabControl . With that in mind and looking at the TabControl events, you should notice the SelectedIndexChanged event.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello all!
I'm attempting to create an active connection to an ftp server without any success. Passive mode works fine, but I have a vendor that will not allow passive mode connections. So I use the PORT command that specifies my IP and then the port number to use and this succeeds, but when I try to send the data, the connection is out right refused.
I'm using FTPClient.cs which was posted on this site (I used *'s instead of the IP address at my company)
private Socket createDataSocket()
{
this.sendCommand("PORT *,*,*,*,7,130");
if ( this.resultCode != 200 ) throw new FtpException(this.result.Substring(4));
Socket socket = null;
IPEndPoint ep = null;
try
{
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
ep = new IPEndPoint(Dns.Resolve("*.*.*.*").AddressList[0], ((7 << 8) + 130));
socket.Connect(ep);
}
catch(Exception ex)
{
// doubtfull....
if ( socket != null && socket.Connected ) socket.Close();
throw new FtpException("Can't connect to remote server", ex);
}
return socket;
}
I then use the STOR command to write the file name on the server, which it completes, but then the data connection is refused.
Any thoughts?
|
|
|
|
|
How do you draw on the main menu bars background? Not the actual menu items themselves but the entire menu bar.
|
|
|
|
|
Ask in the ASP.NET forum, which is specific for ASP.NET-related questions.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|