You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
I'm using bitmaps as buttons in my latest project. The bitmaps are applied to the dialog using GRAPHIC RENDER. I would like to map a text legend on to the bitmaps in such a way that it looks like the text is part of the bitmap. Is this possible? If so, a piece of sample code would be greatly appreciated.
Maybe this is the kind of thing you were after?
I've added code for an 'image button' for comparison. Maybe you have code to alter the graphic control so it reacts to being clicked - to give the user visual feedback like a 'normal' button does?
Probably you would have to subclass the control and redraw on Button Down / Button Up events..
Code:
#Dim All
#Register None
#Compile Exe
#Include "WIN32API.INC"
%GFX_Button1 = 102
%IMG_Button2 = 103
'------------------/
CallBack Function DlgProc() As Long
Select Case CbMsg
Case %WM_InitDialog
Static hBmp1, hBmp2, hBmp3, hFont1 As Dword
Font New "Arial", 18, 1, 0, 0, 0 To hFont1
' Using 'Render'
Graphic Bitmap New 128, 128 To hBmp1 ' Create memory bitmap
Graphic Attach hBmp1, 0
Graphic Set Font hFont1
Graphic Render "C:\Windows\Gone Fishing.bmp", (0,0)-(128,128) ' render image into bitmap
Graphic Set Pos (12, 45)
Graphic Color %BLACK, -2
Graphic Print "Button 1" ' print onto it
Graphic Attach CbHndl, %GFX_Button1
Graphic Copy hBmp1, 0 ' copy to the graphic control
' Using 'Load'
Graphic Bitmap Load "C:\Windows\Gone Fishing.bmp", 128, 128 TO hBmp2 ' Load memory bitmap
Graphic Attach hBmp2, 0
Graphic Set Font hFont1
Graphic Set Pos (12, 45)
Graphic Color %BLACK, -2
Graphic Print "Button 2" ' print onto it
Graphic Save "Temp2.bmp" ' Save modified image to temp file
hBmp3 = LoadImage(0, "Temp2.bmp", %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)
Control Send CbHndl, %IMG_Button2, %BM_SETIMAGE, %IMAGE_BITMAP, hBmp3 ' copy to button
Case %WM_Command
Select Case CbCtl
Case %GFX_Button1
If CbCtlMsg = %BN_Clicked Or CbCtlMsg = 1 Then
MsgBox "Button1 clicked!"
End If
Case %IMG_Button2
If CbCtlMsg = %BN_Clicked Or CbCtlMsg = 1 Then
MsgBox "Button2 clicked!"
End If
Case %IDCANCEL
If CbCtlMsg = %BN_Clicked Or CbCtlMsg = 1 Then
Dialog End CbHndl, 0
End If
End Select
Case %WM_Destroy
Graphic Attach hBmp1, 0
Graphic Bitmap End
Graphic Attach hBmp2, 0
Graphic Bitmap End
Kill "Temp2.bmp"
End Select
End Function
'------------------/DlgProc
Function PBMain() As Long
Local hDlg As Dword
Dialog New Pixels, 0, "GFX Button Test", , , 360, 250, %WS_OVERLAPPEDWINDOW, To hDlg
Control Add Button, hDlg, %IDCANCEL, "Exit", 280, 215, 75, 25
Control Add Graphic, hDlg, %GFX_Button1, "", 40, 15, 128, 128, %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR _
%SS_NOTIFY, %WS_EX_STATICEDGE 'OR %WS_EX_CLIENTEDGE
Control Add Button, hDlg, %IMG_Button2, "", 190, 15, 128, 128, %BS_BITMAP ' BitMap style
Dialog Show Modal hDlg, Call DlgProc
End Function
'------------------/PBMain
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment