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?
spiral2007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.