Quantcast
Channel: Visual C forum
Viewing all 15302 articles
Browse latest View live

#error : MFC requires use of Winsock2.h

$
0
0

I m using vs 2008 c++ compiler try to compile my code and it is giving error #error : MFC requires use of Winsock2.h.

in that file in which i used socket API.

c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ATLMFC\INCLUDE\afxwin.h(84) : fatal error C1189: #error : MFC requires use of Winsock2.h


Regex repeated alternation

$
0
0

Using VS2013, in the following code sample, I have the repeated alternation "(?:(a)|(b)|(c)|(d))+"

#include <regex>

std::smatch match_pieces; std::string text = "acbd"; std::regex pattern("(?:(a)|(b)|(c)|(d))+"); std::regex_search(text, match_pieces, pattern);

Trying to match this to the string "acbd", produces the following matches.

0: acbd
1: a
2: b
3: (unmatched)
4: d

Where as the expected result would have been:

0: acbd
1: a
2: b
3: c
4: d

Is this a bug as i don't understand what is the match strategy here ... ? 

Thanks


please help with old WINAPI (16bit) / WIN32API knowledge: values for WINVER, _WIN32_WINNT, _WIN32_WINDOWS, _WIN32_IE

$
0
0

Hi there,

Can some one help me to complete my list about values of symbol WINVER which you can set.

OS                             DATE               WINVER=

