|
Asalam o Alaikum:
I am getting problem while finding the ListView Header text through SendMessage()
Does any body Knows
Thanx
|
|
|
|
|
Is there any particular reason you are using SendMessage() instead of
<br />
myListView.Columns[columnIndex].Text<br />
|
|
|
|
|
Actually i am trying to get ListView Header text from other application.
So i have to use SendMessage();
there are other functions like LVM_GETITEM ,i am in a search of this kind of function.
Thanx
|
|
|
|
|
Here's a sample on how to do it (just copy / paste the code and build it)
<br />
public const UInt32 LVM_FIRST = 0x1000;<br />
public const UInt32 LVM_GETCOLUMN = LVM_FIRST + 95;<br />
public const UInt32 LVCF_TEXT = 0x0004;<br />
<br />
[StructLayout(LayoutKind.Sequential, Pack=8, CharSet=CharSet.Auto)]<br />
public struct LVCOLUMN <br />
{<br />
public uint mask;<br />
public int fmt;<br />
public int cx;<br />
public IntPtr pszText;<br />
public int cchTextMax;<br />
public int iSubItem;<br />
public int iImage;<br />
public int iOrder;<br />
}<br />
<br />
[DllImport("User32", CharSet=CharSet.Auto)]<br />
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, UInt32 wParam, ref LVCOLUMN lParam); <br />
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
int iTextSize = 255;<br />
IntPtr pText = Marshal.AllocHGlobal(iTextSize);<br />
LVCOLUMN lCol = new LVCOLUMN();<br />
lCol.mask = LVCF_TEXT;<br />
lCol.cchTextMax = iTextSize - 1;<br />
lCol.pszText = pText;<br />
uint nIndex = 0;<br />
SendMessage(listView1.Handle, LVM_GETCOLUMN, nIndex, ref lCol);<br />
System.Diagnostics.Trace.WriteLine(Marshal.PtrToStringAuto(pText));<br />
Marshal.FreeHGlobal(pText);<br />
}<br />
}<br />
}<br />
I hope that not naming my controls properly will not bother you The demo uses list view on the same form, but I assume you already know how to get the handle of the listview, and replace it in the code above.
Cheers,
Svetlin
|
|
|
|
|
Thank you for ur reply .this code is working fine but when i pass the handle of the listview from some other application it does not return anything
can you have any idea please
Thanx
|
|
|
|
|
ya. i got that
i tried to p[ass the exceptio than ther dataset.
that was some connection problem now its working properly
thanks
My small attempt...
|
|
|
|
|
I am about to write an application in which is is needed to which language online.
The article : http://www.codeproject.com/csharp/formlanguageswitch.asp
tells how to do that, and it works.
My problem is then to get the resource translated. The translator do not have Visual
Studio installed. Therefore I would preper to export the resource from Visual Studio
to e.g. Excel, let the translator do the job in a seperat column, and the import the
resource to Visual Studio again.
But I have not found any tool which can do that. Do anyone know if this is possible
and then how it is done?
or is there another way to solve my problem?
|
|
|
|
|
Hi am new bee 2 this forum I want to know what is the exact difference between Application Server and Web Server that we will use in Web Applications
Think Globally And Work Locally In A Creative Way...
|
|
|
|
|
A web server answers HTTP requests from browsers (for example, IIS or Apache); an application server is an environment which hosts server-side applications, which can be used to process data to and from a web server (eg IBM WebSphere).
|
|
|
|
|
Hi,
I've got a datatable with an integer column named "ID", which is loaded at runtime from a database. I know the table loading is working correctly and the ID values range from zero to 10.
DataRow[] r = dataTableObject.Select("ID = " + indexValue.ToString());
This line of code works fine in some cases, though for some values of indexValue (an int) no rows are returned, although I know for a fact that matching rows exist within dataTableObject.
Anyone got any ideas why this might be?
Thanks
|
|
|
|
|
Hi,
How do I get the System idle time in C# (.Net FW 2.0)?
Thanks in advance.
Subrahmanyam K
|
|
|
|
|
http://www.codeproject.com/csharp/GetIdleTimeWithCS.asp
|
|
|
|
|
I am wondering if it is possible to localize a WinForms application at run-time.
I would like to create an application where the culture is changed according to what the user selects in a ComboBox. If "sv-SE" is selected the application should behave as a Swedish application, and if "en-US" is selected it should behave as a US English application.
The application will also contain a NumericUpDown Control that is showing a number containing 2 decimals. In Swedish this could be rendered as '0,00' and in English as '0.00' (notice the difference of the decimal separator).
If I write either of the following two lines of code in the constructor of the WinForm - before the InitializeComponent call it all works:
Thread.CurrentThread.CurrentCulture = new CultureInfo("sv-SE");<br />
Application.CurrentCulture = new CultureInfo("sv-SE");
This means however that the user cannot make this change at run-time (constructor and before InitializeComponent).
If I put the following code in a SelectedIndexChanged event-handler of the ComboBox where the culture is selected it has no impact on how the NumericUpDown is rendered:
if(myComboBox.SelectedIndex == 0)<br />
{<br />
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");<br />
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("en-US");<br />
Application.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");<br />
}<br />
else<br />
{<br />
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("sv-SE");<br />
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("sv-SE");<br />
Application.CurrentCulture = CultureInfo.CreateSpecificCulture("sv-SE");<br />
}
Now my question is: is it possible to change this during run-time, and if so, how?
|
|
|
|
|
Yes... after set the currentCulture, you must reinitialize all your text in your form to see the changes.
|
|
|
|
|
How do I do that?
I have tried Refresh etc on the NumericUpDown, but no change.
|
|
|
|
|
Sample:
ResourceManager resMan = new ResourceManager(typeof(MyForm));
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
this.label1.Text = resMan.GetString("MyLabel1");
this.label2.Text = resMan.GetString("MyLabel2");
this.label3.Text = resMan.GetString("MyLabel3");
...
|
|
|
|
|
|
Yep, the change is pretty much valid. There are just 2 things you should do:
1) Set the Localizable property on your form to true.
2) The decimal separator change will occur after the value in your NumericUpDown has changed. So you might add something like :
<br />
else<br />
{<br />
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("sv-SE");<br />
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("sv-SE");<br />
Application.CurrentCulture = CultureInfo.CreateSpecificCulture("sv-SE");<br />
numericUpDown1.Value++;<br />
numericUpDown1.Value--;<br />
}<br />
I wouldn't advise using these two lines in production code though (e.g. numericUpDown1's current value might be at maximum).
I hope it will work for you.
Cheers,
Svetlin
|
|
|
|
|
Thanks.
Localizable is set. It was changing the value that got me. That is a real pain to have to do. It also cannot be set to the same value, this doesn't trigger the change.
Wonder if there is any Win32 call or something that could be sent to all the Controls so that they do this 're-rendering' or whatever.
|
|
|
|
|
Sure, you can try
<br />
numericUpDown1.ResetText();<br />
|
|
|
|
|
Check out the following article http://www.codeproject.com/csharp/formlanguageswitch.asp
This right away
|
|
|
|
|
Thanks, I will read that one.
Wonder why I didn't find that article straight away...
|
|
|
|
|
Hi
I want to draw an image on the screen and because I want to do it as fast as possible I decide to use BitBlt instead of DrawImage method.
When I use BitBlt to draw the content of the screen on itself everything works fine but when I try to draw an image that is loaded into memory nothing happens.
here's what I do:
<br />
Image image=Image.FromFile(myfilepath);<br />
Graphics imageGraphics=Graphics.FromImage(image);<br />
IntPtr imageHdc=imageGraphics.GetHdc();<br />
BitBlt(screenHdc,screen.Left,screen.Top,screen.Width,screen.Height,imageHdc,0,0,SRCCOPY);<br />
imageGraphics.ReleaseHdc(imageHdc);<br />
Please tell me what should I do?
Thanks a lot
|
|
|
|
|
|
What do you think calling DrawImageUnscaled is going to do, under the hood ? I suspect it does nothing more than this.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|