|
|
I need my application to respond when a certain other application window is resized. The other app is completely external (I did not write it, I don't have the source, etc).
Is there a way to do this via .NET structures, or do I have to use Windows Messages? Either way, I'm not sure how this is to be done. If it's the latter case, how do I get the resize message that (I presume) is generated when a user resizes the external application, assuming I already have the windows-handle to the app?
|
|
|
|
|
I guess you have two options here:
a) intercept the window messages (WM_SIZE/WM_RESIZE) of the other window using a hook
b) periodically get the size of the other window in a timer and compare it with the size of the last timer tick (seems like a bad solution, but easier than using a hook)
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I suspect you will need global hooks which according to ms cannot be implemented in .NET but there is an article on codeproject explaining how to do it.
|
|
|
|
|
Hi All;
I'm working in VS2005, and have a DataGridView that draws from a datasource. Is there a way to change a column to be a link style column after the DataGridView populates? Here's how I populate it:
<br />
DataSet ds = new DataSet();<br />
dgvShipmentHistory.DataSource = null;<br />
SqlDataAdapter da = new SqlDataAdapter(mySQLClass.Query, mySQLClass.SqlCon);<br />
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;<br />
da.Fill(ds, "ShipmentHistory");<br />
dgvShipmentHistory.DataSource = ds.Tables[0];<br />
dgvShipmentHistory.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);<br />
I want to be able to change one of the columns to be a link type column so that users can click the hyperlink and I can throw up a page.
Thanks
|
|
|
|
|
|
|
Did u try using DataGridViewLinkColumn?
If ur grid id bound to datasource, goto properties -> Columns -> select the appropriate column from ur columns list -> and change ColumnType property
Let me know if that works or am i thinking too simple.
Ketty
|
|
|
|
|
The only property I can see is the CellStyle property, I dont see a ColumnType property on the datagridview column.
|
|
|
|
|
There is a DataGridViewLinkColumn class, but dont know if that will help me once the grid has been populated already, as I'm unsure how to change the type of column.
|
|
|
|
|
This is simple Designer generated code.
How to reach that property.
1. Select ur DataGridView control on designer.
2. F4
3. Columns (collection)
4. Select <column1>
5 On right side u see all column properties.
6. Change ColumnType to DataGridViewLinkColumn
<br />
namespace WindowsApplication1<br />
{<br />
partial class Form1<br />
{<br />
private System.ComponentModel.IContainer components = null;<br />
<br />
protected override void Dispose(bool disposing)<br />
{<br />
if (disposing && (components != null))<br />
{<br />
components.Dispose();<br />
}<br />
base.Dispose(disposing);<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
<br />
private void InitializeComponent()<br />
{<br />
this.components = new System.ComponentModel.Container();<br />
this.dataGridView1 = new System.Windows.Forms.DataGridView();<br />
this.actionTypesBindingSource = new System.Windows.Forms.BindingSource(this.components);<br />
this.fISM0702DataSet = new WindowsApplication1.FISM0702DataSet();<br />
this.actionTypesTableAdapter = new WindowsApplication1.FISM0702DataSetTableAdapters.ActionTypesTableAdapter();<br />
this.actionTypeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewLinkColumn(); this.descriptionDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();<br />
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();<br />
((System.ComponentModel.ISupportInitialize)(this.actionTypesBindingSource)).BeginInit();<br />
((System.ComponentModel.ISupportInitialize)(this.fISM0702DataSet)).BeginInit();<br />
this.SuspendLayout();<br />
this.dataGridView1.AutoGenerateColumns = false;<br />
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;<br />
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {<br />
this.actionTypeDataGridViewTextBoxColumn,<br />
this.descriptionDataGridViewTextBoxColumn});<br />
this.dataGridView1.DataSource = this.actionTypesBindingSource;<br />
this.dataGridView1.Location = new System.Drawing.Point(213, 281);<br />
this.dataGridView1.Name = "dataGridView1";<br />
this.dataGridView1.Size = new System.Drawing.Size(240, 150);<br />
this.dataGridView1.TabIndex = 3;<br />
this.actionTypesBindingSource.DataMember = "ActionTypes";<br />
this.actionTypesBindingSource.DataSource = this.fISM0702DataSet;<br />
this.fISM0702DataSet.DataSetName = "FISM0702DataSet";<br />
this.fISM0702DataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;<br />
this.actionTypesTableAdapter.ClearBeforeFill = true;<br />
this.actionTypeDataGridViewTextBoxColumn.DataPropertyName = "ActionType";<br />
this.actionTypeDataGridViewTextBoxColumn.HeaderText = "ActionType";<br />
this.actionTypeDataGridViewTextBoxColumn.Name = "actionTypeDataGridViewTextBoxColumn";<br />
this.actionTypeDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;<br />
this.actionTypeDataGridViewTextBoxColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;<br />
this.descriptionDataGridViewTextBoxColumn.DataPropertyName = "Description";<br />
this.descriptionDataGridViewTextBoxColumn.HeaderText = "Description";<br />
this.descriptionDataGridViewTextBoxColumn.Name = "descriptionDataGridViewTextBoxColumn";<br />
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);<br />
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;<br />
this.ClientSize = new System.Drawing.Size(636, 562);<br />
this.Controls.Add(this.dataGridView1);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
this.Load += new System.EventHandler(this.Form1_Load);<br />
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();<br />
((System.ComponentModel.ISupportInitialize)(this.actionTypesBindingSource)).EndInit();<br />
((System.ComponentModel.ISupportInitialize)(this.fISM0702DataSet)).EndInit();<br />
this.ResumeLayout(false);<br />
<br />
}<br />
<br />
#endregion<br />
<br />
private System.Windows.Forms.DataGridView dataGridView1;<br />
private FISM0702DataSet fISM0702DataSet;<br />
private System.Windows.Forms.BindingSource actionTypesBindingSource;<br />
private WindowsApplication1.FISM0702DataSetTableAdapters.ActionTypesTableAdapter actionTypesTableAdapter;<br />
private System.Windows.Forms.DataGridViewLinkColumn actionTypeDataGridViewTextBoxColumn;<br />
private System.Windows.Forms.DataGridViewTextBoxColumn descriptionDataGridViewTextBoxColumn;<br />
}<br />
}<br />
Are you binding ur grid on runtime????
Ketty
|
|
|
|
|
Yes, the grid is bound at runtime, so although I know what the columns will be for the most part, they could change.
|
|
|
|
|
I need to write a performance driven utility that allows user to write C# code in a text area. When they click on execute to see what is the final out, utility should complie and run the code written by user as if it is a function body.
e.g. I am trying to achieve:
<br />
private void ExecuteUser()
{<br />
<br />
<br />
<br />
}<br />
I am not a C# coder for past few years , so any code snippet would be awesome. We are using .Net 2.0. VS 2005.
Ketty
|
|
|
|
|
You can't put code into an existing method. You have to compile the code into a new assembly.
Take a look at the Microsoft.CSharp.CSharpCodeProvider class.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks, I did see an example of "Microsoft.CSharp.CSharpCodeProvider class" on CodeProject, if you or any body has used it. Is it performance promising?
Ketty
|
|
|
|
|
private void ExecuteUser()
{
if(txtUserCode.Text != "while(true){}"){
}
}
Feel free to use this as a safeguard after you get the rest of it figured out
|
|
|
|
|
I am not quite sure if I understand the idea completely.
Please advice.
Ketty
|
|
|
|
|
Just a joke about the dangers of letting users execute their own code -- the code I wrote "checks" for an infinite loop.
|
|
|
|
|
:-DJokes are fine but I am looking for serious comments on this issue
Ketty
|
|
|
|
|
If you just want to compile code and execute it, you can always invoke the compiler with the correct command line options when the user would like to execute the code, and then start / wait on the process that you just compiled. That's probably the most general way to do things. I wouldn't advise it though, as I don't see any practical application. If, on the other hand, you want to do some kind of scripting, you could always encapsulate existing functions and dynamically call them by parsing a script, using a virtual address space within your actual program for the storage of stack variables and dynamically allocated memory.
|
|
|
|
|
you said goole maps will work if the pc is online.what should I do if I want to work offline?
then you said somthing about Dundas and you assume it sells maps offline.would you please explain about it?How can I reach to these maps?
|
|
|
|
|
First of all, you got lucky, if I wasn't online, no-one would know what you were talking about.
second, if you're offline, google maps can't work, I said that.
third, the ads for Dundas are on this site all the time, and google is all you need, if you can't work out to try www.dundas.com.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Well, it's an updated version that was done and can be found at http://wyday.com/blog/2007/csharp-splitbutton/
anyways, I have it implemented just fine, but I am having difficulty constructing an event handler to deal with the selection that the user makes.
The code works by constructing a a contextMenuStrip, then adds Items to it. I am wondering how do I set up an event handler that takes the chosen item and when the button is clicked, does a particular action. If I can at least get a hint to what I need to implement to set it up, that would be great.
If you need more code, just ask.
Thank you,
Fare
|
|
|
|
|
Ok let's try this again...
(sorry if this violates some sort of double post law)
<<designer class="">>
<br />
this.splitButton.ContextMenuStrip = new<br />
System.Windows.Forms.ContextMenuStrip();<br />
this.splitButton.ContextMenuStrip.Items.Add("Item1");<br />
this.splitButton.ContextMenuStrip.Items.Add("Item2");<br />
this.splitButton.ContextMenuStrip.Items.Add("Item3");<br />
<br />
<br />
this.splitButton.Click += new System.EventHandler(this.cmdSplitButton_Click);<br />
<>
<<splitbutton class="">>
<br />
protected override void OnMouseUp(MouseEventArgs mevent)<br />
{<br />
if (!showSplit)<br />
{<br />
base.OnMouseUp(mevent);<br />
return;<br />
}<br />
<br />
if (mevent.Button == MouseButtons.Right)<br />
{<br />
ShowContextMenuStrip();<br />
}<br />
else if (m_SplitMenu == null || !m_SplitMenu.Visible)<br />
{<br />
SetButtonDrawState();<br />
<br />
if (Bounds.Contains(Parent.PointToClient(Cursor.Position)) && !dropDownRectangle.Contains(mevent.Location))<br />
{<br />
OnClick(new EventArgs());<br />
}<br />
}<br />
}<br />
<>
<>
<br />
private void cmdSvAllImg_Click(object sender, EventArgs e)<br />
{<br />
}<br />
<>
My question is what do I need to do so that when the button is clicked, it does an action that corresponds with the selection of the splitbutton (e.g if the user selected Item1, it would do an Item1 specific job, and Item2 selection would do an Item2 job)
If any other info is needed, just let me know. The splitButton class can be downloaded at http://wyday.com/files/SplitButton.zip
Thank you again,
Anthony Novak
|
|
|
|
|
I've looked at all the properties and tried anchoring it to all the sides. Looked up auto-sizing and found out how to do it for the label but not to make the text in the label enlarge or shrink when I re-size the box. Any ideas?
|
|
|
|