Windows 1.x:
Windows 1.01         (11/15/85)
Windows 1.02
Windows 1.03            (8//86)
Windows 1.04            (4//87)

Windows 2.x:
Windows 2.0     
Windows 2.03           (11//87)
Windows/286 2.10      (5/27/88)
Windows/386 2.10
Windows 2.11          (3/13/89)

Windows 3.x:
Windows 3.0              (5/22/90)   WINVER=0x0300
Windows 3.0a          (10/31/90)
Windows 3.0a MME         (1991)
Windows 3.1            (4/6/92)      WINVER=0x030a
Windows 3.11         (12/31/93)
Windows 3.2  [VR China]  (1994)

Windows for Workgroups 3.1
Windows for Workgroups 3.11

Windows NT 3.1     _WIN32_WINNT=0x030A
(Win32s                  _WIN32_WINNT=0x0)
Windows NT 3.5
Windows NT 3.51


Windows 95 and Windows NT 4.0         WINVER=0x0400
Windows NT 4.0     [only, no Win95]      WINVER=0x0400 and _WIN32_WINNT=0x0400
Windows 95           [only, no WinNT]      WINVER=0x0400 and _WIN32_WINDOWS=0x0400
Windows 98 and Windows NT 4.0         WINVER=0x0400 and _WIN32_WINDOWS=0x0410

Windows 98 WINVER=0x0400 and _WIN32_WINDOWS=0x0410
Windows ME WINVER=0x0400 and _WIN32_WINDOWS=0x0490


Minimum version required    Minimum value of _WIN32_IE
Internet Explorer 8.0    _WIN32_IE_IE80 (0x0800)
Internet Explorer 7.0    _WIN32_IE_IE70 (0x0700)
Internet Explorer 6.0 SP2    _WIN32_IE_IE60SP2 (0x0603)
Internet Explorer 6.0 SP1    _WIN32_IE_IE60SP1 (0x0601)
Internet Explorer 6.0    _WIN32_IE_IE60 (0x0600)
Internet Explorer 5.5    _WIN32_IE_IE55 (0x0550)
Internet Explorer 5.01    _WIN32_IE_IE501 (0x0501)
Internet Explorer 5.0, 5.0a, 5.0b    _WIN32_IE_IE50 (0x0500)
Internet Explorer 4.01 _WIN32_IE >= 0x0401
Internet Explorer 4.0  _WIN32_IE >= 0x0400
Internet Explorer 3.0, 3.01, 3.02 _WIN32_IE >= 0x0300

Minimum system required    Value for NTDDI_VERSION
Windows 7    NTDDI_WIN7 (0x06010000)
Windows Server 2008    NTDDI_WS08 (0x06000100)
Windows Vista with Service Pack 1 (SP1)    NTDDI_VISTASP1 (0x06000100)
Windows Vista    NTDDI_VISTA (0x06000000)
Windows Server 2003 with Service Pack 2 (SP2)    NTDDI_WS03SP2 (0x05020200)
Windows Server 2003 with Service Pack 1 (SP1)    NTDDI_WS03SP1 (0x05020100)
Windows Server 2003    NTDDI_WS03 (0x05020000)
Windows XP with Service Pack 3 (SP3)    NTDDI_WINXPSP3 (0x05010300)
Windows XP with Service Pack 2 (SP2)    NTDDI_WINXPSP2 (0x05010200)
Windows XP with Service Pack 1 (SP1)    NTDDI_WINXPSP1 (0x05010100)
Windows XP    NTDDI_WINXP (0x05010000)

Minimum system required    Minimum value for _WIN32_WINNT and WINVER
Windows 7    _WIN32_WINNT_WIN7 (0x0601)
Windows Server 2008    _WIN32_WINNT_WS08 (0x0600)
Windows Vista    _WIN32_WINNT_VISTA (0x0600)
Windows Server 2003 with SP1, Windows XP with SP2    _WIN32_WINNT_WS03 (0x0502)
Windows Server 2003, Windows XP    _WIN32_WINNT_WINXP (0x0501)
Windows 2000 _WIN32_WINNT=0x0500 and WINVER=0x0500

I found above information here:

http://support.microsoft.com/kb/32905/en-us

http://support.microsoft.com/kb/320479/en-us

http://msdn.microsoft.com/en-us/library/6sehtctf%28v=vs.80%29.aspx

http://blogs.msdn.com/b/oldnewthing/archive/2007/04/11/2079137.aspx

http://web.archive.org/web/20050307184910/http://msdn.microsoft.com/library/en-us/midl/midl/targeting_stubs_for_specific_32_bit_or_64_bit_platforms.asp

http://msdn.microsoft.com/en-us/library/aa383745.aspx

http://osdir.com/ml/gnu.mingw.user/2002-11/msg00381.html

http://social.msdn.microsoft.com/Forums/en-AU/vs2008sp1beta/thread/6408acd5-51b6-4815-82ad-266dea33ce92

http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/5b849641-fd49-4445-acc3-28d83885d5e0

http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745%28v=vs.85%29.aspx

generating dynamic Resource File in VC++

$
0
0

Hi Experts,

I am a fresher in vc++. We want to generate dynamic resource file for VC++ where the data will come from database (Oracle).

For an example,

When a user log in the system, at that time if User is an English User, then some data in english language needs to be loaded in vc++ resource file. If the user is French then French data will be loaded into the resource file.

Right now all the data are hard-coded in the resource file but we want to load it dynamically from database, based on the login-user language.

Can you please suggest any idea/concept how to do this dynamic implementation as I am not able to find any such concept in google.

how to compile and run a program which has a class separated in a .h and a .cpp file?

$
0
0

Hi

I have a main.cpp, a GradeBook.cpp and a GradeBook.h.

I am using Microsoft visual studio 2010. I have made a win32 console application  and I have added my .cpp files in 'source files' and my .h file in 'Header Files' but there is some warnings and errors:

d:\mitra\c++examples\chapter2\chapter2\gradebook.cpp(3): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header

d:\mitra\c++examples\chapter2\chapter2\gradebook.cpp(6): warning C4627: '#include "GradeBook.h"': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header

d:\mitra\c++examples\chapter2\chapter2\gradebook.cpp(35): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?

Note that:

  1. the program worked correctly before I separate the GradeBook class implementation from it's interface (I mean function prototypes)
  2. I have tested many ways including my .h files in StdAfx.h / StdAfx.cpp / add my resource path using project properties ... but it didn't work

I would appreciate any step by step instruction to do with my own classes, when I want to separate them into two file (a .h file and a .cpp file) for further use!

Thank you so much 

Application Error - Faulting Module name: KERNELBASE.dll, version: 6.3.9600.16408, time stamp: 0x523d4548

$
0
0

I am developing windows phone 8 app on windows 8 machine x64bit environment, my VS2012 is crashing or myApp is crashing. I am totally confused i am writing the error logs frmo the Event Viewer Two type of errors i found there 

1) Application Error

2) .Net Runtime Error

I have mentioned both errors respectively, Please Please help me.

Application Error log is following

Faulting application name: devenv.exe, version: 11.0.61030.0, time stamp: 0x5270a974
Faulting module name: KERNELBASE.dll, version: 6.3.9600.16408, time stamp: 0x523d4548
Exception code: 0xe0434352
Fault offset: 0x00012eec
Faulting process id: 0x24c0
Faulting application start time: 0x01cf0866b6233d5f
Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe
Faulting module path: C:\WINDOWS\SYSTEM32\KERNELBASE.dll
Report Id: 2ef41cb3-745a-11e3-befb-844bf5a2c13e
Faulting package full name: 
Faulting package-relative application ID: 

.Net Runtime Error is Following

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Reflection.TargetInvocationException
Stack:
   at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])
   at System.Reflection.RuntimeMethodInfo.UnsafeInvoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.Delegate.DynamicInvokeImpl(System.Object[])
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)


Ashish Jain



Take error when build vlc with vs2010 in release mode!

$
0
0

I try to build vlc with vs2010 but it only works in debug mode. I'm so tired. It has been taking all week! Can anyone that issue? Help me please!

