Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - HPEN troubles
  
User name:
Password:
Reply:
 

UserPost
HyperLamer
Posts: 5118/8210
If you're not sure whether something needs to be deleted, try deleting it anyway and check the return code. If the delete fails, it probably isn't necessary.
sloat
Posts: 61/85
use the CreatePen function if you need to specify a width. once you create it, you use SelectObject to set it to the DC you want to draw on. After that, use the Rectangle function to draw a rectangle. The shape is outlined with the pen and filled with the current brush. If you want it to just be the outline, you might have to use GetStockObject with the NULL_BRUSH value and select the object it returns in to the DC. I'm not sure if DCs use a null brush by default.

If you only use SetDCPenColor, then you don't need to delete anything. You only need to delete objects that you create. There are exceptions, but usually MSDN will tell you if you need to delete an object from a function or not.

In my editor, I used the PatBlt function to draw an inverse selection rectangle. There are two problems with that though. 1) it's a little more complicated, and 2) it doesn't show up on gray tiles. Feel free to check out the source to my project if you'd like. It's on my website.
beneficii
Posts: 150/567
Me, in my program, I'm doing it the hard way. Basically, my editor will draw all boxes onto the window, clears them off, etc., without consulting the Windows API. After getting the bitmap with all the settings I want, I'll finally draw it onto the screen. Maybe I'll do it the WInAPI way later, but I just want to do it my way for now. Maybe when people start writing better tutorials on the subject....
Lenophis
Posts: 494/830
Last month, while still in the preparation stages for Jade's map editor, I was throwing in what it should be able to do (you know, besides edit the map.) FFHackster gives you the option to display what tile you have selected, like so:

Well, now I'm trying to do so with Jade. The purpose, to make editing the map like so:

easier on the user.

Sounds simple so far? For the most part, but I always wind up making things complicated. About 3 weeks ago, I floated an idea to a friend of mine about letting the user customize the colors of those boxes, among other things related to this issue. After looking through MSDN, turns out that something called SetDCPenColor can, but is restricted to the 2k and XP users. At least it appears that way, so that's out. I think I found a way around the color changing, but I now have this problem: I don't know how to draw with them. They are declared and created (1 pixel wide) but beyond that I don't know what to do, and MSDN's example isn't the greatest. So my question is, how do I make the box dimensions and then draw that box afterwards?

Bonus question: My method of getting around the color changing is making the pens local variables, but do they still need to be deleted when I'm done?
Acmlm's Board - I2 Archive - Programming - HPEN troubles


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.011 seconds.