Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Loadbitmapfromresource
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Loadbitmapfromresource

 Post Reply Post Reply
Author
Message
WaleedSeada View Drop Down
Groupie
Groupie
Avatar

Joined: 29 March 2007
Location: Egypt
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote WaleedSeada Quote  Post ReplyReply Direct Link To This Post Topic: Loadbitmapfromresource
    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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 16 March 2008 at 3:12pm
Hi,
 
Use ImageMaanger control instead. Add ImageManager to form, show properties and add icons you need.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
ijwelch View Drop Down
Senior Member
Senior Member


Joined: 20 June 2006
Status: Offline
Points: 262
Post Options Post Options   Thanks (0) Thanks(0)   Quote ijwelch Quote  Post ReplyReply Direct Link To This Post Posted: 16 March 2008 at 11:04pm
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

Back to Top
WaleedSeada View Drop Down
Groupie
Groupie
Avatar

Joined: 29 March 2007
Location: Egypt
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote WaleedSeada Quote  Post ReplyReply Direct Link To This Post Posted: 18 March 2008 at 3:05am

Thanks ijwelch, VB examples can always help.

 
again thanks for your reply.
Best,
:Powerbuilder 10.5
:Codejock suite 11.2.2
=========================
Waleed Seada
Back to Top
WaleedSeada View Drop Down
Groupie
Groupie
Avatar

Joined: 29 March 2007
Location: Egypt
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote WaleedSeada Quote  Post ReplyReply Direct Link To This Post Posted: 12 April 2008 at 9:46am
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
Back to Top
WaleedSeada View Drop Down
Groupie
Groupie
Avatar

Joined: 29 March 2007
Location: Egypt
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote WaleedSeada Quote  Post ReplyReply Direct Link To This Post Posted: 12 April 2008 at 12:19pm

Thanks Guys, I mange to solve that issue ..

 

Best regards,

:Powerbuilder 10.5
:Codejock suite 11.2.2
=========================
Waleed Seada
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.484 seconds.