急 ,VC问题,跪求高手解答
#include<Windows.h>#include<stdlib.h>#include<stdio.h>#defineIDL_SAMPLST101#defineFIL...
#include <Windows.h>
#include <stdlib.h>
#include <stdio.h>
#define IDL_SAMPLST 101
#define FILE_LIST 0x4010
HWND hWndList;
HINSTANCE hInst;
WCHAR lpszListBoxClassName[] = L"ListBox";
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(
__in HINSTANCE hInstance,
__in_opt HINSTANCE hPrevInstance,
__in_opt LPSTR lpCmdLine,
__in int nShowCmd )
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
WCHAR lpszClassName[] = L"窗口";
WCHAR lpszTitle[] = L"列表框示例程序";
wndclass.style = CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
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(WHITE_BRUSH);
wndclass.lpszClassName = (LPCTSTR)lpszClassName;
wndclass.lpszMenuName = NULL;
(LPCWSTR)lpszTitle;
if(!RegisterClass(&wndclass))
{
MessageBeep(0);
return false;
}
hInst = hInstance;
hwnd = CreateWindow(
lpszClassName,lpszTitle,
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,NULL,
hInstance,
NULL);
ShowWindow(hwnd,nShowCmd);
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)
{ int nIndex;
switch (message)
{
case WM_CREATE:
hWndList = CreateWindow(lpszListBoxClassName,
NULL,
WS_CHILD|WS_VISIBLE|LBS_STANDARD|LBS_EXTENDEDSEL|LBS_MULTIPLESEL,
40,
80,
200,
100,
hwnd,
(HMENU)IDL_SAMPLST,
hInst,
NULL);
SendMessage(hWndList,LB_DIR,FILE_LIST,(LPARAM)"*.*");
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDL_SAMPLST:
if(HIWORD(wParam) == LBN_DBLCLK)
{
nIndex = SendMessage(hWndList,LB_GETCURSEL,0,0L);
SendMessage(hWndList,LB_DELETESTRING,nIndex,0L);
}
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return(0);
}
为什么在列表框中只显示 驱动磁盘而不显示文件呢 ?我已经把FILE_LIST定义为0x4010了?怎么样才能显示文件呢 ? 展开
#include <stdlib.h>
#include <stdio.h>
#define IDL_SAMPLST 101
#define FILE_LIST 0x4010
HWND hWndList;
HINSTANCE hInst;
WCHAR lpszListBoxClassName[] = L"ListBox";
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(
__in HINSTANCE hInstance,
__in_opt HINSTANCE hPrevInstance,
__in_opt LPSTR lpCmdLine,
__in int nShowCmd )
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
WCHAR lpszClassName[] = L"窗口";
WCHAR lpszTitle[] = L"列表框示例程序";
wndclass.style = CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
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(WHITE_BRUSH);
wndclass.lpszClassName = (LPCTSTR)lpszClassName;
wndclass.lpszMenuName = NULL;
(LPCWSTR)lpszTitle;
if(!RegisterClass(&wndclass))
{
MessageBeep(0);
return false;
}
hInst = hInstance;
hwnd = CreateWindow(
lpszClassName,lpszTitle,
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,NULL,
hInstance,
NULL);
ShowWindow(hwnd,nShowCmd);
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)
{ int nIndex;
switch (message)
{
case WM_CREATE:
hWndList = CreateWindow(lpszListBoxClassName,
NULL,
WS_CHILD|WS_VISIBLE|LBS_STANDARD|LBS_EXTENDEDSEL|LBS_MULTIPLESEL,
40,
80,
200,
100,
hwnd,
(HMENU)IDL_SAMPLST,
hInst,
NULL);
SendMessage(hWndList,LB_DIR,FILE_LIST,(LPARAM)"*.*");
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDL_SAMPLST:
if(HIWORD(wParam) == LBN_DBLCLK)
{
nIndex = SendMessage(hWndList,LB_GETCURSEL,0,0L);
SendMessage(hWndList,LB_DELETESTRING,nIndex,0L);
}
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return(0);
}
为什么在列表框中只显示 驱动磁盘而不显示文件呢 ?我已经把FILE_LIST定义为0x4010了?怎么样才能显示文件呢 ? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询