I have a simple login screen windows form application and I am controlling that application through an adapter now i want to find the coordinates of the textboxes and button, I tried using the coordinates after right clicking the textbox control and picking the location from its property but it did not work. So i want to find the proper location, as windows form application form size can be changed during the run-time. So, how can i find the windows form coordinates.
I have tried using the coordinates provided in the properties of the textbox and button controls but those did not work.
IntPtr childHwnd = Win32API.FindWindowByPosition(ptr, new Point(intFirstNameCoordX,intFirstNameCoordY));
This is how i want to find the window.
I want to find the textbox and buttons position in windows form. I was googling and found some Spy++ tool but i am not sure if that is what i require and if it is then can anyone please guide me how i can use it to find the position in a simple window form application.
OK, I can see that you are using WinApi functions, so I won't go deeper into that, just give you some idea.
First, you can get the main window handle. You can get the handle by process (enum process windows) or by it's caption. If you want to get the handle by caption you can use FindWindow
This handle is the window handle. Next, you can enum it's child windows - for example panels or other controls, using EnumChildWindows
Now the rest depends on your GUI architecture. You may have edits and buttons in panels, so you will have to search for child windows of that panel. You may have controls just put on your main window - so you just search for child controls of that window.
Next, when you find the control, you're interested in, you can get more info, using for example GetWindowRect
Related
This is something that surprisingly wasn't able to find a solution online.
I have in my main form a couple of user control, that after doing a certain action, I want to show a notification icon.
The examples shown about doing from a different form don´t apply to User Controls, as you can't directly reference the form that is using it.
In the case the question is a bit confusing:
Application
- Main Form
--NotifyIcon
--UserControl
---Button that when pressed, show the NotifyIcon
--UserControl
---Button that when pressed, show the NotifyIcon
I´m using VS2010 by the way.
hi I want to make a wpf c# application which shows every form(Ex:- user registration, reports , etc..)in one window in other words I want to make an application which have one window and every user control appears and closed there when I want just like games in some games like middle of honor warfighter they have one window and if we chose option option buttons appear in the same window and if we chose graphics that graphic page content appear in that same window.
and I want to know is there any frame work or special method is there which I should fallow other than putting wpf controls one over another and changing there visibility and isopen status.If there is any examples please give me a link
You can use ContentControl for holding any element. also PRISM is best approach.
You can use WPF Popup forms below are some links for more info:-
http://www.dzone.com/articles/understanding-wpf-popups
http://www.c-sharpcorner.com/Blogs/11700/
Take a look at this MDI Control. It helps you to show any kind of usercontrol in one container as window.
I am using Windows form in C# and i am trying to create one single form dialog that will be responsible displaying other dialogs within the boundary of it's dialog. To do that i tried Tab Control and it worked well and i can create different types of form in tab control easily without opening any separate forms.
but the problem is i don't want to use Tab control , I have some buttons on the main form at left side and clicking those buttons i want to display separate forms beside those buttons. I searched google but did not find any example like that nor i am able to find any control as this. My application is very simple one dialoge with left side buttons and on right side i want to show different forms based on those buttons... C# is not my native language but now i have to work on it and require help.
Kindly check the attached image for more information
Each page could be an instance of Panel, then show/hide the Panel instances according to which button is clicked....make them all the same size, shape, and position ;)
I'm developing a bunch of user controls which do different things - like a maintenance screen, enquiry screen, report screen that sort of thing. Each screen has a dedicated purpose and a single user control holds all the functionality for the one screen.
I'm using avalondock and can place these user controls into LayoutDocuments. This creates a separate tab for each screen/user control. I've got a menu system setup so users can choose which screens they need access to. For each new screen I create a new LayoutDocument, add the appropriate control to it, then add the LayoutDocument to the Docking panel's children.
This is all working fine.
Avalon dock also has the feature of being able to drag out the layout document and make it float - you can also dock it somewhere else in the app if you wish.
I'd like to take this concept one step further: Being able to say right click on a layout document and choose "Make external window" (i'll work out the exact wording later). The effect of this action would be to create a new application with it's own icon in the task bar; being able to alt-tab between it and other apps;
Kind of like when you're in say Excel editing a document and you then open up a second instance of excel. In Windows 7 you get two excel icons in the task bar (one behind the other), and you can alt-tab between them.
This is nearly the behaviour that i'm after. However the second app isn't a full blown copy of the first; it has only the one user control that the user selected.
This is where i'm stuck and would like a bit of guidance.
I'm thinking that i'll probably need some kind of shell app where I can pass in the user control that I want. The shell would act as a window with title, X, minimising etc; the user control would then be the sole content of that shell. Use process.start to create new process and launch ?
Ideally i'd be able to pass in the same control in the same state as the user is currently viewing - so if for example they are part way through editing some customer record in a maintenance screen, then choose the "external window" option, that same customer record would appear in the new window.
Has anyone done something similar or offer advice if i'm on the right track ?
I think I know how to create a shell app but not sure on passing a user control to it dynamically. I'd like to avoid creating different shell apps for each user control.
No need to start a new process for that scenario.
Just create a new Window add your UserControl at runtime and remove the UserControl from the DockingManager. Make sure the Window has ShowInTaskbar set if you want it to show up there.
To get the command to undock the UserControl as a seperate Window you just have to restyle the ContextMenu to incorporate your command (take a look at the VS2010 theme and how the ContextMenu is styled there VS2010 theme.xaml).
I am unable to figure out why I can use Spy++ to get handle, window class etc of some windows application. For example, iexplore.exe, it just doesn't work on url text box or any text, edit box area if any in the page loaded; there are also windows application I get only the outer layer's properties whereas its internal buttons, textbox or combox are inaccessible. In these applications what should I do to reach them ? Thank you :)
These programs use windowless controls.
Instead of using standard Windows controls, they draw and process everything themselves within one giant container.