|
hello guys
pls help me
wats wrong with this code
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
BOOL afHooks = FALSE;
switch (message)
{
case WM_CREATE:
myhookdata.nType = WH_CALLWNDPROC;
myhookdata.hkprc = CallWndProc;
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case ID_FILE_HOOK:
if (!afHooks)
{
myhookdata.hhook = SetWindowsHookEx(
myhookdata.nType,
myhookdata.hkprc,
(HINSTANCE) NULL, 0);
afHooks = TRUE;
}
else
{
UnhookWindowsHookEx(myhookdata.hhook);
afHooks = FALSE;
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
LRESULT WINAPI CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
CWPRETSTRUCT *msg = (CWPRETSTRUCT*)lParam;
switch((int)msg->hwnd)
{
case 0XC039A:
int i = 1;
break;
}
return NULL;
}
|
|
|
|
|
Hi,
I have a small question:
Working with Visual C++ .Net 2003, if I choose to create a .NET project, does this mean that I must work with managed C++ ?
Is MFC and Managed code mutually exclusive, or what is the relation between the two?
thanks
regards
doneirik
|
|
|
|
|
- bill' : local function definitions are illegal
- unexpected end of file found
wats wrong with it
#include<iostream>
#include<conio.h>
#include<cctype>
#include<string>
#include<stdlib.h>
#include<fstream>
#include<iomanip>
#include<time.h>
#include<string>
#include<stdio.h>
const char *filename="c:\\information.txt";
const char *file="c:\\rooms.txt";
using namespace std;
class hotel
{
private:
//string name;
//string family;
//string city;
//string telephone;
//int time;
//char type_room;
//double cost_perday;
int single;
int doubler;
int triple;
public:
ifstream infile,in,inp;
ofstream outfile,out,outp;
void menu();
void submenu();
void bill();
hotel(){single=100;doubler=200;triple=300;};
~hotel(){};
};
class information : public hotel
{
public:
string name;
string family;
string city;
string telephone;
int time;
char type_room;
double cost_perday;
//int single;
//int doubler;
//int triple;
};
int main()
{
hotel custom;
custom.menu();
getch();
return 0;
}
void hotel::menu()
{
char selection;
cout<<"****************************************************************"<<endl;
cout<<"xxx="" hotel."<<endl;
="" cout<<"r-=""> Reservation."<<endl;
cout<<"b-=""> Bill."<<endl;
cout<<"q-=""> Quit."<<endl;
cout<<"****************************************************************";
="" cout<<"enter="" your="" choose:="" "<<endl;
="" cin="">>selection;
cin.get();
selection=(char)toupper(selection);
switch(selection)
{
case 'R':
{
submenu();
break;
}
case 'B':
{
bill();
break;
}
case 'Q':
{
exit(1);
break;
}
default:
{
menu();
}
}
}
void hotel::submenu()
{
information n;
char choose;
int number=0;
int room;
char continues;
outfile.open (filename,ios::out|ios::app);
outfile.close();
int single=100;
int doubler=200;
int triple=300;
cout<<"*******************"<<endl;
cout<<"reservation"<<endl;
="" cout<<"="" ---------------="" "<<endl;
="" cout<<"s-="">Single"<<endl;
cout<<"d-="">Double"<<endl;
cout<<"t-="">Triple"<<endl;
cout<<"q-="">Quit "<<endl;
cout<<"*******************"<<endl;
="" cout<<"enter="" the="" type="" of="" room="" you="" want:="" "<<endl;
="" cin="">>choose;
cin.get();
choose=(char)toupper(choose);
n.type_room=choose;
int account_s=0;
int account_d=0;
int account_t=0;
int r_number;
char type;
string r_name;
string r_family;
string r_city;
string r_telephone;
int r_time;
double r_price;
if (choose=='S'||choose=='D'||choose=='T')
{
infile.open(filename,ios::in);
if (infile==NULL)
cout<<"Error opening the file"<<endl;
while(!infile.eof())
="" {
="" infile="">>r_number>>r_name>>r_family>>r_city>>r_telephone>>type>>r_price>>r_time;
if(type=='S')
{
account_s++;
}
if (type=='D')
{
account_d++;
}
if (type=='T')
{
account_t++;
}
}
single=single-account_s;
doubler=doubler-account_d;
triple=triple-account_t;
infile.close();
if (type=='S')
{
single=single+1;
}
if (type=='D')
{
doubler=doubler+1;
}
if (type=='T')
{
triple=triple+1;
}
if (n.type_room=='S')
{
if (single!=0)
{
cout<<"Total single bed available is "<<single;
cout<<"\nhow="" many="" single="" bed="" you="" need?";
="" cin="">>number;
}
else
{
cout<<"\nSorry,No Room available,Try at YMCA";
}
}
if (n.type_room=='D')
{
if (doubler!=0)
{
cout<<"Total double bed available is "<<doubler;
cout<<"\nhow="" many="" double="" bed="" you="" need?";
="" cin="">>number;
}
else
{
cout<<"\nSorry,no room available,try at YMCA";
}
}
if (n.type_room=='T')
{
if (triple!=0)
{
cout<<"Total triple bed available is "<<triple;
cout<<"\nhow="" many="" bed="" you="" need?";
="" cin="">>number;
}
else
{
cout<<"Sorry,no any room Available,Try at YMCA";
}
}
cin.get();
cout<<"First Name : ";
cin>>n.name;
cout<<"Family Name : ";
cin>>n.family;
cout<<"City : ";
cin>>n.city;
cout<<"Tel : ";
cin>>n.telephone;
cout<<"Charge :";
cin>>n.cost_perday;
cout<<"Days : ";
cin>>n.time;
int flag=0;
for (int i=1;i<=number;i++)
{
cout<<"Room NO.: "<<endl;
cin="">>room;
if (n.type_room=='S')
{
if(room<100 || room>199)
{
cout<<"You Should Choose The Number Between 100 And 199"<<endl;
cout<<endl;
="" i="i-1;
" continue;
="" }
="" infile.open(filename,ios::in);
="" while="" (!infile.eof())
="" {
="" infile="">>r_number>>r_name>>r_family>>r_city>>r_telephone>>type>>r_price>>r_time;
if (room==r_number)
{
cout<<"You Should Choose Other Room.This is occupied."<<endl;
cout<<endl;
="" flag="1;
" i="i-1;
" break;
="" }
="" else
="" {
="" infile.close();
="" if="" (flag="=1)
" continue;
=""
="" }
="" (n.type_room="='D')
" if(room<200="" ||="" room="">399)
{
cout<<"YOU Should Choose The Number Between 200 And 399"<<endl;
cout<<endl;
="" i="i-1;
" continue;
="" }
="" infile.open(filename,ios::in);
="" while="" (!infile.eof())
="" {
="" infile="">>r_number>>r_name>>r_family>>r_city>>r_telephone>>type>>r_price>>r_time;
if (room==r_number)
{
cout<<"You must choose other room.This is occupied."<<endl;
cout<<endl;
="" flag="1;
" i="i-1;
" break;
="" }
="" else
="" {
=""
="" infile.close();
="" if="" (flag="=1)
" continue;
="" (n.type_room="='T')
" if(room<400="" ||="" room="">499)
{
cout<<"You should Choose The Number Between 400 And 499"<<endl;
cout<<endl;
="" i="i-1;
" continue;
="" }
="" infile.open(filename,ios::in);
="" while="" (!infile.eof())
="" {
="" infile="">>r_number>>r_name>>r_family>>r_city>>r_telephone>>type>>r_price>>r_time;
if (room==r_number)
{
cout<<"You Should choose other room.This is occupied."<<endl;
cout<<endl;
="" flag="1;
" i="i-1;
" break;
="" }
="" else
="" {
="" infile.close();
="" if(flag="=1)
" continue;
="" }=""
="" outfile.open="" (filename,ios::out|ios::app);
="" outfile<<room<<"="" ";
="" outfile<<n.name<<"="" ";="" outfile<<n.family<<"="" outfile<<n.city<<"="" outfile<<n.telephone<<"="" outfile<<n.type_room<<"="" outfile<<n.cost_perday<<"="" outfile<<n.time<<endl;="" outfile.close();="" cout<<"the="" reservation="" is="" finished"<<endl;
="" if="" (choose="='Q')
" menu();
="" cout<<"another="" reservation?="" (y="" n)"<<endl;
="" cin="">>continues;
if(continues=='y'||continues=='Y')
menu();
}
void hotel::bill()
{
int temp_room,n=3,r_number,amount;
char type;
string temp_name;
string r_name;
string r_family;
string r_city;
string r_telephone;
int r_time;
double r_price;
double total,discount,sum=0,tax;
double service_tax;
int i;
cout<<endl;
cout<<"how="" many="" rooms="" you="" want="" to="" pay="" ?="" "<<endl;
="" cin="">>amount;
for (int k=0;k<amount;k++)
{
="" cout<<"please="" input="" the="" room="" number:="" "<<endl;
="" cin="">> temp_room;
}
infile.open(filename,ios::in);
cout<<"Customer Information"<<endl;
for="" (i="0;i<78;i++)
" {
="" cout<<"_";
="" }
="" cout<<endl;
="" cout<<"|"<<setw(4)<<"no."<<"|"<<setw(12)<<"first="" name"<<"|"<<setw(12)<<"family="" name"<<"|"<<setw(10)<<"city"<<"|"<<setw(15)<<"telephone"<<"|"<<setw(5)<<"type"<<"|"<<setw(6)<<"price"<<"|"<<setw(6)<<"days"<<"|";
="" cout<<"|";
="" (int="" l="1;l<78;l++)
" int="" nobody="0;
" m="0;m<amount;m++)
" while="" (!infile.eof())
="" infile="">>r_number>>r_name>>r_family>>r_city>>r_telephone>>type>>r_price>>r_time;
if (temp_room==r_number )
{
cout<<endl;
cout<<"|"<<setw(4)<<r_number<<"|"<<setw(13-r_name.length())<<r_name<<"|"<<setw(13-r_family.length())<<r_family<<"|"<<setw(11-r_city.length())<<r_city<<"|"<<setw(16-r_telephone.length())<<r_telephone<<"|"<<setw(5)<<type<<"|"<<setw(6)<<r_price<<"|"<<setw(6)<<r_time<<"|";
="" cout<<endl;=""
="" cout<<"|";
="" for="" (int="" i="0;i<77;i++)" {
="" cout<<"_";
="" }="" sum="sum+r_price*r_time;
" nobody="1;
" break;
="" }
="" else
="" if="" (nobody="=0)
" cout<<"\nthe="" room="" "<<temp_room<<"="" is="" empty.";
="" infile.close();
="" (sum="">0 && sum<=500)
{
total=sum*(1+0.15+0.05);
discount=0;
tax=sum*0.15;
service_tax=sum*0.05;
}
else
{
if (sum<=1000)
{
discount=sum*0.1;
total=sum*(1+0.15+0.05-0.1);
tax=sum*0.15;
service_tax=sum*0.05;
}
else
{
if (sum<=5000)
{
discount=sum*0.15;
total=sum*(1+0.15+0.05-0.15);
tax=sum*0.15;
service_tax=sum*0.05;
}
else
{
discount=sum*0.2;
total=sum*(1+0.15+0.05-0.2);
tax=sum*0.15;
service_tax=sum*0.05;
}
}
}
cout<<endl<<endl<<endl;
cout<<"----------------------"<<endl;
="" cout<<"sub="" total="" :="" "<<sum<<endl;
="" cout<<"discount="" "<<discount<<endl;
="" cout<<"tax="" "<<tax<<endl;
="" cout<<"service="" tax="" "<<service_tax<<endl;
="" cout<<"total="" "<<total<<endl;
="" cout<<"\npress="" any="" key="" to="" return="" main="" menu.";
="" getch();
="" int="" comp="0;
" for="" (i="0;i<amount;i++)
" {
="" infile.open(filename,ios::in);
="" while="" (infile)
="" infile="">>r_number>>r_name>>r_family>>r_city>>r_telephone>>type>>r_price>>r_time;
if (temp_room!=r_number && r_number!=comp )
{
out.open(file,ios::out|ios::app);
out<
|
|
|
|
|
|
ya i found but thx anyway
and another problem is
the information isnot passing to the txt
|
|
|
|
|
|
|
Hi,
I need to extract the text from a PDF file into a plain txt file. Many articles on programming with pdf are for C# but I need to work with c++
anyone who can help me ??
|
|
|
|
|
Hi,
I have an MFC Dll with multiple directories like,
MyProj,
MyProj/Sample1
MyProj/Sample2
The class files are under the Sample1 and Sample2 directories. However, the StdAfx.cpp and the StdAfx.h (precompiled header) are under the parent directory (MyProj).
My question is, If we need to "Use precompiled header" for the cpp files under Sample1/2 directories, is it sufficient if we
#include "StdAfx.h" and "Use precompiled header" through "StdAfx.h" for these files
Or
Do we need to give the relative paths for the precompiled header
like #include "../StdAfx.h" and the same for the Use precompiled header "../StdAfx.h"
Thanks in advance,
Raghav
|
|
|
|
|
Yes, you can get by with a single stdafx.h and stdafx.cpp for each project.
My understanding is that your project (DSP, DSW) is in a single location and your source files are in different folders. This works fine. The single stdafx.h and stdafx.cpp should be in the location where the DSP and DSW are located.
You might need to include the other folders int he 'proeprocessor' tab - as additional include directories, so the header files in those other folders are visible to files in the project folder and to each other.
I do this all the time with a folder of 'common code' and other folders containing their own projects, each referencing headers and source files in the 'common code' folder.
|
|
|
|
|
Hi,
Thanks for the reply. Actually, it works by giving the common "StdAfx.h" as the precompiled header for all the source files under different sub directories of the project.
However, when i try to open the StdAfx.h file (using "Open document") from the #include "StdAfx.h" in the cpp file (which is in the sub directories), it is opening a StdAfx.h file of another DLL project. I am not sure if the compiler is taking the proper StdAfx.h file during compilation.
Actually, we have around 20 DLL projects under the same "Sources" directory and each one of these DLLs has a separate StdAfx.h file. How can we be sure that the StdAfx.h file included in a DLL is not referenced by the source files of another DLL project?
Thanks,
Raghav
|
|
|
|
|
I am not sure, except to check your global includes setting and then to check the preprocessor setting for the debug and release of each project.
Also, it is possible that one of the paths might have snuck into an environment variable, but I thought those are only used for command line builds.
I usually do this, and have avoided many problems as a result:
1. I put ONLY the Platform SDK include paths into the global include paths (Tools Menu, Options Menu, Dirctores Tab, Include Files)
2. I never put anything implying a relative path for the stdafx.h. It is always plainly
#include "stdafx.h"
3. I modify the preprocessor setting for each project to include the local directory first as in "." and then follow it with the other folders required.
4. I never place a stdafx.h or stdafx.cpp in a folder that is going to contain 'shared' header or source files, as this will lead to the confusion about which stdafx.* to actually include.
I think someone wrote a 'header dependency walker' type tool and posted it on CodeProject. Maybe it will help you to determine which files are including which stdafx.h
|
|
|
|
|
Hi,
Thanks for the helpful information. I have modified the preprocessor settings accordingly. I also searched for the header dependency walker, but could not locate it in CodeProject or elsewhere. Please let me know if you have the link to it.
Thanks,
Raghav
|
|
|
|
|
|
hi,
i want to make an app which will be able to transfer files over bluetooth, over the obex file transfer profile. since i am a novice to both networking and visual c++ plz help me find an easy to use api or a sockets implementation for this or guide me how to do the same
|
|
|
|
|
I want to write wmi program using vc++(win32).Beacause c++.net or c# does not run on win98.How can i do this?Can u give some examples?
Please help me...
A lot of thanx...
|
|
|
|
|
I think you will probably need to implement use the IWbemLocator, IWbemServices and IWbemObjectSink interfaces. What are you trying to achieve?
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
I am trying to get system information of a local computer.But i new in win32.
Thanx
|
|
|
|
|
|
Hi all,
I recently was helped out here and given a pointer to use Createfile/Readfile/Writefile for my direct disk access in a bit of code I'm working on...
Unfortunately, while it seems fairly straightforward, I'm having a few difficulties.
The following is my code (with all error checking and other superfluous bits removed, just for clarity - but they are really there!).
I can't for the life of me figure out why this doesn't work. It should simply:
1 - Open the A drive for reading (this does seem to happen)
2 - Open c:\file.img for writing (this does seem to happen)
3 - Read 256bytes from the A drive in to a buffer (actually only doing 256bytes during testing... what I really want it to do is get the size of the disk using GetDiskFreeSpaceEx, then use that as the size to read/write so it does the whole disk)
4 - Write these 256bytes back to c:\file.img
What ends up happening is that I get 256bytes of what appears to be random garbage written in to the file... so it's writing, but WHAT it's writing and where it's getting it from I have no idea...
It's likely the problem lies in a fundamental failure to understand how this process is supposed to work. Therefore, this is probably something insanely simple and I'm going to feel like a complete moron, but as a relative beginner in C++ (despite the scary concept that I now do it "officially" for work) I think I'm entitled to be a moron on rare occasions
<br />
HANDLE hDriveRead;<br />
hDriveRead = CreateFile(TEXT("\\\\.\\a:"), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);<br />
<br />
HANDLE hFileWrite;<br />
<br />
hFileWrite = CreateFile(TEXT("c:\\file.img"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);<br />
<br />
DWORD dwImageBuffer[256];<br />
DWORD nBytesToCopy=256;<br />
DWORD nBytesRead;<br />
DWORD nBytesWritten;<br />
ReadFile(hDriveRead, dwImageBuffer, nBytesToCopy, &nBytesRead, NULL);<br />
WriteFile(hFileWrite, dwImageBuffer, nBytesToCopy, &nBytesWritten, NULL);<br />
<br />
CloseHandle(hFileWrite);<br />
CloseHandle(hDriveRead);<br />
Any help would be greatly appreciated.
|
|
|
|
|
YttriumOxide wrote:
What ends up happening is that I get 256bytes of what appears to be random garbage written in to the file
What are you expecting to see in the image file? The first sector (512 bytes) of the disk is the boot sector, which has mostly machine language code.
--Mike--
LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
I'm aware of that... but what I'm getting really is garbage - not the first 256bytes of the disk (which as you quite rightly point out is the first 256bytes of the bootsector).
|
|
|
|
|
Hi,
I've subclassed CComboBox. I've setup the background and text colours called Invalidate(). Which works perfectly well with the edit box. It's when I dropdown it's crashing the app. I want to able to change the colour of the listbox part as well.
Here's the code snippet:
<br />
BEGIN_MESSAGE_MAP(CComboEx, CComboBox)<br />
ON_WM_CTLCOLOR_REFLECT()<br />
ON_WM_CTLCOLOR()<br />
END_MESSAGE_MAP()<br />
<br />
<br />
HBRUSH CComboEx::CtlColor(CDC* pDC, UINT nCtlColor) <br />
{<br />
<br />
<br />
pDC->SetTextColor(m_Text);<br />
pDC->SetBkColor(m_Background);<br />
pDC->SetBkMode(TRANSPARENT);<br />
m_brush.DeleteObject();<br />
m_brush.CreateSolidBrush(m_Background);<br />
return m_brush;<br />
}<br />
<br />
HBRUSH CComboEx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) <br />
{<br />
HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);<br />
<br />
return hbr;<br />
}<br />
<br />
Thanks in advance,
Alton
|
|
|
|
|
I need some help with the function CRecentFileList::GetDisplayName.
How did I get the full Path back from this function?
Although the full Path is stored in the Registry I always retrieve the shortened Path like
"D:\MyProgramm\DirLevel1\...\DirLevel4".
Could someone give me a hint on that please?
Thanks
|
|
|
|
|
|