Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include "resource.h"
- #include <tchar.h>
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
- int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int nCmdShow )
- {
- MSG msg ;
- HWND hwnd;
- WNDCLASS wc;
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.lpszClassName = TEXT( "Window" );
- wc.hInstance = hInstance ;
- wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
- wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
- wc.lpfnWndProc = WndProc;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- RegisterClass(&wc);
- hwnd = CreateWindow( wc.lpszClassName, TEXT("Window"),
- WS_SYSMENU | WS_VISIBLE,
- 100, 100, 250, 250, NULL, NULL, hInstance, NULL);
- ShowWindow(hwnd, nCmdShow);
- UpdateWindow(hwnd);
- while( GetMessage(&msg, NULL, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return (int) msg.wParam;
- }
- LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
- {
- static HWND listbox;
- static HWND button;
- static HWND button_del;
- static HWND edit;
- PAINTSTRUCT ps;
- HDC hd;
- switch(msg)
- {
- case WM_DESTROY:
- {
- PostQuitMessage(0);
- return 0;
- }
- case WM_CREATE:
- {
- listbox = CreateWindow(TEXT("listbox") , NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | LBS_NOTIFY,
- 10, 10, 210, 120, hwnd,(HMENU) 1, NULL, NULL);
- button = CreateWindow(TEXT("button") , TEXT("Find"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
- 120, 140, 100, 25, hwnd,(HMENU) 2, NULL, NULL);
- button_del = CreateWindow(TEXT("button") , TEXT("Clr"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
- 10, 140, 100, 25, hwnd,(HMENU) 4, NULL, NULL);
- break;
- }
- case WM_COMMAND:
- {
- if(HIWORD(wParam) == BN_CLICKED)
- {
- if(LOWORD(wParam) == 2)
- {
- TCHAR buff[2048];
- WIN32_FIND_DATA fData = {0};
- GetCurrentDirectory(sizeof(buff), buff);
- wcscat(buff, L"\\*");
- HANDLE hFile = FindFirstFile(buff, &fData);
- if(hFile != INVALID_HANDLE_VALUE){
- do {
- if(_tccmp(fData.cFileName, L".") && _tccmp(fData.cFileName, L".."))
- SendMessage(listbox, LB_ADDSTRING, NULL, (LPARAM)fData.cFileName);
- } while (FindNextFile(hFile, &fData));
- }
- FindClose(hFile);
- } else if(LOWORD(wParam) == 4)
- {
- SendMessage(listbox, LB_RESETCONTENT, 0, 0);
- }
- }
- if(LOWORD(wParam) == ID_FILE_INFO)
- {
- MessageBox(0, L"Programm by Push", L"Thanks", 0);
- }
- if(HIWORD(wParam) == LBN_SELCHANGE)
- {
- if(LOWORD(wParam) == 1)
- {
- TCHAR* buff = new TCHAR[1024];
- SendMessage(listbox, LB_GETTEXT, SendMessage(listbox, LB_GETCURSEL, NULL, NULL), (LPARAM)buff);
- MessageBox(NULL, buff, NULL, NULL);
- }
- }
- break;
- }
- }
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
Advertisement
Add Comment
Please, Sign In to add comment