Error	17480	error LNK1120: 124 unresolved externals	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\Release\lib_plugin.dll	lib_plugin
Error	17166	error LNK2001: unresolved external symbol "int __cdecl poll(struct pollfd *,unsigned int,int)" (?poll@@YAHPAUpollfd@@IH@Z)	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\input.obj	lib_plugin
Error	17167	error LNK2001: unresolved external symbol "int __cdecl poll(struct pollfd *,unsigned int,int)" (?poll@@YAHPAUpollfd@@IH@Z)	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\sap.obj	lib_plugin
Error	17238	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libfontconfig.lib(fcname.o)	lib_plugin
Error	17239	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libfontconfig.lib(fcstr.o)	lib_plugin
Error	17240	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libfontconfig.lib(fclist.o)	lib_plugin
Error	17241	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libiconv.lib(iconv.o)	lib_plugin
Error	17242	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libzvbi.lib(teletext.o)	lib_plugin
Error	17243	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libzvbi.lib(exp-html.o)	lib_plugin
Error	17244	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libupnp.lib(libupnp_la-httpreadwrite.o)	lib_plugin
Error	17246	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libbluray.lib(mpls_parse.o)	lib_plugin
Error	17247	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libspeexdsp.lib(resample.o)	lib_plugin
Error	17248	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libzvbi.lib(packet.o)	lib_plugin
Error	17249	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libzvbi.lib(exp-txt.o)	lib_plugin
Error	17250	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libbluray.lib(clpi_parse.o)	lib_plugin
Error	17251	error LNK2001: unresolved external symbol ___chkstk	D:\Visual Project\vlc-2.1.0.oldlib-2010-master\lib_plugin\libbluray.lib(sound_parse.o)	lib_plugin
.................
thanks everyone!

using Files inside program problem

