kompilacja projectu Interrupt/Exception caught

0

Witam

mam problem z aplikacja a wlasciwie z kompilatorem uzywam dev c++

i gdy zrobie projekt to nie moge z kompliowac szukalem na necie i nie moge znaleŹĆ niczego co moglo by mi pomoc
zainstalowalem dev werscie na 64 bit i tez
uzywalem block::code (tutaj mi sie nic nie kompiluje (ale to pewnie dlatego ze cos robie zle ;))
uzywalem tez visual studio 2010 expres
ale tm jest jakos dziwnie wszystko moj kod sie w ogole nie chce skapilowac a gdy uzyje gotowego szablonu okienka
to znow nie dzialaja pliki naglowke ktore sa potrzebde do mojej aplikacji wiec stwerdzialem ze prosciej bd naprawic ten blad

Interrupt/Exception caught (code = 0xc0000005, addr = 0x750443f9)

0

Przecież błąd opisuje dokładnie co się stało.
Dev, code::blocks, visual studio to są IDE, a nie kompilatory.
Nie używaj deva, generalnie nie jest polecany :)
Podaj kod, znajdziemy błędy.
Albo podaj błędy jakie c::b/visual Ci podaje, choc i tak z kodem będzie prościej.

0
 
// move_viewer3.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "move_viewer3.h"
#include <iostream>
#include <string>
#include <fstream>
#include <dirent.h>


using namespace std;

#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

// 

HWND g_hPrzycisk;
HWND selectMove;
HWND hText;
HWND h_odtwarzacz;
DWORD dlugosc;
HWND hListBox;


// 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);




bool is_file(string file){
	FILE* plik = fopen(file.c_str(), "r");
	if(plik)
		return true;
	return false;
}


string* ListFiles(string* maineTab, string* maineTab2, string src){
	struct dirent* pozycja=0; 
	string fileName;
	int nb = 0;	
	while(maineTab[nb] != "")		
		nb++;	
	
	DIR* folder = opendir(src.c_str());
	
	while(pozycja=readdir(folder)){	
				
		fileName=(*pozycja).d_name;		
		if(fileName != "." && fileName != ".."){
			string tmpname = src + "/" + fileName;			
			
			if(is_file(tmpname)){
				if((fileName.find(".avi")==(fileName.length()-4)) || (fileName.find(".rmvb")==(fileName.length()-5))){
					
					maineTab[nb] = tmpname;
					maineTab2[nb] = fileName;
					
					nb++;
				}
			}else{
				ListFiles(maineTab, maineTab2, tmpname);				
			}		 
		}		
	}	
	return maineTab;
} 



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_MOVE_VIEWER3, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow))
	{
		return FALSE;
	}

	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MOVE_VIEWER3));

	// 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_MOVE_VIEWER3));
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName	= MAKEINTRESOURCE(IDC_MOVE_VIEWER3);
	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;
	}
	
	
	/* PRZYCISKI */
	g_hPrzycisk = CreateWindowEx(WS_EX_CLIENTEDGE, L"BUTTON", L"OK", WS_CHILD | WS_VISIBLE,20, 40, 150, 30, hWnd, NULL, hInstance, NULL );
	selectMove = CreateWindowEx(WS_EX_CLIENTEDGE, L"BUTTON", L"Otworz ten film", WS_CHILD | WS_VISIBLE,20, 500, 150, 30, hWnd, NULL, hInstance, NULL );
    hText = CreateWindowEx( WS_EX_CLIENTEDGE, L"EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 20, 10, 250, 26, hWnd, NULL, hInstance, NULL );
    h_odtwarzacz = CreateWindowEx( WS_EX_CLIENTEDGE, L"EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 300, 10, 250, 26, hWnd, NULL, hInstance, NULL );
    SetWindowText(hText, L"d:/filmy" );
    SetWindowText(h_odtwarzacz, L"D:/ins/mplayerc.exe" );
	hListBox = CreateWindowEx( WS_EX_CLIENTEDGE, L"LISTBOX", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | ES_AUTOVSCROLL, 20, 100, 700, 400, hWnd, NULL, hInstance, NULL );

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}

//
//  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 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;
}


