|
You are mastering the art of finding the answers for your own questions! =)
Good job!
Vini
|
|
|
|
|
Hi All,
I've recently tackled a project that involves a little bit of DirectX in managed code (c# with the June 06 DirectX SDK). I'm wondering if anyone has any recommendations for a good DirectX book? Something that focuses on managed DirectX, for someone who is comfortable programming in c# (a lot of the DirectX related stuff is sort of geared to people with very little development background). Just wondering if anyone here has run across a good reference that they would recommend.
Thanks,
Aaron
|
|
|
|
|
I want to put a copyright symbol inside a label
I tried alt+ctrl+C, but it didnt output anything. Any ideas?
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Two approaches:
1) Go to Character Map, find ©. Copy and paste it to your control
2) Find the ASCII code (or Unicode) for © (ASCII code is 169 in my RedHat Linux). Directly use the code in your application.
Best,
Jun
|
|
|
|
|
|
Hi guys;
I have a configuration form with tab controls where I have next and back buttons and I would like to disable the tab buttons, is there any way I can show the tab buttons but not allow the user to click on them and instead have them use the back and next buttons?
Please help!!!
sasa
|
|
|
|
|
i'm not sure if u can do it.
maybe u could use the user controls and with the buttons next/back u could show/hide them.
enrico
VentoEngine corp.
Program your life ^^
|
|
|
|
|
I've created a login dialog box to an application, which works fine, but now the customer wants to change to using a system login to the application to track who's on without needing to create separate login's in the app for each person. Also, the person running the app may or may not be the same person that logged into the computer (most likely not).
I've been digging around, and found some promising things - but nothing that quite matched up completely. The NetworkCredential class seemed the most promising, but I'm not going to be accessing any resource, I only need to see if it's a valid login, so I couldn't see how I could use this. The WindowsIdentity class also seemed promising, but I didn't see how that could be used for my purposes either.
Any ideas?
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
<br />
[DllImport("advapi32.dll", SetLastError = true)]<br />
public static extern bool LogonUser(String lpszUsername, <br />
String lpszDomain, String lpszPassword,<br />
int dwLogonType, int dwLogonProvider, ref IntPtr phToken);<br />
<br />
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]<br />
public extern static bool CloseHandle(IntPtr handle);<br />
<br />
private bool LogonUser()<br />
{<br />
IntPtr tokenHandle = new IntPtr(0);<br />
const int LOGON32_PROVIDER_DEFAULT = 0;<br />
const int LOGON32_LOGON_INTERACTIVE = 3;<br />
<br />
tokenHandle = IntPtr.Zero;<br />
string DomainName = ConfigurationManager.AppSettings["Domain"];<br />
<br />
try<br />
{<br />
if(LogonUser(txtName.Text, DomainName, txtPwd.Text,<br />
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,<br />
ref tokenHandle))<br />
{<br />
WindowsIdentity WinIdentity = new WindowsIdentity(tokenHandle);<br />
System.Threading.Thread.CurrentPrincipal =<br />
new WindowsPrincipal(WinIdentity);<br />
<br />
return true;<br />
}<br />
else<br />
{<br />
return false;<br />
}<br />
}<br />
catch(SystemException)<br />
{<br />
MessageBox.Show("Domain could not be found. Check network connection.");<br />
DialogResult = DialogResult.Abort;<br />
}<br />
catch(Exception ex)<br />
{<br />
ExceptionPolicy.HandleException(ex, "Unhandled Exception Policy");<br />
DialogResult = DialogResult.Abort;<br />
}<br />
finally<br />
{<br />
if( tokenHandle != IntPtr.Zero )<br />
CloseHandle(tokenHandle);<br />
}<br />
}<br />
only two letters away from being an asset
|
|
|
|
|
Beautiful! I wasn't quite expecting a full solution, but definite thanks! Works perfectly!
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
I just happened to have it lying around from a recent project.
only two letters away from being an asset
|
|
|
|
|
Ok,
I can not for the life of me figure out what is going on here. The problem is that another process is locking one of the files I am trying to read. All I want to do is get the contents of the file and parse them. I'm not writing to the file at all. How can I make this thing work? The only option I can think of is to make a temporary copy of the file and then open that, but that seems rather hackish. The process locking the file is mission critical and runs for hours.
This program is essentially an attempt on my part to periodically parse the logs and notify me if there are errors.
I have the following function:
static string GetFileContents(string fileName)
{
bool success = false;
string ret = string.Empty;
FileInfo fi = new FileInfo(fileName);
while(!success)
{
try
{
using(FileStream fs = fi.Open(FileMode.Open, FileAccess.Read))
{
Console.WriteLine("Reading File {0}", fi.Name);
using(StreamReader sr = new StreamReader(fs))
{
ret = sr.ReadToEnd();
}
fs.Close();
success = true;
}
}
catch(Exception ex)
{
//Some sort of problem reading the file - we'll wait and then try again.
Console.WriteLine("Trouble reading file {0} - Will wait 5 minutes and try again. {1}", fi.Name,DateTime.Now);
System.Diagnostics.Debug.WriteLine(ex);
Thread.Sleep(300000);
}
}
return ret;
}
|
|
|
|
|
Hello
Few Questions:
1- Did you make these logs?? If not, then maybe the other program that made them, is exclusively opening them.
2- Can you open them using the notepad?
3- What exactly is the exception thrown when you open the file??
4- Is it thrown upon File.Open() or upon sr.ReadToEnd() Excution?
5- Do they open upon retrial sometimes, or are they always locked??
Regards
|
|
|
|
|
Hi all,
I have created a class library project in .Net C#.
I want to create a multiple instance of this control in a form based application, same as we create buttons.
But when i drop the control second time, the previous gets disappear. At a time i can see only one instance of control on form, internally it creates different objects of the control.
Please suggest me, how can i do it.
Thanks.
Gajesh
Pune(India)
|
|
|
|
|
ooooook guys heres a little tinker for ya!
im trying to read some fields from Flash FXP (in c#) using the Windows User32 API...
GetWindowText is what il be using...
so i use Microsoft Spy++ to get the Handle for one of the input boxes, lets say for arguments sake its 4134644.. (thats the handle to the text box...)
Spy++ reports this as an EDIT class, good so far!
so i use GetWindowText to try get the text from the text box.... empty string??
mmmmm so im stratching my head... i know ill test my code and use:
static extern int GetWindowTextLength(IntPtr hWnd)
this has got to work! i should get a length back now!! NOPE! nothing is coming back from ANY EDIT class field
HOWEVER if i use GetWindowText on anything else, Labels, Window Titles it works!!
What am i doing wrong here? Am i using the wrong API call to get data from an Edit Field?
its driving me mad!!! lol
|
|
|
|
|
wbjohnson wrote: this has got to work!
No, it doesn't! Just because the control derives from EDIT does NOT mean that you can use this, or any other method you want for getting the text out of the control. It will only work if the control responds to WM_GETTEXT, which not every EDIT control does.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
ah hah!!
that explains alot! thanks!
can i send the WM_GETTEXT command and then read the message buffer? assuming the control supports this command?
Cheers dude!
|
|
|
|
|
Yes. You might want to try these[^]. You might also want to look at the limitations of GetWindowText[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
[DllImport("user32.dll")]<br />
public static extern int SendMessage(IntPtr hWnd, IntPtr Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPArray)] byte[] lParam);<br />
<br />
int __titleLength = SendMessage(hWnd, WM_GETTEXTLENGTH, IntPtr.Zero, null);<br />
<br />
byte[] __data = new byte[__titleLength];<br />
SendMessage(hWnd, WM_GETTEXT, new IntPtr(__data.Length), __data);<br />
<br />
foreach (byte __b in __data)<br />
Console.Write((char)__b);
this loks like its working!!!
|
|
|
|
|
Hi,
I am using/ or wanting to use the new application blocks. I am already using the DAAB, but would like to make use of the other blocks. I worked through the hands-on labs from Microsoft, but I don't understand the other blocks like the DAAB. I want to make use of the exception block, the logging block, and the caching block.
Can anyone advise please advise some good reading articles or tutorials that has helped you understand the application blocks a bit better.
I hope someone can help.
Regards,
ma se
|
|
|
|
|
The samples that come with the Enterprise Library seemed easy to understand to me. What are you having difficulties with? Provided you have the config file entries setup correctly this is about all there is to it.
<br />
try<br />
{<br />
LogEntry log = new LogEntry();<br />
log.Categories.Add("LogCategory");<br />
log.Message = "Tell what you want";<br />
log.Title = "I'm logging";<br />
<br />
Logger.Write(log);<br />
}<br />
catch(Exception ex)<br />
{<br />
if( ExceptionPolicy.HandleException(ex, "PolicyName") )<br />
throw ex;<br />
}<br />
only two letters away from being an asset
|
|
|
|
|
Hi,
Thanks for the reply.
WHat I am trying to do is to display a nicer error message if something goes wrong. This is how my code flow goes: .aspx page -> BLL class -> DAL class -> and then DAL class -> BLL class -> .aspx page. Now if something goes wrong in the DAL class, how do I get the error to display nicely to the user instead of that big yellow screen with the red and black text?? I thought of using the exception block for this would be the better way to go, not sure if I am right??
So you have used the January 2006 Enterprise Library alot?? I have only used the DAAB alot, I'll go and work through those hands on labs again the weekend.
Cheers
|
|
|
|
|
Any exception handling in your aspx pages could do this. The benfits of using the Enterprise Library blocks is that you can easily configure it to do more than just handle the exceptions, such as log the exception, ignore it, or wrap it in another exception, all with changes to your code.
only two letters away from being an asset
|
|
|
|
|
Hi all.
When I execute a simple sql command through my C# app, I get an error that says that an sql timeout has occured.
When I run the exact same command through query analizer it takes about 8 seconds to complete and returns all rows.
Does anyone have an idea why this happens. I have set the connection time out to 30 seconds and then to 60 seconds and I still recieve the same error.
Thanx in advance
He who laughs last is a bit on the slow side
|
|
|
|
|
I'm sure I'm not the best expert on this, but the first two things I would do are:
1) double check your connection string in the app
2) check out the resources that your app is using, potentially it could be hogging everything so that sql server runs more slowly and times out
hope those help or that someone else can give you the real low down
~A
|
|
|
|