AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Draw hexagon - need someone who knows about DLLs

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Pip
Guest





PostPosted: Fri Dec 11, 2009 7:25 pm    Post subject: Draw hexagon - need someone who knows about DLLs Reply with quote

Hi

Can someone give me an example of how to draw a hexagon using hpen?

Thank you

Pip
Back to top
Guest






PostPosted: Fri Dec 11, 2009 8:49 pm    Post subject: Reply with quote

Hwre is the formula for drawing a Hexagon.
Someone else will need to show you how to use GDI's hpen.
http://en.wikipedia.org/wiki/Hexagon
Back to top
txquestor



Joined: 22 Aug 2009
Posts: 294

PostPosted: Fri Dec 11, 2009 8:56 pm    Post subject: Reply with quote

Here is Lexikos code for drawing a rectangle.
You'll need to change it using the forumula for a Hexagon above in previous post.

Code:

OnMessage(0x14, "WM_ERASEBKGND")
Gui, -Caption +ToolWindow
Gui, +LastFound
WinSet, TransColor, Black
; Create the pen here so we don't need to create/delete it every time.
RedPen := DllCall("CreatePen", "int", PS_SOLID:=0, "int", 5, "uint", 0xff)
return

WM_ERASEBKGND(wParam, lParam)
{
    global x1, y1, x2, y2, RedPen
    Critical 50
    if A_Gui = 1
    {
        ; Retrieve stock brush.
        blackBrush := DllCall("GetStockObject", "int", BLACK_BRUSH:=0x4)
        ; Select pen and brush.
        oldPen := DllCall("SelectObject", "uint", wParam, "uint", RedPen)
        oldBrush := DllCall("SelectObject", "uint", wParam, "uint", blackBrush)
        ; Draw rectangle.
        DllCall("Rectangle", "uint", wParam, "int", 0, "int", 0, "int", x2-x1, "int", y2-y1)
        ; Reselect original pen and brush (recommended by MS).
        DllCall("SelectObject", "uint", wParam, "uint", oldPen)
        DllCall("SelectObject", "uint", wParam, "uint", oldBrush)
        return 1
    }
}

+LButton::
    MouseGetPos, xorigin, yorigin
    SetTimer, rectangle, 10
return

rectangle:
    MouseGetPos, x2, y2
   
    ; Has the mouse moved?
    if (x1 y1) = (x2 y2)
        return
   
    ; Allow dragging to the left of the click point.
    if (x2 < xorigin) {
        x1 := x2
        x2 := xorigin
    } else
        x1 := xorigin
   
    ; Allow dragging above the click point.
    if (y2 < yorigin) {
        y1 := y2
        y2 := yorigin
    } else
        y1 := yorigin
   
    Gui, Show, % "NA X" x1 " Y" y1 " W" x2-x1 " H" y2-y1
    Gui, +LastFound
    DllCall("RedrawWindow", "uint", WinExist(), "uint", 0, "uint", 0, "uint", 5)
return

+LButton Up::
    SetTimer, rectangle, Off
    Gui, Cancel
return


Have Fun, Rolling Eyes Laughing
_________________

"Man's quest for knowledge is an expanding series whose limit is infinity"
Back to top
View user's profile Send private message
Pip
Guest





PostPosted: Fri Dec 11, 2009 10:10 pm    Post subject: Hexagon Reply with quote

Cool - thanks guys
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group