taki mam kod
i wszystko jest ladnie ale gdy dodam ta funkcje ListFiles to cos sie dzieje na poczatku
nie bylo <dirent.h> wiec dodalem do projektu zeby moglo sebie zaincludowac

a blad jest taki

 1>------ Build started: Project: move_viewer3, Configuration: Debug Win32 ------
1>  move_viewer3.cpp
1>c:\users\backen\desktop\nowy folder\fsa20120\move_viewer3\move_viewer3\move_viewer3.cpp(41): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen'
1>move_viewer3.obj : error LNK2019: unresolved external symbol _readdir referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl ListFiles(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?ListFiles@@YAPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAV12@0V12@@Z)
1>move_viewer3.obj : error LNK2019: unresolved external symbol _opendir referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl ListFiles(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?ListFiles@@YAPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAV12@0V12@@Z)
1>C:\Users\Backen\Desktop\Nowy folder\fsa20120\move_viewer3\Debug\move_viewer3.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
0

nie bylo <dirent.h> wiec dodalem do projektu zeby moglo sebie zaincludowac
to nie spowoduje, że funkcje z tego nagłówka nagle staną się dostępne.
To jest niestandardowy (jak na Windows) nagłówek, którego pod Visualem nie ma (i nie będzie).

0

Daj w visualu empty project żeby ci nie dodawało tych prekompilowanych nagłówków i wtedy też będziesz miał normalne kodowanie znaków i nie będziesz musiał używać wchar_t

0

Dlaczego nie uzywasz normalnej funkcji WinMain?

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

Co do bledów, to linker nie widzi opendir. dirent.h powinien rozwiazac sprawe, przynajmniej u mnie dziala bez problemu z MinGW (nie musze dolaczac zadnej biblioteki). Chyba musisz zrobic troche porzadku. Przejrzyj np to:

http://zetcode.com/gui/winapi/

Bawie sie ostatnio WinAPI w C i zwykly gcc radzi sobie swietnie. Proste, czytelne i exe ma ponizej 100 kB :)

0

zadne porady nie skutkuja niestety

ale na necie znalazlem takie cos

HANDLE hFind;
WIN32_FIND_DATA FindFileData;

if((hFind = FindFirstFile("C:/some/folder/*.txt", &FindFileData)) != INVALID_HANDLE_VALUE){
    do{
        printf("%s\n", FindFileData.cFileName);
    }while(FindNextFile(hFind, &FindFileData));
    FindClose(hFind);
}
 

i moze bd dzialac na razie w ogole cos sie posypalo i nic sie nie chce kompilowac wiec sciagm jeszcze raz msvs
jednak najbardziej zadowolilbym sie rozwiazaniem tego bledu :)

0

Jezeli opendir nie dziala, to znaczy ze masz problem ze srodowiskiem albo ze swoim programem -- gdzies w fundamentach. Szukanie w tej sytuacji innej funkcji przypomina sposób, w jaki liderzy UE próbuja rozwiazac problem zadluzenia: pozyczyc jeszcze wiecej pieniedzy :) Spróbuj napisac krótki testowy program uzywajacy opendir i doprowadz do jego zadzialania. Do tego wystarczy zwykly gcc.

0
 
    struct dirent* pozycja=0;  // to dziala 
    DIR* folder = opendir('D:/cos'); // to nie

na zwyklym mi dziala dobrze wszystko tylko do projektu musze dodac pliki rc

0

Ja uzywam takiej funkcji:

