|
Vista is a nightmare. The main thing tho, is to make sure you don't try to write to any files in the application directory. Your config files need to be in the users folder, not the app folder.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
So if i had my form open, and i click, the click will fall to the desktop, or other forms...
any easy way to do this?
|
|
|
|
|
Not a trivial way, no.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hmm so does the hard way involve wndproc in some fashion, or are we talking harder :P
|
|
|
|
|
You can actually call an API called WindowFromPoint. So, hide your window, call that API on the screen point you clicked, convert to a point relative to the window and send it a WM_CLICK message. And a WM_LBUTTONDOWN and WM_LBUTTONUP. FIddly, more than anything.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Ya no luck with WindowFromPoint (in vista) so far... Also how do i "hide" a form from WindowFromPoint but keep it visible?, i tried making it not enabled, and some ShowWindowAsync(shades.Handle, SW_HIDE) which definatally hides it from view, but i want it visible still...
Also i tried with one of those lowlevel-ish hooks to watch the mouse when it's off my form, and so far WindowFromPoint returns 0 regardless...
something that caught my eye though was:
private const int WM_NCHITTEST = 0x0084;
private const int HTTRANSPARENT = (-1);
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCHITTEST)
{
m.Result = (IntPtr)HTTRANSPARENT;
}
else
{
base.WndProc(ref m);
}
}
but it doesn't work for other threads... else it'd be very good solution :P
|
|
|
|
|
Ok no idea why but now i'm seeing WindowFromPoint working now... i'll see now if i can get this to work.
|
|
|
|
|
Ok been through hell with this, and starting to show progress:
1. i made a new WindowFromPoint function that effectively finds the window underneath. to do this i had to use api:enumWindows... whichs gives a list of windows in the correct z-order, and just filter the results to visible windows that don't match my programs handle... then just check which rectangle the mouse is within and there you go... it works 100%
2. sendmessage to relay messages is no joke as it would appear... pain in the ass would best describe it... apparently something is blocking any messages from getting through! my guess = vista lol.
i tried using microsof spy to watch for any messages in a test program, and i placed my window above it... and spy showed no messages getting through...
that's not to say "some" messages don't get through... i did notice doubleclicking on the taskmanager through my form did infact do what double clicking would do to it... but nothing in way of rightclick, or highlights... and the code that sends these messages is same... basically catch alot of mouse messages in my wndproc, and send them to another window... so i'm not sure what to do next.
i need another way to send mouse messages :P
|
|
|
|
|
Did you use search? There are several articles at codeproject showing how to achieve it.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Try searching for "hooks"
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
I have 2 connections strings in the settings file that are used by various datasetgridviews and other functions. The problem comes in that the databases are in the \CurrentUser\My Document\MyProgramsDataFolder. Other data is also being stored here for processing.
I know this may not be considered a "Best programming practice", but it suits the nature of the program.
Is there anyway of setting the connection sting in the settings file so that instead of
Data Source=.\SQLEXPRESS;AttachDbFilename="|DataDirectory|Database1.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True
it looks something like
Data Source=.\SQLEXPRESS;AttachDbFilename="|MyDocuments|Database1.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True
|
|
|
|
|
The |DataDirectory| value is a substitution string that indicates the path to the database so you don't have to hard-code the full path. There is no corresponding |MyDocuments| substition string.
What you should do is call the AppDomain.SetData[^] method. If you don't, the following rules are applied:- For applications that are put in a folder on the user's computer, the database folder uses the application folder.
- For applications that are running under ClickOnce, the database folder uses the specific data folder that is created.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines][ Articles][ Blog]
|
|
|
|
|
I have a file that opens automatically with an excelApp.Workbooks.Open statement, i.e., I'm not using MessageBox.Show. If the file is in use, I get the message, "'filename' is being modified. Open as read-only", with OK and Cancel as options. I need to trap the "Cancel" option so I can take various actions if the user chooses this. But since I didn't use the MessageBox, class, how do I do this?
|
|
|
|
|
I guess the obvious thing is, can you check afterwards if it opened or not ? If it didn't open, you can assume they pressed cancel ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian: Sorry, I guess I didn't explain it very well. The Excel file being opened is in background and isn't launched by the user. However, if there's an Excel object left open from an exception being thrown during testing, then during the next program launch, I get prompted by Excel that the file is open and do I want to open a Read Only version. I'd like to be able to Cancel at that point but, if I do, I get a COM exception. So I'd like to trap the Cancel and redirect the code so I don't get an exception. But I don't know how to do that without using the DialogResult class.
|
|
|
|
|
I am working on a community site i want to store the array of frinds in the profile of the user. I have looked for it on google but could'nt find. Is it possible or not. Thks
(or can an object be stored in profile? )
|
|
|
|
|
Sounds like an ASp.NET question ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have come to CP after searching Google so ur answer is not helpful in any way .......
|
|
|
|
|
Muhammad Zeeshan wrote: I have come to CP after searching Google
That's great, that you looked somewhere first.
Muhammad Zeeshan wrote: ur answer is not helpful in any way
Actually, it's very helpful. Pointing out to you that we have an ASP.NET forum ( which you still haven't found, I just answered this in the web dev forum ), means that
a - you don't clutter our forums with off topic questions, and
b - you ask in a place where people who can help you, will look.
Which just means you get an answer faster. Sorry if you don't think that will help you at all.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
oh yes thks sorry for being rude. new to CP now definitly will find right forums to put questions thanks for ur kind help.
|
|
|
|
|
Glad to help
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi
I recieve this exception:
"Only one usage of each socket address (protocol/network address/port) is normally permitted"
I should get several files from an ftp server. I implemented it by sockets so: create the datasocket, recieve the file and then close data socket. But the next time I do this for another file(create data socket with Endpoint (the same local address/another port)), i recieve this exception message when Binding the socket. Can anyone tell me why? And the way to solve that?
(the code, if necessary)
public void download(string remFileName, string locFileName)
{
if (!logined)
{
login();
}
setBinaryMode(true);
Console.WriteLine("Downloading file " + remFileName + " from " + remoteHost + "/" + remotePath);
if (locFileName.Equals(""))
{
locFileName = remFileName;
}
if (!File.Exists(locFileName))
{
Stream st = File.Create(locFileName);
st.Close();
}
FileStream output = new FileStream(locFileName, FileMode.Open);
createDataSocket(true);
if (dataSocket != null)
{
throw new SocketException();
}
sendCommand("RETR " + remFileName);
if (!(retValue == 150 || retValue == 125))
{
throw new IOException(reply.Substring(4));
}
dataSocket = listeningSocket.Accept();
listeningSocket.Close();
listeningSocket = null;
if (dataSocket == null)
{
throw new Exception("Winsock error: " +
Convert.ToString(System.Runtime.InteropServices.Marshal.GetLastWin32Error()));
}
while (true)
{
bytes = dataSocket.Receive(buffer, buffer.Length, 0);
output.Write(buffer, 0, bytes);
if (bytes <= 0)
{
break;
}
}
output.Close();
if (dataSocket.Connected)
{
dataSocket.Close();
dataSocket = null;
}
Console.WriteLine("");
readReply();
if (!(retValue == 226 || retValue == 250))
{
throw new IOException(reply.Substring(4));
}
}
public void createDataSocket(bool flag)
{
try
{
listeningSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
}
catch (Exception e)
{
ftpLog(e.Message);
throw new IOException(e.Message);
}
string localAddress = clientSocket.LocalEndPoint.ToString();
int ix = localAddress.IndexOf(':');
if (ix < 0)
throw new Exception("local IP ERROR");
string localIP = localAddress.Substring(0, ix);
IPEndPoint localEP = new IPEndPoint(IPAddress.Parse(localIP), localDataPort);
try
{
<big>listeningSocket.Bind(localEP);</big>
listeningSocket.Listen(1);
}
catch (SocketException se)
{
ftpLog(se.Message);
throw new IOException(se.Message);
}
localIP = localIP.Replace('.', ',');
string portCMD = string.Format("PORT {0},{1},{2}", localIP, localDataPort / 256, localDataPort % 256);
localDataPort++;
sendCommand(portCMD);
if(retValue!=200)
throw new IOException(reply.Substring(4));
}
|
|
|
|
|
Hi Guys. I have been busy with an Application that writes data to Excel. Now, I have successfully written the application and now I need to make some changes/enhancements. Problem is that I am unsure on how to do the following: Below a snippet of the data in Excel.
Discl Level Level 1 Level 2
1 378600
2 350000
2 28600
1 50000
2 50000
I have a disclosure Level which is the 1's and 2's on the left.
I have to somehow calculate all the Level2 totals and ensure that they balance to the Level1 balance. If there is an imblance then I need to write this into an adjacent cell to level2 on the same line as the level1. I'm not sure how to do that. I have now been searching a number of websites for a few days now and can't find anything that explains how to do this.
The other problem is that I don't know where the level 1 and level2 starts so I need to somehow be able to determine this as well.
If anybody can help with this I would greatly appreciate this or if you have a website that explains this please please let me know.
Cheers
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Since you've posted so many problems regarding excel I guess you should read this article
http://support.microsoft.com/kb/302084[^]
It has everything you need to know!!
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Hello,
I'm trying to navigate from the middle of the xml page back to the top(to the parent node).
So I can perform another search looking for matches to my random number,
while (xmlReader.Read())
{
xmlReader.MoveToElement();
TempNo = xmlReader.Value;
if (tempNo == Convert.ToString(userID))
{
UserID = RadNo.Next(10, 99);
}
}
The above is my code, hope this help.
Sorry if this is a simple question, I'm totally new to xml and c#
just learning it really...
-JC
|
|
|
|