Well I'm programming a little game on visual studio with c++ and windows forms. I know that you can't have new pages within a window or atleast there is no feature for it. So my question is, is there any workaround to do so?.. or I'm totally wrong with that.
If it's not really clear what I mean then let me try to explain it a little bit. Most of you know those installation executives where you press the NEXT button and another pages pops up within the same window. That's exactly what I want.
I hope you can help me,thanks in advance.
Use a TabControl object and in the constructor of your form add
tabControl1.ItemSize = new System.Drawing.Size(0, 1);
tabControl1.Multiline = true;
tabControl1.SizeMode = TabSizeMode.Fixed;
Lines above make TabPages without the possibility to be selecetd by user.
Then you can create TabPages and switch them using SelectedIndex property of TabControl
Change the apparearance of tiles to Button.
The code is c#, is simple to be translated to c++.
Related
This is my first question in this community. I always search a lot when having problems and I always find an answer. But not in this one. Maybe I am not asking Google correctly.
Anyways this looks like a bug to me but I might get it wrong.
Using VS2012 (or 2013) I create the default Multiple documents MFC application. I do not write a single line of code. I compile and run. Then as a user I dock the properties window which by default is at the right to the output window as shown below .
Then I close the application and restart. The window is where it should be but with different width as shown below
If you dock the window to the right (in the view and not in another window) then there is no problem. The position and width are restored just fine. Also this only happens if the main window is maximized. The behaviour, if the main window is not, is as expected.
Do you think it is actually how Microsoft wanted to make this work or they missed that? Is there a workaround for this?
Again forgive me if this question has been asked before but really...
I couldn't find anything.
Appreciate any kind of help.
I'm fairly new at c++ programming, and yet I searched around and couldn't find an answer to how to do it, so I'm sorry if this is kind of a stupid question.
Anyway, I'm working on designing a custom window (in Microsoft Visual C++), and I just can't figure out how to remove the menu bar from the window. This is what I'm referring to:
I used an image editing software to put a box around what i want to remove in the program in case i'm not referring to it correctly. Anyway, please tell me what code to remove and/or edit to remove it. (Also, a brief explanation of why would be good because i'm still new to this)
Thanks!
You can use the SetMenu() function to show or hide the menubar. Use it like this:
SetMenu(hwnd, NULL);
where hwnd is the handle to the window, which menubar you want to hide.
You can also try using the DestroyMenu() function to destroy the menu, like this:
DestroyMenu(hMenu);
where hMenu is the handle to the menu you want to destroy.
I am learning Visual C++ 2010 Express on windows XP
This must be a standard task I am trying to do!!!
I have a very basic form with an input text box, an output text box and a button
I enter a value into the input text box and press the button and the answer is displayed in the output text box.
This all works.
I want to press the return key after I have enterd the value into the input textbox (single line box) and have the answer displayed in the output textbox. (the same as pressing the button).
Is this not a simple thing to do?
Any help will be appreciated.
thanks
I hate to break the news, but you are not writing C++ code. The language you are using is called C++/CLI, a managed language that resembles C++ about as well as C# does. The dead give-away is writing code that uses the ^ hat. Easy to see in the code that the GUI designer generates for you.
The Express edition you use is a major cue, it only supports creating GUIs by using C++/CLI. By taking advantage of the Winforms class library and the designer it supports. Very nice, you can plop controls on a form and double click them to implement the default event. Adding the Click event for a button is trivial.
The native way, MFC, is not supported in that edition. And is urky, MFC has no designer support beyond creating dialogs.
Biggest thing about a GUI app is that is does not use the Enter key to move from one control to another. Users are familiar, and know, to press the TAB key instead. The Enter key is reserved to operate the OK button in a dialog.
It is not like you couldn't make it work, Winforms is flexible enough to let you trap the Enter key to change the focus. it is just that you shouldn't, users know when they are not working with a console mode app and are happy to use the TAB key.
Wrong language, wrong UI mode, not what the school you went to told you about, I guess. They don't.
I always been interested on how we can accomplish this (hide/show the main menu using the alt key), and now some applications do this very often. One that really please me is the visual studio 2010 with this plugin:
http://visualstudiogallery.msdn.microsoft.com/bdbcffca-32a6-4034-8e89-c31b86ad4813?SRC=VSIDE
(firefox also do this, but i think that is in a different way)
Can anyone explain me how this can be achieved or if you known of any sample project that demonstrate this please tell me.
(what i can see in some replies here in stack is that we have to destroy the menu when is to hide and create it when is to show?! but this seems a bit bad solution...)
Thanks
The SetMenu function lets you add/remove the menu from the window. It does not destroy the menu.
Note that most applications which have the dynamic menu hide/show behavior are not really showing a menu. They're showing a custom control that looks like a menu.
You might also take a look at MFC support for auto hiding menus. I used this technique and it worked really well.
in CMainFrame::OnCreate I did
m_wndMenuBar.ShowWindow(SW_HIDE);
which actually works fine in our project
I stumbled across a related pit fall that will show a hidden main frame without your consent:
Whenever the focus for a child window in an MDI application changes (e.g. due to right clicking in it), the function CMDIChildWnd::OnMDIActivate will be called, which in turn shows the main menu (even if it was removed or destroyed previously) of the MDI application.
This works basically by adding the saved main manu from the underlying's CMDIChildWnd m_hMenuShared variable.
A quick&dirty hack to prevent this, is setting m_hMenuShared to NULL (it's protected in CMDIChildWnd so this needs a custom derived child class of CMDIChildWnd) for all child frames.
I know this type of thing is looked negatively upon but I write software for people with disabilities and sometimes good gui practices don't make sense. In this case, the user interacts with a assistive interface and under certain conditions, my control app needs to prompt the user with a question. My background process creates a dialog (I'm using wxwidgets wxDialog class) and calls Show(). The dialog box appears but it does not have focus (the application that the user was previously using keeps it). Since my users can't use mice, they can't simply click on the window. I've tried calling show and then followed by SetFocus(HWND) but that doesn't do it. What's the problem? Is this even possible? Window7. I'm thinking that it might have something to do with it being a dialog and not a full window (wxFrame). Any help is greatly appreciated.
Try using SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE)
Unfortunately, not only is it 'looked negatively upon', but it is not possible. There's no getting around this; ask yourself what would happen if every application could do this? Obviously, if you can put your dialog on top of the other application, it can do exactly the same back to you.
http://blogs.msdn.com/b/oldnewthing/archive/2010/11/25/10096329.aspx
The only think I can think of would be for you to put a notification icon in the system tray, and then have it display a notification balloon.
I had to do something like this before. Simply calling functions like SetForegroundWindow or SetWindowPos didn't do the trick.
I ended up using this ForceForegroundWindow function (1st one) and it works pretty well.
I know this is Delphi code, but the API is the same and Delphi is a pretty simple language.