$
0
0
//bankAccount.h file
#include <string>
#include"User.h"
using namespace std;
class bankAccount
{private:
string bankName;
public:
	bankAccount(string="AUMBANK");
	void AdminMenu ();
	void setBankName (string);
	string getBankName ();
	int transCheckDiposit( double );
	void displayBalance();
	void showBankMenu(User );
void manageBankAccounts();
};
//bankAccount.cpp
#include "bankAccount.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <fstream>
#include "Admin.h"
#include <cstdlib>
using namespace std;
//bool exitProgram = false;
string bankName = "Hello and Welcome to AUM Bank";
User a1;
void bankAccount::showBankMenu(User a2)
{
	bankAccount x;
	int TrueOrFlase;
	int secoundID;
    int selected = 0;
	User a3;
	double amount2;
    double amount;
    system("CLS");
    cout << "Welcome " << a2.getUserName() << " to AUM Bank"  << endl << endl;
    cout << endl;
    cout << "1-Deposit" << endl;
    cout << "2-Withdraw" << endl;
    cout << "3-Balance Inquiry" << endl;
    cout << "4-Transfer" << endl;
	cout << "5-Logout" << endl;
    cout << "Enter Choice: " << endl;
    cin >> selected;
    switch(selected)
    {
        case 1:
			cout<< "Your Balance is:" << a2.getBalance();
         cout << endl << "Enter deposit amount: $";
        cin >> amount;
        TrueOrFlase=x.transCheckDiposit(amount);
		if (TrueOrFlase==1)
        {amount=amount+a2.getBalance () ;
		a2.setBalance(amount);
		fstream fs("userInfo.txt" , ios::in | ios::out | ios::binary);
		fs.seekp(sizeof(a2)*(a2.getID()-1));
		fs.write( reinterpret_cast<const char*> (&a2), sizeof(a2) );
		fs.close();
		cout<< "Your Balance is:" << a2.getBalance();
		}
		else
        cout<<"Invaild value";
		showBankMenu(a2);
		break;
        case 2:
			cout<< "Your Balance is:" << a2.getBalance();
        cout << endl << "Enter withdraw amount: $";
        cin >> amount;
		if (amount<=0 || amount>a2.getBalance() )
			cout<< "Invaild value. Try again";
		else
        {amount=a2.getBalance()-amount;
		a2.setBalance(amount);
		fstream fs("userInfo.txt" , ios::in | ios::out | ios::binary);
		fs.seekp(sizeof(a2)*(a2.getID()-1));
		fs.write( reinterpret_cast<const char*> (&a2), sizeof(a2) );
		fs.close();
		cout<< "Your Balance is:" << a2.getBalance();
		}
		showBankMenu(a2);
        break;
        case 3:
        a2.displayinfo();
		showBankMenu(a2);
        break;
        case 4:
			cout<<"The Account ID number you want to transfer money for is:";
			cin>>secoundID;
			if(secoundID>0 && secoundID>11)
			{
				cout<< "Your Balance is:" << a2.getBalance();
				cout << endl << "Enter trasfer amount: $";
        cin >> amount;
		if (amount<=0 || amount>a2.getBalance() )
		cout<< "Invaild value. Try again";
		else
		{
			amount2=amount;
			fstream fs("userInfo.txt" , ios::in | ios::out | ios::binary);
	fs.seekg( sizeof(a3)*(secoundID-1) );
	fs.read( reinterpret_cast<char*> (&a3), sizeof(a3) );
	amount=a2.getBalance()-amount;
		a2.setBalance(amount);
	fs.seekp(sizeof(a2)*(a2.getID()-1));
		fs.write( reinterpret_cast<const char*> (&a2), sizeof(a2) );
		amount2=amount2+a3.getBalance () ;
		a3.setBalance(amount2);
		fs.seekp(sizeof(a3)*(a3.getID()-1));
		fs.write( reinterpret_cast<const char*> (&a3), sizeof(a3) );
		fs.close();
		cout<< "Your Balance is:" << a2.getBalance();
		}
			}
			else
				cout<< "wrong ID number";
			showBankMenu(a2);
        break;
		case 5:
			x.manageBankAccounts();
        default:
        cout << endl << "Invalid Entry please try again" << endl << endl;
        system("PAUSE");
        break;
	}
};
void bankAccount::manageBankAccounts()
{
	int adminPinCode=12345;
		int adminPass=54321;
	bankAccount b;
    int selection = 0;
    system("cls");
    cout << "Welcome to AUM Bank Machine." << endl << endl;
	cout << endl;
    cout << "1. User select/login." << endl;
    cout << "2. Admin login." << endl;
    cout << "3. Close the system." << endl;
    cout << "Enter Selection: ";
    cin >> selection;
    switch(selection)
    {
        case 1:
			a1.userLogin();
			break;
        case 2:
			cout<<"Please enter the pin code and password: "<<endl;
			cin>>adminPinCode>> adminPass;
			if (adminPinCode==12345 && adminPass==54321)
			b.AdminMenu();
			else
				cout<<" wrong password or code";
			break;
        case 3:
			exit (EXIT_FAILURE);
			break;
        default:
			cout << endl << "Invalid entry please try again" << endl << endl;
			system("PAUSE");
			break;
    }
}
int bankAccount::transCheckDiposit( double amount)
{
    if(amount <= 0)
    {
        cout << endl << "Invaild value try again" << endl;
		return 0;
    }
    else
    {
        cout << endl << " Transaction Processing " << endl;
		return 1;
    }
}
void bankAccount::AdminMenu ()
{
	Admin Notes;
	User NewUser;
	int ID;
	int Password;
	string username;
	double balance;
	system("cls");
	cout << endl;
	 int selection = 0;
	 int selection2 =0;
	 int amount;
    cout << "1.Check all bank notes." << endl;
    cout << "2.Add currency notes." << endl;
    cout << "3.Create User Accounts." << endl;
	cout << "4.Delete User Accounts." << endl;
	cout << "5.Display any User Account information." << endl;
	cout << "6.Logout." << endl;
    cout << "Enter Selection: "<<endl;
    cin >> selection;
	fstream Bank("bankNote.txt" , ios::in | ios::out | ios::binary);
	Bank.seekp(0);
	Bank.read( reinterpret_cast<char*> (&Notes), sizeof(Notes) );
    switch(selection)
    {
	case 1:
	Notes.display();
	system("pause");
	AdminMenu ();
	break;
	case 2:	
	cout << "1.Add 20 KD notes" << endl;
    cout << "2.Add 10 KD notes." << endl;
    cout << "3.Add 5 KD notes." << endl; 
	cout << "Enter Selection: "<<endl;
    cin >> selection2;
	switch (selection2)
	{
	case 1:
		cout<<"Please enter the amount of notes you want to add";
		cin>> amount;
		amount=amount+Notes.getTwentyKD();
		Notes.setTwentyKD(amount);
		Bank.seekp(0);
		Bank.write( reinterpret_cast<const char*> (&Notes), sizeof(Notes));
		AdminMenu ();
		break;
	case 2:
		cout<<"Please enter the amount of notes you want to add";
		cin>> amount;
		amount=amount+Notes.getTenKD();
		Notes.setTenKD(amount);
		Bank.seekp(0);
		Bank.write( reinterpret_cast<const char*> (&Notes), sizeof(Notes));
		AdminMenu ();
		break;
	case 3:
		cout<<"Please enter the amount of notes you want to add";
		cin>> amount;
		amount=amount+Notes.getFiveKD();
		Notes.setFiveKD(amount);
		Bank.seekp(0);
		Bank.write( reinterpret_cast<const char*> (&Notes), sizeof(Notes));
		AdminMenu ();
		break;
		default:
		cout << endl << "Invalid entry please try again" << endl << endl;
			system("PAUSE");
			break;
	}
		break;
	case 3:
		cout<<"Please put ID number for the new account between from 1 to 10";
		cin>> ID;
		if(ID>0 && ID <11)
		{Bank.seekg( sizeof(NewUser)*(ID-1) );
	Bank.read( reinterpret_cast<char*> (&NewUser), sizeof(NewUser) );
	if(NewUser.getUserName()=="")
	{cout<<"Please enter the username, password and balance" <<endl;
	cin>>username>>Password>>balance;
	NewUser.setUserName(username);
	NewUser.setPassword(Password);
	NewUser.setBalance(balance);
	NewUser.setID(ID);
	Bank.seekp(sizeof(NewUser)*(NewUser.getID()-1));
		Bank.write( reinterpret_cast<const char*> (&NewUser), sizeof(NewUser) );
		AdminMenu ();
	}
	else
		{cout<<" The ID you wrote is already used. Please try another ID";
	manageBankAccounts();}
		}
		else 
			{cout<<"Invaild ID value";
		manageBankAccounts();}
		break;
	case 4:
		cout<<"Please put ID number for the new account between from 1 to 10";
		cin>> ID;
		if(ID>0 && ID <11)
		{Bank.seekp(sizeof(NewUser)*(NewUser.getID()-1));
		Bank.write( reinterpret_cast<const char*> (&NewUser), sizeof(NewUser) );
		AdminMenu ();}
		else
		{cout<<"Invaild ID value";
		manageBankAccounts();}
		break;
	case 5:
		cout<<"Please put ID number for the new account between from 1 to 10";
		cin>> ID;
		if(ID>0 && ID <11)
		{Bank.seekg(sizeof(NewUser)*(NewUser.getID()-1));
		Bank.read( reinterpret_cast<char*> (&NewUser), sizeof(NewUser) );
		NewUser.displayinfo();
		AdminMenu ();}
		else
		{cout<<"Invaild ID value";
		manageBankAccounts();}
		break;
	case 6:
		manageBankAccounts();
		break;
	default:
			cout << endl << "Invalid entry please try again" << endl << endl;
			system("PAUSE");
			break;
}
Bank.close();
}
bankAccount::bankAccount(string nme)
{
	setBankName (nme);
}
void bankAccount::setBankName (string nam)
{
	bankName=nam;
}
string bankAccount::getBankName()
{
	return bankName;
}
//User.h
#include <string>
using namespace std;
#include <iostream>
class User
{ 
private:
	string userName;
		int password;	
		int ID;	
		double balance;
public:
	User(string= "" ,int=0,int=0,double= 0.0);
	string getUserName ();
	int getPassword ();
	int getID ();
	double getBalance ();
	void setUserName (string);
	void setPassword (int);
	void setID (int);
	void setBalance (double);
	void userLogin ();
	void displayinfo ();
};
//User.cpp
#include <string>
#include <iostream>
#include <fstream>
#include "bankAccount.h"
using namespace std;
User::User(string userN ,int PassW,int Id,double Balnce)
{setUserName (userN);
	setPassword (PassW);
	 setID (Id);
	 setBalance (Balnce);
}
string User:: getUserName ()
{
	return userName;
}
	int User::getPassword ()
	{
		return password;
	}
	int User::getID ()
	{
		return ID;
	}
	double User::getBalance ()
	{
		return balance;
	}
	void User::setUserName (string n)
	{
		userName=n;
	}
	void User::setPassword (int p)
	{
		password=p;
	}
	void User::setID (int id)
	{
		ID= id;
	}
	void User::setBalance (double b)
	{
balance=b;
	}
	void User::userLogin ()
	{cout<<"Please enter your ID and password:";
	int pw;
	int Id;
	cin>>Id >>pw;
	bankAccount a;
	User user2;
fstream fs("userInfo.txt" , ios::in | ios::out | ios::binary);
	fs.seekg( sizeof(user2)*(Id-1) );
	fs.read( reinterpret_cast<char*> (&user2), sizeof(user2) );
	fs.close();
	if(pw==user2.getPassword())
		a.showBankMenu(user2);
	else
	{	cout<<"invaild password";
	system("pause");
	a.manageBankAccounts(); 
	}
	}
	void User::displayinfo ()
	{
		cout<< endl<< ID << endl << userName << endl << balance; 
	}
