views:

257

answers:

4

I am programming in C, using the Windows API, and would like to know how I could draw separators.

I'm a total noob when it comes to writing GUI applications, so I may need a code example.

Edit: Here's an illustration...

alt text

A: 

You insert separators in menus when you insert a normal menu item with a hyphen "-" as text.

Windows will automatically expand them to separators.

codymanix
Initially, I also believed that this was the kind of separators he was looking for. Rather evil to give you a -1, for your response was posted prior to the clarification.
Andreas Rejbrand
I wasn't the one who voted you down by the way.
someguy
+2  A: 

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.

Terry Mahaffey
Thanks (to Andreas as well). Is this the only way though? I thought there would've been a more "official" way. I'll wait a while (for a reply) before setting this as the accepted answer.
someguy
Owner draw is overkill when there is a common control that does exactly what you want (And you don't have to handle Classic vs Visual styles etc)
Anders
+2  A: 

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.

Andreas Rejbrand
+1  A: 

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)

Anders
I believe that is for MFC. I'm using Win32, but maybe I can look into MFC.
someguy
No, the static control is a normal native win32 control
Anders
Thanks. This is what I was looking for :)
someguy
@someguy maybe you should change the marked answer then...
Anders
Sorry, I wasn't aware you could do that (lol).
someguy