|
I've not been able to trap this event in my WndProc override on my form. I did a search for this problem on this message board and saw two similar responses, anybody know anything about this ?
|
|
|
|
|
The WM_NCLBUTTONUP message is only generated on the extreme edge of a client window.
You could try using the WM_LBUTTONUP message instead and checking to see if the mouse position is outside the client area to get the same effect.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It appears that the WM_LBUTTONUP or WM_LBUTTONDOWN messages are not generated until you click in the client area of the form. In other words if I launch my Form and the first place I click is in the control bar (Nonclient Area) at the top of the Form no messages are raised. However, if I click in the Client area first, then the messages are raised no matter where the click event occurs....
Any other ideas ?
I tried this.Focus() in my Form_Load handle, just incase the Form needed to have focus first, but same results.
|
|
|
|
|
I don't have any other ideas...
This appears to be something that Microsoft screwed up the documentation on.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I have a ColumnChanging event attached to a dataset to perform validations. For some reason unknown to me, the event does not get fired when the user presses the 'tab' key with a null cell.
I am trying to make sure that no cell is null. When no value is entered in a cell, and the column is changed, I want the ColumnChanging event to capture it and throw a messagebox to the user. Please help.
Here is what I have -->
private void Division_ColumnChanging(object sender, System.Data.DataColumnChangeEventArgs e)
{
...
..
.
if ( (e.Column.ColumnName.Equals("Div_Code")) ||
(e.Column.ColumnName.Equals("Div_Name")) )
{
if(e.ProposedValue.ToString().Length == 0)
{
MessageBox.Show("Column " + cs.HeaderText + " cannot be null.", "SPIRIT2 - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
dataGrid1.CurrentCell = (DataGridCell) sender;
}
}
...
..
.
}
|
|
|
|
|
Hi,
Typically in the empty column of a table, the value "(null)" is entered by default(for a data grid atleast) and that is probably why the null case is not being detected. You will probably need to put in a break point to see if the value being returned is indeeed "NULL" instead of "" like you expect. I haven't tested this myslef so I could be way off.
Hope this helps.
|
|
|
|
|
i have a project all developed with technology smartclient(webservices).Need to know as I make to know in the machine customer the application he is being had access through a LAN(Intranet) for example or is being had access the application saw WAN(Internet) it are of the LAn?
|
|
|
|
|
I really couldn't make heads or tails of what you wrote. I'm guessing that you want to know if your WebService can determine if a call came from the local network or Intranet (inside a corporate network) or from out the corporate network?
The short answer is no. The only thing you could do is take the IP address of the request and mask it with the WebServer's subnet mask and compare it to the network address of the WebServer. This will only tell you in the request came from the EXACT SAME SUBNET as the WebServer, otherwise, it's a request that came from over a router and is considered over the WAN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Here is my question.
Not sure how to ask this really.
I have had very bad luck passing values between forms.
If I open a form and pass a value that works fine. But If I have to pass
some values back to a "Parent" form it does not work so well.
The only way that I have found to do this is using the registry.
Write values to the registry then from the parent window close the form
and read the values that were set.
Is there a better way to return a value from a form?
Thanks
Will
|
|
|
|
|
You can use public members as a starting point.
public class MyForm : Form
{
public int MyTestInt;
}
public int MyMethodInAnotherForm()
{
int returnValue = 0;
MyForm dlg = new MyForm();
dlg.MyTestInt = 0;
if (dlg.ShowDialog() == DialogResult.Ok)
{
returnValue = dlg.MyTestInt;
}
dlg.Dispose();
return returnValue;
}
|
|
|
|
|
Thank you for the reply.
I think I asked this wrong..
I have a Main Form lets call it FormMain.
On this form is a TextBox where a user will enter in a Part Number
Now I have to look for the Part Number. If I can not find an exact match I can
A) Display a list of Part Numbers that are close
B) Allow the user to enter a New Part Number
In order to do this I open another Form.. Lets call it FormPart
Now On FormPart lets say that the user decides to add this New Part, so they input
the Description.. and other information. Now the Stored Procedure that I use to enter the
New Part in the database returns the ID Number for that Part. I need to send this ID back to FormMain and continue processing. It is really easy to send a value to a form, It is also easy to return a value if there is no end user interaction. But because of the type of application, I have to allow the user to either Select an Existing part or enter a new Part.
Again thank you for the answer
Hopefuly I have described my problem better this time. If I can find a solution I will post it. But from where I am looking, the registry looks like the best place for temp storage of this ID
Will
|
|
|
|
|
Will,
You are thinking to hard and missing the simple solution. I have coded hundreds of dialogs that process similar logic.
Just because your second form processes data does not mean it can't store the result (PartID) in a public member variable for the other form to pick up. If you are using Modal dialogs (ShowDialog()) then the example template I gave you will work well.
If you are using Modeless dialogs, then the second dialog needs to call back to the first (simply pass a reference to the first form in the constructor).
Think of the question you are asking FormPart: "What is the PartId the user has chosen?"
It doesn't matter to the first form if the part was just created or has been in the database for a century. The first form just needs a valid PartId. Have FormPart do whatever processing it needs to do and store the resultant PartId in a public member variable.
If you are still having trouble, I would be happy to trade a few samples with you until you get the idea. Using the registry is a very sloppy way of handling data transfer within an single process. I would hate to see you continue on that path.
You can contact me directly at mdpotter55@yahoo.com
|
|
|
|
|
The simplest way is to pass a reference of the first form to the second form, either by passing it to the other form's constructor or assigning it to a property. Don't just use Form , though. Declare the type of the parameter or property the actual type of your form so that you can easily access public or internal members.
Typically, though, it's easy to "return" a value. For instance, you could declare a property that can get (or optionally set) the part name for which similar part names should be found. When that form returns, get the value (which the popup form sets):
private void someButton_Click(object sender, EventArgs e)
{
using (PopupForm form = new PopupForm())
{
form.PartName = "asdf";
form.ShowDialog(this);
someTextBox.Text = form.PartName;
}
} Using this approach allows you to reuse that popup form from other forms when you need it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is there an event that lets you know when a new row is being added to a datatable edited in datagrid? There is an event for RowDeleting. Any way to know when a row is being added?
|
|
|
|
|
It's actually on the DataTable class, along with several other events. The DataGrid is implemented abstractly, working with any data source that implements IList or IListSource . Anything specific to how that data is manipulated would be specific to the data source. In this case, all the events you'd need for knowing when a row was inserted, changed, or deleted are defined on the DataTable class. See the class member documentation in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
As far as I can see there is no event for when a row is inserted. If there is can you tell me what the event is called. anybody?
|
|
|
|
|
Handle DataTable.RowChanging or DataTable.RowChanged (whichever is appropriate). The DataRowChangeEventArgs.Action specifies whether a DataRow is being added, changed, committed, deleted, or rollbacked.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
It is possible to lock the Excel process my app creates at runtime so that if the PC user opens another Excel file it does not get opened into 'my' excel process?
Would this be an Excel thing that I can control?
|
|
|
|
|
There is no way to "lock" the Excel process.
You can't really handle the WorkbookLoad event either, because that event fires AFTER the new workbook is loaded...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I've had this crazy idea in one of my personal projects to have a go at skinning a bit like WindowBlinds (think just my app for now).
My question is how do you draw on the area outside of the ClipRectangle? I need to be able to draw where the current XP theme is usually drawn.
For example where the control box is on a form.
Anyone got any ideas on this?
Thanks
|
|
|
|
|
You need to override WndProc in your Form derivative and handle the WM_NCPAINT (0x0085) notification message. See the documentation for the WM_NCPAINT message in the Platform SDK in the MSDN Library Online[^] for more information about the WPARAM and LPARAM values. I will tell you the WPARAM is the HRGN (handle to a region) that you can wrap in a .NET Region class using the static Region.FromHrgn method. To get a Graphics object, P/Invoke GetDCEx to get the HDC (handle to a device context) for the HRGN . You can then use Graphics.FromHdc to get a Graphics object. Just be sure to call Graphics.ReleaseHdc then Graphics.Dispose when you're done drawing otherwise you'll have a memory leak.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks i'll give that a shot 
|
|
|
|
|
I am working on this same issue. I use a standard form with no title bar or controls. I then put placeholder images for the standard items like titlebar, control box, form control buttons. I then read in from a skin file what images to use for what items and where the position needs to be. This way I can even use a background image that is non-rectangular with regions to create a nicely skinned application.
Yes, I program in VB, but only to feed my addiction to a warm place to sleep and food to eat!
Visit my Code Project blog (Mobile Audio project)[^]
|
|
|
|
|
I would like to retrieve the IP address assigned to my machine from a VPN connection. Obviously I can go Dns.GetHostByName(Dns.GetHostName()).AddressList to get the list of addresses assigned to my local machine, and this does indeed return both my LAN address and my VPN address, however, is it possible to distiguish in code which address is my VPN address and which one is my LAN address?
#include "witty_sig.h"
|
|
|
|
|
You'll either have to use:
1) The Win32 API IPHelper functions to iterate through the network adapters and get the addresses for each of them
or
2) Use the System.Management classes (WMI) to iterate through the adapters, looking for the VPN adapter. The class to find in the WMI query will be Win32_NetworkAdapter .
There is no ".NET Way" to do this...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|