|
|
y should use
[DllImport("user32.dll")]
static extern bool SetSystemCursor(IntPtr hcur, uint id);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetCursor();
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr CopyIcon(IntPtr hInstance);
to change system cursor .
my cursor style is an image
get image
Bitmap image = new Bitmap(asm.GetManifestResourceStream(SIECURSORBusyImageResourseName));
sIECURSORBusyMouseCursor = image.GetHicon();
IntPtr intPtr = default(IntPtr);
SetSystemCursor(intPtr , OCR_NORMAL);
then you can change the cursor, i have test it in window 8。
|
|
|
|
|
That's a nice thought and all, but each application controls the mouse cursor when the mouse is over their windows. You can try to change it, but don't expect that change to stick or work in every situation.
You can change the cursor at the system level, basically, the "default" cursor shape, but don't expect it to stay that way when the mouse moves over an application window.
|
|
|
|
|
Hi I am try to get rid of an error caused by a null when I run the app it stops at:
HERE---> if (mySettings.Contains("setUserName"))<---HERE
Error Message "An unhandled exception of type 'System.NullReferenceException' occurred in Password.dll"
it doesnt show any errors prior to the button click, app loads up fine.
code below
using System.IO.IsolatedStorage;
namespace Password
{
public partial class MainPage : PhoneApplicationPage
{
IsolatedStorageSettings mySettings;
public void Settings()
{
InitializeComponent();
mySettings = IsolatedStorageSettings.ApplicationSettings;
if (mySettings.Contains("setUserName"))
txtUserName.Text = mySettings["setUserName"].ToString();
if (mySettings.Contains("setPassword"))
txtPassword.Password = mySettings["setPassword"].ToString();
}
public MainPage()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
if (txtUserName.Text != "" && txtPassword.Password != "")
{
if (txtPassword.Password == txtPasswordConfirm.Password)
{
if (mySettings.Contains("setUserName"))
{
mySettings["setUserName"] = txtUserName.Text;
}
else
mySettings.Add("setUserName", txtUserName.Text);
if (mySettings.Contains("setPassword"))
{
mySettings["setPassword"] = txtPassword.Password;
}
else
mySettings.Add("setPassword", txtPassword.Password);
mySettings.Save();
MessageBox.Show("Settings Saved Successfully");
}
else
MessageBox.Show("Passwords are not matching");
}
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
NavigationService.GoBack();
}
}}
|
|
|
|
|
IsolatedStorageSettings.ApplicationSettings;
seems to return null for some reason. Why? I have no idea, best guess is that you haven't it initialized anywhere.
Veni, vidi, caecus
|
|
|
|
|
Marco has clearly identified the most probable source of your 'null error.
Any time you have an error like this, it's a good idea to set a break-point before the error occurs, and then single-step through the code, inspecting the value of variables, the values returned by methods, etc.
"What Turing gave us for the first time (and without Turing you just couldn't do any of this) is he gave us a way of thinking about and taking seriously and thinking in a disciplined way about phenomena that have, as I like to say, trillions of moving parts.
Until the late 20th century, nobody knew how to take seriously a machine with a trillion moving parts. It's just mind-boggling." Daniel C. Dennett
|
|
|
|
|
|
Hi,
Can anyone suggest a best way to license my application so it requires an activation.. therefore, application will be protected from being shared with others?
Is there a free tool within Visual Studio or a free third-party?
Technology News @ www.JassimRahma.com
|
|
|
|
|
Maybe this SO thread[^] is going to help you.
Or maybe this one[^] is of use to you.
However, there are a few things you need to think about first:
- Activation
Is your key validated using a key server, or are you going to use a pattern which proves it to be an original key?
- Storing
I strongly recommend you to encrypt the key stored on the disk by using a hash
- Signign
Do you want to sign the key, and your assembly (not directly related, but worth a thought)
Veni, vidi, caecus
|
|
|
|
|
You could have also pointed him to a few articles here on CodeProject...
|
|
|
|
|
|
Why wouldn't you want your application to become popular? 
|
|
|
|
|
Jassim Rahma wrote: Can anyone suggest a best way to license my application so it requires an activation.. therefore, application will be protected from being shared with others?
The best way is a legally binding contract which was created by a competent attorney.
|
|
|
|
|
hi
how to set transparent on listbox???
i check this tutorial :
http://www.codeproject.com/Articles/11359/Transparent-ListBox
but idont undrestand , this source for c++
http://qfs.mobi/f1077792[^]
pls help me 
|
|
|
|
|
|
A List box has a property called "Opacity",which you can set to a value between 0 and 100 to make your listbox transparent.
Veni, vidi, caecus
|
|
|
|
|
 thanks guys.
