text in paint like application - winforms

Hope I can make the question clear.
I am working on a paint like application where users can add different objects and also text. The way to add text is that we show a dialog where user can enter text and then that text is added to the draw area.
Now we want that text should be added in the same way as in Power Point. A user clicks any where in the draw area, a rectangular text entering area is shown, where user can enter text, format it, move the rectangle to move the text and then click outside to enter the text on the drawing area.
Since the paint event of the draw area is called and every object is added to the draw area using graphics and paint, what is the best way to add text using the interface as I explained above.
Any suggestions would be appreciated.

Your best option is to place a TextBox as a child control and that will allow the user to modify the text as required. Once they finish changing the text you then remove the text box and draw the string instead. If they click the text becaues they want to change it then you put the text box back again so they can edit it.

Related

Combo box in a MFC application

My question is about combo boxes in Windows MFC applications.
The dropdown part of the combo box contains items composed of a bitmap and a string.
Sometimes, the strings are too long and I have to adjust the width of the dropdown part of the combo box using the CComboBox::SetDroppedWidth() method.
My problem is that when the combo box is near the right edge of the computer screen, the right part of the dropdown is hidden (see image_1 and image_2 below).
I would like it to behave like in Excel (see image_3 below) meaning I would like the dropdown list to be shifted accordingly so that all its items can be seen without being cropped.
How can this be achieved?
image_1: right part of the dropdown is NOT hidden
image_2: near the computer right edge, the right part of the dropdown is hidden
image_3: Excel combo box
=================================================================
EDIT 1
=================================================================
EDIT 2
Ok. I forgot to mention that m_cbXmodels is a CComboBoxEx object. This is why the handles are NULL. I could get the handles via GetComboBoxCtrl()...
Handle the CBN_DROPDOWN notification.
Get the handle for the list control with GetComboBoxInfo.
Now use MoveWindow to adjust the window as needed.
Getting the current screen size is available with MonitorFromWindow. See rcWork member in MONITORINFO. You just need to adjust the left and right coordinates.
EDIT: As you can read in the comments: My Approach with CBN_DROPDOWN is to early Thanks to zett42). It is not possible to resize the combo box list part here.
But it is possible to post a user defined message to the same window and to reposition the window than.

How can I neatly line up right-aligned check boxes with with other controls?

The Visual Studio WinForms designer lets you snap together text boxes, list boxes, buttons, and so forth reasonably well. However, a check box with CheckAlign=MiddleRight does not work quite like the others, because it has two components: the built-in label, and the check box itself. If you line up the text with other labels, the check box is left floating and will not automatically line up. You can turn off AutoSize and attempt to size the CheckBox control so the check box lines up, but this is touchy and will be thrown off by custom font sizes.
In this example, I've almost lined up the check box with the other controls, but not quite:
If I had several check boxes it would be a real headache, as with AutoSize turned off the position of the check box is relative to the end of the text, so each control has to be individually sized pixel by pixel.
What's the best way to line up check boxes with other controls?
One workaround is to not include text with the CheckBox and instead have a separate Label control. However, by doing so you lose the ability to click on the label to toggle the check box. On a high-resolution screen, clicking a 10x10 pixel is finicky, a poor UX experience. You could add an OnClick event to the label, of course, but that seems like solving the wrong problem.
Here's an example of someone else with the same issue: in the preferences panel in Oracle SQL Developer, when there's a mix of properties the check boxes are handled with separate labels and boxes:
Personally, i avoid that issue by not having the CheckBoxes aligned to the right:
rather than having the caption on the left.

WPF Input Method Editor

I'm trying to enable the IME in WPF... which works for some textboxes but not the one I actually need it for. I do the following in XAML
InputMethod.IsInputMethodEnabled="True" InputMethod.PreferredImeConversionMode="Native" InputMethod.PreferredImeState="On"
I have a custom on-screen keyboard, the textbox has focus, and keys can be pushed on the screen and send the appropriate letter to the textbox. But when setting this above xaml to the textbox in this custom keyboard, the candidate window doesn't display at all, instead a strange small black control appears on the top left of the screen with a text box and a green arrow which has a caption of "Enter". Any text pressed on the keyboard goes to that small black control without showing the text, but after pressing enter, that text appears in my keyboard.
Ultimately I'm trying to incorporate simplified Chinese. Again, this works perfect on every other textbox but the one I actually need it for, being the custom onscreen keyboard.
Any thoughts? I'm really stuck with this.
Cheers.
UPDATE
This is the image I see, don't scroll down, it's the black little control with the green arrow.
http://babelstone.blogspot.ca/2010/05/prototyping-tangut-imes-or-why-windows.html
So I've been looking for a different design of the IME, Notepad seems to show something different. But I eventually got the little black box control to work and display what I'm actually typing. Moved xaml to code behind and it started working.

SSRS Action hyperlink colour change

See attached screen shot.
I have made the 4 text box's hyperlinkes to different reports.
Is it possible to have a some sort of formula which will say change the colour of the box when the cursor is hovered over the hyperlink like a webpage button could do?
Unfortunately SSRS does not allow events like onHover etc. The only thing you can do is to provide a label for the entry or to simply color the text using the properties section and set it to underline. However, this would mean at all times it would be underlined and colored.

Wrap text into semi-circle region

I'm modifying this glass button code to allow for both a Text and a TextExtra property. The goal is to render the Text in a larger/bolder font on the top half of the button and the TextExtra in a smaller font on the bottom half.
I'm having trouble finding a good way to do this when the button is round. As written, the code uses the text rendering of it's Button superclass, which works fine even for a round button with just the Text property. I assume I'll need to render the Text and TextExtra myself, but can't think of an elegant algorithm to wrap the text into the semi-circular regions.
Any approach/pointers welcome.

Resources