Loading ...
Sorry, an error occurred while loading the content.

Re: [libertybasic] How to display a bitmap in a statusbar???

Expand Messages
  • Stefan Pendl
    ... The example below uses the resize handler to update the size of the status bar and to set some text. Its a bit clumsy, but for testing things out its good
    Message 1 of 3 , May 7, 2012
    • 0 Attachment
      Am 07.05.2012 20:03, schrieb Stefan Pendl:
      > Am 11.04.2012 04:14, schrieb Fabio:
      >> Hi Folks,
      >>
      >> I would like to display a bitmap in a statusbar. Does anybody know how to achieve this result with Liberty Basic? Hunting high and low on the Net I read tons of docs and finally I tried the following but it does not work. Any suggestion would be greatly appreciated...
      >>
      >
      > You can't display a bitmap, you can only display a real icon.
      >
      > The example below displays the LB icon from the LB executable.
      >

      The example below uses the resize handler to update the size of the
      status bar and to set some text.

      Its a bit clumsy, but for testing things out its good enough.


      '---code start (watch for line wraps)

      nomainwin
      open "Status Bar Test" for window as #m
      #m "trapclose [quit]"
      #m "resizehandler [resizer]"

      calldll #comctl32, "InitCommonControls", _
      result as void

      style = _WS_CHILD or _WS_VISIBLE
      lpszText$ = "Test Icon"
      hwndParent = hwnd(#m)
      wID = 500

      calldll #comctl32, "CreateStatusWindowA", _
      style as long, _
      lpszText$ as ptr, _
      hwndParent as ulong, _
      wID as ulong, _
      hwndStatus as ulong

      struct parts, part1 as long, part2 as long
      parts.part1.struct = 150
      parts.part2.struct = -1

      numParts = 2
      SB.SETPARTS = 1028

      calldll #user32, "SendMessageA", _
      hwndStatus as ulong, _
      SB.SETPARTS as long, _
      numParts as long, _
      parts as struct, _
      result as long

      ' get the handle of the current executable
      calldll #kernel32, "GetModuleHandleA", _
      _NULL as ulong, _
      hinst as ulong

      ' load the icon resource with ID 1
      IMAGE.ICON = 1
      lpszName = 1
      cxDesired = 16
      cyDesired = cxDesired

      calldll #user32, "LoadImageA", _
      hinst as ulong, _
      lpszName as ulong, _
      IMAGE.ICON as ulong, _
      cxDesired as long,_
      cyDesired as long, _
      fuLoad as ulong, _
      hIcon as ulong

      ' place the icon in the second part
      part = 1
      SB.SETICON = 1039

      calldll #user32, "SendMessageA", _
      hwndStatus as ulong, _
      SB.SETICON as long, _
      part as long, _
      hIcon as ulong, _
      result as long
      wait

      [resizer]
      calldll #user32, "SendMessageA", _
      hwndStatus as ulong, _
      _WM_SIZE as long, _
      0 as long, _
      0 as long, _
      result as long

      SB.SETTEXT = 1025
      part = 1
      newText$ = "Window Size = "; WindowWidth; "x"; WindowHeight

      calldll #user32, "SendMessageA", _
      hwndStatus as ulong, _
      SB.SETTEXT as long, _
      part as long, _
      newText$ as ptr, _
      result as long
      wait

      [quit]
      close #m

      ' free memory from icon
      calldll #user32, "DestroyIcon", _
      hIcon as ulong, _
      result as long
      end

      '---code end

      --
      Stefan Pendl
      http://stefanpendl.runbasichosting.com/

      LB 4.04 Pro ... http://www.libertybasic.com/assist.html
      LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe

      LB Community Wiki .............. http://basic.wikispaces.com/
      LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
      LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/

      Books at http://www.lulu.com/ and http://www.amazon.com/
      Alyce Watson ... APIs for Liberty BASIC
      Carl Gundel .... Beginning Programming with Liberty BASIC

      Windows 7 Home Premium 64-bit SP1
      AMD Turion X2 RM-70 2GHz, 4GB RAM
    Your message has been successfully submitted and would be delivered to recipients shortly.