我正在创建一个包含foders列表的Listbox。我想显示用户双击的文件夹的名称。为此,我写了:
...
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
char Temp[_MAX_DIR]
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Analizar las selecciones de menú:
switch (wmId)
{
case ID_LIST:
SelIndex = SendMessage(hList, LB_GETCURSEL, 0, 0L);
SendMessage(hList, LB_GETTEXT, (WPARAM)(int)(SelIndex), (LPARAM)(LPCTSTR)(Temp));
printf("The folder is: %s\n", Temp);
...
最相关的行是:
SelIndex = SendMessage(hList,LB_GETCURSEL,0,0L);
SendMessage(hList,LB_GETTEXT,(WPARAM)(int)(SelIndex),(LPARAM)(LPCTSTR)(Temp));
使用第一个我应该获得用户点击的列表框的行,而第二个我应该在Temp中存储单击行中出现的文本。但我什么都没得到,我做错了什么?
谢谢
/////////////////结合一些用户的答案,一个有效的脚本如下:
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Analizar las selecciones de menú:
if (wmEvent == LBN_DBLCLK)
{
if(wmId == ID_LIST)
{
SelIndex = SendMessage(hList, LB_GETCURSEL, 0, 0L);
printf("The index is %d\n", SelIndex);
len = SendMessage(hList, LB_GETTEXT, (WPARAM)(int)(SelIndex), (LPARAM)(LPCTSTR)(Temp));
printf("Lenght is %d\n", len);
printf("The folder is: %s\n",Temp);
答案 0 :(得分:3)
您的程序存在一些问题。首先,你似乎做了比你需要的更多的铸造。这总是让人担心。您也忽略了基本的错误检查。例如:
SelIndex = SendMessage(hList, LB_GETCURSEL, 0, 0L);
您已分配到SelIndex
,但请勿检查错误。该文档告诉您,如果发生错误,则返回LB_ERR
。你必须检查一下。
接下来是:
SendMessage(hList, LB_GETTEXT, (WPARAM)(int)(SelIndex), (LPARAM)(LPCTSTR)(Temp));
施法似乎极端。你可以这样写:
SendMessage(hList, LB_GETTEXT, SelIndex, (LPARAM)Temp);
您还应捕获返回值并检查错误。同样,您必须仔细查阅文档。
现在,问题的最可能原因是您正在编译Unicode项目。因此预计会提供宽字符的缓冲区。所以改变Temp
的声明就像这样:
wchar_t Temp[_MAX_DIR];
另一个可能的问题是,您应该为字符串和null终止符提供足够长度的缓冲区。同样,文档清楚地说明了这一点。使用LB_GETTEXTLEN
找出您需要多大的缓冲区。
注意:我假设您的代码确实执行了。但其他答案表明您的代码可能无法执行。在这种情况下,首先要解决这个问题。确认这样的事实是调试的基本部分,是您必须学会做的事情。所以,无论什么解决问题,我能给你的最好建议是尝试学习如何更好地诊断和描述问题。这样做可以让您更轻松地缩小问题范围,从而找到解决方案。换句话说,在我看来,你所遇到的主要问题是你没有完全确定你的问题。
答案 1 :(得分:2)
除了@DavidHeffernan在答案中提到的内容之外还有几点:
a)case ID_LIST
的逻辑应在if (wmEvent == LBN_DBLCLK)
b)printf()
在Windows应用程序中不会执行任何操作,请尝试OutputDebugString()代替调试版本或MessageBox()
答案 2 :(得分:1)
我正在创建一个包含foders列表的列表框。我想显示用户双击的文件夹的名称。
您可以使用简单的列表框来执行此操作,或者您可以使用DlgDirList function来执行此操作 - 您需要做的就是将DDL_DIRECTORY
作为最后一个参数传递。此功能始终将文件名添加到列表框中,因此您需要找到一种方法来自行过滤它们。另外,请注意它提供了HWND
静态控件,它将显示文件夹的名称,因此这可能对您有用(如果您不希望使用静态控件,则此参数可以是NULL
)。
注意关于DlgDirList
:
目录名称的方括号如下:[directory]
。
但我一无所获,我做错了什么?
你得到某些结果。你不能只是出现在这里说“我什么都没得到”。解释你得到的行为是什么,以及你期望的是什么。
查看代码后,我可以看到可能出现的问题 - 您尚未处理LBN_DBLCLK通知消息。
另外。请注意您的列表框必须具有LBS_NOTIFY
样式,才能将通知消息发送到您的父窗口。
如果您提供更详细的问题解释社区将有更好的机会帮助您。到目前为止,这是我在您的代码中看到的唯一相关问题。
Microsoft 有两个很好的例子来填充列表框并从中提取数据。
如果您允许用户查看文件和目录,那么您可以使用this示例,只是不要忘记DDL_DIRECTORY
标志我上文提到的。
如果您在列表框中只想要目录,那么您会发现this示例有用。
为了帮助您完成这些示例,我制作了一个演示应用程序,演示了两种方式。
此代码显示如何使用您的数据填充列表框以及如何通过双击提取字符串。
只需转到文件,然后从两个选项中选择一个来查看演示。
菜单中的第一个选项会在您双击编辑控件中的项目时列出播放器的数据(我已修改了上面的Microsoft's
第二个示例),而第二个选项列出了文件在当前目录中删除双击的文件。
在我看来,您寻求的解决方案最好在对话框程序ListBoxExampleProc
中说明。注意项目的添加方式(WM_INITDIALOG
处理程序)以及如何通过双击(WM_COMMAND
处理程序查找和研究case IDC_LIST1
)从项目中获取字符串。
您需要自己实现所需的行为(获取目录名称并正确填充列表框)因为我没有时间为您做到这一点 - Christnmas已经通过所以没有礼物对你来说这次:)
希望这会对你有所帮助。如果您还有其他问题,请发表评论,我会回复。
最好的问候。
说明:
在default Win32 project
中创建Visual Studio
。 将其命名为“列表框测试”。
然后,您所要做的就是用我的代码替换以下文件的原始文本:
stdafx.h
:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include <tchar.h>
#include <Strsafe.h>
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
Resource.h
:
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by list box test.rc
//
#define IDC_MYICON 2
#define IDD_LISTBOXTEST_DIALOG 102
#define IDS_APP_TITLE 103
#define IDD_ABOUTBOX 103
#define IDM_ABOUT 104
#define IDM_EXIT 105
#define IDI_LISTBOXTEST 107
#define IDI_SMALL 108
#define IDC_LISTBOXTEST 109
#define IDR_MAINFRAME 128
#define IDD_DIALOG1 129
#define IDD_DIALOG2 130
#define IDC_LIST1 1000
#define IDC_EDIT1 1002
#define IDS_PATHTOFILL 1003
#define ID_FILE_SIMPLELISTBOX 32771
#define ID_FILE_DIRECTORYLISTBOX 32772
#define IDC_STATIC -1
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 32773
#define _APS_NEXT_CONTROL_VALUE 1004
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif
list box test.rc
:
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_LISTBOXTEST ICON "list box test.ico"
IDI_SMALL ICON "small.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDC_LISTBOXTEST MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "Simple list box", ID_FILE_SIMPLELISTBOX
MENUITEM "Directory list box", ID_FILE_DIRECTORYLISTBOX
MENUITEM "E&xit", IDM_EXIT
END
POPUP "&Help"
BEGIN
MENUITEM "&About ...", IDM_ABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDC_LISTBOXTEST ACCELERATORS
BEGIN
"?", IDM_ABOUT, ASCII, ALT
"/", IDM_ABOUT, ASCII, ALT
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About list box test"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
ICON 128,IDC_STATIC,14,14,21,20
LTEXT "list box test, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX
LTEXT "Copyright (C) 2014",IDC_STATIC,42,26,114,8
DEFPUSHBUTTON "OK",IDOK,113,41,50,14,WS_GROUP
END
IDD_DIALOG1 DIALOGEX 0, 0, 335, 180
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,205,159,50,14
PUSHBUTTON "Cancel",IDCANCEL,278,159,50,14
LISTBOX IDC_LIST1,23,14,99,140,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_EDIT1,140,34,179,22,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY
END
IDD_DIALOG2 DIALOGEX 0, 0, 316, 180
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,205,159,50,14
PUSHBUTTON "Cancel",IDCANCEL,259,159,50,14
LISTBOX IDC_LIST1,24,17,173,141,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LTEXT "",IDS_PATHTOFILL,209,31,90,18,0,WS_EX_CLIENTEDGE
CTEXT "Current working directory:",IDC_STATIC,209,18,89,9,SS_ENDELLIPSIS
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 163
TOPMARGIN, 7
BOTTOMMARGIN, 55
END
IDD_DIALOG1, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 328
TOPMARGIN, 7
BOTTOMMARGIN, 173
END
IDD_DIALOG2, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 309
TOPMARGIN, 7
BOTTOMMARGIN, 173
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#ifndef APSTUDIO_INVOKED\r\n"
"#include ""targetver.h""\r\n"
"#endif\r\n"
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_APP_TITLE "list box test"
IDC_LISTBOXTEST "LISTBOXTEST"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
list box test.cpp
:
// list box test.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "list box test.h"
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
//*********** Variables required for the second list box example
typedef struct
{
TCHAR achName[MAX_PATH];
TCHAR achPosition[12];
int nGamesPlayed;
int nGoalsScored;
} Player;
Player Roster[] =
{
{TEXT("Haas, Jonathan"), TEXT("Midfield"), 18, 4 },
{TEXT("Pai, Jyothi"), TEXT("Forward"), 36, 12 },
{TEXT("Hanif, Kerim"), TEXT("Back"), 26, 0 },
{TEXT("Anderberg, Michael"), TEXT("Back"), 24, 2 },
{TEXT("Jelitto, Jacek"), TEXT("Midfield"), 26, 3 },
{TEXT("Raposo, Rui"), TEXT("Back"), 24, 3},
{TEXT("Joseph, Brad"), TEXT("Forward"), 13, 3 },
{TEXT("Bouchard, Thomas"), TEXT("Forward"), 28, 5 },
{TEXT("Salmre, Ivo "), TEXT("Midfield"), 27, 7 },
{TEXT("Camp, David"), TEXT("Midfield"), 22, 3 },
{TEXT("Kohl, Franz"), TEXT("Goalkeeper"), 17, 0 },
};
//**************************************************
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_LISTBOXTEST, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LISTBOXTEST));
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage are only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_LISTBOXTEST));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_LISTBOXTEST);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HINSTANCE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//************ Modified second example of the list box *****************//
//*********** from http://msdn.microsoft.com/en-us/library/windows/desktop/hh298365%28v=vs.85%29.aspx
INT_PTR CALLBACK ListBoxExampleProc(HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
// Add items to list.
HWND hwndList = GetDlgItem(hDlg, IDC_LIST1);
for (int i = 0; i < ARRAYSIZE(Roster); i++)
{
int pos = (int)SendMessage(hwndList, LB_ADDSTRING, 0,
(LPARAM) Roster[i].achName);
// we do not need the rest from Microsoft's example
}
// Set input focus to the list box.
SetFocus(hwndList);
return TRUE;
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
case IDC_LIST1:
{
switch (HIWORD(wParam))
{
case LBN_DBLCLK:
{
HWND hwndList = GetDlgItem(hDlg, IDC_LIST1);
// Get selected index.
int lbItem = (int)SendMessage(hwndList, LB_GETCURSEL, 0, 0);
// display item's text
TCHAR buff[MAX_PATH];
SendMessage(hwndList, LB_GETTEXT, lbItem, (LPARAM)buff);
SetDlgItemText(hDlg, IDC_EDIT1, buff);
return TRUE;
}
}
}
return TRUE;
}
}
return FALSE;
}
//************ Modified first example of the list box **************//
//*********** from http://msdn.microsoft.com/en-us/library/windows/desktop/hh298372%28v=vs.85%29.aspx
INT_PTR CALLBACK DlgDelFileProc(HWND hDlg, UINT message,
UINT wParam, LONG lParam)
{
PTSTR pszCurDir;
PTSTR pszFileToDelete;
int iLBItem;
int cStringsRemaining;
int iRet;
TCHAR achBuffer[MAX_PATH];
TCHAR achTemp[MAX_PATH];
BOOL fResult;
switch (message)
{
case WM_INITDIALOG:
// Initialize the list box by filling it with files from
// the current directory.
pszCurDir = achBuffer;
GetCurrentDirectory(MAX_PATH, pszCurDir);
DlgDirList(hDlg, pszCurDir, IDC_LIST1, IDS_PATHTOFILL, DDL_DIRECTORY);
SetFocus(GetDlgItem(hDlg, IDC_LIST1));
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_LIST1:
if( HIWORD(wParam) == LBN_DBLCLK )
{
// When the user double clicks the item,
// first retrieve the selected file.
pszFileToDelete = achBuffer;
DlgDirSelectEx(hDlg, pszFileToDelete, MAX_PATH, IDC_LIST1);
// Make sure the user really wants to delete the file.
achTemp[MAX_PATH];
StringCbPrintf (achTemp, ARRAYSIZE(achTemp),
TEXT("Are you sure you want to delete %s?"),
pszFileToDelete);
iRet = MessageBox(hDlg, achTemp, L"Deleting Files",
MB_YESNO | MB_ICONEXCLAMATION);
if (iRet == IDNO)
return TRUE;
// Delete the file.
fResult = DeleteFile(pszFileToDelete);
if (!fResult)
{
MessageBox(hDlg, L"Could not delete file.", NULL, MB_OK);
}
else // Remove the filename from the list box.
{
// Get the selected item.
iLBItem = SendMessage(GetDlgItem(hDlg, IDC_LIST1),
LB_GETCURSEL, 0, 0);
// Delete the selected item.
cStringsRemaining = SendMessage(GetDlgItem(hDlg, IDC_LIST1),
LB_DELETESTRING, iLBItem, 0);
// If this is not the last item, set the selection to
// the item immediately following the one just deleted.
// Otherwise, set the selection to the last item.
if (cStringsRemaining > iLBItem)
{
SendMessage(GetDlgItem(hDlg, IDC_LIST1), LB_SETCURSEL,
iLBItem, 0);
}
else
{
SendMessage(GetDlgItem(hDlg, IDC_LIST1), LB_SETCURSEL,
cStringsRemaining, 0);
}
}
}
break;
case IDOK:
case IDCANCEL:
// Destroy the dialog box.
EndDialog(hDlg, TRUE);
return TRUE;
default:
return FALSE;
}
default:
return FALSE;
}
}
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case ID_FILE_SIMPLELISTBOX:
DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, ListBoxExampleProc);
break;
case ID_FILE_DIRECTORYLISTBOX:
DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hWnd, DlgDelFileProc);
break;
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}