|
ok, thanks for answers
I have finally chosen to use an option tree control: http://www.codeproject.com/treectrl/coptiontree.asp
This is a very cool and good looking library (maybe still needs some debug but is almost ok).
Thanks again
morbac
|
|
|
|
|
|
I need to first of all read a line of a file until a newling or '\n'. I would then store that to a string and put it into the first element in the array, then I will turn the previous string to empty then read the line until another newline '\n' and store that line to a string which will be stored at the next array element. I know that I have to allocate the array since I don't know how much lines will be in the array, could be hundreds to thousands of elements but I need to do this in win32. I will do the storing into the array elements until the end of the file is reached. I will be very happy if someone could help me, I so far have the following code:
int *p;<br />
int uc = 0;<br />
string all;<br />
cout <<"has something in it\n";<br />
try<br />
{<br />
p = new int;<br />
}<br />
catch(bad_alloc xa)<br />
{<br />
cout << "Allocation Failure\n";<br />
exit(1);<br />
}<br />
do<br />
{<br />
all = null;<br />
do<br />
{<br />
all = all + data.get(); <br />
} while(data.get != '\n');<br />
p[uc] = all;<br />
uc++;<br />
} while(data);<br />
delete []p;
Please help me, I would appreciate it if someone can make a similair but simpler program like this or help me with this or even an article about this if anyone know something like this.
|
|
|
|
|
Why not use a vector ? Why does it matter that you need to do it in Win32 ? Then use getline() to read the file.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I don't know how to use vectors and I have to do it in win32 is because I already started on a project with it and I can't go back and change its type... it would take too long. I also don't know how to use getline().
|
|
|
|
|
Snyp wrote:
I have to do it in win32 is because I already started on a project with it and I can't go back and change its type
What I asked is why does it *matter* that you're using Win32 ? The Microsoft libraries sit on top of the C++ language and should only be your first port of call if you're trying to do something OS specific, like throw up a window. Stuff C++ doesn't support.
Snyp wrote:
I don't know how to use vectors
Snyp wrote:
I also don't know how to use getline().
I have articles on this site on both, use the search box above.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Ok I think I know how I'm going to do this, first if I find the getline() function and how it works I will get the line store it to first element and then on and on until the end of file is reached. I will then use a sort to sort the big list.
|
|
|
|
|
Yes, exactly. One benefit of the STL is you get your sorting algorithms for free.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Thankyou very much, I don't use the stl alot to none but I think you made me 'cross over'
|
|
|
|
|
Then my job here is done
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
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
|
|
|
|