学习型 ASP/PHP/ASP.NET 主机 30元/年全能 ASP/PHP/ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付
轻松建立自己的群组,招兵买马   
发新话题
打印

谁有一个ListBox控件的例子 SDK程序 不用CListBox实现

谁有一个ListBox控件的例子 SDK程序 不用CListBox实现

想只用SDK单文件实现 不想用MFC/VC++下CListBox类实现
MSDN上的资料全是关于CListBox类实现的
现在已经创建了一个控件窗口 但是就是不知道该如何声明一个结构变量去控制(不知道数据类型是什么名)
希望有经验的朋友帮帮忙

TOP

啊。。难得碰到一位仁兄跟我一样喜欢用SDK哈。恩。。给你从Programming Windows里面摘录的一段关于列表框的。。
附件: 您所在的用户组无法下载或查看附件
MAY 1, 1964 -- The Birth of BASIC
Over 40 years later, it still enables ANYONE to write their own programs.
P.S. 遠離御宅 抵制禁宅

TOP

多谢 在别人电脑 考回去看看再来交流
越来越感觉自己非常菜了,但是越来越发现这是好事!!

TOP

看了 不是我要的
我要的是LISTBOX控件的使用 不是用EDIT实现LISTBOX控件的功能
越来越感觉自己非常菜了,但是越来越发现这是好事!!

TOP

我已经完成了控件的创建 但是不知道该如何显示:
复制内容到剪贴板
代码:
#include <windows.h>
#include <malloc.h>
#include <commctrl.h>

#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;
}
越来越感觉自己非常菜了,但是越来越发现这是好事!!

TOP

我太菜了 自己本机就有例子就然没发现:
C:\Program Files\Microsoft Platform SDK\Samples\WinUI\Controls\Common\VListVw
越来越感觉自己非常菜了,但是越来越发现这是好事!!

TOP

ShowWindow()
大家一起来编程吧!

TOP

引用:
flyue 在 2008-7-3 19:15 的发言:

ShowWindow()
??
越来越感觉自己非常菜了,但是越来越发现这是好事!!

TOP

啊。。對不起哦。。失誤了
MAY 1, 1964 -- The Birth of BASIC
Over 40 years later, it still enables ANYONE to write their own programs.
P.S. 遠離御宅 抵制禁宅

TOP

我下载了PDF文档,正是我想要的!
谢谢了

TOP

发新话题