Author Topic: What is the equivalent for PB IMGBUTTONX ?  (Read 2851 times)

0 Members and 2 Guests are viewing this topic.

chrisc

  • Guest
Re: What is the equivalent for PB IMGBUTTONX ?
« Reply #15 on: March 16, 2018, 08:33:09 AM »
Hello Roland
maybe the below is the correct way, i replaced one line as below

Code: [Select]
  '     hBmp=LoadImage(hInstance, IDB_BITMAP, IMAGE_BITMAP, width,height, 0 )
hBmp = LoadImage(GetModuleHandle(BYVAL  NULL), IDB_BITMAP, IMAGE_BITMAP, width,height,0)

and it works perfectly except i use my own icon instead of oxicon.ico
see the attached image

chrisc

  • Guest
Re: What is the equivalent for PB IMGBUTTONX ?
« Reply #16 on: March 16, 2018, 08:35:13 AM »
the adjusted code is as below
please check if i had done it right, Thanxx Roland

Code: [Select]
'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 "ImgButtonX.exe"

'use rtl32
use rtl64

'% review

uses dialogs
'namespace

% DS_CENTER=0x0800
% LR_LOADFROMFILE=0x0010
% IMAGE_BITMAP=0
% ICON_BIG=1
% WM_SETICON=0x80

! GetDlgItem lib "user32.dll" (sys hDlg, int nIDDlgItem) as sys
! MapDialogRect lib "user32.dll" (sys hDlg, lpRect) as bool

#define IDD_DLG1 1000
#define IDC_BTN1 1001

% IDI_APPICON=500
% IDB_BITMAP =501

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

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

'init_common_controls()

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
       sys AppIcon = LoadIcon(hInstance, IDI_APPICON)
       'Set Icon to Main Window
       SendMessage(hDlg, WM_SETICON, ICON_BIG, AppIcon)
   
       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

                             ' LR_DEFAULTCOLOR
'       hBmp=LoadImage(hDlg,"cowgirl.bmp",IMAGE_BITMAP, width,height, LR_LOADFROMFILE )
  '     hBmp=LoadImage(hInstance, IDB_BITMAP, IMAGE_BITMAP, width,height, 0 )
hBmp = LoadImage(GetModuleHandle(BYVAL  NULL), IDB_BITMAP, IMAGE_BITMAP, width,height,0)
     
 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()

  sys lpdt
 
  'provide memory for DLGTEMPLATE structure etc   
  dyn::init(lpdt) '1024

  Dialog( 1,  10,10,130,130, "ImgButton Test", lpdt,
          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
  CONTROL "IDC_BTN", IDC_BTN1,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP or BS_LEFT or BS_PUSHBUTTON or WS_DLGFRAME,32,32,65,65

  CreateModalDialog( null, @DialogProc, 0, lpdt )
end sub

winmain()


Karen Zibowski

  • Guest
Re: What is the equivalent for PB IMGBUTTONX ?
« Reply #17 on: March 17, 2018, 07:39:10 AM »
Many Thanks Arnold

I believe that Chris got it corrected.