I am very new to Visual C++ programming, but I have to write simple program which needs to do two things: ( I am using MS Visual C++ )
main ( parent ) form should be displayed when program starts, and after clicking a button on it, second form should be shown.
Second form ( child ) also has a button, but this one should ( after clicking, of course ) show current X,Y child form position but on ( important ) parent form.
And this is where i got stuck.
I can display child form with:
a) adding #include "child.h" in parent form.h
b) adding child ^child_form; in public: section
and afterwards using:
child_form = gcnew child();
child_form->Show();
I was googling for two days now and cannot find a way to get it the other way: click on a button on child_form and display it's coordinates on parent form on label->text :/
when i tried to add #include "child.h" in child_form I just got error saying: "there are to many include files..."
I really need to get this done and I would really appreciate any suggestions.
Thanks in advance :)
Related
I have started using the imgui system for visualizing "whatever". I am in my first few hours, and am running up against what seem to be common snags.
However, although I can see some pretty good support for the C++ versions of ImGui (which I'll transition to eventually), the python imgui content is mostly obscured.
What I am looking for is the solution to the following problem:
while not glfw.window_should_close(window):
...
imgui.new_frame()
imgui.begin("foo-window", closable=True)
imgui.end()
Everything works fine. However, the window doesn't close. I understand that the window doesn't close because it is always created every loop.
What I am looking for is:
How do I detect and identify that the particular window has been closed, and block it from being re-generated?
I'm not at all familiar with the imGui for Python, but if it at all follows the similar pattern as in imGui for c++, then you need to follow this pattern:
static bool show_welcome_popup = true;
if(show_welcome_popup)
{
showWelcomePopup(&show_welcome_popup);
}
void showWelcomePopup(bool* p_open)
{
//The window gets created here. Passing the bool to ImGui::Begin causes the "x" button to show in the top right of the window. Pressing the "x" button toggles the bool passed to it as "true" or "false"
//If the window cannot get created, it will call ImGui::End
if(!ImGui::Begin("Welcome", p_open))
{
ImGui::End();
}
else
{
ImGui::Text("Welcome");
ImGui::End();
}
}
JerryWebOS's answer is basically correct, but to add to that here's the python version. Note that the documentation for pyimgui is a good source to find answers to questions like this one.
https://pyimgui.readthedocs.io/en/latest/reference/imgui.core.html?highlight=begin#imgui.core.begin
imgui.begin() returns a tuple of two bools: (expanded, opened).
You can use this to detect when the user closes the window, and skip rendering the window in the next frames accordingly:
window_is_open = True
while not glfw.window_should_close(window):
...
imgui.new_frame()
if window_is_open:
_, window_is_open = imgui.begin("foo-window", closable=True)
...
imgui.end()
Im triying to automate the control of a program. I want to load a big amount of files automatically.
The program loke like this (winspector view and and corresponding api view):
As you can see, I have 7 element in my toolstrip. What I want to do is to figure out some way to click the desire element of this toolstrip (lets call the "n" element)
By doing this:
'lhWndP is the parent window handle
toolstriphandl= FindWindowEx(lhWndP, 0&, "WindowsForms10.Window.8.app.0.378734a", "toolStrip1")
I get the handle of the toolstrip, but I dont know what to do now.
I tried to do this:
toolstripmenu = GetMenu(toolstriphandl)
toolstripmenu = GetSubMenu(toolstripmenu, n)
SendMessage toolstriphandl, WM_COMMAND, toolstripmenu, 0
But doesn't seems to work.
Any idea please? Im desperate with this.
Thank you.
I'm writing a script that will fill in a form in Microsoft Edge. I know I should use WinActivate to change focus, but I don't know how to find out what the argument should be? For example if I go to Stackoverflow I can sort of guess it would be like Stack Overflow - Microsoft Edge but if the title is longer it gets truncated in the toolbar and I honestly don't know where I can go to see the full title of a process? I tried Task Manager.
Is there a better way? It seems a bit hacky to rely on the title of the program, especially when the title of the website determines it.
Basically I'm asking, how do you use WinActive to change focus?
Process, Exist, MicrosoftEdge.exe
EdgePID = %ErrorLevel%
if( EdgePID )
{
MsgBox, Edge is running, with PID: %EdgePID%
}
WinGetTitle, Title , ahk_pid %EdgePID%
MsgBox, Title: %Title%
IfWinExist, %Title%
WinActivate ; this doesn't work
You can use the process name which should be always the same. I'm assuming the name for Microsoft Edge is MicrosoftEdge.exe, change it if your process is named differently.
First get the process PID, which is stored in ErrorLevel:
Process, Exist, MicrosoftEdge.exe
EdgePID = %ErrorLevel%
if( EdgePID
{
MsgBox, Edge is running, with PID: %EdgePID%
}
Then get the window title of that process, using the special command ahk_pid:
WinGetTitle, Title , ahk_pid %EdgePID%
MsgBox, Title: %Title%
The window can be activated using the same method:
WinActivate, ahk_pid %EdgePID%
Alternatively the process name can be used directly:
WinActivate, ahk_exe MicrosoftEdge.exe
I'm trying to make a game (Universal DX11 application) and at some point I need access to image library to allow user to select avatar. But for some reason call of PickSingleFileAsync on picker rises an exception.
Windows::Storage::Pickers::FileOpenPicker^ openPicker = ref new Windows::Storage::Pickers::FileOpenPicker();
openPicker->SuggestedStartLocation = Windows::Storage::Pickers::PickerLocationId::PicturesLibrary;
openPicker->ViewMode = Windows::Storage::Pickers::PickerViewMode::Thumbnail;
// Filter to include a sample subset of file types.
auto filters = openPicker->FileTypeFilter;
filters->Clear();
filters->Append(".png");
openPicker->PickSingleFileAsync();// same exception with create_task(...);
Seems like the sample works only if I put it into UI thread. How can I use picker from my own thread?
UPD: HRESULT:0x80004005
Ok, I just decided to call dipatcher's RunAsync to execute this code. But I still have no idea why I cannot open picker inside non-UI thread.
I'm trying to set up a coded UI test to allow me to check for an error message on a login. The test runs, but I'm struggling to get the assert to work.
The response that comes back is nested as follows:-
<div class='ui-errors'>
<ul>
<li>Your password is invalid</li>
</ul>
</div>
What do I need to set up to check the first li in the div of that class in an assert?
Coded UI can capture DIV. In the following code I've created a custom DIV object from your provided example. AdrianHHH's answer will definitely get you information you need to insert in to my example.
var error = new HtmlDiv(new Parent(RootParentWindow));
error.SearchProperties.Add("Class", "ui-errors");
var errors = error.FindMatchingControls();
foreach (var item in errors)
{
Assert.IsTrue(item.GetProperty("InnerText").ToString().Contains("Your password is invalid"));
}
Coded UI does not really look at DIVs or ULs etc. Coded UI looks at what is drawn on the display. I suggest you use the Coded UI cross-hair tool to examine the error message then add an assertion to check for the message. You might also examine the same area of the screen for a test which passes to see how they differ.
If you are hand coding your test rather than letting Coded UI generate the code for you, I recommend creating a sandbox project and recording the assertion into that. Then copy the useful ideas from the generated code into your own test code.
If you can get a sample of the page where the assertion is needed I could create it for you, otherwise do what AdrianHHH said.
In case you don't know when you use the assertion tool, all the options you get are different ways to assert that particular control, eg you could assert if it exists or if the inner text is equal etc.
yonitdm answer will solve your problem, but as per your words, "first li in the div of that class" try below.
// Find Error Div
var errorDiv = new HtmlDiv(new Parent(RootParentWindow));
errorDiv.SearchProperties.Add("Class", "ui-errors");
errorDiv.Find();
// Get UL - First item in div
var errorUL = errorDiv.GetChildren().First(); // or GetChildren()[0]
// Get all LIs and take first item
var firstLI = errorDiv.GetChildren().First(); // or GetChildren()[0]
Assert.IsTrue(firstLI.GetProperty("InnerText").ToString().Contains("Your password is invalid"));