WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Dialog Editor version 6.X
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Smooth Dialog Edges

 Keywords:  smooth dialog edges rounded dialog edges

This script displays a dialog with smooth edges. I think you can create a dialog of any form with the API region functions. I removed the caption because it looks better. To move the dialog just click on it.

With some work it could be used to have true skins instead of only backgrounds, drawing a custom caption with buttons on it.

You can move the dialog only when you click on the fake caption, or any control, with a little more work.

There is a small drawback: If you remove the caption, you can't minimize the dialog clicking on the taskbar icon. You have to right-click and choose minimize. This also happens with QuickTime, which uses a similar window.


;Smooth dialog edges
;Guido 12/02

IntControl(1002,0,0,0,0) ;no winbatch icon
IntControl(49,1,0,0,0)   ;system menu

#definesubroutine dlgproc(handle,msg,id,p4,p5)
select msg
  case 0 ;Init
    DialogProcOptions(handle,2,1)   ;buttons
    DialogProcOptions(handle,1,100) ;timer
   
    GWL_STYLE=-16
    WS_CAPTION=12582912
    HTCAPTION=2
    WM_NCLBUTTONDOWN=161
    user32=strcat(dirwindows(1),"user32.dll")
    gdi32=strcat(dirwindows(1),"gdi32.dll")
    dlgid=WinIdGet("")
    RECT=binaryalloc(16)

    ;remove caption
    os=dllcall(user32,long:"GetWindowLongA",long:handle,long:GWL_STYLE)
    dllcall(user32,long:"SetWindowLongA",long:handle,long:GWL_STYLE,long:os & ~WS_CAPTION)

    ;create region
    dllcall(user32,long:"GetClientRect",long:handle,lpbinary:RECT)
    hrgn=dllcall(gdi32,long:"CreateRoundRectRgn",long:0,long:0,long:binarypeek4(RECT,8),long:binarypeek4(RECT,12),long:100,long:100)
    dllcall(user32,long:"SetWindowRgn",long:handle,long:hrgn,long:@true)

    binaryfree(RECT)

  case 1 ;timer 
    ;move dlg when clicking on it
    if MouseInfo(8)==4 
      if MouseInfo(9)==dlgid then dllcall(user32,long:"SendMessageA",long:handle,long:WM_NCLBUTTONDOWN,long:HTCAPTION,lpnull)
    endif
    break

  case 2 ;buttons
    select id
      case 1 ;hide
        dllcall(user32,long:"CloseWindow",long:handle)
        return -2
    endselect

endselect
return -1
#endsubroutine


MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`WIL Dialog 1`
MyDialogX=-1
MyDialogY=-1
MyDialogWidth=142
MyDialogHeight=136
MyDialogNumControls=002
MyDialogProcedure=`dlgproc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,255|255|0`
MyDialogConfig=4513660

MyDialog001=`017,103,036,012,PUSHBUTTON,DEFAULT,"Hide",1,1,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`083,103,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog",1)


More: Here's a slight variation...

For a Circle: Replace:
hrgn=dllcall(gdi32,long:"CreateRoundRectRgn",long:0,long:0,long:binarypeek4(RECT,8),long:binarypeek4(RECT,12),long:100,long:100)
with:
hrgn=dllcall(gdi32,long:"CreateEllipticRgn",long:0,long:0,long:binarypeek4(RECT,8),long:binarypeek4(RECT,12))
For a Polygon: Don't feel like trying to figure this one out, but here's a reference...
http://math.msu.su/~vfnik/WinApi/c/createpolygonrgn.html

Here is an example for the polygon, without removing the caption:

;Non rectangular dialogs
;Guido 12/02

IntControl(1002,0,0,0,0) ;no winbatch icon
IntControl(49,1,0,0,0)   ;system menu

#definesubroutine dlgproc(handle,msg,id,p4,p5)
select msg
  case 0 ;Init
    DialogProcOptions(handle,2,1)   ;buttons
    DialogProcOptions(handle,1,100) ;timer
   
    WS_CAPTION=12582912
    HTCAPTION=2
    WM_NCLBUTTONDOWN=161
    user32=strcat(dirwindows(1),"user32.dll")
    gdi32=strcat(dirwindows(1),"gdi32.dll")
    dlgid=WinIdGet("")
    RECT=binaryalloc(16)
    WINDING=2

    ;array of POINT structures
    ;3 points * 8 bytes each = 24
    POINTARR=binaryalloc(24) 

    ;dlg width & heigth
    dllcall(user32,long:"GetWindowRect",long:handle,lpbinary:RECT)
    dlgwidth=binarypeek4(RECT,8)-binarypeek4(RECT,0)
    dlgheight=binarypeek4(RECT,12)-binarypeek4(RECT,4)
    
    ;1st point
    binarypoke4(POINTARR,0,5)
    binarypoke4(POINTARR,4,dlgheight-20)

    ;2nd point
    binarypoke4(POINTARR,8,dlgwidth/2)
    binarypoke4(POINTARR,12,30)

    ;3rd point
    binarypoke4(POINTARR,16,dlgwidth-5)
    binarypoke4(POINTARR,20,dlgheight-20)
    
    ;create region
    hrgn=dllcall(gdi32,long:"CreatePolygonRgn",lpbinary:POINTARR,long:3,long:WINDING)
    dllcall(user32,long:"SetWindowRgn",long:handle,long:hrgn,long:@true)

    binaryfree(RECT)
    binaryfree(POINTARR)

  case 1 ;timer 
    ;move dlg when clicking on it
    if MouseInfo(8)==4 
      if MouseInfo(9)==dlgid then dllcall(user32,long:"SendMessageA",long:handle,long:WM_NCLBUTTONDOWN,long:HTCAPTION,lpnull)
    endif

  case 2 ;buttons
    select id
      case 1 ;hide
        dllcall(user32,long:"CloseWindow",long:handle)
        return -2
    endselect

endselect
return -1
#endsubroutine


MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`WIL Dialog 1`
MyDialogX=-1
MyDialogY=-1
MyDialogWidth=142
MyDialogHeight=136
MyDialogNumControls=002
MyDialogProcedure=`dlgproc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,255|255|0`
MyDialogConfig=4513660

MyDialog001=`017,103,036,012,PUSHBUTTON,DEFAULT,"Hide",1,1,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`083,103,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog",1)



Article ID:   W15476
File Created: 2003:05:13:11:28:06
Last Updated: 2003:05:13:11:28:06