Loadbitmapfromresource |
Post Reply |
Author | |
WaleedSeada
Groupie Joined: 29 March 2007 Location: Egypt Status: Offline Points: 88 |
Post Options
Thanks(0)
Posted: 16 March 2008 at 10:23am |
Hello All,
I want to implement the loadbitmapfrom resource, but i can't get it to work.
can anyone paste a sample of the script to do that.
Best regards
|
|
:Powerbuilder 10.5
:Codejock suite 11.2.2 ========================= Waleed Seada |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Use ImageMaanger control instead. Add ImageManager to form, show properties and add icons you need.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
ijwelch
Senior Member Joined: 20 June 2006 Status: Offline Points: 262 |
Post Options
Thanks(0)
|
Hi, here's VB6 code:
This in new class named CResource: Option Explicit Private Const ERR_BASE As Long = 3375 Private Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000 Private Const FORMAT_MESSAGE_IGNORE_INSERTS = &H200 Private Declare Function FormatMessage _ Lib "kernel32" _ Alias "FormatMessageA" (ByVal dwFlags As Long, _ lpSource As Any, _ ByVal dwMessageId As Long, _ ByVal dwLanguageId As Long, _ ByVal lpBuffer As String, _ ByVal nSize As Long, _ Arguments As Long) As Long Private Declare Function LoadLibraryEx _ Lib "kernel32" _ Alias "LoadLibraryExA" (ByVal lpLibFileName As String, _ ByVal hFile As Long, _ ByVal dwFlags As Long) As Long Private Declare Function FreeLibrary _ Lib "kernel32" (ByVal hLibModule As Long) As Long Private m_sFileName As String Private m_hMod As Long Public Property Get Filename() As String Filename = m_sFileName End Property Public Property Let Filename(ByVal sFileName As String) Init sFileName End Property Public Property Get hModule() As Long hModule = m_hMod End Property Public Function Init(ResourceFile As String) As Boolean On Error GoTo ErrHandler pClearUp m_sFileName = ResourceFile If Not (m_sFileName = "") Then m_hMod = LoadLibraryEx(m_sFileName, 0, 0) If (m_hMod = 0) Then Err.Raise vbObjectError + 1048 + 1, "CResource", pWinError( _ Err.LastDllError) Init = False Else Init = True End If End If Exit Function ErrHandler: Err.Raise vbObjectError + ERR_BASE, "CResource.Init", _ "CResource component failure in Function Init" End Function Private Sub Class_Terminate() pClearUp End Sub Private Sub pClearUp() On Error Resume Next If (m_hMod <> 0) Then FreeLibrary m_hMod End If m_hMod = 0 m_sFileName = "" End Sub Private Function pWinError(ByVal lLastDLLError As Long) As String On Error Resume Next Dim sBuff As String Dim lCount As Long sBuff = String$(256, 0) lCount = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM Or _ FORMAT_MESSAGE_IGNORE_INSERTS, 0, lLastDLLError, 0&, sBuff, Len( _ sBuff), ByVal 0) If lCount Then pWinError = Left$(sBuff, lCount) End If End Function Then use it with code like this: Private Sub pLoadResources() Dim IDS() As Long Dim oRes As CResource ReDim IDS(7) IDS(0) = ID_VIEWTHUMBS IDS(1) = ID_VIEWICONS IDS(2) = ID_VIEWSMALLICONS IDS(3) = ID_VIEWLIST IDS(4) = ID_VIEWDETAILS IDS(5) = ID_SHOWGROUPS IDS(6) = ID_ARROWDOWN IDS(7) = ID_ARROWUP Set oRes = New CResource oRes.Init "C:\The path to MyResourceDLL.dll" ImageManager1.Icons.LoadBitmapFromResource oRes.hModule, 1000, IDS(), xtpImageNormal Set oRes = Nothing End Sub |
|
WaleedSeada
Groupie Joined: 29 March 2007 Location: Egypt Status: Offline Points: 88 |
Post Options
Thanks(0)
|
:Powerbuilder 10.5
:Codejock suite 11.2.2 ========================= Waleed Seada |
|
WaleedSeada
Groupie Joined: 29 March 2007 Location: Egypt Status: Offline Points: 88 |
Post Options
Thanks(0)
|
Hello ijwelch,
Thanks for your example, I try to load one bitmap and it shown okay, when I try to load another one the commandbar doesn't show any image;
here is the code I have:
Dim MainModulesIDs(), SubModulesIDs() As Long
Dim oRes As CResource Set oRes = New CResource
oRes.Init App.Path & "\xxxxx.DLL" ReDim MainModulesIDs(16)
MainModulesIDs(0) = ID_1 MainModulesIDs(1) = ID_2
MainModulesIDs(2) = ID_3 and so on ....
CommandBars.Icons.LoadBitmapFromResource oRes.hModule, 1000, MainModulesIDs(), xtpImageNormal
(this went fine for the first time) ReDim SubModulesIDs(8)
SubModulesIDs(0) = ID_10 SubModulesIDs(1) = ID_11 SubModulesIDs(2) = ID_12 and so on ... CommandBars.Icons.LoadBitmapFromResource oRes.hModule, 1001, SubModulesIDs(), xtpImageNormal
the only difference is that I added then to the commandbars.icons not to the ImageManager ...
any ideas ...
Best regards,
|
|
:Powerbuilder 10.5
:Codejock suite 11.2.2 ========================= Waleed Seada |
|
WaleedSeada
Groupie Joined: 29 March 2007 Location: Egypt Status: Offline Points: 88 |
Post Options
Thanks(0)
|
Thanks Guys, I mange to solve that issue ..
Best regards, |
|
:Powerbuilder 10.5
:Codejock suite 11.2.2 ========================= Waleed Seada |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |