Solved

Resizing Menus List boxes

Posted on 1998-03-19
4
278 Views
Last Modified: 2013-12-03
I need to create screens to use on a touch screen.  I want to create menus and list boxes in the editor that are larger.  I tried changing the font, but the size seems to only change at run time, which makes it difficult to design the screen.  I also couldn't seem to change the font in the menu.  Any Help?
0
Comment
Question by:bradyd
  • 2
4 Comments
 
LVL 2

Expert Comment

by:marti
ID: 1459466
If you want to shange menu's font you have to do that for the entire system using control panel or desktop properties. Tthe listbox width doesn't chahge when the font is changed. The listbox height always match the exact number of rows.
Hope this will help.
0
 

Author Comment

by:bradyd
ID: 1459467
I didn't want to change the font for the entire system.  I have a status bar that I would like to remain at a smaller, different font
0
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 50 total points
ID: 1459468
Then you'll have to create owner draw menus. You'll have to intercept WM_MEASUREITEM message to set a different size, and WM_DRAWITEM to draw the menu:

Dim hProc as long
hProc = SetWindowLong(me.hwnd, GWL_WNDPROC, AddressOf WindowProc)

'In a module
Function WindowProc(hwnd as long, uMsg as long, wParam as long, lParam as long) as long
''Draw the menu here

WindowProc=CallWindowProc(hProc, hwnd, umsg, wparam, lparam)
End Function

-----------------------------------------------------------------
Here is info about WM_DRAWITEM and WM_MEASUREITEM
-----------------------------------------------------------------

 
The WM_DRAWITEM message is sent to the owner window of an owner-drawn button, combo box, list box, or menu when a visual aspect of the button, combo box, list box, or menu has changed.
 
WM_DRAWITEM
idCtl = (UINT) wParam;             // control identifier
lpdis = (LPDRAWITEMSTRUCT) lParam; // item-drawing information
 
 
Parameters
idCtl
Value of wParam. Specifies the identifier of the control that sent the WM_DRAWITEM message. If the message was sent by a menu, this parameter is zero.
lpdis
Value of lParam. Points to a DRAWITEMSTRUCT structure containing information about the item to be drawn and the type of drawing required.
Return Values
If an application processes this message, it should return TRUE.
Default Action
The DefWindowProc function draws the focus rectangle for an owner-drawn list box item.
Remarks
The itemAction member of the DRAWITEMSTRUCT structure specifies the drawing operation that an application should perform.
Before returning from processing this message, an application should ensure that the device context identified by the hDC member of the DRAWITEMSTRUCT structure is in the default state.
See Also
DefWindowProc, DRAWITEMSTRUCT

 
 
The DRAWITEMSTRUCT structure provides information the owner window must have to determine how to paint an owner-drawn control or menu item. The owner window of the owner-drawn control or menu item receives a pointer to this structure as the lParam parameter of the WM_DRAWITEM message.
 
typedef struct tagDRAWITEMSTRUCT {  // dis
    UINT  CtlType;
    UINT  CtlID;
    UINT  itemID;
    UINT  itemAction;
    UINT  itemState;
    HWND  hwndItem;
    HDC   hDC;
    RECT  rcItem;
    DWORD itemData;
} DRAWITEMSTRUCT;
 
 
Members
CtlType
Specifies the control type. This member can be one of the following values:
 
Value      Meaning

ODT_BUTTON      Owner-drawn button
ODT_COMBOBOX      Owner-drawn combo box
ODT_LISTBOX      Owner-drawn list box
ODT_LISTVIEW      List view control
ODT_MENU      Owner-drawn menu item
ODT_STATIC      Owner-drawn static control
ODT_TAB      Tab control
CtlID
Specifies the identifier of the combo box, list box, button, or static control. This member is not used for a menu item.
itemID
Specifies the menu item identifier for a menu item or the index of the item in a list box or combo box. For an empty list box or combo box, this member can be -1. This allows the application to draw only the focus rectangle at the coordinates specified by the rcItem member even though there are no items in the control. This indicates to the user whether the list box or combo box has the focus. How the bits are set in the itemAction member determines whether the rectangle is to be drawn as though the list box or combo box has the focus.
itemAction
Specifies the drawing action required. This member can be one or more of the following values:
 
