用c# .net compact 编wince界面程序,因为compact版本的控件statusbar的状态栏只支持一个栏,不支持多栏目,而项目实际需要分成5个栏,所以先用API,查了可通过发SB_SETPARTS消息来设置,但小弟新手,不知如何编写,希望各位帮忙,能提供个代码的例子,谢谢!下面为MSDN上关于SB_SETPARTS的描述:
http://msdn.microsoft.com/en-us/library/ms932515.aspx
Send Feedback
This message sets the number of parts in a status window and the coordinate of the right edge of each part.
SB_SETPARTS wParam = (WPARAM) nParts; 
  lParam = (LPARAM)(LPINT) aWidths;
Parameters
nParts
Number of parts to set (cannot be greater than 255).
aWidths
Address of an integer array that has the same number of elements as parts specified by nParts. Each element in the array specifies the position, in client coordinates, of the right edge of the corresponding part. If an element is –1, the position of the right edge for that part extends to the right edge of the window.
Return Values
TRUE indicates success. FALSE indicates failure.APIC#WinCESB_SETPARTS

解决方案 »

  1.   

    int widths[] = { 10, 10, 10 };
    SendMessage(状态栏句柄, SB_SETPARTS, (WPARAM)3, (LPARAM)(LPINT)&widths[0]);
      

  2.   

    我按如下的代码为什么编译提示“无法找到 PInvoke DLL“user32.dll”        [DllImport("user32.dll", EntryPoint = "SendMessage")]
            public static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int[] lParam);
            public const int WM_USER = 0x0400;
            public const int SB_SETPARTS = WM_USER + 4;        //调用
            int[] widths = { 150, 300, 400, -1 };
            SendMessage(this.statusBar1.Handle, SB_SETPARTS, 3, widths);
      

  3.   

    多谢版主,原来在wince中是coredll.dll中。
    修改完,第一栏有按设置宽度显示,但是后面2个栏没有分开显示出来,不知什么原因。
            
    [DllImport("coredll.Dll")]
    public static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int[] lParam);
    public const int WM_USER = 0x0400;
    public const int SB_SETPARTS = WM_USER + 4;int[] widths = { 200, 100, 100, -1 };
    SendMessage(this.statusBar1.Handle, SB_SETPARTS, 3, widths);