VC++界面设计的问题

VC++界面设计的问题

很简单

就从 CWnd继承就行。

首先是数据管理,看显示项,有图片有文字,然后有位置,和ID用来通知父窗口。可以定义个结构。

struct tagListItem

{

UINT nMyID;

CString strMyName;

HBITMAP hMyPicture;

CRect rcMyPos,这个不是指定的,wm_size时候重新布局生成的,方便绘制,和鼠标命中坚持。

}

用个链表来管理这些按钮项目。

然后重要的是窗口绘制部分。

wm_paint;

cdc* pdc= GetDC();

// 图片

cdc*memdc= createcom...

memdc.selectobjec(item.hMyPicture);

bitblt...

// 文字

drawtext

//

等待就能绘制管理部分的界面了。

事件控制,响应 wm_lbuttondown 就行了

1.管理/查询界面。类中用个标记判断当前是管理还是查询。鼠标点击查询就切换到查询,点击管理就切换到管理界面,wm_paint绘制的时候根据这个标记值来绘制相应内容。 (类中可以存“管理”“查询”按钮的rect就行了,在wm_lbuttondown事件函数里面判断鼠标位置)。

2.按钮点击,在wm_lbutdown里面枚举按钮链表,判断光标在那个按钮的 rcMyPos 里面就行了,简单点,直接使用sendmessage向父窗口发送消息:

sendmessage(wm_command, wparam, lparam)。发送别的消息也可以,随便定义一个就可以了,关键是要把这个按钮的ID给传过去,或者把按钮的数据信息都传过去。(如果是wm_command的话,比较通用,但是ID不要和菜单项工具条里面的冲突)

左边像是CListCtrl,你可以定义两组不同的快捷方式分别显示嘛

以下是MSDN上CListCtrl的成员函数:

CListCtrl

Constructs a CListCtrl object.

Create

Creates a list control and attaches it to a CListCtrl object.

CreateEx

Creates a list control with the specified Windows extended styles and attaches it to a CListCtrl object.

ApproximateViewRect

Determines the width and height required to display the items of a list view control.

CancelEditLabel

Cancels item text editing operation.

GetInsertMark

Retrieves the current position of the insertion mark.

InsertMarkHitTest

Retrieves the insertion point closest to a specified point.

GetInsertMarkColor

Retrieves the current color of the insertion mark.

GetInsertMarkRect

Retrieves the rectangle that bounds the insertion point.

GetOutlineColor

Retrieves the color of the border of a list view control.

SetOutlineColor

Sets the color of the border of a list view control.

GetTileInfo

Retrieves information about a tile in a list view control.

GetTileViewInfo

Retrieves information about a list view control in tile view.

GetSelectedColumn

Retrieves the index of the currently selected column in the list control.

IsGroupViewEnabled

Determines whether group view is enabled for a list view control.

SetInfoTip

Sets the tooltip text.

SetInsertMark

Sets the insertion point to the defined position.

SetInsertMarkColor

Sets the color of the insertion point.

SetTileInfo

Sets the information for a tile of the list view control.

SetTileViewInfo

Sets information that a list view control uses in tile view.

EnableGroupView

Enables or disables whether the items in a list view control display as a group.

GetGroupInfo

Gets the information for a specified group of the list view control.

GetGroupMetrics

Retrieves the metrics of a group.

GetView

Gets the view of the list view control.

HasGroup

Determines if the list view control has the specified group.

InsertGroup

Inserts a group into the list view control.

InsertGroupSorted

Inserts the specified group into an ordered list of groups.

MoveGroup

Moves the specified group.

MoveItemToGroup

Moves the specified group to the specified zero based index of the list view control.

RemoveAllGroups

Removes all groups from a list view control.

RemoveGroup

Removes the specified group from the list view control.

SetGroupInfo

Sets the information for the specified group of a list view control.

SetGroupMetrics

Sets the group metrics of a list view control.

SetSelectedColumn

Sets the selected column of the list view control.

SetView

Sets the view of the list view control.

SortGroups

Sorts the groups of a list view control with a user-defined function.

GetBkColor

Retrieves the background color of a list view control.

GetBkImage

Retrieves the current background image of a list view control.

GetCallbackMask

Retrieves the callback mask for a list view control.

GetCheck

Retrieves the current display status of the state image associated with an item.

GetColumn

Retrieves the attributes of a control's column.

GetColumnOrderArray

Retrieves the column order (left to right) of a list view control.

GetColumnWidth

Retrieves the width of a column in report view or list view.

GetCountPerPage

Calculates the number of items that can fit vertically in a list view control.

GetEditControl

Retrieves the handle of the edit control used to edit an item's text.

GetExtendedStyle

Retrieves the current extended styles of a list view control.

GetFirstSelectedItemPosition

Retrieves the position of the first selected list view item in a list view control.

GetHeaderCtrl

Retrieves the header control of a list view control.

GetHotCursor

Retrieves the cursor used when hot tracking is enabled for a list view control.

GetHotItem

Retrieves the list view item currently under the cursor.

GetHoverTime

Retrieves the current hover time of a list view control.

GetImageList

Retrieves the handle of an image list used for drawing list view items.

GetItem

Retrieves a list view item's attributes.

GetItemCount

Retrieves the number of items in a list view control.

GetItemData

Retrieves the application-specific value associated with an item.

GetItemPosition

Retrieves the position of a list view item.

GetItemRect

Retrieves the bounding rectangle for an item.

GetItemState

Retrieves the state of a list view item.

GetItemText

Retrieves the text of a list view item or subitem.

GetNextItem

Searches for a list view item with specified properties and with specified relationship to a given item.

GetNextSelectedItem

Retrieves the index of a list view item position, and the position of the next selected list view item for iterating.

GetNumberOfWorkAreas

Retrieves the current number of working areas for a list view control.

GetOrigin

Retrieves the current view origin for a list view control.

GetSelectedCount

Retrieves the number of selected items in the list view control.

GetSelectionMark

Retrieves the selection mark of a list view control.

GetStringWidth

Determines the minimum column width necessary to display all of a given string.

GetSubItemRect

Retrieves the bounding rectangle of an item in a list view control.

GetTextBkColor

Retrieves the text background color of a list view control.

GetTextColor

Retrieves the text color of a list view control.

GetToolTips

Retrieves the tooltip control that the list view control uses to display tooltips.

GetTopIndex

Retrieves the index of the topmost visible item.

GetViewRect

Retrieves the bounding rectangle of all items in the list view control.

GetWorkAreas

Retrieves the current working areas of a list view control.

SetBkColor

Sets the background color of the list view control.

SetBkImage

Sets the current background image of a list view control.

SetCallbackMask

Sets the callback mask for a list view control.

SetCheck

Sets the current display status of the state image associated with an item.

SetColumn

Sets the attributes of a list view column.

SetColumnOrderArray

Sets the column order (left to right) of a list view control.

SetColumnWidth

Changes the width of a column in report view or list view.

SetExtendedStyle

Sets the current extended styles of a list view control.

SetHotCursor

Sets the cursor used when hot tracking is enabled for a list view control.

SetHotItem

Sets the current hot item of a list view control.

SetHoverTime

Sets the current hover time of a list view control.

SetIconSpacing

Sets the spacing between icons in a list view control.

SetImageList

Assigns an image list to a list view control.

SetItem

Sets some or all of a list view item's attributes.

SetItemCount

Prepares a list view control for adding a large number of items.

SetItemCountEx

Sets the item count for a virtual list view control.

SetItemData

Sets the item's application-specific value.

SetItemPosition

Moves an item to a specified position in a list view control.

SetItemState

Changes the state of an item in a list view control.

SetItemText

Changes the text of a list view item or subitem.

SetSelectionMark

Sets the selection mark of a list view control.

SetTextBkColor

Sets the background color of text in a list view control.

SetTextColor

Sets the text color of a list view control.

SetToolTips

Sets the tooltip control that the list view control will use to display tooltips.

SetWorkAreas

Sets the area where icons can be displayed in a list view control.

SubItemHitTest

Determines which list view item, if any, is at a given position.

Operations

Arrange

Aligns items on a grid.

CreateDragImage

Creates a drag image list for a specified item.

DeleteAllItems

Deletes all items from the control.

DeleteColumn

Deletes a column from the list view control.

DeleteItem

Deletes an item from the control.

EditLabel

Begins in-place editing of an item's text.

EnsureVisible

Ensures that an item is visible.

FindItem

Searches for a list view item having specified characteristics.

HitTest

Determines which list view item is at a specified position.

InsertColumn

Inserts a new column in a list view control.

InsertItem

Inserts a new item in a list view control.

RedrawItems

Forces a list view control to repaint a range of items.

Scroll

Scrolls the content of a list view control.

SortItems

Sorts list view items using an application-defined comparison function.

Update

Forces the control to repaint a specified item.

Overridables

DrawItem

Called when a visual aspect of an owner-draw control changes.

创建列表控件

左边是一个自定义控件,控件里面是由 另一个控件组成滴,这个控件是由一个Button和一个listctl组成滴

class pannel

{

private:

CArray< CMenuCtl > m_Menus;

}

class CMenuCtl

{

private:

CButton m_button;

CListCtl m_list;

}

CMenuCtl一层一层的画到pannel上去,通过层变换和顶层CMenuCtl 的Movewindow就可以实现动态效果。

楼主,明白?

可以使用树状控件来编写CTreeList

横向的是自定义的快捷工具栏

纵向的有点像是ListCtrl的Icon(图标)格式

至于你说的显示不同的快捷图标,你可以用隐藏啊,

点"管理"的时候 显示一部分图标,隐藏一部分图标

(可用ShowWindow函数 的SW_HIDE 和SW_SHOW参数)

点"查询"同理