|
There are two Windows API functions PostMessage and SendMessage . In order to utilize them you will need to research a technique called P/Invoke.
Either Google for P/Invoke C#, or PostMessage C# or SendMessage C#
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Good People,
So, my software installs a file that is read/write while the application is running. During debug, it works fine - read/write no problem. So, I created an MSI (Windows Installer Project in Visual Studio 2008 Sp1) for the application. It installs fine.
However, now two problems have emerged:
1) It states that access to the path where the file is located has been denied (it's nested in Program Files).
2) I tried to uninstall it but it's telling me that the appropriate level of access to the registry (something about HKEY_CURRENT_USER roots, certificates, blah, blah...) is not present.
Any help you can provide would be great.
(What really irks me is that when I created the install project before, I never had this issue. I bet it's some setting I missed. Oh well.)
Thanks,
Blitz
|
|
|
|
|
Hi,
for 1) I am not surprised; you probably needed admin privileges to get your app installed (so all users can use it), however a regular user cannot write to Program Files and its descendents.
Furthermore, one could make the whole app folder (or even Program Files) read-only for added protection, so the user trying to write files there is no good.
I suggest you use one of the preferred file locations using the Environment.GetFolderPath() method, probably with the SpecialFolder.ApplicationData or .CommonApplicationData parameter. You can creaye subfolders and files in there as much as you need to or want to.
Mind you, the actual path returned by GetFolderPath will depend on the specific Windows version, and some admin choices made while installing Windows; however the method takes care of all that.
for 2) I have no idea.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks Luc,
I will use the strategy you suggest.
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I am interested in sending an image I have in memory out through the VGA/DVI port, to a projector connected to the port. Something similar to what you do with PowerPoint. But I want to do it within my own application. Is there a way to access the VGA/DVI in the .NET framework?
|
|
|
|
|
Hi,
welcome to CodeProject.
Haven't done this before, but this is what I would try:
- use the Control Panel "Display Settings" to extend the desktop to your "second monitor" and choose its position
- use Screen.AllScreens to find the location and size of your second monitor
- open a borderless Form with those location and size values
- then paint your image to that Form
WARNING: extending the desktop also extends the range you can mouse over, so your mouse cursor now may wander of the primary screen and become invisible.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thank you for your response, I will look into that.
|
|
|
|
|
Thank you again for your reply, but it is not quite what I was for. I should be a little more specific. Within a C# forms application I would like to give the user the ability to select an image, and then send that image out to the projector which then projects it on a screen. But only that image nothing more. Is there a way to do that in the .NET framework? I am going to try your suggestion next week when I finally get the projector, but have been thinking about the problem since then.
I was hoping for something like the SerialPort class where you can open, write and close the port. But in my case the port would be the second DVI. But I'm not sure that exists. Does it?
Thank you for your help and suggestions.
|
|
|
|
|
Hi,
that was how I understood your question before.
No, you can't deal with a monitor, projector or DVI plug yourself; it needs a lot of data, some sync signals and all that at a very precise and high frequency. That is what the video drivers and video hardware are for.
Try my suggestion. I would start with a second monitor connector rather than the projector, just to separate the issues, although I don't think a projector is any different from a monitor. The "Display Settings" control panel would tell you pretty soon. Only when that is happy does it make sense to start writing some code.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I tried your suggestion yesterday and everything is working. Thank you again. There are a couple things to look out for with this setup. One is what you had mentioned, the mouse being allowed into the projector monitor. The other is the two "monitors" need to be the same resolution, so if the projector has a resolution of 1280x1024, then your 24 inch monitor must run on 1280x1024.
I think I can use Cursor.Clip to solve the mouse problem and I think if I use two video cards then I can run the primary monitor at full resolution and the projector at its resolution. Does that sound reasonable?
|
|
|
|
|
Great.
Bobby Hang wrote: the two "monitors" need to be the same resolution
that is not how I remember it.
Bobby Hang wrote: use Cursor.Clip
haven't used it yet. may be OK within your app, I don't expect it would work for the whole system, say when Explorer has focus.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I stand corrected. After a reboot, I can have 2 separate monitors at different resolutions. The Cursor.Clip is working for me because I have a dedicated application running, so the user can't interact with the rest of the system. But you are correct, once the application loses focus, the Cursor.Clip no longer works. Everything is working just the way a want it to, so thanks again.
|
|
|
|
|
Need to time stamp the last time a file was considered good.
I was trying to use something like: last_Time = DateTime.Now;. This is used inside a decision block. The problem even if the condition to enter the particular block isn't met, it still updates.
So does DateTime.Now execute no matter what?
Now for what I really need. I need to timestamp a infopacket/file/situation as to the last time it passed inspection. In other words when was the last good infopacket/file/situation.
The following code is what I thought would work:
public static DateTime last_Time;
public void Packet_Check(int decision)
{
pass_counter++;
if (decision == 1)
{
stateIndicatorComponent2.StateIndex = 4;
pass_counter = 0;
last_Time = DateTime.Now;
TRUCK_ID_DISPLAY.BackColor = Color.White;
Performance_Log_File(this.Name, Convert.ToString(last_Time)+ " last good packet " + port_in );
}
else
{
if (pass_counter > 3)
{
stateIndicatorComponent2.StateIndex = 3;
}
if (pass_counter > 7)
{
stateIndicatorComponent2.StateIndex = 2;
}
if (pass_counter > 12)
{
Diag_Box.Text = "lastime is " + last_Time;
if (light == true)
{
stateIndicatorComponent2.StateIndex = 3;
TRUCK_ID_DISPLAY.BackColor = Color.Red;
light = false;
}
else
{
stateIndicatorComponent2.StateIndex = 2;
TRUCK_ID_DISPLAY.BackColor = Color.Yellow;
light = true;
}
}
}
}
Thanks
modified on Thursday, May 21, 2009 10:12 AM
|
|
|
|
|
DateTime.Now is a static property that will always return a DateTime set to the current system's time.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks. One more bit of knowledge in the bucket.
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Something like this. Reread
|
|
|
|
|
much better. Now I'll read it.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
the code shown has only one way to modify last_Time. If you are not satisfied with the value of last_Time, AFAIK there are only two possibilities:
1. Check(1) is called where Check(0) was intended, causing the block with "ast_Time=now" to execute.
2. More Check(1) calls are performed, maybe entirely unrelated to the ones you are looking at, but since last_Time is static, they all share that one variable.
Suggestions:
1. don't use static variables unless you really need them; when they just seem the easy way to solve something, they will come back at you later on. A better way would be to make them non-static and instantiate your class once for every independent series of checks you want to perform (you already have to instantiate since Check itself is not static).
2. choose better names for your variables, especially the class members (last_Time) and the method parameters (decision). Also use boolean type if only two values are allowed, use an enum when more than two non-counting values are acceptable.
Instead of if(decision==1) ... I would write if (packetOK) ... or if (packetState==PacketState.Good)...
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Funny thing you should say about the static last_time. That's exactly what I did. Take off the static and it worked just as planned. Thanks for the second confirmation.
That's why I like this place
Later!!
|
|
|
|
|
Hi,
I have written a program that goes out to Fox News (http://www.foxnews.com) on an hourly basis and picks up the podcast for broadcasting on my local radio station. The software has been working perfect for the last 3 years. Now all of a sudden it will pick up and play the same .mp3 file over and over again. I suspect it is left over in the cache and that they are now tagging to cache that file. If I reboot the machine it picks up the latest podcast and works again. However every following hour it repeats the 1st newscast again and again.
I haven't done a lot of web programming and I've been looking at my C# book but I'm unsure how to ensure the cache has been cleared. How can I ensure the cache has been cleared?
Thanks,
Glenn
|
|
|
|
|
hell sir,
i am working on datagrid control in c# window application
i use datagridtextbox in datagrid . my probblem is that how can i do datagrid textbox column enable=false if it contains data =sunday
my code is...
try
{
dataGrid1.DataSource=null;
dt.Clear();
dataGrid1.TableStyles.Clear();
ad=new SqlDataAdapter("select * from attendance where months='"+txtmonth.Text+"' and class='"+txtcurrentclass.Text+"' and section='"+txtsection.Text+"' and session='"+Class1.session+"'",cn);
ad.Fill(dt);
dt.Tables[0].DefaultView.AllowNew=false;
dataGrid1.DataSource=dt.Tables[0];
DataGridTableStyle tbl=new DataGridTableStyle();
tbl.MappingName=dt.Tables[0].TableName;
DataGridTextBoxColumn txt=new DataGridTextBoxColumn();
// txt.MappingName=dt.Tables[0].Columns["id"].ColumnName;
// txt.HeaderText="SNo.";
// txt.TextBox.BorderStyle=BorderStyle.FixedSingle;
// txt.TextBox.Enabled=false;
// txt.ReadOnly=true;
// txt.Width=45;
// txt.TextBox.BackColor=Color.Salmon;
// txt.NullText="0";
//
// tbl.GridColumnStyles.Add(txt);
//
txt=new DataGridTextBoxColumn();
txt.MappingName=dt.Tables[0].Columns["Studentcode"].ColumnName;
txt.HeaderText="Student Code";
txt.ReadOnly=true;txt.TextBox.BorderStyle=BorderStyle.FixedSingle;txt.TextBox.BackColor=Color.Salmon;
txt.TextBox.Enabled=false;
txt.TextBox.WordWrap=true;
txt.Width=160;
txt.Alignment=HorizontalAlignment.Left;
tbl.GridColumnStyles.Add(txt);
//
txt=new DataGridTextBoxColumn();
txt.MappingName=dt.Tables[0].Columns["studentname"].ColumnName;
txt.HeaderText="Name";
txt.TextBox.BorderStyle=BorderStyle.FixedSingle;
txt.TextBox.Enabled=false;
txt.TextBox.BackColor=Color.Salmon;
txt.TextBox.ForeColor=Color.Blue;
txt.ReadOnly=true;
txt.Width=80;
txt.Alignment=HorizontalAlignment.Center;
tbl.GridColumnStyles.Add(txt);
txt=new DataGridTextBoxColumn();
txt.MappingName=dt.Tables[0].Columns[4].ColumnName;
txt.HeaderText="1 "+txtmonth.Text;
txt.TextBox.BorderStyle=BorderStyle.FixedSingle;txt.Alignment=HorizontalAlignment.Center;
txt.Width=65;
if(txt.TextBox.Text==DayOfWeek.Sunday.ToString())
{
txt.ReadOnly=true;
txt.TextBox.BackColor=Color.Red;
}
else
{
txt.ReadOnly=false;
txt.TextBox.BackColor=Color.White;
}
tbl.GridColumnStyles.Add(txt);
txt=new DataGridTextBoxColumn();
txt.MappingName=dt.Tables[0].Columns[5].ColumnName;
txt.HeaderText="2 "+txtmonth.Text;
txt.Width=47;
txt.TextBox.BorderStyle=BorderStyle.FixedSingle;
txt.Alignment=HorizontalAlignment.Center;
if(txt.TextBox.Text==DayOfWeek.Sunday.ToString())
{
txt.ReadOnly=true;
txt.TextBox.BackColor=Color.Red;
}
else
{
txt.ReadOnly=false;
txt.TextBox.BackColor=Color.White;
}
tbl.GridColumnStyles.Add(txt);
txt=new DataGridTextBoxColumn();
txt.MappingName=dt.Tables[0].Columns[6].ColumnName;
txt.HeaderText="3 "+txtmonth.Text ;
txt.Width=47;
txt.TextBox.BorderStyle=BorderStyle.FixedSingle;txt.Alignment=HorizontalAlignment.Center;
if(txt.TextBox.Text==DayOfWeek.Sunday.ToString())
{
txt.ReadOnly=true;
txt.TextBox.BackColor=Color.Red;
}
else
{
txt.ReadOnly=false;
txt.TextBox.BackColor=Color.White;
}
tbl.GridColumnStyles.Add(txt);
//class1
txt=new DataGridTextBoxColumn();
tbl.GridColumnStyles.Add(txt);
dataGrid1.TableStyles.Add(tbl);
my problem is that i want to make textbox readonly in txt.Textbox contains data=sunday and when i scroll data datagrid first three columns do not scroll except else.
please help me ..
|
|
|
|
|
Investigate the OnCellPaint event handling.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hello all,
I've added this line in my VC# editor as a reference from the Outlook
Object model:
using Outlook = Microsoft.Office.Interop.Outlook;
But, I don't think this exists (or I get an error anyways).
Can anyone direct me to the correct reference?
Thanks.
|
|
|
|