'http://www.garybeene.com/power/pb-tutor-controls-imgbuttonx.htm

'This short example creates a complete application with a single imgbuttonx control.
'When clicked, the imgbuttonx control responds with a message.
'This tutorial page discusses most of the statements used,
'however the DDT, Controls, Messages, and Callback tutorials provide
'background information that may be helpful in understanding the example.
/*
   #Compile Exe
   #Resource "pb-test.pbr"
   Global hDlg As Dword
   Function PBMain() As Long
      Dialog New Pixels, 0, "ImgButtonX Test",300,300,200,200, _
                                      %WS_SysMenu, 0 To hDlg
      Control Add ImgButtonX, hDlg, 100,"cowgirl", 50,50,100,100
      Dialog Show Modal hDlg Call DlgProc
   End Function

   CallBack Function DlgProc() As Long
      If Cb.Msg = %WM_Command And Cb.Ctl = 100 And _
                        Cb.CtlMsg = %BN_Clicked Then
         MsgBox "Pushed!"
      End If
   End Function 
*/

'====================================================================
' Simple modal dialog as main.
'====================================================================

$ filename "DDTequiv.exe"
'uses rtl32
'uses rtl64

'% review

uses dialogs
   
#define IDD_DLG1 1000
#define IDC_BTN1 1001

==============================================

'MAIN CODE
=============================================
 
'dim nCmdline as asciiz ptr, hInstance as sys
'&nCmdline = GetCommandLine
'hInstance = GetModuleHandle(NULL)


function DialogProc( sys hDlg, uint uMsg, sys wParam, lParam ) as int callback
  float pixelX, pixelY
 
  sys Button=GetDlgItem(hDlg, IDC_BTN1)
         
  select case uMsg
 
    case WM_INITDIALOG
       RECT rc = {0, 0, 4, 8}
       MapDialogRect (hDlg, @rc)
       PixelX = rc.right/4
       pixelY = rc.bottom/8
         
 
       int width=65*pixelX
       int height =65*pixelY
       sys hBmp=LoadImage(hDlg,"mask2.bmp",IMAGE_BITMAP, width,height, LR_LOADFROMFILE )
       SendMessage (Button, BM_SETIMAGE, IMAGE_BITMAP, hBmp)
 
      return true
 
    case WM_COMMAND
      select case loword(wParam)
        case 1001
           mbox "Pushed!"
           
        case IDCANCEL
           EndDialog( hDlg, null )
      end select
     
    case WM_CLOSE
      EndDialog( hDlg, null )
               
  end select

  return 0
end function

sub winmain()

  Dialog( 10,10,130,130, "ImgButton Test",
          WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU or DS_CENTER or DS_SETFONT,
          8,"MS Sans Serif" )
  CONTROL "IDC_BTN",IDC_BTN1,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP or BS_BITMAP or WS_DLGFRAME,32,32,65,65

  CreateModalDialog( null, @DialogProc, 0 )
end sub

winmain()