Value      Meaning

ODA_DRAWENTIRE      The entire control needs to be drawn.
ODA_FOCUS      The control has lost or gained the keyboard focus. The itemState member should be checked to determine whether the control has the focus.
ODA_SELECT      The selection status has changed. The itemState member should be checked to determine the new selection state.
itemState
Specifies the visual state of the item after the current drawing action takes place. This member can be a combination of the following values:
 
Value      Meaning

ODS_CHECKED      The menu item is to be checked. This bit is used only in a menu.
ODS_COMBOBOXEDIT      The drawing takes place in the selection field (edit control) of an ownerdrawn combo box.
ODS_DEFAULT      The item is the default item.
ODS_DISABLED      The item is to be drawn as disabled.
ODS_FOCUS      The item has the keyboard focus.
ODS_GRAYED      The item is to be grayed. This bit is used only in a menu.
ODS_SELECTED      The menu item's status is selected.
hwndItem
Identifies the control for combo boxes, list boxes, buttons, and static controls. For menus, this member identifies the menu containing the item.
hDC
Identifies a device context; this device context must be used when performing drawing operations on the control.
rcItem
Specifies a rectangle that defines the boundaries of the control to be drawn. This rectangle is in the device context specified by the hDC member. Windows automatically clips anything the owner window draws in the device context for combo boxes, list boxes, and buttons, but does not clip menu items. When drawing menu items, the owner window must not draw outside the boundaries of the rectangle defined by the rcItem member.
itemData
Specifies the application-defined 32-bit value associated with the menu item. For a control, this parameter specifies the value last assigned to the list box or combo box by the LB_SETITEMDATA or CB_SETITEMDATA message. If the list box or combo box has the LBS_HASSTRINGS or CBS_HASSTRINGS style, this value is initially zero. Otherwise, this value is initially the value that was passed to the list box or combo box in the lParam parameter of one of the following messages:
CB_ADDSTRING
CB_INSERTSTRING
LB_ADDSTRING
LB_INSERTSTRING
If ctlType is ODT_BUTTON or ODT_STATIC, itemData is zero.
See Also
CB_ADDSTRING, CB_INSERTSTRING, CB_SETITEMDATA, LB_ADDSTRING, LB_INSERTSTRING, SETITEMDATA, WM_DRAWITEM

 
 
The WM_MEASUREITEM message is sent to the owner window of an owner-drawn button, combo box, list box, list view control, or menu item when the control or menu is created.
 
WM_MEASUREITEM
idCtl = (UINT) wParam;                // control identifier
lpmis = (LPMEASUREITEMSTRUCT) lParam; // item-size information
 
 
Parameters
idCtl
Value of wParam. Contains the value of the CtlID member of the MEASUREITEMSTRUCT structure pointed to by the lpmis parameter. This value identifies the control that sent the WM_MEASUREITEM message.
If the value is zero, the message was sent by a menu. If the value is nonzero, the message was sent by a combo box or by a list box. If the value is nonzero, and the value of the itemID member of the MEASUREITEMSTRUCT pointed to by lpmis is (UINT) -1, the message was sent by a combo edit field.
lpmis
Value of lParam. Points to a MEASUREITEMSTRUCT structure that contains the dimensions of the owner-drawn control or menu item.
Return Value
If an application processes this message, it should return TRUE.
Remarks
When the owner window receives the WM_MEASUREITEM message, the owner fills in the MEASUREITEMSTRUCT structure pointed to by the lParam parameter of the message and returns; this informs Windows of the dimensions of the control. If a list box or combo box is created with the LBS_OWNERDRAWVARIABLE or CBS_OWNERDRAWVARIABLE style, this message is sent to the owner for each item in the control; otherwise, this message is sent once.
Windows sends the WM_MEASUREITEM message to the owner window of combo boxes and list boxes created with the OWNERDRAWFIXED style before sending the WM_INITDIALOG message. As a result, when the owner receives this message, Windows has not yet determined the height and width of the font used in the control; function calls and calculations requiring these values should occur in the main function of the application or library.
See Also
MEASUREITEMSTRUCT, WM_INITDIALOG

 

0
 

Author Comment

by:bradyd
ID: 1459469
Thanks for the info!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now