|
IMO a forum is the wrong, erm, forum, as what you probably want is a more of a discussion of the pros and cons to different approaches, often including not just the technical discussion but help with evaluating third party solutions vs. roll your own.
As I've mentioned to others, I enjoy mentoring and would be happy to help. If this whole mentoring thing takes off with more than a few people, I might set up a Slack (or similar) site!
Latest Article - Code Review - What You Can Learn From a Single Line of Code
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
Yeah, something like that! If I worked with developers, I could just hit one of them up on Skype, but I'm a firefighter and don't have access to that now. It will be less important to me when I get a job in the tech industry again, but until then, I'm pretty isolated.
The lack of surety in programming is part of the reason software is fragile.
|
|
|
|
|
@RickBishop It seems to me that you have been getting good responses on the QA forums here. Have you accepted any of the solutions ? Do you respond promptly to queries that ask you to clarify your posts ?
Compared to StackOverFlow, CP is 1000% gentler, kinder
cheers, Bill
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)
|
|
|
|
|
@BillWoodruff I'm very pleased with Code Project and I agree with you completely. I wasn't wanting to replace it. I was hoping for a resource to ask quick questions, nothing that requires digging through code and whatnot. Just ask for some quick advice, like "do you see this in the real world?" and "Is there an easier way to handle NULL values than == null?" stuff like that.
The lack of surety in programming is part of the reason software is fragile.
|
|
|
|
|
Hi Rick,
I think the kind of questions you mention are fair game for QA.
I hypothesize that some questions that appear simple are hard to distinguish from questions dashed off by folks who are looking for a quick fix for homework ... so many of those on QA.
Other questions that QA responders may see as being an indication that the OP is not engaging in basic research, is not taking the time to read the docs ... those questions, imho, may also get ignored, or dismissed with a quick reply.
For me, I know that anyone who shows responsiveness to my attempts to clarify questions in comments, or responds quickly, and in depth, if I respond with code or links to resources ... well, I am motivated to engage further.
cheers, Bill
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)
|
|
|
|
|
I'm uploading files to a server. The FTP class reports progress:
foreach (var file in publishInfo.Files)
{
Progress<double> progress = new Progress<double>(x =>
{
ShowProgress("", x);
});
client.UploadFile(file.FileName, targetFile, FtpExists.Overwrite, true, FtpVerify.Throw, progress);
}
then...
private void ShowProgress(FileEntity file, double progress)
{
}
I need to pass the loop object 'file' to the ShowProgress method. How do I get access it inside the progress callback?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
I have a stored procedure like this
PROCEDURE PRC_ABCD_GETALL (resultset_out OUT TYPES.cursorType)
AS
BEGIN
OPEN
resultset_out FOR SELECT * FROM ABCD;
END PRC_ABCD_GETALL;
using (OracleConnection conn = new OracleConnection(cnn))
{
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "PRC_ABCD_GETALL";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("resultset_out", OracleType.Cursor, ParameterDirection.Output);
OracleDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
result.Add(Construct(rdr));
}
}
but I'm getting error 'OracleDbType' does not contain a definition for 'Cursor' in
OracleType.Cursor. Any solution for this??
|
|
|
|
|
Hi,
I'm not familiar with OracleDB, however reading one page of documentation[^] suggests you might want RefCursor .
|
|
|
|
|
hi luc,thanks for reply . let me try it using refCursor
|
|
|
|
|
I'm using the code below to temporarily set a window to top most foreground. How can I return it to the standard function of being in the foreground depending on the last time it was touched by the mouse? I can't seem to figure out which uint32 to use to achieve what I'd like?
private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
private static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
private const UInt32 SWP_NOSIZE = 0x0001;
private const UInt32 SWP_NOMOVE = 0x0002;
private const UInt32 SWP_NOZORDER = 0x0004;
private const UInt32 SWP_NOREDRAW = 0x0008;
private const UInt32 SWP_NOACTIVATE = 0x0010;
private const UInt32 SWP_DRAWFRAME = 0x0020;
private const UInt32 SWP_FRAMECHANGED = 0x0020;
private const UInt32 SWP_SHOWWINDOW = 0x0040;
private const UInt32 SWP_HIDEWINDOW = 0x0080;
private const UInt32 SWP_NOCOPYBITS = 0x0100;
private const UInt32 SWP_NOOWNERZORDER = 0x0200;
private const UInt32 SWP_NOREPOSITION = 0x0200;
private const UInt32 SWP_NOSENDCHANGING = 0x0400;
private const UInt32 SWP_DEFERERASE = 0x2000;
private const UInt32 SWP_ASYNCWINDOWPOS = 0x4000;
private const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
private const UInt32 NOTOPMOST_FLAGS = SWP_SHOWWINDOW;
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
SetWindowPos(this.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
Thanks!
|
|
|
|
|
|
Hi,
I've tried multiple variations of what I think is correct and it is not working. Here is an example of what I thought was correct
SetWindowPos(this.Handle, HWND_TOP, 120, 240, 200, 400, 0);
Can you tell me what I'm doing wrong? When using the above code, the window is still at the top most, even when I click on another window to bring it to the foreground.
|
|
|
|
|
It all seems to work for me. Can you provide some more details of exactly what you are doing, and exactly what results you get?
|
|
|
|
|
Sure, I am having the program go to top most after a button click and then selecting coordinates on the screen with the mouse and clicking another button to send keys to those coordinates and then after it is done I'd like for it to go back to standard Z order, but it is staying at top most.
|
|
|
|
|
Fine, but we cannot guess what your code is actually doing.
|
|
|
|
|
Here is the button click function, would you like me to copy/paste the entire code?
private void btnSelectTypingBox_Click(object sender, EventArgs e)
{
try
{
if (tempBlocker == false)
{
if (btnSelectTypingBox.Text == "Select Box")
{
btnSelectTypingBox.Text = "Waiting";
tempBlocker = false;
SetWindowPos(this.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
}
else if (btnSelectTypingBox.Text == "Waiting")
{
btnSelectTypingBox.Text = "Select Box";
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " | " + ex.Source + " | " + ex.InnerException + " | " + ex.StackTrace);
}
}
|
|
|
|
|
How about
SetWindowPos(this.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE| SWP_NOZORDER); ?
some extra SWP values might be required...
|
|
|
|
|
Hi Luc,
Here is what I tried, but it did not work for me
private void btnTest_Click(object sender, EventArgs e)
{
SetWindowPos(this.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
}
And here is my pininvoke code
private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
private static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
private static readonly IntPtr HWND_TOP = new IntPtr(0);
private const UInt32 SWP_NOSIZE = 0x0001;
private const UInt32 SWP_NOMOVE = 0x0002;
private const UInt32 SWP_NOZORDER = 0x0004;
private const UInt32 SWP_NOREDRAW = 0x0008;
private const UInt32 SWP_NOACTIVATE = 0x0010;
private const UInt32 SWP_DRAWFRAME = 0x0020;
private const UInt32 SWP_FRAMECHANGED = 0x0020;
private const UInt32 SWP_SHOWWINDOW = 0x0040;
private const UInt32 SWP_HIDEWINDOW = 0x0080;
private const UInt32 SWP_NOCOPYBITS = 0x0100;
private const UInt32 SWP_NOOWNERZORDER = 0x0200;
private const UInt32 SWP_NOREPOSITION = 0x0200;
private const UInt32 SWP_NOSENDCHANGING = 0x0400;
private const UInt32 SWP_DEFERERASE = 0x2000;
private const UInt32 SWP_ASYNCWINDOWPOS = 0x4000;
private const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
private const UInt32 NOTOPMOST_FLAGS = SWP_SHOWWINDOW;
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
|
|
|
|
|
Hi,
two things:
1. "did not work for me" isn't helpful; what did it do? and what did it not do that you were hoping to get? please be precise.
2. why is this in a new Click handler, I was expecting this to go in the else block, as counterpart to your SetWindowPos(this.Handle, HWND_TOPMOST...) .
|
|
|
|
|
It did not remove the topmost flag as the application is still set to topmost. I would like it to go from a topmost application back to a standard z ordered application as it is before the topmost flag is set.
I was testing it with a test button for simplification is all, as soon as I get a working example I will then incorporate it into an else block
|
|
|
|
|
The problem is that your X, Y, cx and cy values are all zero, and when you switch to NoTopMost, you have omitted the flags to keep the size and position. Edit your code and replace the definition of NOTOPMOST_FLAGS with the following.
private const UInt32 NOTOPMOST_FLAGS = TOPMOST_FLAGS | SWP_SHOWWINDOW;
Had you explained exactly what happened when you ran your code we could have helped earlier.
|
|
|
|
|
Thank you.
Strangely enough when I have the above code in a separate button it removes the topmost flag correctly, but when I have it at the end of the send.keys function it does not remove the topmost flag? Any ideas on what could be causing that?
modified 5-Jan-18 22:58pm.
|
|
|
|
|
turbosupramk3 wrote: what could be causing that? Not without seeing the actual code.
|
|
|
|
|
Sure thing, the first block is my Pininvoke code, then the standard function and then the test button.
The standard function code will put the form to topmost, but will not remove the topmost flag. The test button will remove the topmost flag after the standard function places the topmost flag.
private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
private static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
private static readonly IntPtr HWND_TOP = new IntPtr(0);
private const UInt32 SWP_NOSIZE = 0x0001;
private const UInt32 SWP_NOMOVE = 0x0002;
private const UInt32 SWP_NOZORDER = 0x0004;
private const UInt32 SWP_NOREDRAW = 0x0008;
private const UInt32 SWP_NOACTIVATE = 0x0010;
private const UInt32 SWP_DRAWFRAME = 0x0020;
private const UInt32 SWP_FRAMECHANGED = 0x0020;
private const UInt32 SWP_SHOWWINDOW = 0x0040;
private const UInt32 SWP_HIDEWINDOW = 0x0080;
private const UInt32 SWP_NOCOPYBITS = 0x0100;
private const UInt32 SWP_NOOWNERZORDER = 0x0200;
private const UInt32 SWP_NOREPOSITION = 0x0200;
private const UInt32 SWP_NOSENDCHANGING = 0x0400;
private const UInt32 SWP_DEFERERASE = 0x2000;
private const UInt32 SWP_ASYNCWINDOWPOS = 0x4000;
private const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
private const UInt32 NOTOPMOST_FLAGS = TOPMOST_FLAGS | SWP_SHOWWINDOW;
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
private void btnType_Click(object sender, EventArgs e)
{
try
{
if (tbxTagList.Text == "")
{
MessageBox.Show("Please enter in at least 1 tag");
return;
}
int x = Convert.ToInt32(tbxXCoordinates.Text);
int y = Convert.ToInt32(tbxYCoordinates.Text);
SimulateMouseClick(x, y);
foreach (char character in tbxTagList.Text)
{
if ((character != '\n') && (character != '\r'))
{
SendKeys.Send(character.ToString());
}
if (character == '\n')
{
SendKeys.Send("{Enter}");
Thread.Sleep(3);
}
Thread.Sleep(3);
}
tbxXCoordinates.Text = "";
tbxYCoordinates.Text = "";
SetWindowPos(this.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, NOTOPMOST_FLAGS);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " | " + ex.Source + " | " + ex.InnerException + " | " + ex.StackTrace);
}
}
private void btnTest_Click(object sender, EventArgs e)
{
SetWindowPos(this.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, NOTOPMOST_FLAGS);
}
|
|
|
|
|