i find a transparent class in you tube but List box dont have a SCROLL.
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
public class ListBox : Label
{
public ListBox()
{
this.Size = new Size(165, 124);
this.MinimumSize = new Size(25, 25);
this.ForeColor = SystemColors.Highlight;
this.Font = new Font("Microsoft Sans Serif", 8F, FontStyle.Regular, GraphicsUnit.Point, 0);
this.ScrollAlwaysVisible = true;
}
#region Storage
List<object> lst = new List<object>();
Color SBorCol = Color.DarkBlue, SelCol = Color.DodgerBlue, BorCol = Color.Navy, InBorCol = Color.SlateBlue;
string tmp = string.Empty;
byte SelAlpha = 50;
Size FSize;
int _Index = -1, SIndex = 0;
bool _Focus;
#endregion
#region Overrides
protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged(e);
FSize = TextRenderer.MeasureText("X", this.Font);
}
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
this.AutoSize = false;
this.Text = string.Empty;
this.BackColor = Color.Transparent;
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (e.Button == MouseButtons.Left)
{
this.Focus();
_Focus = true;
_Index = -1;
Point P = this.PointToClient(MousePosition);
for (int i = lst.Count; i-- > 0; )
{
if (i < MaxCount)
{
if (P.Y >= (FSize.Height * i) + 5 & P.Y < (FSize.Height * i) + (FSize.Height + 5))
{
this.Refresh();
_Index = i + SIndex;
this.CreateGraphics().FillRectangle(new SolidBrush(Color.FromArgb(SelAlpha, SelCol)), new Rectangle(5, (FSize.Height * i) + 5, this.Width - 12, FSize.Height));
this.CreateGraphics().DrawRectangle(new Pen(SBorCol), new Rectangle(5, (FSize.Height * i) + 5, this.Width - 12, FSize.Height));
}
}
}
}
}
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
tmp = string.Empty;
int Co = 0;
for (int i = SIndex; i < lst.Count; i++)
{
if (Co == MaxCount) return;
tmp += lst[i] + "\n";
Co++;
}
}
#endregion
#region Draw
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawRectangle(new Pen(BorCol, 4), new Rectangle(2, 2, this.Width - 5, this.Height - 5));
e.Graphics.DrawRectangle(new Pen(InBorCol, 2), new Rectangle(4, 4, this.Width - 9, this.Height - 9));
TextRenderer.DrawText(e.Graphics, tmp, this.Font, new Point(5, 5), this.ForeColor);
if (_Index != -1)
{
e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(SelAlpha, SelCol)), new Rectangle(5, (FSize.Height * (_Index - SIndex)) + 5, this.Width - 12, FSize.Height));
e.Graphics.DrawRectangle(new Pen(SBorCol), new Rectangle(5, (FSize.Height * (_Index - SIndex)) + 5, this.Width - 12, FSize.Height));
}
}
#endregion
#region UserSettings
public Color SelectBorderColor
{
get { return SBorCol; }
set { SBorCol = value; }
}
[Browsable(false)]
public new Color BackColor
{
get { return base.BackColor; }
set { base.BackColor = Color.Transparent; }
}
public Color BorderColor
{
get { return BorCol; }
set { BorCol = value; }
}
public Color BorderColorInner
{
get { return InBorCol; }
set { InBorCol = value; }
}
public Color SelectColor
{
get { return SelCol; }
set { SelCol = value; }
}
public byte SelectAlpha
{
get { return SelAlpha; }
set
{
SelAlpha = value <= 100 ? value : (byte)50;
}
}
#endregion
#region Functions
public void Add(object Value)
{
if (Value == null) return;
int i;
if ((i = lst.IndexOf(Value)) == -1)
{
lst.Add(Value);
}
this.Invalidate();
}
[Browsable(false)]
public int SelectedIndex
{
get { return _Index; }
}
public void RemoveAt(int Index)
{
if (Index != -1 & Index <= lst.Count)
{
lst.RemoveAt(Index);
this.Invalidate();
}
}
public void Remove(object Value)
{
if (Value == null) return;
int i;
if ((i = lst.IndexOf(Value)) != -1)
{
lst.RemoveAt(i);
this.Invalidate();
}
}
public bool Contains(object Value)
{
return lst.Contains(Value);
}
public void Clear()
{
lst.Clear();
this.Invalidate();
}
int MaxCount
{
get
{
return ((this.Height - 8) / FSize.Height);
}
}
[Browsable(false)]
public object SelectedItem
{
get
{
return SelectedIndex != -1 ? lst[_Index] : null;
}
}
#endregion
#region Disabled Settings
[Browsable(false)]
public override string Text { get; set; }
[Browsable(false)]
public override bool AutoSize { get; set; }
[Browsable(false)]
public new BorderStyle BorderStyle { get; set; }
[Browsable(false)]
public new FlatStyle FlatStyle { get; set; }
[Browsable(false)]
public new Image Image { get; set; }
[Browsable(false)]
public new Image ImageAlign { get; set; }
[Browsable(false)]
public new Image ImageIndex { get; set; }
[Browsable(false)]
public new Image ImageKey { get; set; }
[Browsable(false)]
public new Image ImageList { get; set; }
[Browsable(false)]
public new Size MinimumSize { get; set; }
[Browsable(false)]
public new DockStyle Dock { get; set; }
[Browsable(false)]
public new HorizontalAlignment TextAlign { get; set; }
[Browsable(false)]
public new bool UseWaitCursor { get; set; }
#endregion
#region Scroll Code
protected override void OnMouseWheel(MouseEventArgs e)
{
base.OnMouseWheel(e);
if (_Focus)
{
if (e.Delta > 0)
{
if (SIndex > 0)
SIndex--;
}
else
{
if ((SIndex + MaxCount) >= lst.Count) return;
if (SIndex <= (lst.Count - 1))
SIndex++;
}
this.Refresh();
}
}
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
_Focus = false;
}
#endregion
public bool ScrollAlwaysVisible { get; set; }
}
when write the class then click build solution and make new listbox in toolbox,
can help me to set Scroll??????
|
|
|
|
|
hi'
am developing project on hand held system,my view is : select the file(excel)by clicking browse. then click on upload.
here it's going to that device but after receiving data that device needs to send "$OK#" back to my program how can i receive that . plz help how to do tha
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Excel=Microsoft.Office.Interop.Excel;
using System.IO;
using System.Threading;
using System.IO.Ports;
namespace Hand_Held_Data_Transporter
{
public partial class Form1 : Form
{
int[] stream_buffer;
public Form1()
{
InitializeComponent();
progressBar1.Enabled = false;
progressBar2.Enabled = false;
serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(serialPort1_DataReceived);
}
private void Browse_Click(object sender, EventArgs e)
{
OpenFileDialog fdlg = new OpenFileDialog();
fdlg.Filter = "All Files(*.*)|*.*";
if (fdlg.ShowDialog() == DialogResult.OK)
{
textBox1.Text = fdlg.FileName;
File.ReadAllText(textBox1.Text);
}
}
private void Upload_Click(object sender, EventArgs e)
{
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(textBox1.Text, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
Excel._Worksheet xlWorksheet = (Excel._Worksheet)xlWorkbook.Sheets[1];
Excel.Range xlRange = xlWorksheet.UsedRange;
int rowCount = xlRange.Rows.Count;
int colCount = xlRange.Columns.Count;
progressBar1.Visible = true;
int k = 100 / rowCount;
for (int i = 1; i <= rowCount; i++)
{
String final = null;
String upload1 = null, upload2 = null, upload3 = null, upload4 = null, upload5 = null,upload6=null,upload7=null;
for (int j = 1; j <= colCount; j++)
{
if (j == 1)
upload1 = xlRange.Cells[i, j].Value.ToString();
if (j == 2)
upload2 = xlRange.Cells[i, j].Value.ToString();
if (j == 3)
upload3 = xlRange.Cells[i, j].Value.ToString();
if (j == 4)
upload4= xlRange.Cells[i, j].Value.ToString();
if (j == 5)
upload5 = xlRange.Cells[i, j].Value.ToString();
if (j == 6)
upload6= xlRange.Cells[i, j].Value.ToString();
if (j == 7)
upload7 = xlRange.Cells[i, j].Value.ToString();
final = "$ POST," + upload1 + "," + upload2 + "," + upload3 + "," + upload4 + "," + upload5 + "," + upload6 + "," + upload7 + " # ";
}
if (serialPort1.IsOpen)
serialPort1.Write(final);
serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
MessageBox.Show(final);
if (progressBar1.Value < 100)
{
Thread.Sleep(1000);
progressBar1.Value += k;
}
}
progressBar1.Value = 100;
}
private void Form1_Load(object sender, EventArgs e)
{
progressBar1.Visible = false;
progressBar2.Visible = false;
serialPort1.Open();
}
private void Download_Click(object sender, EventArgs e)
{
Excel.Application xlApp = default(Excel.Application);
Excel.Workbook xlWorkBook = default(Excel.Workbook);
Excel.Worksheet xlWorkSheet = default(Excel.Worksheet);
serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
string fName = @"C:\STL\Download\Download_" + DateTime.Now.ToString("dd MMM YY HH mm").Trim() + ".xls ";
try
{
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlWorkSheet.Cells[1, 1] = "Name";
xlWorkSheet.Cells[1, 2] = "ID Number";
xlWorkSheet.Cells[1, 3] = "Installment";
xlWorkSheet.Cells[1, 4] = "Paid Amount";
xlWorkSheet.Cells[1, 5] = "Due Amount";
xlWorkSheet.Cells[1, 1].Interior.ColorIndex = 39;
xlWorkSheet.Cells[1, 2].Interior.ColorIndex = 39;
xlWorkSheet.Cells[1, 3].Interior.ColorIndex = 39;
xlWorkSheet.Cells[1, 4].Interior.ColorIndex = 39;
xlWorkSheet.Cells[1, 5].Interior.ColorIndex = 39;
xlWorkBook.SaveAs(fName, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
releaseObject(xlWorkSheet);
releaseObject(xlWorkBook);
releaseObject(xlApp);
}
finally
{
if (xlApp != null)
releaseObject(xlApp);
if (xlWorkBook != null)
releaseObject(xlWorkBook);
if (xlWorkSheet != null)
releaseObject(xlWorkSheet);
}
if (System.IO.File.Exists(fName))
{
if (MessageBox.Show("Would you like to open the excel file?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
System.Diagnostics.Process.Start(fName);
}
catch (Exception ex)
{
MessageBox.Show("Error opening the excel file." + Environment.NewLine +
ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void releaseObject(object obj)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
obj = null;
}
catch (Exception ex)
{
obj = null;
MessageBox.Show("Unable to release the Object " + ex.ToString());
}
finally
{
GC.Collect();
}
}
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
try
{
String inputdata = serialPort1.ReadExisting();
MessageBox.Show(inputdata);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
} t.
|
|
|
|
|
|
I have to create a web app using ASP .Net and C#. Here we use only IE 8, so I can't use HTML5 and CSS 3 to create this app.
I have to show an organizational chart where data is dynamic and the user has to be able to select a card in the chart and delete it, edit it, and more.
I've been trying with treeview, but it's vertical.
Thank you for your answers, and sorry because the english.
|
|
|
|
|
Good Luck!
That's about all I can say as you haven't asked a question.
|
|
|
|
|
|
Hello
How I can find selected control on any window from mouse click c#
I want to snapshot the object when mouse click
thanks
|
|
|
|
|
Try
private void Control_Clicks(object sender, EventArgs e)
{
Control control = (Control)sender;
MessageBox.Show(control.Name.ToString());
}
|
|
|
|
|
see this
IntPtr hWnd = WindowFromPoint(Control.MousePosition);
if (hWnd != IntPtr.Zero)
{
Control ctl = Control.FromHandle(hWnd);
if (ctl != null)
label1.Text = ctl.Name;
}
it works inside the form I need it ouside the form to snapshot the control when mouse click.
thanks
|
|
|
|
|