sandyrepope
06-08-2007, 05:56
I've been trying to understand how to use bmps in labels in my scripts. I'm just not getting it. Here is what I'm trying:
uses "UI"
dim hDlg AS long
dim Msg AS LONG
dim wParam AS LONG
dim lParam AS LONG
dim Width as long '---width
dim Height as long '---height
dim hImg1 AS DWORD
dim hImg2 AS DWORD
dim hImg3 AS DWORD
dim hImg4 AS DWORD
%Label_01 = 400
%Label_02 = 401
%Label_03 = 402
%Label_04 = 404
%IMAGE_BITMAP = 0
%LR_LOADFROMFILE = &H0010
%STM_SETIMAGE = &H172
dim BITMAP1 as string = App_SourcePath + "NEW.bmp"
dim BITMAP2 as string = App_SourcePath + "OPEN.bmp"
dim BITMAP3 as string = App_SourcePath + "SAVE.bmp"
dim BITMAP4 as string = App_SourcePath + "COPY.bmp"
DECLARE FUNCTION LoadImage LIB "USER32.DLL" ALIAS "LoadImageA" (BYVAL hInst AS DWORD, lpsz AS ASCIIZ, BYVAL uType AS DWORD, BYVAL cxDesired AS LONG, BYVAL cyDesired AS LONG, BYVAL fuLoad AS DWORD) AS DWORD
Width = 150
Height = 135
DIALOG NEW 0, "Toolbar example", -1, -1, Width, Height, _
%WS_DLGFRAME _
OR %DS_CENTER _
OR %WS_CAPTION _
OR %WS_SYSMENU _
OR %WS_OVERLAPPEDWINDOW _
OR 0 TO hDlg
control add label, hDlg, %Label_01, "1", 0, 0, 16, 16, %ss_notify or %SS_ETCHEDFRAME OR %SS_CENTERIMAGE
hImg1 = LoadImage ( %NULL, BITMAP1, %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)
CONTROL SEND hDlg, %Label_01, %STM_SETIMAGE, %IMAGE_BITMAP, hImg1
control redraw hDlg, %Label_01
control add label, hDlg, %Label_02, "2", 16, 0, 16, 16, %ss_notify or %SS_ETCHEDFRAME OR %SS_CENTERIMAGE
hImg2 = LoadImage ( %NULL, BITMAP2, %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)
CONTROL SEND hDlg, %Label_02, %STM_SETIMAGE, %IMAGE_BITMAP, hImg2
control redraw hDlg, %Label_02
control add label, hDlg, %Label_03, "3", 32, 0, 16, 16, %ss_notify or %SS_ETCHEDFRAME OR %SS_CENTERIMAGE
hImg3 = LoadImage ( %NULL, BITMAP3, %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)
CONTROL SEND hDlg, %Label_03, %STM_SETIMAGE, %IMAGE_BITMAP, hImg3
control redraw hDlg, %Label_03
control add label, hDlg, %Label_04, "4", 48, 0, 16, 16, %ss_notify or %SS_ETCHEDFRAME OR %SS_CENTERIMAGE
hImg4 = LoadImage ( %NULL, BITMAP4, %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)
CONTROL SEND hDlg, %Label_04, %STM_SETIMAGE, %IMAGE_BITMAP, hImg4
control redraw hDlg, %Label_04
' ** Display the dialog
DIALOG SHOW modeless hDlg
WHILE IsWindow(hDlg)
'---Get the message and fill wParam and lParam
Msg = GetMessage(hDlg, wParam, lParam)
'---Now test the message
SELECT CASE Msg
case %WM_COMMAND
'---Test which control has been clicked
SELECT CASE lowrd(wParam)
case %Label_01
select case HIwrd(wParam)
case %CBN_SELCHANGE
msgbox 0, "You clicked the NEW button"
end select
'---Something has happened with %Combo02
case %Label_02
select case HIwrd(wParam)
case %CBN_SELCHANGE
msgbox 0, "You clicked the OPEN button"
end select
CASE %Label_03
SELECT CASE HIWRD(wParam)
case %CBN_SELCHANGE
msgbox 0, "You clicked the SAVE button"
end select
CASE %Label_04
SELECT CASE HIWRD(wParam)
case %CBN_SELCHANGE
msgbox 0, "You clicked the COPY button"
end select
end select
CASE %WM_SYSCOMMAND
select case wParam
CASE %SC_CLOSE
EXIT WHILE
end select
end select
wend
DIALOG END hDlg
Everything works except for the bmps. They just won't show in the labels. There are a few things that I don't understand in the script.
Can someone help me with this?
Thanks
Sandy
uses "UI"
dim hDlg AS long
dim Msg AS LONG
dim wParam AS LONG
dim lParam AS LONG
dim Width as long '---width
dim Height as long '---height
dim hImg1 AS DWORD
dim hImg2 AS DWORD
dim hImg3 AS DWORD
dim hImg4 AS DWORD
%Label_01 = 400
%Label_02 = 401
%Label_03 = 402
%Label_04 = 404
%IMAGE_BITMAP = 0
%LR_LOADFROMFILE = &H0010
%STM_SETIMAGE = &H172
dim BITMAP1 as string = App_SourcePath + "NEW.bmp"
dim BITMAP2 as string = App_SourcePath + "OPEN.bmp"
dim BITMAP3 as string = App_SourcePath + "SAVE.bmp"
dim BITMAP4 as string = App_SourcePath + "COPY.bmp"
DECLARE FUNCTION LoadImage LIB "USER32.DLL" ALIAS "LoadImageA" (BYVAL hInst AS DWORD, lpsz AS ASCIIZ, BYVAL uType AS DWORD, BYVAL cxDesired AS LONG, BYVAL cyDesired AS LONG, BYVAL fuLoad AS DWORD) AS DWORD
Width = 150
Height = 135
DIALOG NEW 0, "Toolbar example", -1, -1, Width, Height, _
%WS_DLGFRAME _
OR %DS_CENTER _
OR %WS_CAPTION _
OR %WS_SYSMENU _
OR %WS_OVERLAPPEDWINDOW _
OR 0 TO hDlg
control add label, hDlg, %Label_01, "1", 0, 0, 16, 16, %ss_notify or %SS_ETCHEDFRAME OR %SS_CENTERIMAGE
hImg1 = LoadImage ( %NULL, BITMAP1, %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)
CONTROL SEND hDlg, %Label_01, %STM_SETIMAGE, %IMAGE_BITMAP, hImg1
control redraw hDlg, %Label_01
control add label, hDlg, %Label_02, "2", 16, 0, 16, 16, %ss_notify or %SS_ETCHEDFRAME OR %SS_CENTERIMAGE
hImg2 = LoadImage ( %NULL, BITMAP2, %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)
CONTROL SEND hDlg, %Label_02, %STM_SETIMAGE, %IMAGE_BITMAP, hImg2
control redraw hDlg, %Label_02
control add label, hDlg, %Label_03, "3", 32, 0, 16, 16, %ss_notify or %SS_ETCHEDFRAME OR %SS_CENTERIMAGE
hImg3 = LoadImage ( %NULL, BITMAP3, %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)
CONTROL SEND hDlg, %Label_03, %STM_SETIMAGE, %IMAGE_BITMAP, hImg3
control redraw hDlg, %Label_03
control add label, hDlg, %Label_04, "4", 48, 0, 16, 16, %ss_notify or %SS_ETCHEDFRAME OR %SS_CENTERIMAGE
hImg4 = LoadImage ( %NULL, BITMAP4, %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)
CONTROL SEND hDlg, %Label_04, %STM_SETIMAGE, %IMAGE_BITMAP, hImg4
control redraw hDlg, %Label_04
' ** Display the dialog
DIALOG SHOW modeless hDlg
WHILE IsWindow(hDlg)
'---Get the message and fill wParam and lParam
Msg = GetMessage(hDlg, wParam, lParam)
'---Now test the message
SELECT CASE Msg
case %WM_COMMAND
'---Test which control has been clicked
SELECT CASE lowrd(wParam)
case %Label_01
select case HIwrd(wParam)
case %CBN_SELCHANGE
msgbox 0, "You clicked the NEW button"
end select
'---Something has happened with %Combo02
case %Label_02
select case HIwrd(wParam)
case %CBN_SELCHANGE
msgbox 0, "You clicked the OPEN button"
end select
CASE %Label_03
SELECT CASE HIWRD(wParam)
case %CBN_SELCHANGE
msgbox 0, "You clicked the SAVE button"
end select
CASE %Label_04
SELECT CASE HIWRD(wParam)
case %CBN_SELCHANGE
msgbox 0, "You clicked the COPY button"
end select
end select
CASE %WM_SYSCOMMAND
select case wParam
CASE %SC_CLOSE
EXIT WHILE
end select
end select
wend
DIALOG END hDlg
Everything works except for the bmps. They just won't show in the labels. There are a few things that I don't understand in the script.
Can someone help me with this?
Thanks
Sandy