Announcement

Collapse
No announcement yet.

StatusBar trouble

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • StatusBar trouble

    Code:
    AStatusBar = {}
    AStatusBar.InitCommonControls = function()
     local lpBuff = MemoryEx.Allocate(MemoryEx.StructSize(INITCOMMONCONTROLSEX) + 100);
     if(lpBuff)then
      hStruct = MemoryEx.AssignStruct(lpBuff + 50,INITCOMMONCONTROLSEX);
      if(hStruct)then
       local ICC_BAR_CLASSES = 0x00000004;
       hStruct.dwSize = hStruct:Size();
       hStruct.dwICC = ICC_BAR_CLASSES;
      else
       MemoryEx.Free(lpBuff);
       return false, "Can't open structure"
      end
     else
      return false, "Can't create buffer"
     end
     if (Comctl32Library.InitCommonControlsEx(hStruct:GetPointer())) == 0 then
      MemoryEx.Free(lpBuff);
      hStruct:Close();
      return false, "Can't get common controls"
     else
      MemoryEx.Free(lpBuff);
      hStruct:Close();
      AToolBar.CommomCTRLS = 1;
      return true, "OK"
     end
    end;
    AStatusBar.Create = function()
      if AToolBar.CommomCTRLS ~= 1 then
       x, y = AStatusBar.InitCommonControls()
       if not x then
        return false, y
       end	
      end
      local WS_CHILD = 0x40000000;
      local STATUSCLASSNAMEA = "msctls_statusbar32";
      local WS_VISIBLE = 0x10000000;
      local SBARS_TOOLTIPS = 0x0800;
      local SBARS_SIZEGRIP = 0x100;
      local S = WS_CHILD + WS_VISIBLE + SBARS_TOOLTIPS + SBARS_SIZEGRIP
      local hWnd = Application.GetWndHandle()
      local X = User32Library.CreateWindowExA(0,STATUSCLASSNAMEA,"",S,0,0,0,0,hWnd,0,0,0)
      if X and (type(X) ~= "number") then
       return false, "Can't create tool bar"
      end
      AStatusBar.Handle = X
      return true, "OK"
    end;
    AStatusBar.SetText = function(Txt)
      if not AStatusBar.Handle then
       return false, "Not loaded"
      end
      local SB_SETTEXT = 0x40B;
      local Txt = Txt or ""
      local n = String.Length(Txt) + 1
      local t = MemoryEx.Allocate(n)
      MemoryEx.String(t, -1, MEMEX_UNICODE, Txt)
      local y = Bitwise.Or(Bitwise.ASL(0,16),0);
      local x = Bitwise.Or(Bitwise.ASL(0,16),y);
      if tonumber(User32Library.SendMessageA(AStatusBar.Handle,SB_SETTEXT,x,t)) == 0 then
       MemoryEx.Free(t);
       return false, "Can't set text"
      else
       MemoryEx.Free(t);
       return true, "OK"
      end
    end;
    calling AStatusBar.Create() will make a basic status bar with gripper but if you set the text with AStatusBar.SetText("Test") then it works but future calls to MemoryEx.Allocate fail:

    Code:
     Buff = MemoryEx.Allocate(10)
     Dialog.Message("",tostring(Buff))
    its failing because of:

    Code:
    MemoryEx.String(t, -1, MEMEX_UNICODE, Txt)
    but if it's set to:

    Code:
    MemoryEx.String(t, -1, MEMEX_ASCII, Txt)
    then future allocate calls work but obviously the text is displayed incorrectly as its not the required Unicode so the question is how do I get around this having tried already to set the StatusBar coding to ASCII with CCM_SETUNICODEFORMAT message?

  • #2
    I got it working with SB_SETTEXTA = 0x401, so anyhow I need to pass this window a integer array in a message for this function:

    http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

    How do I go about dong that? I want basically a statusbar with 4 parts with the first being text and the next two for 16x16 icons with the last just a line to separate the gripper.

    Comment


    • #3
      Never mind, I forgot a structure can be a table.

      Comment

      Working...
      X