|
Moving the button with the mouse...
> On the button's OnMouseDown event, set a bool flag to true and store both the mouse's current position (MousePosition ), and the buttons current Location .
> On the button's OnMouseUp event, clear the bool flag.
> On the button's OnMouseMove event, (if the bool flag is set) set the button's Location to it's last stored location + the difference between the new MousePosition and the last stored mouse position.
A simple way of resizing the groupbox is setting its AutoSize property to true, and AutoSizeMode to GrowAndShrink. This will resize the groupbox to the location of the button (assuming it is the lowest and rightmost object in the groupbox).
This has always worked for me in the past... although you may want to look at using MdiParents (www.codeproject.com/csharp/mdiformstutorial.asp[^]).
MdiParents have much more to offer (layouts etc) and look more professional.
Hope this helps.
Matthew Butler
|
|
|
|
|
I need drawstring() to print a trailing blank space but it seems to be trimming the string... does anyone know a workaround to this???
|
|
|
|
|
AFAIK Graphics.DrawString() only paints the foreground, i.e. pixels belonging to the
characters in the string, so it does not paint spaces, it just skips them.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
see the prob is that...i need to format numbers such that they are aligned. -ve numbers are denoted in brackets
eg.
5000
(20)
here the nos are not aligned...so i need to print a blank space after the +ve nos so that they align properly.
eg.
5000
(20)
is this possible using drawstring() ??????
|
|
|
|
|
Hi,
Graphics.DrawString() will paint a string at the given coordinates (specified by either
a PointF or two floats, and indicating the top-left corner as always).
So it is up to you to specify the right x-value to get the alignment you want.
There are two possibilities:
1. using a non-proportional font, such as Courier New, where all symbols have the same width:
you can simply keep x constant and adjust the string, i.e. add spaces to the left and/or
the right, so the characters appear where you want them.
2. using an arbitrary font:
since character widths may vary now, you must find out how wide a specific string is,
and then adjust the x-value to get it to align properly.
The width can be obtained from Graphics.MeasureString(). Be careful to specify the
same parameters (text, font, brush, ...) you are going to pass to DrawString() later on.
If you want the unit digits to align, you should split the string in two parts, the left one
ending on the unit digit, the right one holding everything else (could be decimal point,
decimals, and/or a closing parenthesis). Then calculate the width of the left part,
and adjust it's x-value accordingly. The right part will have to be drawn at a constant
x-value, since that one needs to be aligned.
As you can see, with arbitrary fonts, spaces don't really come into the solution.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
thanks a lot..
|
|
|
|
|
Hi,
I have created a Local User Account programmatically say "MyUser" and then Iam Creating a process as MyUser. From within this process( which means Iam working as "MyUser") I have created a Pdf file and then Iam trying to open it Programmatically using DOS command "cmd /c start myfile.pdf". But the Pdf file is not getting opened. Even when I click on it. It Says "Access denied". The Same file if I login using "MyUser" it is being opened.Then after If Iam trying to Open it Programmatically or Normally I could open the File from my current user Account.
So,Is it a must for me to login as "MyUser" atleast once to work with that user Programmatically?
What I observed is once I login as that user, In Documents and Settings a folder is created under the name "MyUser".
So Is there any thing more I need to do apart from creating a user Programmatically?
Any suggestions would be helpful.
Thanks in Advance
Today is a gift, that's why it is called the present.
|
|
|
|
|
i had a program that use TAPI methods to answer a call ,it work correctly with SIP TSP and asnswer the call but this programm didnt work correctly in h323 TSP and didnot answer the call , so does h323 support the call answer if yes whats my program problem ???? tank you
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using JulMar.Tapi3;
using QuartzTypeLib;
namespace IncomingSample
{
public partial class IncomingForm : Form
{
public IncomingForm()
{
InitializeComponent();
}
private void IncomingForm_Load(object sender, EventArgs e)
{
_tapiMgr.Initialize();
foreach (TAddress addr in _tapiMgr.Addresses)
{
if (addr.QueryMediaType(TAPIMEDIATYPES.AUDIO))
{
try
{
// Supports audio -- attempt to select video as well if the provider supports it.
TAPIMEDIATYPES mt = TAPIMEDIATYPES.AUDIO;
if (addr.QueryMediaType(TAPIMEDIATYPES.VIDEO))
mt |= TAPIMEDIATYPES.VIDEO;
// Open - this owns inbound calls
addr.Open(mt);
}
catch(TapiException ex)
{
if (ex.ErrorCode == unchecked((int)0x80040004))
{
try
{
addr.Open(TAPIMEDIATYPES.DATAMODEM);
}
catch
{
}
}
else
MessageBox.Show(string.Format("Open(VOICE) {0}: {1}", addr.AddressName, ex.Message));
}
// Add any existing calls.
foreach (TCall call in addr.Calls)
{
lbCalls.Items.Add(call);
}
}
}
}
void OnSelectedCallChange(object sender, EventArgs e)
{
TCall call = (TCall) lbCalls.SelectedItem;
if (call != null)
{
if (call.Privilege == CALL_PRIVILEGE.CP_OWNER)
{
btnAnswer.Enabled = call.CallState == CALL_STATE.CS_OFFERING;
btnDisconnect.Enabled = true;
return;
}
}
btnAnswer.Enabled = false;
btnDisconnect.Enabled = false;
}
private void OnAnswerClicked(object sender, EventArgs e)
{
TCall call = (TCall)lbCalls.SelectedItem;
TTerminal captureTerminal = call.Address.GetDefaultStaticTerminal(TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_CAPTURE);
TTerminal renderTerminal = call.Address.GetDefaultStaticTerminal(TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_RENDER);
foreach (TStream stream in call.Streams)
{
if (stream.MediaType == TAPIMEDIATYPES.AUDIO)
{
if (stream.Direction == TERMINAL_DIRECTION.TD_CAPTURE)
stream.SelectTerminal(captureTerminal);
if (stream.Direction == TERMINAL_DIRECTION.TD_RENDER)
stream.SelectTerminal(renderTerminal);
}
}
try
{
call.Answer();
}
catch (Exception ex)
{
// MessageBox.Show(ex.ToString());
}
}
private void OnDisconnectClicked(object sender, EventArgs e)
{
TCall call = (TCall)lbCalls.SelectedItem;
try
{
call.Disconnect(DISCONNECT_CODE.DC_NORMAL);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void IncomingForm_FormClosed(object sender, FormClosedEventArgs e)
{
_tapiMgr.Shutdown();
}
private void OnCallStateChange(object sender, TapiCallStateEventArgs e)
{
if (e.Call.Privilege == CALL_PRIVILEGE.CP_OWNER)
{
lbCalls.Items.Remove(e.Call);
if (e.State != CALL_STATE.CS_DISCONNECTED)
lbCalls.Items.Add(e.Call);
}
}
private void OnNewCall(object sender, TapiCallNotificationEventArgs e)
{
if (e.Call.Privilege == CALL_PRIVILEGE.CP_OWNER)
lbCalls.Items.Add(e.Call);
}
|
|
|
|
|
Hello experts...
I am developing an game using desktop application in C#.net 2005.
In that I have 3 forms (No MDI form).
I want to show form1 then form2 and then form3.
But if user press cntl+f4 key form goes close and second forms show
how to prevent this..?
I also have close button on each form.
Regards
Pankaj Joshi
|
|
|
|
|
Handle the Closing event on the form, the event arguments will have a Cancel property. Set that Cancel property to true .
|
|
|
|
|
1. Set the form's KeyPreview property to true.
2. Add a KeyDown event to the form like this:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == (int)Keys.F4 && e.Modifiers == Keys.Control)
{
e.SuppressKeyPress = true;
}
}
That's it.
Hope it'll help.
Danny
|
|
|
|
|
Hello DannyAdler sir,
This is working fine. Thannks for the help.
I only have one question .. Is their any problem to using that code.?
I don't think so... But if any, please tell me points to be remember
while using this code.
Regards
Pankaj Joshi
|
|
|
|
|
Two things I can think of:
1. After setting the KeyPreview property to true, ALL the key-down events will first go through this function.
2. The CTRL-F4 will never work on that window, as long as the key-down is supressed in the if statement.
Just to keep in mind.
Danny
|
|
|
|
|
Hi all,
Trying to send mail with System.Net.SmtpClient, using very simple code
just for testing:
SmtpClient smtp = new SmtpClient("mail.server.com", 25);
smtp.Credentials = new
System.Net.NetworkCredential("user", "password");
try
{
smtp.Send("sen...@server.com",
"recipi...@server.com",
"Subject",
"Body");
MessageBox.Show("Mail Sent!");
}
catch (Exception ex)
{
txtErrorMsg.Text = ex.ToString();
}
BTW, the mail.server.com is not mine, it's an ISP mail server.
On my local machine, this code works fine and actualy sending the
mail.
BUT, on my remote server the same code produces the exceptions as
follows:
System.Net.Mail.SmtpException: Failure sending mail. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: No connection could be made
because the target machine actively refused it
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketState state, IAsyncResult asyncResult, Int32
timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream,
Object owner, Boolean async, IPAddress& address, Socket& abortSocket,
Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean
async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject,
GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject,
GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32
port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32
port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at System.Net.Mail.SmtpClient.Send(String from, String recipients,
String subject, String body)
at TestWindows.FrmSendSMTPMail.btnSend_Click(Object sender,
EventArgs e)
Weird stuff...
My remote server has Windows Server 2003.
So, am I missing something?
Sounds to me like a connectivity problem... How can I check that?
Thanks in advance,
Danny
|
|
|
|
|
I'd guess that your ISP rejects connections from IP addresses that do not belong to them.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You may be able to authenticate to your isp's smtp server by passing it your user credentials.
Alteratively, consider using the windows server SMTP service.
"You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"
|
|
|
|
|
Hi
I am trying to create a Richtextbox that able to be able to copy and paste from Word document. The method to paste from word document I have used is Paste(); However there is a problem when in Word document there is table. If the table is located further to the right then when pasted to the richtextbox then the richtextbox will cover a bit of the table.
I have a screen shot here
http://www.mediafire.com/imageview.php?quickkey=3xdzy9xnjmj&thumb=4
Can you please tell me is that the right method to use to paste the table from Word file into richtextbox? Is there any way that I can fix that please?
Thank you very much. I really do appreciate your help.
Best regards
-- modified at 11:59 Thursday 1st November, 2007
|
|
|
|
|
Hi!
The regular RichTextBox cannot display everything you can have in a Word document and some features can be transferred but will not be shown exactly the way they appear in Word.
Tables are among these features.
You can come a little closer to Word if you use a more recent version of the Rich Edit Control than the one the regular RTB uses (V2.0).
This can be done by overriding CreateParams in a class deriving from RichTextBox like this:
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr LoadLibrary(string lpFileName);
protected override CreateParams CreateParams
{
get
{
CreateParams par = base.CreateParams;
if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
{
par.ClassName = "RICHEDIT50W";
}
return par;
}
But unfortunately you'll never achieve a 100% match...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
HI,
i know there is a "dateTimePicker" Cell Style
but i do not know how to build, HELP
is there an existing Example of it that i can take and Add-On to my APP?
THNKS IN ADVANCE
Have Fun
Never forget it
|
|
|
|
|
My DataGrid contain :
<ItemTemplate>
<a href='<%# "javascript:void(window.open('..SubPages/MusicDetail.aspx?item_id=DataBinder.Eval(Container.DataItem,("id_BaiHat"))&type=type','toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=450,height=250'))" %>'><%#DataBinder.Eval(Container.DataItem, "TenBaiHat") %></a>
</ItemTemplate>
This code is used to open a popup window when user click this link.
But I get error at: '<%# "javascript:void(window.open('..SubPages/MusicDetail.aspx?item_id=DataBinder.Eval(Container.DataItem,("id_BaiHat"))&type=type'
I don't know how to fix it.help me please !
Thanks advace.
nothing
|
|
|
|
|
You should place the literal javascript code outside of the databinding expression block. Only your call to DataBinder.Eval should be placed within this block.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Can you give me your code exactly ?
nothing
|
|
|
|
|
I've already told you what to do. Only your call to DataBinder.Eval needs to be placed inside the <%# %> block. Your literal Javascript code should be placed outside of this block, the same as your anchor tag.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I rewrite my code and it like below:
<a href="javascript:void(window.open('../SubPages/MusicDetail.aspx?item_id=<%#DataBinder.Eval(Container.DataItem,("id_BaiHat"))%>&type=type','toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=450,height=250'))"><%#DataBinder.Eval(Container.DataItem, "TenBaiHat") %></a>
There is no error any more.But it can open new window when I click this link.Nothing happened after clicking this link.
nothing
|
|
|
|
|
Have you viewed the source for your page output? Look at how the anchor tag has been constructed and see if there are any obvious problems with the HTML code.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|