Capture a window inside my form - winforms

I want to capture a window inside my form, how can I do that? I remember seeing a code that did this. It worked with the window handle. It behaves kind of like WinRAR's extraction window:

Sorry, English isn't my main language. I actually found what I wanted (but it didn't exactly work):
var
hWindow: hwnd;
begin
hWindow := FindWindow(nil,PChar(Edit1.Text)); //Edit1.Text is the window's handle
if hWindow <> 0 then
begin
Form1.ParentWindow := hWindow;
end else
ShowMessage('Window not found!');
end;
The reason I wanted something like this is because some applications that run on fullscreen present glitches because of the wrong refresh rate on my monitor. By doing this I'd force the application to run on the known "borderless" mode. But it didn't work with DirectX apps. Sorry for the inconvenience.

Related

How to make tkmessagebox on the top of all windows

I run r via rstudio using Windows, however, when I run the following code
library(tcltk)
tcltk::tk_messageBox(title = "Confirm",
message = "message",
icon = "question", type = "yesno",
default = "yes")
The messagebox is hiding behind the Rstudio, and I need to minimize the Rstudio window to view and click on the messagebox.
I would like to find a way to make the window of messagebox on the top of all windows.
Also the documentation of the package is not helpful. I really appreciate if you share any useful ones.
Thanks

Me.Close() not working in VB with WPF

I'm using VB with WPF and I am trying to close an application... the code I usually use ( Me.Close() ) is not working this time. The error it gave me was BC30545.. but it didn't help me understand the issue. Thanks for any solutions you all respond with.
The error code BC30545 corresponds with this message:
Property access must assign to the property or use it's value
Make sure you don't have another method/property/control with the same name (For example, a button on your form called "Close"
In the case of this example, you'd rename to something like CloseBtn so that it doesn't interfere.

Installshield 2011: Take path from one window, take text from second

Good day, everyone. I have that task assigned which consists in creating simple installscript-only project, that should have 2 windows: first will prompt user to enter a path and create text file in this specified location, while second will promt for text input and save anything user writes into this text file.
Funny point is that I have small installshield experience (completed tutorials... well, yeah, that's all) and very little programming experience on top of that. As far as i understand, I should first create two custom dialog windows (for example by cloning them from standard ones), then create .rul files with functions, determining behavior for each. After which, include them into main setup.rul and call functions at specific point of time.
Question is - what exact dialog windows/functions/points of time will be best for such task? For reference i searched into "Serial Number Validation Sample Project" but, honestly, the way it customized default window is just confused me even more... So, please, can anybody help? Thank you.
For future reference, here's working solution.
Asked that same question at flexera forums, and here's what I got:
Off the top of my head (without InstallShield handy to check this) 1)
Create an InstallScript project, just accept all of the defaults in
the new project wizard unless you want to add localization or
something. 2) Your description implies that you do not need
maintenance (repair, modify, uninstall) support. If correct go to
Project\Settings and on the Maintenance tab select 'no uninstall or
maintenance'. 3) You can put your code at the top of the
OnFirstUIBefore function and then call Exit so that the rest of that
default code is never executed, since you are not installing anything.
As part of your InstallShield IDE, in the Start menu (for IS2012
Spring) is a tool that demonstrates all of the built in dialogs. You
can look through those choices and select the dialog that is best for
your situation. It sounds like you want to:
Call AskPath or SdAskDestPath (there are several other possibilities)
Then call AskText and save that string.
If you need to make layout or text changes to the default dialogs look
at your Dialogs view and select which ever dialog you selected above
and edit it. (If you decide to use skins make sure you select the skin
before you make any dialog layout changes.)
Then do something similar to the functional body of the WriteLine
example http://kb.flexerasoftware.com/doc/Helpnet/installshield14langref/LangrefWriteLine_Example.htm
The actual WriteLine example function prototype is for a MSI custom
action which is not what you want. Ignore the function protoype and
just use the code in your project to create the file at the path you
already collected and write the line of text that you collected.
Then call Exit;
(big thanks to user phill_mn for that answer)
And here's the code for setup.rul:
#include "ifx.h"
function OnFirstUIBefore()
number nvFileHandle;
string svResult;
string szTargetPath, szFeatures;
BOOL bLicenseAccepted;
begin
AskPath ("Please choose a path where text file will be saved","c:\\",szTargetPath);
MessageBox("File yourtext.txt wiil be created or overwritten at " +szTargetPath, INFORMATION);
AskText ("Please enter some text to save into that file", "Text goes here", svResult);
OpenFileMode (FILE_MODE_APPEND);
if (CreateFile (nvFileHandle, szTargetPath, "yourtext.txt") < 0) then
MessageBox ("Creating failed.", SEVERE);
abort;
else
if (WriteLine(nvFileHandle, svResult) < 0) then
MessageBox ("Writing failed.", SEVERE);
else
MessageBox ("Success.", INFORMATION);
endif;
endif;
CloseFile (nvFileHandle);
Do(EXIT);
return 0;
end;

is it possible to fill in a windows credential prompt programmatically?

Issues of robustness, stability and you shouldn't do this aside, has anyone ever filled in a windows credential prompt via code (so that's one that looks like this:)
Is it possible to interact with these dialog boxes through Win32 APIs, or using SendKeys/send mouse / UI Automation? Any ideas / tips anyone has would be greatly appreciated!
I ended up using the UI Automation framework, which allowed me to grab a reference to the credential prompt and then fill it out and complete it that way.
Code snippet:
AutomationElement desktop = AutomationElement.RootElement;
//get all windows on the desktop
AutomationElementCollection windows = desktop.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window));
foreach (AutomationElement window in windows)
{
if (window.Current.ClassName.Equals("#32770")) //security dialog
{
// access the appropriate AutomationElements to enter credentials here
}
}
To interact with an element, you grab the appropriate Pattern object and call its methods (eg Textboxes have a ValuePattern which has a .SetValue() method.
I also used UISpy to find all the values for things like ClassNames, AutomationIds, etc to help find the correct item through .FindAll() and PropertyConditions objects.
Use something like AHK (Auto HotKey) it is a simple language that can be compiled to an EXE and is designed for automating the keyboard and mouse.
Or you could do it from WPF:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6fc7f1f6-f3e2-4b32-9d2b-9c7a2680e04a/
Or users could simply tick "Remember my credentials"

How do I tell if a form is in help mode?

There's a certain control which I don't have the source to (Steema TTree) it doesn't send a help message when help is requested through the form. (clicking the ? near the X on the dialog, then clicking the TTree)
I can just call help directly on the form and pass in my own helpmessage, but I don't know whether the form is in help mode.
The form's cursor is acutally 0 even when it has a ? next to it... That I find odd.
Anyway, I know I'm hacking my way through this, but I don't care. All I want to know is if there is a way to tell whether the user is requesting help and currently has a ? next to their cursor
The form's cursor is acutally 0 even
when it has a ? next to it... That I
find odd.
That's because that is your forms cursor
Try Screen.Cursor that should be the active one.
Torry helped
procedure wmNCLButtonDown(var Msg: TWMNCLButtonDown); message WM_NCLBUTTONDOWN;
procedure wmNCLButtonUp(var Msg: TWMNCLButtonUp); message WM_NCLBUTTONUP;
I overrode those functions to set a global variable
fHelpMode : Boolean
to true when
if Msg.HitTest = HTHELP then
fHelpMode := true;
That allowed me to know when if the user was requesting help and I could override a mouse event on the TTree to do my help pop-up.

Resources