|
You cannot.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
I have drawn an image on picture control using GDI. I want to crop the image accroding to user selection with a rectangle over the image.
How can I draw a transparent rectangle area over an image?
|
|
|
|
|
Here's an old post of mine describing how to rubberband a line but the idea is basically the same for a rectangle. Rubberbanding[^]
Also have a look at CRectTracker which works nice in this context.
|
|
|
|
|
Look for ROP2 drawing codes in the GDI documentation (function SetROP2()). They do exactly what you want.
Rozis
|
|
|
|
|
Hi!
I've stored my file contents in a Vector of std::string . My file has 55 rows of numbers. I've to get a particular row from the vector. How to do this?
Code:
void CGameMenuPlayerProfileState::setPlayerData(int countryId, int btnId)
{
ifstream myfile("E://Work//Data//playerdata.txt.txt", ios_base::in);
std::string line;
vector<std::string> sets;
vector<std::string>::iterator it = sets.begin();
int player_no = (countryId*11)+btnId;
while(getline(myfile, line))
{
sets.push_back(line);
cout<<line;
}
}
I've to get a particular player data using the int player_no; . i.e I've to get sets[player_no].
How to do?
|
|
|
|
|
T.RATHA KRISHNAN wrote: How to do?
You answered your question yourself:
sets[player_no];
|
|
|
|
|
Firstly, don't go messing round with iterators until after you've filled the collection:
ifstream myfile("E://Work//Data//playerdata.txt.txt");
typedef vector<string> SetColl;
SetColl set;
string line;
while (getline(myfile, line))
{
set.push_back(line);
}
int player_no = (countryId*11)+btnId;
if (player_no < set.size())
{
string player_data = set[player];
}
Steve
|
|
|
|
|
Hi!
It's printing "player_no" value.i.e if contrycode =1 & btnid =1,it will print 11 Not the contents of row corresponting to 11of myfile.I want the contents of the row of myfile corresponting to player_no to be printed.
How to do?
|
|
|
|
|
What's wrong with:
sets[ player_number ]
?
I'm not sure what you're trying to do but if you only want a single row don't read the entire file. If you want player N (and you're using zero based indexing) read and discard the first N and read the (N + 1)th into the string.
Another option is to fix the size of the fields in the file so you can seek to the start of a particular line before doing a read.
Yet another is to create a class that represents each line (presumably player) and implement a constructor that initialises itself from a stream or an overloaded extraction operator.
Cheers,
Ash
|
|
|
|
|
Thanks. It's working. I did a mistake.
|
|
|
|
|
Hi all,
i m working on SDI type application,
i have some data in ListCtrl,in number or rows and column,i want to print this data and see preview for thing printing data.
there is data or row in List may be so large so i shift it and display in multi line,
but still is there is some problem exits.
like some times its not calculate correct no of pages to print,or some times problem in allignment.
i already checked so many articles for printing.
currently i taking help of this article for printing
Another ListView print (preview) sample.[^]
please provide me any sample application or example that perfectly print and preview the list data.
or tell me the better way or printing.
|
|
|
|
|
Hi!
I've got the following exception in my program.
Unhandled exception at 0x005e47c9 in SlogOut3D.exe: 0xC0000005: Access violation writing location 0x006f1b89.
My Code is:
ifstream myfile("E://Work//Data//playerdata.txt.txt", ios_base::in);
char* line = "";
ofstream test("E:\Work\Data\test.txt", ios_base::out);
if(!myfile.is_open())
{
cout<<"Opening File E://Work//Data//playerdata.txt failed"<<endl;
cout<<"ERROR Code:"<<"\t"<<GetLastError()<<endl;
}
if(!test.is_open())
{
cout<<"Opening File E://Work//Data//test.txt failed"<<endl;
cout<<"ERROR Code:"<<"\t"<<GetLastError()<<endl;
}
if(myfile)
{
myfile.getline(line, 1);
cout<<line<<endl;
test.write(line, 1);
}
Call Stack:
> SlogOut3D.exe!std::basic_istream<char,std::char_traits<char> >::getline(char * _Str=0x006f1b89, int _Count=0, char _Delim='
') Line 638 + 0x3 bytes C++
SlogOut3D.exe!std::basic_istream<char,std::char_traits<char> >::getline(char * _Str=0x006f1b89, int _Count=1) Line 596 C++
SlogOut3D.exe!CGameMenuPlayerProfileState::GUIEvent(CGameManager * pManager=0x0012fdb4, const irr::SEvent & event={...}) Line 143 C++
SlogOut3D.exe!CGameManager::OnEvent(const irr::SEvent & event={...}) Line 171 + 0x1d bytes C++
Irrlicht.dll!1000dccf()
[Frames below may be incorrect and/or missing, no symbols loaded for Irrlicht.dll]
Irrlicht.dll!10002d28()
Irrlicht.dll!1000e1b6()
Irrlicht.dll!101325ae()
Irrlicht.dll!101333b3()
shimeng.dll!6c9c4435()
gdi32.dll!763948d9()
user32.dll!760c0979()
opengl32.dll!6d50834f()
user32.dll!760bfd72()
user32.dll!760bfe4a()
user32.dll!760bfdf3()
user32.dll!760c018d()
user32.dll!760b8343()
Irrlicht.dll!10134005()
SlogOut3D.exe!main() Line 24 + 0x25 bytes C++
SlogOut3D.exe!_QueryPerformanceFrequency@4() + 0x347f bytes C++
SlogOut3D.exe!004f7f26()
kernel32.dll!7600d0e9()
ntdll.dll!773b19bb()
ntdll.dll!773b198e()
SlogOut3D.exe!applyAnisotropicFriction() + 0x4f bytes
Irrlicht.dll!10044800()
How to resolve this exception?
|
|
|
|
|
Dump the char* and use std::string instead:
#include "stdafx.h"
#include <tchar.h>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
ifstream ifs("C:\\In.txt");
string line;
while (getline(ifs, line))
{
cout << line << endl;
}
return 0;
}
Steve
|
|
|
|
|
Hi!
getline() expects only a char* not a std::string. IT shows error.
|
|
|
|
|
There's a getline[^] which accepts std::string s. Have you added #include <string> to the include files? If you haven't added using namespace std; somewhere in the scope remember you need to use a fully qualified name: std::string .
Steve
|
|
|
|
|
|
Hi all,
i have an static text control when i use to display some text in Static control,use SetWindowText
my text is "Test & Test Project" but its display like "Test _ Test Project" or "Test Test Project".
please tell me how can display the same text as it is whether it is contain 1 & or 2 &.
thank in advnace.
|
|
|
|
|
Use double ampersand - "Test && Test Project"
|
|
|
|
|
Try using two "&" characters: "Test && Test Project".
Steve
|
|
|
|
|
its a entry that is filled by user,how can i insist the user to enter && in place of &,
think if he did it but there no similarity again betwwn entered value and displayed value.
he enterd && but dispaly onle 1 &,
please tell me how can i handle it.
|
|
|
|
|
The cleanest approach would be to add the SS_NOPREFIX[^] style to the control.
Steve
|
|
|
|
|
Yes its done now thanks.
same problem with DrawText when i want to print this text.
please tell me how can i solve this.
|
|
|
|
|
If you look at the documentation for DrawText[^] you'll find this:
DT_NOPREFIX
Turns off processing of prefix characters. Normally, DrawText interprets the mnemonic-prefix character & as a directive to underscore the character that follows, and the mnemonic-prefix characters && as a directive to print a single &. By specifying DT_NOPREFIX, this processing is turned off. For example,
Example:
input string: "A&bc&&d"
normal: "Abc&d"
DT_NOPREFIX: "A&bc&&d"
Compare with DT_HIDEPREFIX and DT_PREFIXONLY.
Steve
|
|
|
|
|
|
You do not want the user to enter it that way.
Just replace & with && before calling SetWindowText .
You could use CString::Replace for this.
|
|
|
|