假如不用MFC的类,该如何用一般api函数(或说SDK)来创建例如状态窗口(STATUESBAR),树状结构等控件呐?
例如:listBox,button...可以用createwindow来创建。
创建那些控件该使用什么,或者需要连入什么文件,麻烦大家给了方法,谢谢!
代码有没有都行的,仅仅一个思路也是可以的,如果100分还不够我可以再加!
例如:listBox,button...可以用createwindow来创建。
创建那些控件该使用什么,或者需要连入什么文件,麻烦大家给了方法,谢谢!
代码有没有都行的,仅仅一个思路也是可以的,如果100分还不够我可以再加!
btn.Create(NULL,WS_CHILD | WS_VISIBLE ,CRect(736,6,736+25,23+6),this,IDC_BUTTON_MAX);
btn.ShowWindow(SW_SHOW);
大概是这样
创建按钮hBtnWnd = CreateWindow("button",....)和CButton的Create()创建按钮一样
主要是第一个参数要设置创建的类型,返回的是控件的句柄。
再如hEditWnd = CreateWindow("edit",...)
LPCTSTR lpClassName,//BUTTON,LISTBOX
LPCTSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
);主要第一个参数LPCTSTR lpClassName,//BUTTON,LISTBOX
使用系统组册好的字符BUTTON,LISTBOX等来创建按钮,listbox等
至于按钮之类的就不用了,不过还是谢谢大家的回答吧,我试试
Creates a status window, which is typically used to display the status of an application. The window generally appears at the bottom of the parent window, and it contains the specified text. Note This function is obsolete. Use CreateWindow instead.
// CreateATreeView - creates a tree-view control.
// Returns the handle to the new control if successful,
// or NULL otherwise.
// hwndParent - handle to the control's parent window.
// lpszFileName - name of the file to parse for tree-view items.HWND CreateATreeView(HWND hwndParent, LPSTR lpszFileName)
{
RECT rcClient; // dimensions of client area
HWND hwndTV; // handle to tree-view control // Ensure that the common control DLL is loaded.
InitCommonControls(); // Get the dimensions of the parent window's client area, and create
// the tree-view control.
GetClientRect(hwndParent, &rcClient);
hwndTV = CreateWindowEx(0,
WC_TREEVIEW,
"Tree View",
WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES,
0,
0,
rcClient.right,
rcClient.bottom,
hwndParent,
(HMENU)ID_TREEVIEW,
g_hinst,
NULL); // Initialize the image list, and add items to the control.
// InitTreeViewImageLists and InitTreeViewItems are application-
// defined functions.
if (!InitTreeViewImageLists(hwndTV) ||
!InitTreeViewItems(hwndTV, lpszFileName))
{
DestroyWindow(hwndTV);
return FALSE;
}
return hwndTV;
}
hwndBar = CreateStatusWindow(WS_CHILD | WS_VISIBLE, TEXT( "1 "), hwnd, IDC_STATUS);
SendMessage(hwndBar,SB_SETPARTS,3,(LPARAM)pint);
SendMessage(hwndBar,SB_SETTEXT,1,(LPARAM)TEXT("2")););
SendMessage(hwndBar,SB_SETTEXT,2,(LPARAM)TEXT("3"));
11,12楼的好像也是这样,CreateStatusWindow没有定义。
是不是要加载这个链接库?
Header commctrl.h
Import library comctl32.lib
Minimum operating systems Windows NT 3.51, Windows 95
Unicode Implemented as ANSI and Unicode versions