/* --------------------------------------------------------------------------
  return TRUE if file exists
---------------------------------------------------------------------------*/
bool file_exists(const char *path_fname)
{

	bool	ret=FALSE;
	char	*last_slash=NULL;
	char	dir[INPUT_LEN]="";
	char	fname[INPUT_LEN]="";
	DIR	*dp;
struct	dirent	*ep;


	last_slash = strrchr(path_fname, '\\');		/* Windows */
	if ( NULL == last_slash )
		last_slash = strrchr(path_fname, '/');	/* UNIX    */

	if ( NULL == last_slash )			/* no slash => current dir */
	{
		strcpy(dir, ".");
		strcpy(fname, path_fname);
	}
	else
	{
		strncpy(dir, path_fname, last_slash-path_fname);
		strcpy(fname, last_slash+1);
	}

/*	printf("\n\npath_fname: [%s]\n", path_fname);
	printf("       dir: [%s]\n", dir);
	printf("     fname: [%s]\n\n", fname); */

	dp = opendir(dir);

	if ( NULL != dp )
	{
		while ( ep = readdir(dp) )
		{
			if ( !strcmp(ep->d_name, fname) )
			{
				ret = TRUE;
				break;
			}
		}
		closedir(dp);
	}
	else
	{
		printf("\n\n No such directory!");
	}

	return ret;

}

Sprawdz u siebie. Jesli nie zadziala, to masz problem ze srodowiskiem.

0
backen napisał(a):

na zwyklym mi dziala dobrze wszystko tylko do projektu musze dodac pliki rc

windres does the trick:

http://stackoverflow.com/questions/708238/how-do-i-add-an-icon-to-a-mingw-gcc-compiled-executable

Aczkolwiek sam jeszcze nie próbowalem.

0

nie dziala mi Twoja funkcja

 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\dirent.h(27): error C2065: 'FILENAME_MAX' : undeclared identifier
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\dirent.h(75): error C2065: 'FILENAME_MAX' : undeclared identifier
0

Czym kompilujesz?

0

visualem ale musze zmienic na cos innego

1

Spróbuj tego:

http://sourceforge.net/projects/mingw/files/

W pakiecie jest od razu windres.exe

Program WinAPI kompilujesz z opcja -mwindows

P.S. Jeszcze hint: MinGW sie nie tyle instaluje, co kopiuje. Warto wrzucic go do folderu bez spacji w nazwie, np. C:\MinGW
Potem tylko dodac C:\MinGW\bin do PATH-a i wszystko. Powinno smigac.

0

zainstalowalem codeblocks
i MinGW w C:\MinGW

tylko nie wiem czy dobrze podalem kompilatory bo jak chce kompilowac projekt to wywala mi takie bledy

 
-------------- Build: Release in fdgd ---------------

Compiling: main.cpp
main.cpp:11:20: warning: deprecated conversion from string constant to 'LPSTR {aka char*}' [-Wwrite-strings]
Linking executable: bin\Release\fdgd.exe
mingw32-g++.exe: error: obj\Release\main.obj: No such file or directory
mingw32-g++.exe: error: gdi32.lib: No such file or directory
mingw32-g++.exe: error: user32.lib: No such file or directory
mingw32-g++.exe: error: kernel32.lib: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
 

a jak zwykly plik cpp

to taki

Compiling: C:\Users\Backen\Desktop\Nowy folder\cb\test.cpp
Linking console executable: C:\Users\Backen\Desktop\Nowy folder\cb\test.exe
mingw32-g++.exe: error: console: No such file or directory
mingw32-g++.exe: error: C:\Users\Backen\Desktop\Nowy folder\cb\test.obj: No such file or directory
mingw32-g++.exe: error: unrecognized option '-subsystem'
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
 

Pomogla calkowta reinstalacja i uruchomienie jako administrator

0

Jako kompilator wystarczy podac gcc. Po rozszerzeniu pliku (.c lub .cpp) gcc sam sie zorientuje co robic.

Pokaz jeszcze move_viewer3.h to spróbuje skompilowac u siebie. (a BTW - nie powinno byc movie_viewer?)

0

kod sie troche zmienil

main.cpp

#include <iostream>
#include <fstream>
#include <dirent.h>
#include <string>
#include <windows.h>
#include <Windowsx.h>

#include "main.h"

using namespace std;

bool is_file(string file){
	FILE* plik = fopen(file.c_str(), "r");
	if(plik)
		return true;
	return false;
}


