|
I need one more thing, I can't seem to find the getline function anywhere, can you tell me in which subtitle it is located in, like files or c++/mfc or whatever...
|
|
|
|
|
|
#include <vector>
#include <algorithm>
#include <functional>
What do those headers mean
|
|
|
|
|
vector contains the dynamic array vector class. algorithm contains all the algorithms that work on STL containers ( well, most of them ), and functional contains stuff you need to write your own function objects ( from memory ).
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Sry about that but I was looking at codeproject articles... wow what a nice collection there is at cplusplus.com
|
|
|
|
|
I need one more thing, I can't seem to find the getline function anywhere, can you tell me in which subtitle it is located in, like files or c++/mfc or whatever...
|
|
|
|
|
Snyp wrote:
...if I find the getline() function and how it works...
Try here.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
i tried to convert the code showed in this article (http://www.codeproject.com/bitmap/screencapture.asp) to non-mfc Standard Win32 code, with a bit of WTL. I came up with this:
void CMainDlg::CopyWndToClipboard(HWND pWnd )
{
CBitmap bitmap;
CClientDC dc(pWnd);
HDC memDC;
RECT rect;
memDC = ::CreateCompatibleDC(dc.m_hDC);
::GetWindowRect(pWnd,&rect);
bitmap.CreateCompatibleBitmap(dc.m_hDC, rect.right-rect.left,rect.top-rect.bottom );
CBitmap* pOldBitmap= (CBitmap*)(HBITMAP)::SelectObject(memDC,&bitmap);
::BitBlt(memDC,0, 0, rect.right-rect.left,rect.top-rect.bottom, dc.m_hDC, 0, 0, SRCCOPY);
::OpenClipboard(::GetParent(pWnd)) ;
EmptyClipboard() ;
SetClipboardData (CF_BITMAP, (HBITMAP)bitmap ) ;
CloseClipboard () ;
SelectObject(memDC,pOldBitmap);
bitmap.Detach();
}
Which doesn't seem to work. All is does is throw some rubbish on the clipboard.
Does somebody know a function to replace my code or does somebody know what i'm doing wrong?
Thanks
|
|
|
|
|
The problem i think its because of Detaching bitmap at the end.
Comment out that and try.
May be you can move Bitmap variable to class variable.
Hope this helps!!!
|
|
|
|
|
hello
I wants to compare tow names in two columns in a sheet of excel,and i want to find the name redundant in the two columns.
how we can do that with VC?
|
|
|
|
|
i need to find a form by it's title.
thanks.
|
|
|
|
|
how can i access the system.web classes from a managed c++ class library project? i am not able to add a reference from the project menu.
|
|
|
|
|
I think you want the Managed C++ Forum
My neighbours think I am crazy - but they don't know that I have a trampoline. All they see my head bobbing up and down over the fence every five seconds
|
|
|
|
|
hey there again-
My problem is I need to create a program that acts as a card dealer. The user will input how many cards he/she wants, then it will deal out those cards. I did a project kinda like this before, but now I have to do it using a main program, three header files (card.h, deck.h, and hand.h) and three specification files (card.cpp, hand.cpp, deck.cpp). I do not know exactly how to "create" the cards or how to tie all of these files together. I also hardly understand in which order the files will operate. If anyone has any advice or wisdom for me that would be great. Thanx.
ZackyD
|
|
|
|
|
Don't sleep in class.
Seriously, if you're coding and you get stuck, I'd love to help you. But if you don't know where to start, you need to either pay attention in class, or change schools.
*sigh*
OK - each file typically represents a class. You also need an entry point for your program, which is your int main() method. Now, the code you put in your main method is the start of program flow, and typically you'd include the three head files in the file that contains it. Now you can create and manipulate cards, decks and hands in your main program, because it can 'see' them. Putting them in seperate files makes them easy to include in multiple places, and also means you have no problems with trying to use one class so it can 'see' another.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
You can use a scheme to identify rank and suit by using div() on an range of integers from 0 to 51 (this is how the cards dll works - google for Cards.dll for tips on how a card can be represented) In this case you could wrap this up with a class with little more than an integer member and an overloaded member that would output the rank and suit.
Now then - what does a deck do? Well, it needs a number of cards, a way of shuffling them, and a way of doling one out - so, you might have a int GimmeACard() method, e.g.
A hand will need to RecieveACard(int) likewise.
The dealer (main.cpp) will need to:
have a deck to work with (for int GimmeACard() )
have hands to be dealt to (with ReceiveACard(int) )
Does this help? Note that the nice thing is that the details involved in the operations are hidden below the interfaces, leaving you with a nice little black box to work with. Take the case of the Deck class. It is free to worry about what type of randomization to use when the Shuffle() method is called. It takes care of knowing what cards are left in the deck after each one is doled out.
Your dealer can then just say:
// declare the object instances
Deck myDeck;
Hand myHand; // or make and array of pointers to hands and new 'em
// Shuffle the deck
myDeck.Shuffle(); // could take a seed parameter
// deal a card to a hand
myHand.RecieveACard(myDeck.GimmieACard());
Each .cpp file #includes its corresponding .h file.
Your main.cpp will #include the headers it needs, and when you instantate the objects they'll be ready for use. The linker will take care of tieing the files together - just make sure they're in the project.
Hope this helps - I'm just killing a little time here, having have had a bit of fun with this kind of thing in the past...
|
|
|
|
|
Hey Man thanks a million!!!!!!!!!!!!!!!!!!!!!!!
zackyD
|
|
|
|
|
Hey, I have a problem. A have a project in a computer science class and I am lost on how to organize all of these OOP files (header files, specification files) Anyways, if someone out there could somehow explain the main concepts behind OOP, that would be very helpful. If there is anyone out there that has a sample program to look at that would be great as well. I am really lost on this subject. Thanx.
ZackyD
|
|
|
|
|
Check out CodeProject code section for examples of object-oriented designs.
Kuphryn
|
|
|
|
|
where do i find the codeproject code section?
ZackyD
|
|
|
|
|
Think of an object as a person, place, or thing that represents what a system needs to know and do about an actual person, place, or thing. Think of an object in first-person form. Instead of saying "How can it do ____ to that object?", say "I am a ____. I know hot to ____ myself." instead. When you can look at an object in this fashion, the laying out of objects and the relationship(s) between objects becomes clearer. Something that I learned in undergraduate school was that of "strong cohesion, weak coupling." While it was not discussed in the context of OOP, it still applies.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi all, im sure this will be an easy question for some of you but i have failed to find an answer after searching through previous posts.
When i open a CFileDialog in my app the directory it starts in is different to the return value of GetCurrentDirectory() (and _getcwd). How do i get the directory that a CFileDialog would point to if i were to open it?
Cheers for any help,
Andy.
|
|
|
|
|
Does this help?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Cheers for the reply but no. I dont want to set the initial directory of the CFileDialog. I want to get the directory that a filedialog will point to if i were to use it. This directory may be different to the current working directory. MFC must be storing this somewhere in the registry based on the app name but i'll be buggered if i know where.
Cheers anyway.
Andy.
|
|
|
|
|
Have you looked at the documentation for the lpstrInitialDir member of the OPENFILENAME structure? I'm pretty sure that it details what Windows will use as the directory when one is (not) specified.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|