永久的守护 发布留言 2008-7-3 14:22 谁有一个ListBox控件的例子 SDK程序 不用CListBox实现想只用SDK单文件实现 不想用MFC/VC++下CListBox类实现 MSDN上的资料全是关于CListBox类实现的 现在已经创建了一个控件窗口 但是就是不知道该如何声明一个结构变量去控制(不知道数据类型是什么名) 希望有经验的朋友帮帮忙 lingluoz 发布留言 2008-7-3 16:25 啊。。难得碰到一位仁兄跟我一样喜欢用SDK哈。恩。。给你从Programming Windows里面摘录的一段关于列表框的。。 永久的守护 发布留言 2008-7-3 16:35 多谢 在别人电脑 考回去看看再来交流 永久的守护 发布留言 2008-7-3 17:45 看了 不是我要的 我要的是LISTBOX控件的使用 不是用EDIT实现LISTBOX控件的功能 永久的守护 发布留言 2008-7-3 17:46 我已经完成了控件的创建 但是不知道该如何显示: [code] #include #include #include
#define ID_LISTVIEW 117
#define WIN_START_X 100 #define WIN_START_Y 100 #define WIN_WIDTH 600 #define WIN_HEIGHT 600
#pragma comment(lib,"comctl32.lib")
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; HWND CreateListBoxView(HWND hwndParent, LPSTR lpszFileName) ;
HINSTANCE g_hinst ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static TCHAR szAppName[] = TEXT ("SineWave") ; MSG msg ; WNDCLASS wndclass; HWND hwnd ; //CListBox *m_list = new CListBox() ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; wndclass.hbrBackground= (HBRUSH) GetStockObject (LTGRAY_BRUSH) ; wndclass.lpszMenuName = NULL ; wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass)) { MessageBox ( NULL, TEXT ("Program requires Windows NT!"), szAppName, MB_ICONERROR) ; return 0 ; }
hwnd = CreateWindow ( szAppName, TEXT ("母本窗口"), WS_OVERLAPPEDWINDOW, WIN_START_X, WIN_START_Y, WIN_WIDTH, WIN_WIDTH, NULL, NULL, hInstance, NULL) ; g_hinst = hInstance ; CreateListBoxView( hwnd, "目录.txt") ;
ShowWindow (hwnd, SW_SHOW) ; UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; }
return msg.wParam ; }
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc ; PAINTSTRUCT ps ; switch (message) { case WM_CREATE: return 0 ;
case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ;
EndPaint (hwnd, &ps) ; return 0 ;
case WM_DESTROY: PostQuitMessage (0) ; return 0 ; }
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
HWND CreateListBoxView(HWND hwndParent, LPSTR lpszFileName) { RECT rcClient; HWND hwndLV; LVITEM m_listBox ;
// Ensure that the common control DLL is loaded. InitCommonControls();
// Get the dimensions of the parent window's client area, and create // the ListBox control. GetClientRect(hwndParent, &rcClient); hwndLV = CreateWindowEx(0, WC_LISTBOXW, TEXT("LIST View"), WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES, 0, 0, rcClient.right, rcClient.bottom, hwndParent, (HMENU)ID_LISTVIEW, g_hinst, NULL);
return hwndLV; }[/code]永久的守护 发布留言 2008-7-3 18:20 我太菜了 自己本机就有例子就然没发现: C:\Program Files\Microsoft Platform SDK\Samples\WinUI\Controls\Common\VListVwflyue 发布留言 2008-7-3 19:15 ShowWindow()永久的守护 发布留言 2008-7-3 21:16 [un]flyue[/un] 在 2008-7-3 19:15 的发言:[/bo]
ShowWindow() |
??
页: [1] 特别说明:如网页特效代码中有引用图片文件等,请自己下载到本地调试! |