|
I use ActiveX componet microsoft winsock ver 6
Mycode is
Server:
VARIANT NewMemberPackage;
NewMemberPackage.vt = VT_BSTR;
NewMemberPackage.bstrVal = MyPacked.AllocSysString();
m_winsockmember.SendData(NewMemberPackage);
----------------------------------------------------------------
Client:
VARIANT mPackage;
VARIANT menumType;
VARIANT mmaxLength;
mPackage.vt = VT_BYREF|VT_BSTR;
menumType.vt = VT_UI1;
menumType.bVal = VT_BSTR;
mmaxLength.vt = VT_I4;
mmaxLength.iVal = 512;
m_WinsockConnect.GetData(&mPackage, menumType, mmaxLength);
---------------------------------------------------------------------
In client is wrong but I can't found information about this Component in my country. How I Programming VC++ Code In Client. Helpme Please
|
|
|
|
|
Hi. I am trying to finish this code for an address book using a struct. Can someone please correct my code. If anyone wishes to help please run the program and you will see what my problem is.
After the user makes an entry (with choice 1), it should be able to display (with choice 2). My display function is not working. I am not doing something right. I need help with that, please, anyone ! Also, if the user enters more than one entry, the display function should display these entries one at a time. The user will hit enter to display the next entry. And so forth. Here is my code:
const char FILENAME[80] = "C:\\MS Visual C++\\Programs\\AddressBooktest.dat";
struct addresstype
{
char lastname[21];
char firstname[21];
char line1[31], line2[31], line3[31], line4[31];
char phone[14];
};
int menu();
void add_to_address_book(struct addresstype &);
void output_info(struct addresstype &, ofstream &);
void input_info(struct addresstype &);
void display_address_book(struct addresstype);
void main()
{
struct addresstype addin;
int choice=0;
ofstream outfile;
outfile.open(FILENAME, ios::out);
if(outfile.fail())
{
cout<<endl;
cout<<filename<<"="" could="" not="" be="" opened="" for="" output."<<endl;=""
cout<<"the="" file="" might="" corrupted."<<endl;=""
exit(1);=""
}=""
else=""
{=""
while(choice!="3)"
choice="menu();"
if(choice=""> 3)
{
system("cls");
cout<<"\t\t" << "INVALID ENTRY"<<endl<<endl<<endl;
}=""
else=""
{=""
switch(choice)=""
case="" 1:="" add_to_address_book(addin);=""
output_info(addin,="" outfile);=""
break;=""
case="" 2:=""
input_info(addin);=""
display_address_book(addin);=""
outfile.close();=""
int="" menu()=""
int="" choice="0;"
cout<<endl<<endl;=""
cout<<"\t\t"="" <<="" "what="" do="" you="" want="" to="" do?"<<endl<<endl;="" "1.="" add="" an="" entry"<<endl;="" "2.="" display="" entries"<<endl;="" "3.="" exit"<<endl;=""
cout<<endl<<endl<<endl;="" "enter="" your="" (1,="" 2="" or="" 3):="" ";=""
cin="">>choice;
return choice;
}
void add_to_address_book(addresstype& addin)
{
system("cls");
cout<<endl<<endl;
cin.ignore(100,="" '\n');=""
cout<<"\t\t"="" <<="" "last="" name:="" ";=""
cin.get(addin.lastname,="" 21,=""
cin.ignore(100,="" "first=""
cin.get(addin.firstname,="" "address="" line="" 1:=""
cin.get(addin.line1,="" 31,="" 2:=""
cin.get(addin.line2,="" 3:=""
cin.get(addin.line3,="" 4:=""
cin.get(addin.line4,="" "telephone="" number:=""
cin.get(addin.phone,="" 14,=""
system("cls");=""
}=""
void="" output_info(addresstype&="" addin,="" ofstream&="" outfile)=""
{=""
outfile<<addin.lastname="" "#"=""
<<addin.firstname=""
<<addin.line1=""
<<addin.line2=""
<<addin.line3=""
<<addin.line4=""
<<addin.phone="" endl;="" input_info(addresstype="" &addin)=""
ifstream="" infile;=""
infile.open(filename,="" ios::in);=""
if(infile.fail())=""
cout<<endl;=""
cout<<filename<<"="" could="" not="" be="" opened="" for="" writing="" into."<<endl;=""
cout<<"the="" file="" might="" corrupted."<<endl;=""
exit(1);=""
infile.get(addin.lastname,="" '#');=""
infile.ignore(1);=""
infile.get(addin.firstname,=""
infile="">> addin.line1;
infile.ignore(1);
infile >> addin.line2;
infile.ignore(1);
infile >> addin.line3;
infile.ignore(1);
infile >> addin.line3;
infile.ignore(1);
infile >> addin.phone;
infile.ignore(100, '\n');
}
void display_address_book(addresstype addin)
{
system("cls");
cout<<"All the entries are:"<
|
|
|
|
|
You people have seen games like RedAlert, Starcraft etc, the way we have a little window into a large map. We can scroll that window to shift our focus to other regions of the map. I want to know how that is possible in MFC? I need a view that only looks at part of the whole "world", and then I want to be able to scroll to other parts without disturbing the underlying "world".
Here's what I have in mind. The world will be a square with 6000 miles sides. I want to see, maybe, a 50 x 50 mile area through my view. So when the view scrolls I see a new portion of the world.
I want to be able to make changes in the world(like change the (x,y) of a car) (without dealing with device coords), and the view updates at regular intervals to show the change(if the view is positioned above an area where a change took place).
Someone help me!
|
|
|
|
|
Two things:
1/ If you're writing a game, you'll want to use DirectX, not just GDI/MFC.
2/ This sort of view is easy to achieve. You keep track of the whole world, and what it is doing, and remember the top left point you are at - then only try to draw things within the 50 x 50 box that is built from it, and compensate for these values when drawing. i.e. if I have an 800x600 screen ( you'd have to draw 600x600 to maintain aspect ratio - option bars on the edges ? ) and I am at point 1000/500, I draw anything between 1000/500 and 1050/550. I subtract 1000 from all X values and 500 from all Y values before I draw, and scale by 12 in both directions to go from 50 to 600. BTW, if you need to divide for any conversions you should multiply by a float, multiplication is faster than division.
As for your little view, again it's a case of taking the point clicked on, normalising it ( making it's top left edge 0,0 and moving the other points so the size is unchanged ) and then getting a co-ordinate by scaling betwen the size of the scanner box and the size of your world.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
>> 1/ If you're writing a game, you'll want to use DirectX, not just GDI/MFC.
OpenGL is another option also. For simple things, OpenGL is easier to pick up than DirectX. But if you're in it for the long run, DirectX will offer more flexibility at the expense of a high learning curve.
- Pros
|
|
|
|
|
I don't think it's that simple - Quake is/are written using GL, after all. I agree with the curve thing - I got GL working in less time than it took me to figure how to get DirectX started. But I presume that a RTS game will use an isometric view, which makes DX a better option, because you can use Direct Draw instead of having to create and draw 3D objects, and given that you'd use Direct Sound/ Direct Input anyhow, it seemed the way to go in this case. But it was remiss of me not to mention GL, all the same.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
Was this reply meant for someone else. My problem is an address book. Not a game!
What does this have to do with my qustion???
|
|
|
|
|
I've noticed this forum mixing things up a little - your reply has appeared in the thread 'A window into a big world', where I answered a question relating to games such as Red Alert.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
The answer you have already gotten is a good one, I think. However, since you expressly asked
if it could be done in MFC, I figured I would toss in here that it can.
I don't want to sound like a commercial, but there is a book called "Beginning Visual C++" from
Wrox Press written by Ivor Horton that contains an example of a sketch program that imcorporates
multiple views and scaling of the views. It sounds like a solution to what you want to do here.
I have the book and learned a lot from it (but I am a beginner). You may want to check it out.
The crux of it is multiple CViews of the CDocument. You then set your scale modes.
I hope that helps. David.
|
|
|
|
|
I store an exe image in my program as a resource,then I load this block in the memory but now I want to execute this exe block wihout need to write it in exe file
|
|
|
|
|
As far as I know you cannot do that.
What you can do is create a temporary file for the .exe with the FILE_FLAG_DELETE_ON_CLOSE flag:
search in MSDN for FILE_FLAG_DELETE_ON_CLOSE and Jeffrey Richter's Win32 Q&A Januari 1998.
This makes sure the file is deleted after all the refering handles are closed.
What you also could try is experimenting with the Win32 API call WriteProcessMemory...
Best regards.
--------------------------------------------------
If my messages appear curt, I apologize.
I try to be brief to save your time as well as mine.
--------------------------------------------------
|
|
|
|
|
I'm using WriteFile, CopyFile and so on... and creating an application that has to work without mouse and without some keyboard combinations (Alt+tab...).
if during the operation of copying files to the disk the user removes the disk, a lot of messages pop up and I would like to avoid this.
Could you help me?
Thank you in advance...
|
|
|
|
|
Excerpt from WriteFile documentation:
"If you are attempting to write to a floppy drive that does not have a floppy disk, the system displays a message box prompting the user to retry the operation. To prevent the system from displaying this message box, call the SetErrorMode function with SEM_NOOPENFILEERRORBOX."
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hello All,
How to convert a variant, which is returned by vb dll that
actually contains a adodb.recordset, to recordet in vc++?
I casted it to IDispatch and to Recordset. But always I'm not getting
records. If I used recordcount, it's returning only -1.
Advance thanks for ur reply.
regards,
ramesh
|
|
|
|
|
You can convert the IDispatch to a _RecordsetPtr.
//mycontrol.h
_RecordsetPtr m_pRS;
//mycontrol.cpp
STDMETHODIMP CMeCTable::put_DataSource(IDispatch *newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (m_pRS == NULL)
m_pRS = NULL;
HRESULT hr = newVal->QueryInterface(__uuidof(_RecordsetPtr), (void**)&m_pRS);
if FAILED(hr)
{
return E_FAIL;
}
}
|
|
|
|
|
Hi chenzhu,
Thank you very much for your suggestion. Even after using the QueryInterface also I didn't get the exact value from the GetRecordCount function. I got one reply such that it is because of the cursor type.
Now, I can traverse thru recordset by using Move functions. The only thing I couldn't able to get the records count and fields count. If any more solutions, let me know.
Thanking you,
regards,
Ramesh
|
|
|
|
|
Hi!
how to PtinLine Function?
Thanks.
|
|
|
|
|
You mean you want to know how to figure out if a point is in a given line ? I suppose you'd have to traverse it, or you could use a mask to check. It depends on what you're doing - i.e. how often you need to check and how quickly you need and answer.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
Hello, I am not familiar with OpenGL and its API, but I was wondering how I would go about using the function glReadPixels()? Yes, yes, I have looked at all of the declarations for it as MSDN, etc., but I still am I not sure how to utilize it. In order to use the function, must I intialize a bunch of OpenGL things as I would for DirectDraw? How would I incorporate this function in a Win32 program that reads the color values of pixels in a game running in OpenGL? Also, once pixel data is retrieved, say with the GL_RGB flag (or any other one for that matter. I'm not too familiar in which mode to use), how do I access the color information of the pixels? Is it stored in hexademical, etc? If possible, it would to great to have example code showing how to use glReadPixels(). Thank you very much in advance.
-Helpless programmer
|
|
|
|
|
i'm no opengl expert but when you read a pixel from a display via a library call such as you are talking about there is usually another function somewhere in the lib that lets you get / set the pixel format (ie, a/r/g/b or a/b/g/r or whatever)
as for hexadecimal ... all numbers are the same regardless of the base encoding they use ... 0xff == 255 == 11111111b etc
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
This is an article about creating a jpeg out of OpenGL screen, (it uses glReadPixels)
http://www.codeguru.com/opengl/snaptojpeg.shtml
Jonathan de Halleux, Belgium.
|
|
|
|
|
|
On the shelves at your local Best Buy.
But seriously, call GetLogicalDrives() to determine the drive letters in use, then GetDriveType() on each drive. GetDriveType() returns DRIVE_CDROM for CD-ROM drives.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
Thanks! Have a great weekend!
|
|
|
|
|
This is an example:
void GetCDROMDrive(void)
{
char buf[10];
BOOL bFind = FALSE;
for (int i = 0;i < 24;i++)
{
if (bFind)
break;
sprintf(buf,"%c:\\",'C'+i);
WORD type = GetDriveType(buf);
switch(type)
{
case DRIVE_UNKNOWN:
break;
case DRIVE_NO_ROOT_DIR:
break;
case DRIVE_REMOVABLE:
break;
case DRIVE_FIXED:
break;
case DRIVE_REMOTE:
break;
case DRIVE_CDROM:
//("CD-ROM");
lstrcpy(g_szCD_ROM,buf);
break;
case DRIVE_RAMDISK:
break;
default:
break;
};
}
}
welcome you to Sky...
|
|
|
|
|