|
omegazafer wrote: We saw even subject and I can make any application about that if I need only clicked button not first and second
This is not an English sentence. It makes no sense.
omegazafer wrote: I make effort to imrove myself, working only with books is not easy way and sometimes it is useless and spending my time.
Well, how is reading a book different to reading here, excepting that a book will cover all bases and has been laid out with a lot more thought than a forum post ?
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 )
|
|
|
|
|
Okey, after now,
I firstly try to look at the books for general subject samples.
|
|
|
|
|
omegazafer wrote: but how can I define the first clicked button and the second clicked button?
The event will be triggered for the first clicked button first and the second clicked button second.
|
|
|
|
|
Thanks for your interest.
|
|
|
|
|
Hey i am trying to create an application that takes control of the keyboard any time a key is pressed, however i don't know how to stop windows from executing the command for such key, example:
If i pressed the windows key + E Key, this is the shortcut to bring windows explorer, i would like to display a menu inside the application, while this is running, but stop windows from bringing Windows Explorer, any ideas how to do that?
And how can i write the registry if i know the key i want to write?
Let's say, as an example, i have this key to write on the registry
[HKEY_LOCAL_MACHINE]\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell = "explorer.exe", how could i write it completely without having to look for it first???
Thanks all!!!
Luis E Tineo S
|
|
|
|
|
kingletas wrote: Hey i am trying to create an application that takes control of the keyboard any time a key is pressed
What do you want to do make it levitate?
kingletas wrote: how could i write it completely without having to look for it first???
Magic? Should be a breeze since you can perform levitation.
|
|
|
|
|
led mike wrote: What do you want to do make it levitate?
No just to avoid users from performing any actions while the application is running, that way basically i am creating a kiosk mode where the user only sees and uses my application... this is one of the few things i need to get it done.
led mike wrote: Magic? Should be a breeze since you can perform levitation.
I don't really like to do anything with the registry but I am planning on modifying certain key on the registry to avoid some keys to be execute by windows. I know that if Explorer is running all windows shortcuts are handle but if not there are not!
any ideas!?
PS: Why are you using the word magic all the time you want to be sarcastic?
Luis E Tineo S
|
|
|
|
|
kingletas wrote: you want to be sarcastic?
I guess I am failing miserably eh?
kingletas wrote: avoid users from performing any actions while the application is running
Hmmm sounds like an interesting application to 'use', somehow I don't think what you wrote is actually what you mean. Anyway Dave's tip on a global keyboard hook is one way you can do that. There might be another involving the CBT mode but I'm not sure, also I don't have enough requirments from you to offer any certainties.
kingletas wrote: I am planning on modifying certain key on the registry
oops I misread your first post to say "if I don't know the key".... my bad
There are BCL classes for working with the registry. I don't remember offhand what namespace they are in but should be easy to find.
|
|
|
|
|
Well, dispatching Windows+E to do something other than launch Explorer is frowned upon since that's a well-known key combination. Generally speaking, modifying the standard functionality of well-known key combinations and controls is frowned upon because it breaks the rules of a "consistant user experience" acrossed all applications.
It can be done, but you have to implement a global keyboard hook. Search the articles for "keyboard hook" and you'll find what you're looking for.
|
|
|
|
|
Well basically the user won't see Windows at all... only the application.
This is what happens:
I have a touchscreen and a fingeprint reader. When the user is identified the application is enabled for the user to "vote" but he cannot do anything else.
So i need to ensure that any key does anything rather than what i want it to do while the application is running but once it stops everything will be turn back to normal!
Thanks... for the article i will look at it now!
Luis E Tineo S
|
|
|
|
|
Good day guys,
How do you reorder a List View? What I am doing is transfer all the LVItems to a DataTable then sort the Datatable, after that, clear the ListView then re-add the sorted data rows.
private static void SortDataTable(DataTable dt, string sort)<br />
{<br />
DataTable newDT = dt.Clone();<br />
int rowCount = dt.Rows.Count;<br />
<br />
DataRow[] foundRows = dt.Select(null, sort);
for (int i = 0 ; i < rowCount; i++)<br />
{<br />
object[] arr = new object[dt.Columns.Count];<br />
for (int j = 0; j < dt.Columns.Count; j++)<br />
{<br />
arr[j]=foundRows[i][j];<br />
}<br />
DataRow data_row = newDT.NewRow();<br />
data_row.ItemArray=arr;<br />
newDT.Rows.Add(data_row);<br />
}<br />
<br />
dt.Rows.Clear();<br />
<br />
for(int i = 0; i < newDT.Rows.Count; i++)<br />
{<br />
object[] arr = new object[dt.Columns.Count];<br />
for (int j = 0; j < dt.Columns.Count; j++)<br />
{<br />
arr[j]=newDT.Rows[i][j];<br />
}<br />
<br />
DataRow data_row = dt.NewRow();<br />
data_row.ItemArray = arr;<br />
dt.Rows.Add(data_row);<br />
}<br />
<br />
}
I'm using that function found on the net. The problem with that one is if I sort {2,11,12,13,14,15} the output is {11,12,13,14,15,2} or {3,1,11,12,15} the output is {1,11,12,15,3}. I don't know why.
Can you suggest an alternate way to reorder a listview? (Not just sorting it, I really mean reordering it.) Not using DataView or listview.sort.
Thank You.
|
|
|
|
|
it is giving you results because it is sorting as string not integer. try this
private static void SortDataTable(DataTable dt, string sort)<br />
{<br />
DataView dv = new DataView(dt);<br />
dv.Sort = sort;<br />
<br />
listView.DataSource = dv;<br />
listView.DataBind();<br />
}<br />
-----
|
|
|
|
|
Thanks for the reply.
Listview does not contain DataSource and DataBind.
|
|
|
|
|
Sorry, I never thought of that, but you could still get the array from the view.. but anyhow you got the the sort method from the other response..
-----
|
|
|
|
|
I have a class that I use for this. I got the basics from a web page that I can't locate to give credit but I've ammended it quite a lot. There's probably quite a few bits 'wrong' but it works.
It uses the Tag property of each column to set the data type as String, Numeric or Date (sent as a string ie "Numeric".
If the column being sorted has two peices of identical data, it will sort recursively through any further SubItems using their Tag to determine data type.
using System;
using System.Collections;
using System.Windows.Forms;
namespace ListViewHandling
{
class Sorter : IComparer
{
private int _SortColumn;
private SortOrder _SortOrder;
private string _SortType;
public Sorter(int SortColumn, string SortType, SortOrder SortOrder)
{
_SortColumn = SortColumn;
_SortOrder = SortOrder;
_SortType = SortType;
}
public int Compare(object x, object y)
{
int Result = 0;
ListViewItem ItemX;
ListViewItem ItemY;
ItemX = (ListViewItem)x;
ItemY = (ListViewItem)y;
switch (_SortColumn)
{
case 0:
switch (_SortType)
{
case "Numeric":
Result = decimal.Compare(Convert.ToDecimal(ItemX.Text), Convert.ToDecimal(ItemY.Text));
break;
case "Date":
Result = DateTime.Compare(DateTime.Parse(ItemX.Text), DateTime.Parse(ItemY.Text));
break;
default:
Result = ItemX.Text.CompareTo(ItemY.Text);
break;
}
break;
default:
switch (_SortType)
{
case "Numeric":
Result = decimal.Compare(Convert.ToDecimal(ItemX.SubItems[_SortColumn].Text), Convert.ToDecimal(ItemY.SubItems[_SortColumn].Text));
break;
case "Date":
Result = DateTime.Compare(DateTime.Parse(ItemX.SubItems[_SortColumn].Text), DateTime.Parse(ItemY.SubItems[_SortColumn].Text));
break;
default:
Result = ItemX.SubItems[_SortColumn].Text.CompareTo(ItemY.SubItems[_SortColumn].Text);
break;
}
break;
}
if (Result == 0 && (ItemX.SubItems.Count - 1) > _SortColumn)
{
for (int i = _SortColumn + 1; i < ItemX.SubItems.Count; i++)
{
switch ((string)ItemX.SubItems[i].Tag)
{
case "Numeric":
Result = decimal.Compare(Convert.ToDecimal(ItemX.SubItems[i].Text), Convert.ToDecimal(ItemY.SubItems[i].Text));
break;
case "Date":
Result = DateTime.Compare(DateTime.Parse(ItemX.SubItems[i].Text), DateTime.Parse(ItemY.SubItems[i].Text));
break;
default:
Result = ItemX.SubItems[i].Text.CompareTo(ItemY.SubItems[i].Text);
break;
}
if (Result != 0) { break; }
}
}
if (_SortOrder == SortOrder.Descending)
{
Result = -Result;
}
return Result;
}
}
}
I fire it from the ColumnClick event but you could easily alter it
public Form1()
{
InitializeComponent();
listView1.ColumnClick += new ColumnClickEventHandler(listView1_ColumnClick);
}
void listView1_ColumnClick(object sender, ColumnClickEventArgs e)
{
listView1.ListViewItemSorter = new ListViewHandling.Sorter(e.Column, (string)listView1.Columns[e.Column].Tag, SortOrder.Ascending);
}
|
|
|
|
|
Thank You, It worked!
I have to force the tag though before sorting it.
ListView.Colums[1].Tag = "Numeric";
|
|
|
|
|
You're welcome.
Ian Uy wrote: I have to force the tag though before sorting it.
Alter the switch block so the default is "Numeric" instead of "String".
|
|
|
|
|
hi
i wrote a simple .net 2 application with csharp and i want to execute it from another client(s) on the network, but when i click on it, the microsoft error has shown me(send report,dont sent) without any useful error message.
i add this code to my AssemblyInfo :
[assembly: PermissionSet(SecurityAction.RequestMinimum, Name="FullTrust")]
but so that error shown me, where does my problem and how to solve that ?
thanks
|
|
|
|
|
A possible security related problem.
Try moving your executable on the desktop.
|
|
|
|
|
Any managed code running from an untrusted source (i.e.: any network share) runs in a restricted sandbox. Go to MSDN and search for "Code Access Security". You've got a bunch of reading to do...
|
|
|
|
|
i don't want to code access security, i want to run my exe file from network.
|
|
|
|
|
You might want to take a look at what has been suggested - it's been pointed out to you for a reason, i.e. you really need to learn how to do this if you want to break out of the Sandbox. Dave IS a MVP for a reason you know.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hdv212 wrote: i don't want to code access security
Well, understanding CAS is a requirement when dealing with managed code, especially in running from untrusted sources. It's not an option. The only reason why all your code to this point works is because of the default security setup under the .NET Framework. Now that you've ventured outside the defaults, you've having problems. You're either going to read up on CAS, or you're going to be stuck writing simple Windows Forms app that have to be run from a local drive.
In order to "run my exe file from network", you must understand CAS. This is not optional.
|
|
|
|
|
ok, thanks.
my problem was solved, but is that any way to perform this operation by code ?
my another question :
if my app use com dll or ocx (non dot net), even above solution was not solved problem and how to run it in network ?
many thanks
|
|
|
|
|
hdv212 wrote: but is that any way to perform this operation by code ?
No, there isn't. Can you, as a normal User, give yourself PowerUser permissions?? Of course not. Managed code has the same restrictions. It cannot give itself permissions greater than that of the security context it's running in.
hdv212 wrote: my another question :
if my app use com dll or ocx (non dot net), even above solution was not solved problem and how to run it in network ?
many thanks
There was a reason why I suggested you read up on Code Access Security. If you want the answers to these questions, you MUST understand how Code Access Security works. If not, you're groping around in the dark hoping to find something that works for you in this particular instance. God help you if if breaks, 'cause if you don't understand why it broke, you're not going to be able to fix it. That's what the documentation is for and why I told you to read it.
|
|
|
|