compact framework - Toolbar button sizes in windows mobile 6.5.3


Question: 

We have a VB.net CF2.0 Apllication that up until now has run on windows mobile platforms from 2003 to 6.0 without any major issues. Our current team use HP iPAQ devices running winodws 6.0 and everything runs fine. There is a good, hardware related reson why we use these devices.

We are looking to update the hardware to motorola hardware running windows mobile 6.5.3 and here in lies the problem. There is a toolbar at the bottom of the application window. This toolbar is made up of several image toolbar buttons that are shown and hidden depending on the functionality of the current screen. On devices up to windows 6.0 all is fine but on windows 6.5.3 it all goes wrong. The toolbar images reamin the same size as always but the clickable area of the button suddenly has become much larger than the image pushing some buttons off the right edge of the screen. You can clearly see when you click the button a large white rectangle much larger than the 40x40 image. this rectangle shows that the control is now much larger than it should be. There doesn't see to be any way to resize this easily. This same effect happens when using the windows 6.5 vga emulator.

I've found the same issue reported by some others online but I couldn't find a suitable solution. Surely this should be simple?

the toolbar is a user control that inherits from System.Windows.Forms.ToolBar and implements a couple of our interfaces (they are very simple and won't affect sizing) and the toolbarbuttons are created directly as New System.Windows.Forms.ToolBarButton and added to the toolbar using .Buttons.Add(...). The images are stored in a System.Windows.Forms.ImageList type. Sizing is applied to the images proportionate to the screen resolution.

All of the above works fine until it is run under 6.5.3. Has anyone come up with a suitable solution to this? Preferrably without rewriting the toolbar code.

thanks in anticipation




1 Answer: 

I solved this by resizing toolbar after creating it.

NativeMethods.SendMessage(toolBar1.Handle, NativeMethods.TB_SETBUTTONSIZE, 0, NativeMethods.MakeLParam(toolBar1.ImageList.ImageSize.Width, toolBar1.ImageList.ImageSize.Height));

   public static class NativeMethods
    {
        public const int TB_GETBUTTONSIZE = 0x43a;
        public const int TB_SETBUTTONSIZE = 0x41f;
        public const int TB_AUTOSIZE = 0x421;
        public const int TB_SETBITMAPSIZE = 0x420;
        public const int TB_SETBUTTONWIDTH = 0x43b;

        public static int MakeLParam(int LoWord, int HiWord)
        {
            return (int)((HiWord << 16) | (LoWord & 0xffff));
        }

        [DllImport("coredll.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);


    }

At some point toolbar is autosized again, so i have to call this method in Form Activated event. I don't think its the best way to solve this, but at least it worked for me.

 

More Articles


c++ - MFC: How to save the position of toolbars in the legacy MFC ver 6?

I have a striking question: How to save the position of toolbars in the legacy MFC ver 6?I can't use CWinApp::SaveBarState because not all toolbars exist at the moment this function would be called (causing it to assert). Instead, I instantiate the toolbars depending on what kind of document is load

android - Different toolbar for each fragment in navigation drawer

I have a MainActivity which has a NavigationDrawer. This NavigationDrawer is Synced with the Toolbar initially. And i want to use the Only one NavigationDrawer across the whole Application. Now the Problem is that each fragment has the different toolbar or CollapsingToolbar.I already read the same

Smooth keydown animation on Canvas in JavaScript

I'm very new to programming and I'm trying to create some code that will allow me to move a square around the Canvas by pressing arrow keys. I'm able to get the square to move, but its motion isn't very smooth. I have it moving by increments of 10 pixels at a time, so I understand why it feels kind


android - hide toolbar when collapsing collapsingtoobarlayout

What I am trying to achieve is hide the collapsingtoolbarlayout when scrolling my recyclerview and collapse the maintoolbar if scrolled further. but I can achieve only upto this http://i.imgur.com/t6wTW5H.gif.<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="htt

javascript - get a smooth animation for a canvas game

How to get a better animation, dinamically, even when browser is busy or idle, for different devices which have different hardware capacity.I have tried many ways and still cannot find the right way to make the game to display a better animation.This is what i tried:var now;var then = Date.now();var

wpf - Giving a stackPanel the same LinearGradientBrush as the toolbar has by default

I have two ToolBars side by side (I had to do that so I could align buttons right and left)But now, I have to add some text that can be aligned right left or center between both toolbars. I added the text in a TextBlock inside a StackPanel disposed on a Grid at the second position (between the toolb


formatting - Excel 2007 floating format toolbar customisation

Is it possible in Excel 2007 to customise the floating format bar that is shown when you right-click on a cell? To avoid confusion, I don't mean the "Cell" commandbar menu, but the second floating toolbar with formatting buttons.e.g. is it possible to add a Styles dropdown, or have any other text al

jquery - CSS for toolbar with UI Slider centered between left and right buttons

I'm attempting to create a 100% width toolbar. This toolbar needs to have a variable number of buttons aligned to the left side, as well as a variable number of buttons aligned to the right. That's the easy part.But now I want to put a jQuery UI slider in the center that takes up the full remaining

WPF c# window navigation

i got 2 window , i want to navigate from one another but i when i debug it , it shows that nav is null , why is that so? Does it suppose to be null? because i used the same way to navigate in the past and it work and i try it now , it doesn't work. But if i put nav == null , it says nav.Navigate(n

android - Horizontal and Vertical linear layout inside a scroll view

I am trying to get a combination of Views established. They must constantly have a Button and Edittext box at the top horizontally next to each other and below that a vertical list of Textviews. The vertical list should be enclosed in a ScrollView to allow the user to scroll down through the TextVie