|
As Richard has mentioned, you should always consider adding the comment to the article itself, it not only helps you but the future readers also.
Secondly, all of these things are covered in the theoretical teaching of these subjects. No author would likely start explaining these things in a single article, that would require a book to cover these algorithms, their descriptions and the methods used in their classification.
Ask the question at the end of the article to see if author has interest in explaining those parts, otherwise, consider getting yourself a good book or learn these online at Wikipedia or so.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I have wrote a simple library, in C# (visual studio 2010), to access ini files for different applications.
The code at the end.
When used in windows application wrote in C# (x86,x64) (visual studio 2010) function properly.
Now I want to use it in a new library (mylib)(x64) where all methods are declared static, running indicates no errors but does not report the values that should have read from ini file.
I tried to add to the new library (mylib)a standard class, where methods aren't static, thinking that the problem was linked to the declaration of the static method of "mylib.getinipara()" , but without results.
Where am I wrong;
Thanks
ps.: all library and programs are compliled using Visual Studio 2010 Ultimate.
This is the code of library for accessing ini files.
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace FileINIAccess
{
public class IniAccess
{
public string path;
[DllImport("kernel32")] private static extern bool WritePrivateProfileSection(string lpAppName, string lpString, string lpFileName);
[DllImport("kernel32")] private static extern bool WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
[DllImport("kernel32")] private static extern int GetPrivateProfileSection (string lpAppName , StringBuilder lpReturnedString, int nSize , string lpFileName );
public void IniFile(string INIPath)
{
path=INIPath;
}
public Boolean WriteProfileString(string Section, string Key, string Value)
{
bool rs=WritePrivateProfileString(Section,Key,Value,path);
return rs;
}
public Boolean WritePrivatSection(string Section, string Value)
{
bool rs=WritePrivateProfileSection(Section,Value,path);
return rs;
}
public string GetProfileString(string Section, string Key, string DefValue)
{
StringBuilder temp=new StringBuilder(255);
int rs=GetPrivateProfileString(Section,Key,DefValue,temp,255,path);
if (rs>0)
{
return temp.ToString();
}
else
{
return DefValue.ToString();
}
}
public string GetProfileSection(string Section)
{
StringBuilder temp=new StringBuilder(255);
int rs = GetPrivateProfileSection(Section, temp, 255, path);
if (rs>0)
{
return temp.ToString();
}
else
{
return "";
}
}
}
}
|
|
|
|
|
|
Thanks for the reply,
I was on the indicated site, I modified the statements as reported, but the result is unchanged.
When I call "myfileini.GetProfileString(lpsection, lpkey, lpdefvalue, sb_retvalue, ui_lenretvalue, lpfile)" its return alwais the default value.
As if it does not find the file, yet it is in a specific directory, which I value by the method "myfileini.IniFile(lpPtah_File)"
Also the same .ini file is used by another application that uses the same library (FileIniAccess.IniAccess) to access and function properly,
|
|
|
|
|
The only way to find out what is happening is to use the debugger to step through the code.
|
|
|
|
|
Yes I have use debug step by step without error, all values are correct, but result its th same.
|
|
|
|
|
Something must be incorrect, but I have no way of guessing what it might be.
|
|
|
|
|
thanks for your time, other tests to do
bye
|
|
|
|
|
I have just tried your code on my system and it all works fine. You must have an invalid path or key somewhere in your code.
|
|
|
|
|
You're right I did not properly copied the .ini file, cut and paste gone bad.
When you read with eyes of the mind and you do not see
Thanks again for the time you have dedicated to me
|
|
|
|
|
Hello,
I am planning to implement cue banner for Text boxes in .net. I want this cue text to work till user enters some text in the box, that is cue text should not disappear if user clicks on text box.
I got this example, but I have two problems with this.
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Runtime.InteropServices;
public class Form1
{
private void Form1_Load(System.Object sender, System.EventArgs e)
{
CueBannerText.SetCueText(TextBox1, "Enter Name here");
}
public Form1()
{
Load += Form1_Load;
}
}
public static class CueBannerText
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static Int32 SendMessage(IntPtr hWnd, int msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)]
string lParam)
{
}
[DllImport("user32", EntryPoint = "FindWindowExA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern IntPtr FindWindowEx(IntPtr hWnd1, IntPtr hWnd2, string lpsz1, string lpsz2);
private const int EM_SETCUEBANNER = 0x1501;
public static void SetCueText(Control cntrl, string text)
{
if (cntrl is ComboBox) {
IntPtr Edit_hWnd = FindWindowEx(cntrl.Handle, IntPtr.Zero, "Edit", null);
if (!(Edit_hWnd == IntPtr.Zero)) {
SendMessage(Edit_hWnd, EM_SETCUEBANNER, 1, text);
}
} else if (cntrl is TextBox) {
SendMessage(cntrl.Handle, EM_SETCUEBANNER, 1, text);
}
}
}
The above code is working good in Windows 7 and above. But in windows xp it is not working properly. In windows xp the cue text disappears when we click on text box.
Secondly I want to change the color of cuetext (currently it is in grey).
Is it possible to achieve my requirements using current code? Or Is there any other suitable methods for me?
|
|
|
|
|
Windows XP is now well out of support so you are on your own when trying to implement new features on it. This feature is only officially supported in Vista and beyond, as described at EM_SETCUEBANNER message (Windows)[^]. If you wish to change colours and other behaviours then you will need to write your own implementation, or subclass the control.
|
|
|
|
|
How to save HTML tag through C# ASP.Net Form?. when using Rich text box the browser display Error Message.
|
|
|
|
|
Member 12676814 wrote: when using Rich text box the browser display Error Message. Unfortunately we cannot see your screen so have no idea what that message may be, or what you code is doing at the time.
|
|
|
|
|
There are some measures for preventing injection of malicious data - HTML tags and scripts are considered dangerous input. If you get a message like A potentially dangerous value was detected from the client and you are really sure you want to save that text, you may override the validation behavior of ASP.Net in the individual page by
<%@ Page Language="c#" ValidateRequest="false" ...
and in web.config
<httpRuntime requestValidationMode="2.0" />
|
|
|
|
|
If you're using .NET 4.5, it would be better to set the ValidateRequestMode property[^] on the specific control(s) which should be allowed to contain HTML.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi All!
I Have a Table1 Like This :
---------------------------
myID | myItem | IdCountry
2-----Japan------1
4-----US---------2
5-----UK---------1
7-----Canada----2
---------------------------
Now ,I fill combobox1 from with this Code :
string strQuery= @"SELECT myID,myItem FROM Table1 WHERE IdCountry=1";
SqlConnection cnnCbx = new SqlConnection(cnnClass.CnnString);
cnnCbx.Open();
SqlDataAdapter daCbx = new SqlDataAdapter(strCbxQueryItems, cnnCbx);
DataTable dtCbx = new DataTable();
daCbx.Fill(dtCbx);
cbxKindOfItems.ValueMember = "myID";
cbxKindOfItems.DisplayMember = "myItem";
cbxKindOfItems.DataSource = dtCbx.DefaultView;
Ho Can I get myID Value When I select an Item from Combobox ?
|
|
|
|
|
Try:
var myID = cbxKindOfItems.SelectedValue;
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
You can get the value of myID by calling the
SelectedValue property on the
ComboBox control.
e.g:
MessageBox.Show(cbxKindOfItems.SelectedValue.ToString());
To show the ValueMember of the SelectedItem.
Hope it helps..
|
|
|
|
|
Hello All , i'm stucked in C# , to get the percentile from array of column values .please check the below code and let me know how can i pass the arguments to the method .
public double Percentile(double[] sequence, double excelPercentile)
{
Array.Sort(sequence);
int N = sequence.Length;
double n = (N - 1) * excelPercentile + 1;
if (n == 1d) return sequence[0];
else if (n == N) return sequence[N - 1];
else
{
int k = (int)n;
double d = n - k;
return sequence[k - 1] + d * (sequence[k] - sequence[k - 1]);
}
}
and i have the array of data - and also k value as 0.95.
percentile(myarray , K);
the above method sending me error . please let me know , what is my mistake.
modified 8-Aug-16 10:57am.
|
|
|
|
|
Mallesh Shantagiri wrote: what is my mistake
For starters, you posted in wrong forum. Try using C# forum or Q & A section.
"You'd have to be a floating database guru clad in a white toga and ghandi level of sereneness to fix this goddamn clusterfuck.", BruceN[ ^]
|
|
|
|
|
You should head over to the Q&A[^] and ask the question there, as the Lounge is the wrong place for programming questions.
|
|
|
|
|
You're gonna get yelled at for not reading the red text at the top of this page!
Get me coffee and no one gets hurt!
|
|
|
|
|