//Admin.h
#include<iostream>
using namespace std;
class Admin
{
private:
	int fiveKD;
	int tenKD;
	int twentyKD;
public:
	Admin(int=100,int=100,int=100);
	void setFiveKD (int);
	void setTenKD (int);
	void setTwentyKD (int);
	int getFiveKD ();
	int getTenKD ();
	int getTwentyKD ();
	void display ();
};
//Admin.cpp
#include "bankAccount.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <fstream>
#include "Admin.h"
using namespace std;
Admin::Admin(int twenty,int ten,int five)
{
	setFiveKD (twenty);
	setTenKD (ten);
	setTwentyKD (five);
}
	void Admin::setFiveKD (int Five)
	{
		fiveKD=Five;
	}
	void Admin::setTenKD (int Ten)
	{
		tenKD=Ten;
	}
	void Admin::setTwentyKD (int Twenty)
	{
		twentyKD=Twenty;
	}
	int Admin::getFiveKD ()
	{
		return fiveKD;
	}
	int Admin::getTenKD ()
	{
		return tenKD;
	}
	int Admin::getTwentyKD ()
	{
		return twentyKD;
	}
	void Admin::display ()
	{
		cout<< endl<<"5 KD notes: " << fiveKD<< endl << "10 KD notes: "<< tenKD << endl << "20 KD notes: "<< twentyKD <<endl;
	}
