How do I draw separators? - c

I am programming in C, using the Windows API, and would like to know how I could draw separators. I would appreciate a code example.
Edit: Here's an illustration.
(source: microsoft.com)

Use a static control/window with the SS_ETCHEDHORZ style (This is what explorer does and should give you the most accurate rendering when it comes to Visual Styles)

I don't suppose you're just looking for LineTo?
For menus and toolbars, generally the separators are drawn for you by the menu and toolbar APIs. For random separators in dialog boxes, etc, like in the picture you added you can just draw a line.

OK, you just want to draw straight lines on the form. That is trivial. When drawing your window, i.e. when processing the WM_PAINT message, simply draw a line using the MoveToEx and LineTo functions.

You insert separators in menus when you insert a normal menu item with a hyphen "-" as text.
Windows will automatically expand them to separators.

Related

Multiline Textbox Vertical Spacing (Winform)

I am using the standard textbox control on a Windows form. I want to display the text VERTICALLY rather than horizontally. To accomplish this I set the multiline property to true, the TextAligh property to center and used the lines property to input each character as a separate array element. So far, so good.
I see the text displayed the way I want but would like to reduce the vertical spacing between lines without reducing the font size. Can it be done? If so, how?
It can be done, but not by the default options on a standard textbox.
You would probably need to override the Paint event and draw the text yourself, but it would get very ugly, and would essentially be reinventing the standard Paint method.

Text on a glass form not appearing right

On a WinForm with an extended borders, when i place a text on the glass area it doesn't appear right.
This is how the text looks like Status
a busy cat http://img833.imageshack.us/img833/4732/95454282.png
![form][1]
how can i fix the text to appear normally?
Text in Winforms is rendered with an alpha of 0. Which makes it transparent when you draw on glass. So you'll see the background color, not the ForeColor you selected.
Drawing text on glass is troublesome, you can't get it easily anti-aliased correctly since the background of the text isn't well defined. Note how the screenshot shows how Windows addresses that problem, the text in the window caption has a milky-white background, thus ensuring that the anti-aliasing properly blends the letter into the background.
Which is what you need to do as well. You get text drawn like that with pinvoke, DrawThemeTextEx() with the DTT_GLOWSIZE flag option. Visit pinvoke.net for the required declarations or use this project. And don't forget to provide a fallback so this window still looks decent on older Windows versions. And newer versions, glass is no longer appropriate for Windows 8.

WPF lines and polylines events for a 2D Editor

i want to create a 2d-editor like application in WPF an i need to know how to do this:
How can intercept the event when i click on a Line or Polyline?
How can detect the end / beginning of a line and show a small dot or small box in the end or the beginning of the line. Is there a way to raise an event if i get close of end or the beginning of the line?
How can i create a panning and zooming functionality? How can i control the canvas for that functionality?
How can i maintain the aspect ratio between X and Y and the scale. I mean if i have a horizontal line of length 5 and a vertical line of length 5, what do i have to do to both lines look the same length visually?
Thanks for your answers.
Eduardo
I don't know much, but the ideas that came to my mind are as below, correct me if anything wrong.
Using Hit-Testing [Ref] or Pre-defined extendable Shapes [Ref], which already have common Input events (like MouseEnter, MouseLeave, ...)
For showing a small dot, u can use Adorners. Every line a has end and start point, u can just get it's value and adjust your visual (small dot) for them. Yes, Adorner can help u, they are just like any other UIElement, so commons events like MouseEnter, MouseLeave, ... are there.
For panning and zooming, u can use the code from here or here or here
The lines will be visually same. Just draw them using Shapes (link above).

Xlib: draw a text input box and read text as it is typed

I am trying to implement a text box where a user can type, use arrow keys, backspace, delete, etc. I would like to be able to know what is in this text box without the user needing to submit anything. I suppose I could catch keypress events, find a way to display a cursor, and basically build a min-text-editor by hand--but maybe that would be reinventing the wheel?
What I am after is rather scrabble-like. You have several letters in the top part of a window and a text box in the bottom. Each time you type a letter it disappears from the top pane so that you know when you've used them all up. I want to be able to edit that text with the arrow keys, 'cause rather than the 7 letters scrabble would give me I hope to be doing this with paragraphs.
I have the window displaying, and the source file processed and displayed as a list of allowable letters... I just want to update the list of allowable letters while the user types in their sentence. Can Xlib do this? Is there something else that might be more suitable? Thanks!
Can Xlib do this?Why yes, Xlib can do a lot of things. What you describe seems simple enough by using X's event processing and drawing functions.
Xlib is pretty crufty, though, and IMO you should only use it if you need closeness to the X protocol. (Even then there are newer replacements like XCB. But I digress.)
You might find it easier to work with a modern toolkit, like GTK+ or Qt.
For example, this might be expressed as a GtkEntry with a "key-press-event" handler.

Center title bar caption of Syncfusion WinForms ribbon form?

Is there a way to center-align the text in a WinForms form? Also known as the title bar caption or title bar text? So far the only way I can see to do it is pad the string with spaces. I am setting the title bar caption using the Form.Text property.
I should add that I am using a 3rd party ribbon form, so the app looks like a Microsoft Office 2007 application. And those apps center-align the text, presumably because when the text is left-aligned it gets added to the jumble of buttons on the top left and looks bad.
Honestly - don't. Windows users expect certain things to work in a certain way, and this would not meet standard practices. Not to mention that the button in the taskbar would then no longer show the titlebar text as it would be pushed to the right.
You can take over the non-client area of a form completely, in which case you can do what you like. Even if you did this, though, my recommendation for your design would be to have the title at the top left, close button at the top right, etc.
For anyone who is interested, I am using Syncfusion Essential Tools. The solution is this:
this.ribbonToolbar.TitleAlignment = Syncfusion.Windows.Forms.Tools.TextAlignment.Center;
The title alignment is a property of the ribbon toolbar and not of the RibbonForm, which explains why I didn't find it before. Thanks to all who responded.
The title bar is rendered by the system and there is no option for centering the text.
In order to effectively center, you'd need to draw the title bar yourself - this can be done in native code by handling WM_NCPAINT messages and such but not sure how this can easily be done in .NET.
But why do you want to change? Windows UX standards have the text left aligned.
I don't believe you can.
You could hide the title bar, and replace it with a user control and implement the same functionality a title bar has, but I don't think that would be a good idea.
Consistency for the user is probably more important than whatever reason you have for wanting to center the text.

Resources