string* ListFiles(string* maineTab, string* maineTab2, string src){
	struct dirent* pozycja=0; 
	string fileName;
	int nb = 0;	
	while(maineTab[nb] != "")		
		nb++;	
	
	DIR* folder = opendir(src.c_str());
	
	while(pozycja=readdir(folder)){	
				
		fileName=(*pozycja).d_name;		
		if(fileName != "." && fileName != ".."){
			string tmpname = src + "/" + fileName;			
			
			if(is_file(tmpname)){
				if((fileName.find(".avi")==(fileName.length()-4)) || (fileName.find(".rmvb")==(fileName.length()-5))){
					
					maineTab[nb] = tmpname;
					maineTab2[nb] = fileName;
					
					nb++;
				}
			}else{
				ListFiles(maineTab, maineTab2, tmpname);				
			}		 
		}		
	}	
	return maineTab;
}

string* DirScan(string* tabswsk, string* Tab4names, string DirName){
	cout << "nazwa katalogu to: " << DirName << "\n";
	
	DIR* katalog = opendir(DirName.c_str());
	if(katalog){
		ListFiles(tabswsk, Tab4names, DirName);
	}else{		
		if(is_file(DirName)){
			cout << "to jest plik \n";
		}else{
			cout << "Taki plik lub katalog nie istnieje \n";
		} 
	}
	delete(katalog);	
} 


string ArrayOfFiles[500]; // Glowna tablica z lista plikow 	
string ArrayOfFiles_names[500]; // Glowna tablica z lista plikow 	

string* W_ArrayOfFiles = ArrayOfFiles; // wskaznik do tablicy z lista plikow 
string* W_ArrayOfFiles_names = ArrayOfFiles_names; // wskaznik do tablicy z lista plikow  



/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK DlgProc( HWND, UINT, WPARAM, LPARAM );
/*  Make the class name into a global variable  */
char szClassName[ ] = "CodeBlocksWindowsApp";

DWORD dlugosc;

// Przyciski

HWND g_hPrzycisk;
HWND selectMove;
HWND hText;
HWND h_odtwarzacz;

HWND hListBox;
HWND hSileSelect;






