• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 552
  • Last Modified:

button text wrap in wm 5

Hello people,
I'm developing a Windows Mobile 5 Application using Visual Studio 2008 and VB.NET.
I hava a button on a panel and I want to wrap button's text into two lines.
I've tried using Environment.NewLine and vbCrLf but none of these worked.
How can I do it?
0
spiral2007
Asked:
spiral2007
  • 3
  • 3
1 Solution
 
alexey_gusevCommented:
use the following code (it's in c# but easily converted to vb.net if you like (eg at developerfusion.com).

one you've defined all P/Invoke stuff, a small function below allows you set it right:

        private void setControlStyle(Control control, UInt32 newStyle)
        {
            UInt32 style = Win32Helper.GetWindowLong(control.Handle, (int)Win32Helper.ControlFieldOffsets.GWL_STYLE);
            Win32Helper.SetWindowLong(control.Handle, (int)Win32Helper.ControlFieldOffsets.GWL_STYLE, style | newStyle);
        }

        public const uint BS_MULTILINE          = 0x00002000;

        public enum ControlFieldOffsets
        {
            GWL_WNDPROC = (-4),
            GWL_HINSTANCE = (-6),
            GWL_HWNDPARENT = (-8),
            GWL_STYLE = (-16),
            GWL_EXSTYLE = (-20),
            GWL_USERDATA = (-21),
            GWL_ID = (-12)
        }

        [DllImport("coredll.dll")]
        public static extern UInt32 GetWindowLong(IntPtr hWnd, int nIndex);
        [DllImport("coredll.dll")]
        public static extern UInt32 SetWindowLong(IntPtr hWnd, int nIndex, UInt32 dwNewLong);

Open in new window

0
 
spiral2007Author Commented:
hello alexey_qusev,
can you tell me where to put this code?
0
 
alexey_gusevCommented:
you can put it in the form where you have your buttons or (if you want to use it in multiple forms) create separate class, add there all the code from the snippet (as I did and called it Win32Helper). then add the function (setControlStyle ) eg to your form class
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
spiral2007Author Commented:
how can i call this function?

eg

dim myButton as button
setControlStyle(myButton, ??)


thanks!
0
 
alexey_gusevCommented:
BS_MULTILINE (or YourHelperClass.BS_MULTILINE) as the last parameter

for myButton, you would use the actual control, not just uninitialized button
0
 
spiral2007Author Commented:
thank you !!

0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now