//main
//main
#include "bankAccount.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <fstream>
#include "Admin.h"
#include <cstdlib>
using namespace std;
int main()
{
	bankAccount Start;
	Admin h;
	User user1;
	User user2("Hussain",1234,1,500);
	User user3 ("Abdulaziz",4321,2,1000);
	fstream fs("userInfo.txt" , ios::in | ios::out | ios::binary);
	fstream Bank("bankNote.txt" , ios::in | ios::out | ios::binary);
	Bank.seekp(0);
		Bank.write( reinterpret_cast<const char*> (&h), sizeof(h) );
		Bank.close();
	//initialize
	for(int i = 1; i<11; ++i)
	{
		fs.seekp(sizeof(user1)*(i-1));
		fs.write( reinterpret_cast<const char*> (&user1), sizeof(user1) );
	}
	fs.seekp(sizeof(user2)*(user2.getID()-1));
		fs.write( reinterpret_cast<const char*> (&user2), sizeof(user2) );
		fs.seekp(sizeof(user3)*(user3.getID()-1));
		fs.write( reinterpret_cast<const char*> (&user3), sizeof(user3) );
	fs.close();
	Start.manageBankAccounts();
	return 0;
}

Above you can see my whole project to make a bank machine.

The problem is with all the read and write command to write and read in files. The information inside the file did not change. I think the program did not even make the files. anyone can help me please and tell why the program did not make any files and if the program made the files why the the infomation inside the files didnot change even after I write inside it some information. btw the program work but the information inside the files is the only problem. Can you please help me as fast as you can because I really need the program to be perfect and I need to give to my doctor in 30 hours so Please help me :).


How can I determine the size of a Dialog Box which is larger than the CFormView?

$
0
0

Hello folks,

I have an application issue where I permit the User to resize a Dialog Box based on a Font selection.

I am having some difficulty in thinking through what else I need to manage.

I want to enable scrolling of the Dialog itself.

In order to do so, I need to know the "real" size of the Dialog Box.

If I use GetClientRect or GetWindowRect, I will get the size that appears within the CFormView.

For example, suppose that the physical screen is 5 by 5.

I can end up with a dialog box that is 10 by 10.

Then I want to be able to show a scrollable dialog box in the 5 by 5 area.

Does that make sense?

If I load the dialog box now, I will only be able to view the 5 by 5 area, and if I issue GetClientRect, I can only see 5 by 5.

I checked my Main Frame, and it does not clip children.

If I use some silly values inside my scroll logic, I can actually scroll through the dialog. Which suggests this is doable.

But, what I'd really like to be able to get is the real Dialog Box size, not just the viewable area from the display.

Is this possible?

Thanks and Happy New Year!

.......Cameron


Cameron Conacher

Upgrade to VS 2013 problems

$
0
0

I have an MFC program that was compiling and running in a trial version of VS 2012 with no issues. When the trial ran out I purchased but was only offered VS 2013. The same project compiles with no errors ( I am using MBCS support downloaded separately). The problem is when running or debugging it fails to load a dialog ( call to doModal() ).

CMFCLaserALTDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();

it returns with -1

