|
Hi...
I have a pictureBox i would like to use as a button!
I want it to be pressed when i press the enter button, and when i press the Tab button it have to get Focus or something (maybe change image) so the user can see he is at the "button"!
I have the Cursor.Hide() Enabled so the mouse dont work!
Thats why i want the pictureBox to could use TabStop!
First i tried to set the BackgroundImage on the Button, but it didn't look good at all!
So if anyone can help me to make a pictureBox to use tabstop and/or work as a button i would be very happy!
QzRz
|
|
|
|
|
Have you tried using a BUTTON with the IMAGE property set to your graphic???
This signature left intentionally blank
|
|
|
|
|
Yes... it still don't look good!
A black line is all around the button!
And it don't look good with that line
QzRz
|
|
|
|
|
I would think then that your only other option is a bit uglier.
Mark the button as OwnerDraw = true and do your own graphic drawing of the button.
You could create your own button inherited from button ... but then again you still are doing your own drawing of the graphics. Hmm...guess it is really only one option.
Just using a picture box will not inherently give you the behavior of a button. It is doing what it is intended to do which is display a graphic and probably inherits from the same base object as label.
This signature left intentionally blank
|
|
|
|
|
Hmmm.... ot suck i can't make a pictureBox like a button... but you are right it does what it i supose to do!!
So i just have to use a Button....!
Thanks!
QzRz
|
|
|
|
|
You could use a PictureBox as a button, it's just a LOT more complicated than using an actual button and customizing it the way you want.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm creating a website mirroring tool that allows you to filter html and image files by thier file size, but I'm trying to figure out the best way to do this. Is there any way to determine the size of a remote html or image file? Or would one have to download the file and then check the file size? Help is greatly appreciates!!
|
|
|
|
|
adeas wrote:
Or would one have to download the file and then check the file size?
Correct, or you could have a remote object on the server check it for you and simply return the value.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Not an option - trying to code it from the perspective of people not having the rights/capabilities/knowledge to have a program on the remote server like that, just plain site mirroring via HTTP
|
|
|
|
|
If this were the case how would people even know what files existed and where?
- Nick Parker My Blog | My Articles
|
|
|
|
|
You could write a remoting object on the webserver and have the client open a channel to that object. By implementing an interface on the remote object....then the user could access info via the methods GetList() and GetSize(string item) where item is a file exposed via GetList. The user would not need any 'special' security if you set it open as such. However this should only be exposed in an internal application and not for Internet Consumption.
This signature left intentionally blank
|
|
|
|
|
|
One way to do it is to make a request for the file, the content-size is one of the headers sent back so you get the size without the contents, but you still have to make a request per file rather then get a list.
I'm not sure, but there might be a head request to get the content size as well. Or if the server supports WebDAV, it might have methods to get that information as well.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
You can use the following HTTP Headers:
Content-Length and Content-Type.
"I don't suffer from insanity, I enjoy every minute of it." -- Unknown
|
|
|
|
|
How would I capture the X and Y point location of the user's insertion point in a System.Windows.Forms.RichTextBox instance?
Happy Programming and may God Bless!
"Your coding practices might be buggy, but your code is always right."
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
I've been hesitant to answer this since I don't have all of the specific calls to make...but lets assume this:
You have an RTF box and the cursor is positioned somewhere inside a valid location in that control.
You have a button which they press and it that button is [Insert Clipboard] for example.
First you get the cursor location by getting this.Cursor.Postion and maybe even you can get this.Cursor.Position.X and .Y but it's not important.
The part I cannot remember is you make a call (into the control?? or into Application???) which translates the relative location of the cursor on the desktop to the relative position of the cursor within the control.
Maybe Nick can add to the reply as to the specific call....but if not, you have a starting point.
This signature left intentionally blank
|
|
|
|
|
Thanks for your help. I finally figured out how to do this and it might help others who might need or want to know how to do this. Below is the bit of code I used to get the Point location of the insertion point.
rchEdit.GetPositionFromCharIndex(rchEdit.SelectionStart)
This did it. GetPositionFromCharIndex(...) when passed the selection start index, returns a Point instance at the insertion point's index (or at the beginning of a selection).
Happy Programming and may God Bless!
"Your coding practices might be buggy, but your code is always right."
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
I have need to authenticate users using windows authentiateion. I am using following code to do that. But problem with this is after three unsuccessful attempts, it locks user out from other applications using Directory Service, the same way when we try to login to windows machine and three consecutive wrong passwords locks the users out.
Does anybody know how can I use Directory Service to make non-blocking call upon wrong password
DirectoryEntry entry = new DirectoryEntry("LDAP://RootDSE");<br />
String str = entry.Properties["defaultNamingContext"][0].ToString();<br />
MessageBox.Show(str);<br />
DirectoryEntry domain = new DirectoryEntry("LDAP://" + str, txtLogin.Text, txtPassword.Text);<br />
<br />
<br />
try<br />
{<br />
Object native = domain.NativeObject;<br />
MessageBox.Show(txtLogin.Text + " Authenticated. Hurray!!!");<br />
}<br />
catch(Exception )<br />
{<br />
MessageBox.Show(txtLogin.Text + " INVALID user :-((");<br />
}
Thanks you very much,
Ruchi
|
|
|
|
|
Hi Ruchi
The administrator (hopefully you) of the AD can change the setting that "locks out accounts on X failed login attempts". This would solve your problem.
Also, you could try the Win32 Logon user function, although I would presume that it will cause the exact same error, as your error is not an error but an AD feature. The following code will log in a user account. The token returned can be used to make ur code impersonate the specific user account, calling System.Security.Principal.WindowsIdentity.Impersonate((System.IntPtr)token), if you should ever need that. If the account is invalid, you should recieve a 0 in the token returned from the function, as well as an error in the error variable.
[DllImport("advapi32.dll", SetLastError=true) ]
public static extern bool LogonUser(string lpszUsername, string
lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider,
outint phToken);
[DllImport("C:\\Windows\\System32\\Kernel32.dll")]
public static extern int GetLastError();
public static int LogonWindowsUser(string username, string domain, string password)
{
int token;
bool isLoggedin = LogonUser(username, domain, password, 3, 0, out token);
int error = GetLastError();
return token;
}
/Zalkina
|
|
|
|
|
Hi,
Can any1 tell me, how could i open an excel application in a "windows form"? I know how to open an Excel application but i am tryin 2 open it in "Windows form". I am trying to do it in C#,
Help would be greatly appreciated.
Bob
|
|
|
|
|
I do not believe that you can do that. Mainly because excel is an independant process and does not expose an interface or control for use in a windows form. Using a data grid is about the best way to do this.
This signature left intentionally blank
|
|
|
|
|
Hi,
Can any1 tell me, how could i open an excel application in a "windows form"? I know how to open an Excel application but i am tryin 2 open it in "Windows form".
Help would be greatly appreciated.
Bob
|
|
|
|
|
Hi folks,
Im building an application that at some point accepts a user name and password. I want to check that a) this user is indeed a valid user and b) that the user account has the right to "Log On as a service" to the local machine on which the application runs.
The first part is easily accomplished by using the advapi32.dll - LogonUser function in an example I found elsewhere.
However, how to check if the user account has the "Log on as a service" right (SeServiceLogonRight)? Ive found out that I (probably) need to once again DllImport a function from advapi32.dll, and that this time it is the "LsaEnumerateAccountRights" function, which I should use to retrieve a list of rights, associated with the user.
However, I cant quite get this to work! Could anyone provide me with a working c# example for performing the above check, I would be very grateful!
/Zalkina
|
|
|
|
|
You might try something like this but I haven't tested it.
[DllImport("advapi32.dll", SetLastError=true)]
static extern uint LsaEnumerateAccountRights(
IntPtr PolicyHandle,
IntPtr AccountSid,
out string[] UserRights,
out ulong CountOfRights);
Another thought is that this would be a lot easier if done in a MC++ wrapper because the native types would be available to you, plus much easier to use in .NET afterwards. Yet another thought would be to place the user/users in a group, assign that group appropriate permissions and then you can easily check if that user is in the group:
AppDomain domain = Thread.GetDomain();
domain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
IPrincipal p = Thread.CurrentPrincipal;
if(p.IsInRole("YourServiceRole"))
{
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi Nick
Thanx for your reply!
Im used to checking user group memberships, as you specified in your second exaxple. However, this is a app for company, which would never ever allow me to change the structure of their Active Directory, adding my own groups etc.
I must find out how to check for the specific "SeServiceLogonRight" right on a user account.
The reason I need to check for this right is that I during install of a service prompt for a username/password, under which the service is configured and started. However, before allowing the user to bypass the install form prompting for the credentials, I want to make sure that the entered user credentials will actually work for the service "run as" credentials.
Besides this, its quite interesting on a general level for me (and others) to know how to actually check a user account for specific WinNT rights. The System.Secirity namespace obviously lacks functionality for this, and one is left to the mercy of the Win32 API.
Documentation clearly shows that for right checks one should use the LsaEnumerateAccountRights function. However, when I import it as you specified in your first code snippet, Im unable to determine what parameters I need to supply for it to work.
So, Im still not able to get my check down on code. But maby you, being more experienced than me (no MC++ exp what-so-ever) would be able to?
I challenge you to, given a user name and the corresponding password, to write a function, checking for the "SeServiceLogonRight" (or any other right for that matter) Or simply to sucessfully call the LsaEnumerateAccountRights function on a user account, as I should be able to evaluate the resulting string array of rights myself ...
/Zalkina
|
|
|
|