int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow){
	HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */
	
    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

   
    hwnd = CreateWindowEx (
			0,                   /* Extended possibilites for variation */
			szClassName,         /* Classname */
			"Code::Blocks Template Windows App",       /* Title Text */
			WS_OVERLAPPEDWINDOW, /* default window */
			CW_USEDEFAULT,       /* Windows decides the position */
			CW_USEDEFAULT,       /* where the window ends up on the screen */
			840,                 /* The programs width */
			680,                 /* and height in pixels */
			HWND_DESKTOP,        /* The window is a child-window to desktop */
			NULL,                /* No menu */
			hThisInstance,       /* Program Instance handler */
			NULL                 /* No Window Creation data */
		);
	
	if( hwnd == NULL ){
        MessageBox( NULL, "Okno odmówiło przyjścia na świat!", "Ale kicha...", MB_ICONEXCLAMATION );
        return 1;
    }
   
	g_hPrzycisk = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "OK", WS_CHILD | WS_VISIBLE,20, 40, 150, 30, hwnd, NULL, hThisInstance, NULL );
	selectMove = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "Otworz ten film", WS_CHILD | WS_VISIBLE,20, 500, 150, 30, hwnd, NULL, hThisInstance, NULL );
    hText = CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 20, 10, 250, 26, hwnd, NULL, hThisInstance, NULL );
    h_odtwarzacz = CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 350, 10, 250, 26, hwnd, NULL, hThisInstance, NULL );
	hListBox = CreateWindowEx( WS_EX_CLIENTEDGE, "LISTBOX", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | ES_AUTOVSCROLL, 20, 100, 700, 400, hwnd, NULL, hThisInstance, NULL );
	
	// 
	hSileSelect = CreateWindowEx( 0, "BUTTON", "...", WS_CHILD | WS_VISIBLE, 280, 10, 30, 26, hwnd, NULL, hThisInstance, NULL );

	SetWindowText(hText, "d:/filmy" );
    SetWindowText(h_odtwarzacz, "D:/ins/mplayerc.exe" );
	
	
   
   
    ShowWindow (hwnd, nCmdShow);

  
    while (GetMessage (&messages, NULL, 0, 0)){
        
        TranslateMessage(&messages);
        
        DispatchMessage(&messages);
    }

    
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
    switch (message){
		case WM_COMMAND:{
			if(( HWND ) lParam == g_hPrzycisk ){
				cout << wParam << " -- " << lParam;
				dlugosc = GetWindowTextLength( hText );
				LPSTR Bufor =( LPSTR ) GlobalAlloc( GPTR, dlugosc + 1 );
				GetWindowText( hText, Bufor, dlugosc + 1 );
				
				//MessageBox( hwnd, Bufor, "Ha!", MB_ICONINFORMATION );
				
				DirScan(W_ArrayOfFiles, W_ArrayOfFiles_names, Bufor);
				
				int indexofmove = 0;
				while(ArrayOfFiles_names[indexofmove] != ""){
					string ole_ole = ArrayOfFiles_names[indexofmove];
					
					
					SendMessage( hListBox, LB_ADDSTRING, 0,( LPARAM ) ole_ole.c_str() );					
					indexofmove++;
				}
				
				
				
			}else if(( HWND ) lParam == selectMove){
				
				int numer = ListBox_GetCurSel( hListBox );
				cout << numer << " -- \n " ;
				//MessageBox( hwnd, numer, "Ha!", MB_ICONINFORMATION );
				
				dlugosc = GetWindowTextLength( h_odtwarzacz );
				LPSTR Player =( LPSTR ) GlobalAlloc( GPTR, dlugosc + 1 );
				GetWindowText( h_odtwarzacz, Player, dlugosc + 1 );
				
				string PlayerSTR = Player;
				if(is_file(PlayerSTR)){
					if(numer > -1){
						string dd = ArrayOfFiles[numer];					
						string p = "\""+PlayerSTR+" \""+dd+"\"\"";				
						system(p.c_str());
					}
				}else{
					MessageBox( hwnd, "Nie moge znalesc odtwarzacza", "Error!", MB_ICONINFORMATION );
				}
			}else if(( HWND ) lParam == hSileSelect){				
				
				OPENFILENAME ofn;
				char sNazwaPliku[ MAX_PATH ] = "";
				
				ZeroMemory( & ofn, sizeof( ofn ) );
				ofn.lStructSize = sizeof( ofn );
				ofn.lpstrFilter = "Pliki tekstowe (*.txt)\0*.txt\0Wszystkie pliki\0*.*\0";
				ofn.nMaxFile = MAX_PATH;
				ofn.lpstrFile = sNazwaPliku;
				ofn.lpstrDefExt = "txt";
				ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
				if(GetOpenFileName(&ofn)){
					cout << "gitara \n";	
				}else{
					cout << "instrument przeciwny do gitary \n";
				}
            
       
			}
			
		}
		break;
		
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}

BOOL CALLBACK DlgProc( HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam ){
    switch( Msg ){
		case WM_COMMAND:{
            // reakcja na przyciski
            switch( LOWORD( wParam ) ){
				case IDOK: EndDialog( hwnd, IDOK ); break;
				case IDCANCEL: EndDialog( hwnd, IDCANCEL ); break;
            }
        }
        break;        
        default: return FALSE;
    }    
    return TRUE;
}

 

main.rc

#include <windows.h>
#include "main.h"

IDD_MOJDIALOG DIALOG DISCARDABLE 20, 20, 200, 66
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Mój własny dialog"
FONT 8, "MS Sans Serif"
{
    DEFPUSHBUTTON "&Fajnie!", IDOK, 124, 18, 50, 14
    PUSHBUTTON "&Anuluj", IDCANCEL, 124, 35, 50, 14
    LTEXT "To jest okno dialogowe", IDC_LABEL, 16, 18, 80, 33
} 

i main.h

 
#define IDD_MOJDIALOG 200
#define IDC_LABEL 201
0

U mnie sie kompiluje, a nawet uruchamia :) Kompiluje tak:

g++ main.cpp main.res -mwindows -lcomdlg32

1 użytkowników online, w tym zalogowanych: 0, gości: 1