Any ideas? Why is this specific to VS 2013 and not VS 2012? Since my VS 2012 trial ended I can lo longer run VS 2012 :(

Thanks in advance for your help,

**** EDITED ****

 When I step into the code, at m_pMainWnd = &dlg I find dlg == NULL. Why would this work in VS 2012 but not in VS 2013? I'm suspecting that when VS 2013 opened my 2012 project the first time the automatic conversion to a VS 2013 project setting changed something I'm not aware of...

 ~Thanks,


Help project removed from MFC

$
0
0
Please add a help system back into MFC. VS2010 is the last platform that supported Context sensitive help as part of the project. We have a huge code base based on MFC and plan to continue using it in the future!

How to get previous C++ version(s) to enable development, compilation and execution in Windows 7

$
0
0

Hello,

   I have VS C++.net 2003 academic v. success on a (slow) windows XP computer (fine) but tried to use this on a Windows 7 (intel i5) computer but there were incompatibilities. So I paid an expert to suggest some modifications which enabled it to install. However, the entire Properties pages for MFC were missing. Also,  recently the conhost.exe reported an access violation (how come? they changed Windows 7 console system?) so that doesn't work. OK, so I reinstalled it on an old XP computer (fine). I guess the 2003 version just isn't going to work on my Windows 7 machine.

   But I would like to use a console version of C++ on my Windows 7 computer so I downloaded Visual Studio C++ Express 2010 (I already have 2010 Express C# on it which worked fine). The C++ Express 2010 installation worked and I recompiled and executed my simple program. But (overnight) now rebooting, a C++ Express 2010 icon or option does not exist; however there are logs of the installation. No way to instantiate C++ 2010 Express now. I should say, I did not (yet) remove the installed old 2003 C++.  I would be happy to just get the C++ Express 2010 version to work. 

    As a second question, during search for options I downloaded VS2012_WDX_ENU.iso and burned a DVD. But I don't find any reference to indicate what this is for or how to use it. I assumed maybe that this was an express 2012 version, but maybe not. It would be helpful to have more info on what these various products are for.

Memory management in native c++ code(unmanaged)

$
0
0

Hi,

  I am using Visual studio 2010 for my c++ application. I was initially a C# developer and hence would love to get similar and at least some ease in memory management. Right now there are too many delete operators in my project.

Whats the best way of handling memory efficiently and effortlessly in native C++.

Regards,

Dhamodharan

  


Sharing is profitable only if it happens with knowledge.

how to handle whit this siutuation

$
0
0

Hi,

I have a program that runs well except in one customer's computer.

This problem will not cause crash so I can't get a dump file,  is there any way to get the call stack information in his computer?

I tried windbg, but the process is hang up when I attach my program to windbg.

Could anyone help about this?

Any suggestion will be appreciated.

All Regards

access violation during garbage collection

$
0
0

I have a set of managed dll's that work fine as a managed standalone program. But, I'm trying to use them from an un-managed application. When I do, once I've returned from calling my managed functions, if I wait a while, the program will crash with "access violation attempted to read or write protected memory". I have a messagebox that pops up with some information about a returned value. If I just sit there with the message box displayed, after a few seconds the exception will happen, so I guess this points to garbage collection.

After the exception, there is no information about where this is happening. Any ideas about tracking this down, or preventing it, or ignoring it?


Dynamic struct array in C

$
0
0

Hello!

I am very new to programming and I am at having problem with a school project where I am trying to make a struct that will hold a winner's name aswell as the year the winner won and I am trying to make this struct into a dynamic array so that it can hold a given number of winners. At the beginning of the program I want to be able to type in how many winners that this struct array will be able to hold and then change the struct array's size to that value.  I have no idea how to go at this and any help would be much appreciated. Please try explaining very simple :)

Here is the code so far:

struct winnerInfo {
	char name[20];
	int year;
};

int main(void){

	
	
	int antalÅr;
	

	printf("Hur många år vill du hantera?\n");
	scanf("%d", &antalÅr);
	printf("\n");

	struct winnerInfo info[antalÅr];


	
	flush(stdin);
	getchar();

}


Active standby events not received by C++ Windows Services

$
0
0

Using the recommended PowerRegisterSuspendResumeNotificationI registered my service for resume and suspend notifications. These events are received correctly when sleep or hibernation is used. The resume and suspend events are also correctly received in a console application which uses the same code, but if the code is in a Windows Service, active standby events are not received.

The two projects (the console app and the service) can be found here:
https://dl.dropboxusercontent.com/u/50537873/StandbyDetectionService.zip

To me this appears to be a Windows bug. If there is a way to receive the suspend and resume events in windows services, please let me know.

 

WaitForMultipleObjects() returns invalid handle

$
0
0

Windows 7, 64 bit, Visual Studio, C++

Here is the code:

 event_triggered = WaitForMultipleObjects(
                   EVENT_ARRAY_SIZE,
                   mp_common_data->event_array,
                   WAIT_FOR_ANY_EVENT,
                   WAIT_TIMEOUT_VALUE );

event_1 = (unsigned int) mp_common_data->event_array[0];
event_2 = (unsigned int) mp_common_data->event_array[1];
event_3 = (unsigned int) mp_common_data->event_array[2];

if( event_triggered == (DWORD) 0xFFFFFFFF )
 {
     last_error = GetLastError();
 }

mp_common_data is a pointer to a structure, declared in part as:

    HANDLE event_array[ EVENT_ARRAY_SIZE ];

    unsigned int    count_of_start_events;
    unsigned int    count_of_stop_events;
    unsigned int    count_of_exit_events;
    unsigned int    count_of_timeout_events;
For completeness, EVENT_ARRAY_SIZE has a value of 3, the size of the array.  WAIT_FOR_ANY_EVENT is a BOOL set to FALSE. WAIT_TIMEOUT_VALUE is set to 10,000 for a ten second timeout.

When the cursor is hovered over the argument mp_common_data->event_arrayit shows item event_array with a plus sign.  Moving the cursor there expands the array showing the three elements.  In this run of the program the values are 0x128, 0x12c, and 0x130.  Using the debugger these are the values put in the array in another part of the application.

However, the integers event_1, 2, and 3 all show a value of 0 (zero).  That explains why the return value of the wait API 0xffffffff.  GetLastError() returns 6 which says invalid handle.  Given that event_1 through 3 only get zero, that fits.  So why do they get zero rather than the values 128, 12c or 130?

WAIT_FOR_ANY_EVENT


~jag77 We need to know what a dragon is before we study its anatomy. (Bryan Kelly, 2010)


My first question (MFC)

$
0
0

Greetings everyone,

this is my first post in this forum, so nice to meet you all.

Now for my question:

I just start to learn MFC, so I am a complete newbie. Before my question, I have to inform you that I created this project without MFC application wizard, just an empty project. This was instructed by my lecturer. I am able to create the initial main window, but I am stuck there for a long time now. Here is my code:

#include "MainMenuWindow.h" // application class
#include <afxwin.h>

// constructor initializes the window
MainMenu::MainMenu()
{
    // Create Window with Title Bar
    Create( NULL, // default CFrameWnd class
        CString("Main Menu"), // window title - convert char array to CString
        WS_OVERLAPPEDWINDOW, // full-featured window
        CRect( 0, 0, 1366, 730 ) ); // screen coordinates left top right bottom

    // add menu and submenu dynamically
    Option.CreateMenu();
    PopupOption.CreatePopupMenu();
    // Add items to the sub menu and menu
    PopupOption.AppendMenuW(MF_STRING, ID_INSERT_OBJECT, CString("Insert Object"));
    PopupOption.AppendMenuW(MF_STRING, ID_OBJECT_CONTENT, CString("Content"));
    PopupOption.AppendMenuW(MF_STRING, ID_EDIT_OBJECT, CString("Edit"));
    PopupOption.AppendMenuW(MF_STRING, ID_DELETE_OBJECT, CString("Delete object"));
    PopupOption.AppendMenuW(MF_STRING, ID_SAVE_FILE, CString("Save"));
    PopupOption.AppendMenuW(MF_STRING, ID_LOAD_FILE, CString("Load"));
    PopupOption.AppendMenuW(MF_STRING, ID_QUIT_WINDOW, CString("Quit"));
    PopupOption.AppendMenuW(MF_STRING, ID_DISPLAY_OBJECT, CString("T - Display Object"));
    Option.AppendMenuW(MF_STRING | MF_POPUP, (UINT)PopupOption.m_hMenu, CString("Option"));

    SetMenu(&Option);
}

// destructor releases resources
MainMenu::~MainMenu()
{
}

afx_msg void MainMenu::InsertObject()
{
    //MessageBox(CString("This is InsertObject window"),CString("Insert Object"));
}

This is just part of my code (not all my code I must admit, I take reference from other website), without including the mainwindow.h file and mainwindowapp.cpp. With this, I am able to create an initial main window with a menu bar, and that's it.

I try to make sub window appear when I choose an option from the window menu, and only the messagebox that I commented above work fine.

Take the insertobject() above as example, when I choose this option in the menu bar, I am hoping to get a subwindow which let user choose an shape object and select its size, then it will draw the shape on the main window. I imagine the subwindow should have some static text, drop down list and buttons.

I try the cdialog function, but generate an error.

I try putting another window create code inside insertobject() function, got another error:

 // Create Window with Title Bar
    Create( NULL, // default CFrameWnd class
        CString("Insert Object Menu"), // window title - convert char array to CString
        WS_OVERLAPPEDWINDOW, // full-featured window
        CRect( 0, 0, 500, 500) ); // screen coordinates left top right bottom

If you need more information, I am able to draw shape object on main window:

afx_msg void MainMenu::OnPaint()
{
    PAINTSTRUCT ps;
    pDC = BeginPaint(&ps);

    //MainMenu::DrawDiamond();
    //MainMenu::DrawSquare();
    //MainMenu::DrawTriangle();

    EndPaint(&ps);
}

So to summarize this, how do I code my program so that a sub window will appear, let user select an object, then draw that object on the main window?

Furthermore, is there any MFC tutorial without using MFC application wizard? Most of the tutorials I found on the internet include using the wizard, so it's not suitable for me.

Lastly, thank you for anyone who read this long post. Since this is my first post, I hope my question is as clear as possible. And pardon my bad English. Thanks!

enumerating device ids

$
0
0

I was wondering what is the best strategy for enumerating device id's for hardware for a new project

I have seen some code for a device manager like project, but I was more interested in a simple table that can be evaluated in code


Corsair Carbide 300R with window
Corsair TX850V2 70A@12V
Asus M5A99FX PRO R2.0 CFX/SLI
AMD Phenom II 965 C3 Black Edition @ 4.0 GHz
G.SKILL RipjawsX DDR3-2133 8 GB
EVGA GTX 6600 Ti FTW Signature 2(Gk104 Kepler)
Asus PA238QR IPS LED HDMI DP 1080p
ST2000DM001 & Windows 8.1 Enterprise x64
Microsoft Wireless Desktop 2000
Wacom Bamboo CHT470M
Place your rig specifics into your signature like I have, makes it 100x easier to understand!

Hardcore Games Legendary is the Only Way to Play!

Viewing all 15302 articles
Browse latest View live




Latest Images