Group box with title as Check box - visual-c++

I am using Visual Studio 6.0 (VC++ with MFC) in Windows XP platform. I am trying to create a group box with the title of the group box as a check box. My intention is this: If the check box is enabled, the controls inside the group box should be enabled; or else disabled.
Is this possible to accomplish? If yes, please give me some directions.
Thanks.

There are a few things you can try, depending on how true you want to stay to your idea and how much work you are prepared to put into the effort:
Simple method
Use a normal group box, and then inside this make the first item be the checkbox. This is simple to accomplish, but you lose the goal of having the checkbox as the title.
Funky drawing method 1
Use a normal group box, then in the space over where you know the title is to go, place your checkbox. You will have to perform some tricky calculation to get it to fit in nicely and draw well without flicker.
Funky drawing method 2
Use some form of superclass or subclass/subclass on the group box. You can override the WM_PAINT handler to draw in only the frame for the group box. Place a normal checkbox in the place where you know the title is to go. This should work better because you will have more control over the drawing, but it is likely to be tricky to get right. In my experience, subclassing is lower risk to implement than superclassing.

Are you using the Dialog editor? If so, put down the group box. Next, on top of it, put a check box over the line of the group box. Edit the resource to set the Z order, or do it in code. You want the checkbox to be on top of the group box. Add a handler for the checkbox and enable / disable controls depending on the check box state.

I wrote one called CGroupCheck a few years back and it's available from CodeProject: http://www.codeproject.com/KB/buttons/groupcheck123.aspx

Related

Options of message box in Excel

We would like to change the font, color and size of the text displayed in message boxes.
Can/how do you VBA this?
Nothing tried, we are not finding any help in online manuals, including the Microsoft help site.
We would like to make the message box big, bold and loud.
Easy answer: You can't.
That's why you can't find anything about it in the official documentation of the MsgBox function.
A workaround can be to create your own UserForm where you are free in how to style it.
Add a UserForm in your workbook's code module, and configure it with as many Label and CommandButton controls as needed.
If the label text will be static, you can configure these all through the Properties window in the IDE:
Labels, Command Buttons, etc., are accessible Controls on the UserForm, and can be altered dynamically during runtime if needed, e.g., during the form's Initialize or Activate or any other event handlers. Controls on the form can even alter other controls, for example you could leverage the command button's Click event handler to modify the text associated with Label1 control, etc.
You can even add (or remove) controls (labels and such) dynamically, too, and fully control their appearance/formatting/etc.

How to deactivate window in Qt

I am trying to create a dockable window in Qt (it sits taking 4px width at the edge of the screen, always on top and it slides out when you hover it). I have to use WindowFlag BypassX11WindowManager (in order to hide taskbar hint, disable moving/resizing/etc. from window manager). I use these flags:
Qt::FramelessWindowHint
Qt::CustomizeWindowHint
Qt::X11BypassWindowManagerHint
Qt::WindowStaysOnTopHint
When I need my dock to be activated, I use the activateWindow() method. However, I have no idea, how to deactivate it.
Is there a way I can force my window deactivate? Now I can do it only by clicking another window and then return to the one that was active before revealing dock.
You should be able to use ->hide() to simply hide it if you don't want it to appear at certain points.
I assume, by the way, you know there is QDockWidget/ class that may help you as well. It's unclear from the above if you're using it or not.

System wide right click context hook

**Hello..
i am creating English To Gujarati Dictionary WinForm Application.
I need to set a system wide hook to the right click context menu on for text selection.
it means when this application is running,and if user selects word from any program and right click on it gujarati meaning of that word should be displayed as menu item.
How to do this?
or any other options like Registery Programming,shell extentions etc...?
i have to do this,even if you say its not possible.
so please help me.**
Hooking the mouse activity is the easy part. See SetWindowsHookEx, and lots of questions regarding hooking in SO. This way, you can tell when the mouse is right-clicked.
Getting the selected text is the harder part. See WindowFromPoint, for starters. You'd have to recognize the control, and if appropriate get the selected text from it. This will not always be possible using simple Win32 functions, if the control is complex.
Adding the translation to the right-click menu is probably the impossible part. Adding stuff to explorer context menu is not a problem, because explorer provides that possibility. But various applications will have various right-click menus, without a way to extend them. They might not even use Win32 for the menus, for whatever reason. A better option, IMO, would be one of the following:
Forget about changing the right-click menu. Open a window next to the point of selection with whatever content you want, and let the application show its own right-click menu.
If the user right-clicks while, say, pressing shift, show your own right-click menu, and don't pass the message to the application. So the user will see only one menu, which is yours. The user must of course be aware of this combination.

Visual C++ ListBox as Preference Chooser

So I'm building a tool that allows a user to edit a whole bunch of preferences for various things. There are several groups of settings, too many to use a TabControl without creating arrow sliders to view all of the tabs, so I decided I would try and use a ListBox to list the groups of preferences, and then when they click on them, the settings that they can change show up to the right of the box.
I'm just not sure how to do this. Obviously it would invoke something in the OnSelectionChanged function of the ListBox, but I'm not sure where to go from there. Surely a dialog can have dynamic design, right? Would I mimic the creation of a tabbed-dialog where I create my designs and then bind them to the TabControl, and just do something similar for the ListBox? Again, it's not the ListBox itself that is dynamic. The user will click on "Settings A" from the ListBox, and to the right of the ListBox will be settings 1, 2, and 3 that each have textboxs/radios/checks.
Any hints on how I can accomplish this? I just think it looks nicer than having a whole bunch of tabs lined up across the top of the box. Thanks in advance to any brilliant minds who can help me out. I'm versed in C++, but I'm very much a beginner at VC++.
You can a vertical splitter with two panes:
one which contains the list
another one which contains the configuration dialogs you would normally use in a tab control
Each time the list selection changes you can load the appropriate dialog in the right pane. You can find a splitter tutorial here: http://www.codeproject.com/KB/wtl/wtl4mfc7.aspx

No default radio button selected (J2ME, Java)

Currently working on a mobile app in J2ME and have questions with ChoiceGroup radio button answer options. Any suggestion on how to make it so that no default answer is selected? We've tried:
cg8.setSelectedIndex( -1, true ); But get an out of bounds exception error
and
cg8.setSelectedFlags( boolean[] ) with all false, but also get another error.
To get around this, we've also tried creating an invisible radio button and have that set as selected, but couldn't find a way to make an invisible radio button either.
Any thoughts or suggestions would be great appreciated!!
It sounds to me like the platform is enforcing an appropriate convention, although I must apologise for taking a purist standpoint here; this won't really answer your question.
Radio buttons are used when there are multiple exclusive choices, of which one must be made; it makes a certain amount of sense, therefore, for the user interface to ensure that something is always selected. Ideally, the initial selection in a radio group should always be a safe and sensible default.
As far as I know, the only way to not have any radio button pre-selected is to draw the control yourself. Re-implement a radio button list using a Canvas or a CustomItem.
It's a lot of work, unfortunately.
You should look into LWUIT as it may have an intermediary solution.

Resources