Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

Sandeep Kalra

@Sandeep Kalra
About
Posts
21
Topics
13
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Preventing another application from calling code of my application.
    S Sandeep Kalra

    Hi All I am developing a windows based application using C# Language in which security is very important. I have used restricted access modifiers such as private,sealed,protected internal etc etc. And also denied permissions to my application at assembly level(in AssemblyInfo.cs) such as for File input output [assembly:FileIOPermission(SecurityAction.RequestRefuse,Unrestricted=false)] and for everything which was not needed in my application for eg registry,IsolatedStorage etc etc. I have also strong named my assembly. I came to know from somebody on the internet that still my code is accessible to other application and any application by using System.Reflection can execute the code of my application. Is it true? If yes What should I do to prevent it.? And please tell other things also which I can do to increase security of my application. Please guide. Thanks Regards THE SK

    C#

  • calling method/event of one form from another
    S Sandeep Kalra

    1.Yes. It is essentially the same as passing a value (a property is just syntactic sugar for a get and set method). Passing Values between Forms with C# and VB.NET examples[^] I have studied above topic but I do not have to pass values. 2. Page? Is this a web application? Its a windows based application. 3.The accessor levels of methods has nothing to do with security. If you want security you might want to look into areas such as CAS (Code Access Security). If someone wants to to call your method then they can do so quite easily using reflection. So, making something private, protected or internal has zero security associated with it. I did not knew about that.So Is this mean that I have to use CAS to improve security of my application. Please guide Thanks Regards THE SK

    C#

  • calling method/event of one form from another
    S Sandeep Kalra

    Hi All I have three forms in my application Form1 (main form), Form2 and Form3. Is there any easy way to call method or event which is on Form1 from Form3.In my application there is a method in form1 which is showing records on ListView of Form1 from a file. In Form3 I am adding two records in the file and after that form3 and form2(which is intermediatery form) both are closed and Form1 becomes the active form.Now I want to call a method or event so that two records are added to the ListView without calling Page load. I can not declare that method/event as public due to security reason. protected internal is okay. Searching on the net confused me and i did not understood anything. Please guide. Thanks Regards The SK

    C#

  • Control background color/image
    S Sandeep Kalra

    thousands line question One line answer Thanks

    C# graphics csharp winforms linq tutorial

  • Control background color/image
    S Sandeep Kalra

    Hi All Look at the code 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; namespace DealingWithImages { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.label1 = new System.Windows.Forms.Label(); this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(53, 52); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(211, 13); this.label1.TabIndex = 2; this.label1.Text = "This is windows forms do you like it?"; this.Controls.Add(label1); Image myimage = Image.FromFile(@"Give path of the image"); this.BackgroundImage = myimage; this.MaximumSize = new System.Drawing.Size(400, 400); this.MinimumSize = new System.Drawing.Size(400, 400); } protected override void OnMove(EventArgs e) { base.OnMove(e); this.Refresh(); this.Invalidate(); } protected override void OnPaintBackground(PaintEventArgs e) { if (this.BackgroundImage != null) { e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; e.Graphics.DrawImage(this.BackgroundImage, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height); } else { base.OnPaintBackground(e); } } } } I have to put image on the background of my windows form which I am doing using the code above. I have some controls which I am generating at runtime. Now the challenge is the background color of the control(here label1) looks odd on the form. Does anybody know How to solve it? Thanks Regards THE SK

    C# graphics csharp winforms linq tutorial

  • File Not Getting Imported (Black Magic)
    S Sandeep Kalra

    I am using Windows Xp SP2 Regards THE SK

    C# help

  • File Not Getting Imported (Black Magic)
    S Sandeep Kalra

    :confused::confused::confused: Hi All I have two files 1.Application File 2.Import File I have some data to be imported to Application File from import file. When the file to be imported is in the executing directory and i run the application the code is working fine and actually importing the data to the application file. Now the challenge is when the Import File is not in the executing directory.My application do not give any error and also runs fine(i used breakpoints and checked the intermediate values of variables(all were correct)).From intermediate variables i conclude that my application is reading data from the file to be imported correctly.But it is not writing into it.And after closing the application The application file is supposed to have Imported data from the import file.But it donot have any imported data and shows the data of previous state. After that I decided to go for an alternative I decided to copy the import file from another location(say desktop) to executing directory. First I used 1.Fileinfo f = new FileInfo("Fully qualified path of import file"); f.CopyTo(@"tempdata.olf"); 2. i used FileStream code to copy files using Binary reader and binary writer The code works fine and do not throw any runtime errors or exception But the import file is not copied to the tempdata.olf. Note: 1.I have used FullName(fully Qualified Path) of both files 2.The application is working as desired only when both the files are in executing directory. 3.I am running the application in admin account Does anyone has idea what may be wrong. Thanks Regards THE SK

    C# help

  • Message Box Challenge
    S Sandeep Kalra

    Hi All Check the code first 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; namespace MessageBoxChallenge { public partial class Form1 : Form { private ProgressBar pb = new ProgressBar(); private Button b = new Button(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { pb.Value = 5; pb.Visible = true; pb.Left = 20; pb.Top = 30; pb.Style = ProgressBarStyle.Blocks; this.Width = 500; pb.Width = 400; this.Controls.Add(pb); b.Text = "click"; b.Top = 300; b.Left = 50; b.Visible = true; this.b.Click += new EventHandler(b_Click); this.Controls.Add(b); } void b_Click(object sender, EventArgs e) { pb.Value = 0; int inc = Convert.ToInt32(100 / 5); DialogResult result = MessageBox.Show("Do you want to continue", "Header", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { for (int i = 0; i <= 4; i++) { System.Threading.Thread.Sleep(300); pb.Value = pb.Value + inc; } } else { this.Dispose(); this.Close(); } } } } In actual problem I have a code which is taking around 300ms for each iteration in the for lood thats why i placed System.Threading.Thread.Sleep(600) in the for loop. Now the problem is When the MessageBox appears and I click on Yes Button, Out of 10 times ,3 times the MessageBox still remains visible even after clicking on the Yes button against the actual behavior of becoming invisible/hiding immediately after clicking the Yes button of MessageBox. Note that On my friend machine this problem does not exists. I do not know .Whats the actual problem is. Please help me with any study material or code. Thanks Regards THE SK

    C# help csharp linq graphics

  • Why integer occupying 16 bytes instead of 4 bytes?
    S Sandeep Kalra

    Hi There I am using encryption and decryption using RijandaelManaged algorithm. When I write integer in plain form .It is occupying 4 bytes. When I use encryption It is occupying 16 bytes. Can anybody tell me why? Your response will be apperciated Thanks

    C# algorithms security question

  • How and Where to store passwords,Credit card number,Username etc on my computer?
    S Sandeep Kalra

    Hi there I am developing a windows application that will store passwords , credit card number and other sensitive information on the computer. Definetilely it will be stored in the file. There are algorithms in System.Security.Cryptography TripleDes,RSACryptoServiceProvider etc etc. Encrypting the file using above algorithms will require private key(in case of asymmetric encryption) or secret key and Intialization Vector(In case of symmetric encryption) I have encrypted the data using the above key and is working fine.Now the challenge is where to store the Private Key so that i can retrive that key later to decrpyt the data and show to the user. Please guide any reading material or code will be of help Thanks THE SK(Sandeep Kalra) I am the One

    C# security graphics help tutorial question

  • Column Header Not dispalying text in center
    S Sandeep Kalra

    Hi All Here is the code below // List view items starts here. ListView listView = new ListView(); listView.Bounds = new Rectangle(new Point(3, 16), new Size(900,900)); // Set the view to show details. listView.View = View.Details; // Allow the user to rearrange columns. listView.AllowColumnReorder = true; // Display check boxes. listView.CheckBoxes = true; // Select the item and subitems when selection is made. listView.FullRowSelect = true; // Display grid lines. listView.GridLines = true; listView.Visible=true; listView.Columns.Add("File Name", 100, HorizontalAlignment.Center); listView.Columns.Add("File Location", 100, HorizontalAlignment.Center); listView.Columns.Add("File size", 100, HorizontalAlignment.Center); // Add the ListView to the control collection. this.Controls.Add(listView); The text in first column header is aligned to left although i have aligned it to center. The text in other two columns header is aligned to center as set by me. How can i make the text in first column header to aligned centerally. Thanks in advance

    C# css question

  • ListView and column header
    S Sandeep Kalra

    Hi All Here is the code below // List view items starts here. ListView listView = new ListView(); listView.Bounds = new Rectangle(new Point(3, 16), new Size(900,900)); // Set the view to show details. listView.View = View.Details; // Allow the user to rearrange columns. listView.AllowColumnReorder = true; // Display check boxes. listView.CheckBoxes = true; // Select the item and subitems when selection is made. listView.FullRowSelect = true; // Display grid lines. listView.GridLines = true; listView.Visible=true; listView.Columns.Add("File Name", 100, HorizontalAlignment.Center); listView.Columns.Add("File Location", 100, HorizontalAlignment.Center); listView.Columns.Add("File size", 100, HorizontalAlignment.Center); // Add the ListView to the control collection. this.Controls.Add(listView); The text in first column header is aligned to left although i have aligned it to center. The text in other two columns header is aligned to center as set by me. How can i make the text in first column header to aligned centerally. Thanks in advance THE SK(Sandeep Kalra) I am the One

    C# css question

  • using lparam parameter of SendMessage function
    S Sandeep Kalra

    I have the handle of that window to which i wanted to send the message. I have also found that the PostMessage API which has same parameters as that of SendMessage ,is working fine. Declared this above in code [DllImport("user32.dll",EnteryPoint="PostMessage"] public static extern bool PostMessage(int hwnd,int msg,int wparam,int lparam) [DllImport("user32.dll",EnteryPoint="SendMessage"] public static extern int SendMessage(int hwnd,int msg,int wparam,int lparam) I am transferribg same parameters to the PostMessage and SendMessage by declaring them public ,on two different button_click event on my form Button with a PostMessage is working fine.But button_click with SendMessage is not working at all.I am not getting any warning, error or runtime errror. Also found that WM_KILLFOCUS,WM_QUIT are not working on PostMessage.However WM_CLOSE ,WM_KEYDOWN,WM_KEYUP worked fine. I do not know whats wrong(sure not coding).Please suggest. And I also want to know whic among SendMessage and PostMessage is more reliable

    C# tutorial json help

  • using lparam parameter of SendMessage function
    S Sandeep Kalra

    Hi Thats the Internet Explorer to which I am sending F1 key.It responds to F1 key if i press it on keyboard. Is it really the case that IE donot responds to WM_KEYUP or WM_KEYDOWN events.I have tried for WM_CLOSE and for quit too but it did not worked. I am trying to find. THE SK (Sandeep Kalra) "I am the One"

    C# tutorial json help

  • using lparam parameter of SendMessage function
    S Sandeep Kalra

    Hi Now I have used SendMessage API for both WM_KEYDOWN and WM_KEYUP . But still nothing happens. I have also included SecurityPermission for unmanaged code. I am not getting any warning or errors.I have already tried 0 as value for lparam but nothing happens no exception no warning etc. Please guide THE SK (Sandeep Kalra) "I am the One"

    C# tutorial json help

  • using lparam parameter of SendMessage function
    S Sandeep Kalra

    Hi All I have send keys to the application(other) which i have started using my windows form . By using API and managed code SetForeGroundWindow.. and SendKeys.Send... This is working fine.But while my application sends keys if a user click on any other window then that(window on which user clicked) get the keys not the window for which it was meant. So i had to chose other way. Now I am using SendMeassage API and I want to send a Key to that application [DllImport("User32.dll", EntryPoint = "SendMessage")] public static extern int SendMessage(int hWnd, int Msg, int wParam,int lParam); I have got the handle(hwnd) of the window to which i want to send a key(for here say F1 key) public const WM_KEYDOWN =0x100; /which is one of the possible value of msg /Here It is for keydown event. public const VK_F1=0x70; // it is a virtual key code for F1 to be passed in wparam For lparam i have following inf lParam Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. 0-15 Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative. 16-23 Specifies the scan code. The value depends on the OEM. 24 Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0. 25-28 Reserved; do not use. 29 Specifies the context code. The value is always 0 for a WM_KEYDOWN message. 30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up. 31 Specifies the transition state. The value is always zero for a WM_KEYDOWN message. Return Value An application should return zero if it processes this message. I do not know how to pass lparam to the function. Note:I have set 0x00 for lparam and i am gettingreturn value 0 which i had stored in a variable.This means the message was processed by the window according to return value condition above.But I did not saw any Help window of that application. Please guide in using lparam particularly for case of KeyDown msg of F1 Thanks THE SK (Sandeep Kalra) "I am the One"

    C# tutorial json help

  • Sending Keystroke To particular window of other application
    S Sandeep Kalra

    Hi All I want to send a Keystroke to the window of other application. I have got the Handle of that window. Is there any API or Managed C# code which will directly send the Keystroke only to that window. setting the window to foreground and then sending the keystroke is working fine.But in the meantime if the user click on other window that window becomes active and the keystrokes are send to that window not to that window for which it was meant. I have also studied about SendMessage Api SendMessage Function Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message. To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function. Syntax LRESULT SendMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ); But i do not know how to put Keystrokes input into msg variable Does anybody know how to send only to particular window? Thanks in advance THE SK (Sandeep Kalra) I am the One

    C# csharp data-structures json tutorial question

  • Progammatically pressing underscore,$,% etc keys
    S Sandeep Kalra

    Hey led mike U have used Fire_Fox.I think u should use Fire_Lion now.It will take 50 years to you :laugh:

    C# help tutorial

  • Progammatically pressing underscore,$,% etc keys
    S Sandeep Kalra

    Hi All Finally got it on below link http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx The correct way is SendKeys.SendWait("{+}"); //for typing plus SendKeys.SendWait("{_}"); //for typing underscore For this spent more than five hours ... great THE SK I am the ONE

    C# help tutorial

  • Progammatically pressing underscore,$,% etc keys
    S Sandeep Kalra

    ************Programming Challenge********************** Hi All Again I have spent more than five hours but still fighting. I just want to type underscore in my windows textbox.I am able to type characters, Hit enter key etc etc but do not yet found how to print underscore and other special characters like @,$,%,^ I have tried following code .Discovered new things but still trying to find the solution SendKeys.SendWait(Keys.Decimal.ToString()); SendKeys.SendWait(Keys.S.ToString()); SendKeys.SendWait(Keys.A.ToString()); SendKeys.SendWait(Keys.N.ToString()); SendKeys.SendWait(Keys.D.ToString()); SendKeys.SendWait(Keys.E.ToString()); SendKeys.SendWait(Keys.Oem1.ToString()); SendKeys.SendWait(Keys.Oem102.ToString()); SendKeys.SendWait(Keys.Oem2.ToString()); SendKeys.SendWait(Keys.Oem3.ToString()); SendKeys.SendWait(Keys.Oem4.ToString()); SendKeys.SendWait(Keys.Oem5.ToString()); SendKeys.SendWait(Keys.Oem6.ToString()); // with this type of code getting Oem6 in // textbox but i wanted 6. SendKeys.SendWait(Keys.Oem7.ToString()); SendKeys.SendWait(Keys.Oem8.ToString()); SendKeys.SendWait(Keys.OemClear.ToString()); SendKeys.SendWait(Keys.OemBackslash.ToString()); SendKeys.SendWait(Keys.OemCloseBrackets.ToString()); SendKeys.SendWait(Keys.Oemcomma.ToString()); SendKeys.SendWait(Keys.OemMinus.ToString()); SendKeys.SendWait(Keys.OemOpenBrackets.ToString()); //with this code getting OemOpenBrackets in textbox but desired was (. SendKeys.SendWait(Keys.OemPeriod.ToString()); SendKeys.SendWait(Keys.OemPipe.ToString()); SendKeys.SendWait(Keys.Oemplus.ToString()); SendKeys.SendWait(Keys.OemQuestion.ToString()); SendKeys.SendWait(Keys.OemQuotes.ToString()); SendKeys.SendWait(Keys.OemSemicolon.ToString()); SendKeys.SendWait(Keys.Oemtilde.ToString()); SendKeys.SendWait("{OemSemicolon}"); //givin error SendKeys.SendWait(Keys.KeyCode== 106); //giving error SendKeys.SendWait(Keys.E.ToString());

    C# help tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups