|
there are 8 records present in the DB already
Success makes life easier. It doesn't make living easier.
SH UVIK
|
|
|
|
|
shouvik.d wrote: there are 8 records present in the DB already
I am not talking about DB, but about the result returned by the query. Get the count of records before moving around in a recordset.
|
|
|
|
|
thanks
prob solved
I instead did this
m_pSet->Close();
query = "Select * from Book where Ac_no = '"+accnum+"'";
m_pSet->Open(CRecordset::dynaset, (LPCTSTR)query,CRecordset::none);
if(m_pSet->IsBOF() && m_pSet->IsEOF())
MessageBox("No records meeting the criteria");
else
{
m_pSet->MoveFirst();
do
{
name=m_pSet->m_Name;
auth=m_pSet->m_Author;
Item=accnum+"\t"+name+"\t"+auth+"\t"+CLibManView::GetStatus(m_pSet->m_Stat);
lb->AddString(Item);
m_pSet->MoveNext();
}while(!m_pSet->IsEOF());
}
Success makes life easier. It doesn't make living easier.
SH UVIK
|
|
|
|
|
Yeah. Always check status of db query results before using them.
|
|
|
|
|
plz can u reply to the prev page post titled
Data Exchange
Plz
Man can acquire accomplishments or he can become an animal, whichever he wants. God makes the animals, man makes himself.
G. C. Lichtenberg (1742-99), German physicist, philosopher.
SH UVIK
|
|
|
|
|
Friends,
I want to implement some file compression/decompression feature in my application. There is lot of code available here to zip the file and then unzip it. In my experience rar provides more compression than zip. But i am unable to find code that compresses file in rar form and then back to original form. Can anyone tell me where i can find such library ?
Imtiaz
|
|
|
|
|
I couldnt add more to the post, it kept giving me errors so I attached the link to this one and a continuation of the post.
http://www.codeproject.com/script/comments/forums.asp?msg=1823085&forumid=1647&XtraIDs=1647&sd=2+Oct+2006&ed=31+Dec+2006&author=godspeed123&stype=1#xx1823085xx[^]
I dont get it, I will fool around with it a little more.
I was looking at the code and there is another class associated to each filter a CSourceStream. After looking at the documentation this class is used to tell the next filter what data to expect. Do I have this right?
So when we get through this other problem abover, how do I pass the height and width, and size, etc of pictures in memory, do I use the similar approach of COM in this filter or is there another way. Cause it seems that in the examples they all populate the values all in the constructors. Is there a way to set this up in code, before I begin to pass data into the filter.
So would I do the following:
1.) CoCreate
2.) Instatiate a COM Class for the CSourceStream Overriden class
3.) Pass all the data in
4.) Then the GetMediaType gets called,
Or am I going about this the wrong way.
Cause I am not sure when the GetMediaType is called. Cause if it is called when the CoCreate hits then this wont work.
Thanks for all the help again
|
|
|
|
|
CSourceStream is the output pin for the source filter.
GetMediaType won't get called until you render the graph - when the pins connect.
You can initialize anything needed after the CoCreateInstance and before the pins connect.
I still can't get your code to work but I made a new stripped-down filter that works.
I'll send it to you if you'd like - shoot me an email.
The only thing I saw in your code was COM not initialized on the app thread but that didn't fix it
Mark
|
|
|
|
|
I guess so, but I would like to be sure of that:
LPSTR CTamScintillaCtrl::GetText ()
{
long lLen = SendMessage(SCI_GETLENGTH, 0, 0) + 1;
if (lLen > 0)
{
TCHAR *pReturn = new TCHAR[lLen];
if (pReturn != NULL)
{
*pReturn = '\0';
SendMessage(SCI_GETTEXT, lLen, (long)pReturn);
return pReturn;
}
}
return NULL;
}
Thank you.
|
|
|
|
|
The caller of the GetText function is required to delete the return value. They can also check the return value for NULL as an error condition.
Style note: The "(long) " cast on the "SendMessage(SCI_GETTEXT, lLen, (long)pReturn); " is A Bad Idea. It should be a "(LPARAM) " cast instead.
Software Zen: delete this;
|
|
|
|
|
The caller of the GetText function is required to delete the return value. It may also check the return value for NULL in the case of an error condition.
Style note: The "(long) " cast in the "SendMessage(SCI_GETTEXT, lLen, (long)pReturn); " call is A Bad Idea. It should actually be an "(LPARAM) " cast.
Software Zen: delete this;
|
|
|
|
|
I have 2 remarks for you.
first of all, you seem to program in C++ (because of the namespace your function is placed on), so, why do you bother using C-Style Strings like this ? can't you use the CString class, or std::string if you can't use MFC ?
the second point i notice is that your functions tells that is returns a LPSTR (char* string), but you actually construct and return a TCHAR* string, which should be declared as LPTSTR.
if the caller is not intended to modify the string returned, it should even be declared LPCTSTR (C for const).
but still I maintain that string classes should be used instead
|
|
|
|
|
Of course, as stated in other answers, the caller has first to check the returned value.
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.
|
|
|
|
|
I just writing the simple twenty one card game...now evth work and fine.
And I put cards from 2 to A with concerning value.But when the debug step coming '0'comes to input with value '10'(K is worth 10 etc). It make me so confused.
here is my code:
[pre]#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
struct
{
char face;
unsigned int value;
}
card[13] =
{ {'2', 2},{'2', 3},{'2', 4},
{'5', 5},{'6', 6},{'7', 7},
{'8', 8},{'9', 9},{'10', 10},
{'J', 10},{'Q', 10},{'K', 10},
{'A', 1}
};
int main()
{
cout<<"simple twenty one card"<<endl;
cout<<"------------------------"<<endl;
int compcard=3,compscore=0,urscore=0,draw=0,urcard=0;
char cond;
const int high=21;
//int ur;
do
{
int comptotal=0,urtotal=0;
//srand(time(NULL));
srand((unsigned)time(0));
cout<<"how many cards u want?(up to 5 cards)"<<endl;
cin>>urcard;
if (urcard>5)
cout<<"You could not get more than five cards!"<<endl;
else
{
cout<<endl<<"Ur cards..."<<endl;
for (int ucard=0;ucard<urcard;ucard++)
{
int x = rand() % 13;
printf(" |%c| ", card[x].face);
urtotal+=card[x].value;
if(urtotal>42)
{
urtotal=urtotal-30;
}
else if(urtotal>31&&urtotal<42)
{
urtotal=urtotal-20;
}
else if(urtotal>21&&urtotal<32)
{
urtotal=urtotal-10;
}
}
cout<<endl;
cout<<"My cards..."<<endl;
for (int Ccard=0;Ccard<compcard;Ccard++)
{
int x = rand() % 13;
printf(" |%c| ", card[x].face);
comptotal+=card[x].value;
if(comptotal>42)
{
comptotal=comptotal-30;
}
else if(comptotal>31&&comptotal<42)
{
comptotal=comptotal-20;
}
else if(comptotal>21&&comptotal<32)
{
comptotal=comptotal-10;
}
}
cout<<endl;
cout<<"I have "<<comptotal<<" and you have "<<urtotal<<" so ";
if(comptotal<=high&& urtotal<comptotal)
{
cout <<"I win "<<endl;
compscore++;
}
else if(comptotal<=high&& urtotal>high)
{
cout <<"I win "<<endl;
compscore++;
}
else if (urtotal<=high&& urtotal>comptotal)
{cout<<" you win"<<endl;
urscore++;
}
else if (urtotal<=high&& comptotal>high)
{cout<<" you win"<<endl;
urscore++;
}
else //(comptotal==urtotal)
{cout<<"no win"<<endl;
draw++;
}
}
cout<<"wana play again(n/y?)"<<endl;
cin>>cond;
}while(cond=='y');
cout<<"I win : "<<compscore<<endl;
cout<<"you win : "<<urscore<<endl;
cout<<"we draw : "<<draw<<endl;
cout<<endl;
//cin>>ur;
}[/pre]
example of output is like " |4||J||0||k||8|".
I dont want to include "0" . How can I do? Pls tell me.
Thanks in advance!
|
|
|
|
|
why do you use [pre][/pre] instead of <pre></pre> ?
please edit your message, for everyone can read your question clearly.
|
|
|
|
|
Thanks.. I wrote different ways.. pls help me out !
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
struct
{
char face;
unsigned int value;
}
card[13] =
{ {'2', 2},{'2', 3},{'2', 4},
{'5', 5},{'6', 6},{'7', 7},
{'8', 8},{'9', 9},{'10', 10},
{'J', 10},{'Q', 10},{'K', 10},
{'A', 1}
};
int main()
{
cout<<"simple twenty one card"<<endl;
cout<<"------------------------"<<endl;
int compcard=3,compscore=0,urscore=0,draw=0,urcard=0;
char cond;
const int high=21;
do
{
int comptotal=0,urtotal=0;
srand((unsigned)time(0));
cout<<"how many cards u want?(up to 5 cards)"<<endl;
cin>>urcard;
if (urcard>5)
cout<<"You could not get more than five cards!"<<endl;
else
{
cout<<endl<<"Ur cards..."<<endl;
for (int ucard=0;ucard<urcard;ucard++)
{
int x = rand() % 13;
printf(" |%c| ", card[x].face);
urtotal+=card[x].value;
if(urtotal>42)
{
urtotal=urtotal-30;
}
else if(urtotal>31&&urtotal<42)
{
urtotal=urtotal-20;
}
else if(urtotal>21&&urtotal<32)
{
urtotal=urtotal-10;
}
}
cout<<endl;
cout<<"My cards..."<<endl;
for (int Ccard=0;Ccard<compcard;Ccard++)
{
int x = rand() % 13;
printf(" |%c| ", card[x].face);
comptotal+=card[x].value;
if(comptotal>42)
{
comptotal=comptotal-30;
}
else if(comptotal>31&&comptotal<42)
{
comptotal=comptotal-20;
}
else if(comptotal>21&&comptotal<32)
{
comptotal=comptotal-10;
}
}
cout<<endl;
cout<<"I have "<<comptotal<<" and you have "<<urtotal<<" so ";
if(comptotal<=high&& urtotal<comptotal)
{
cout <<"I win "<<endl;
compscore++;
}
else if(comptotal<=high&& urtotal>high)
{
cout <<"I win "<<endl;
compscore++;
}
else if (urtotal<=high&& urtotal>comptotal)
{cout<<" you win"<<endl;
urscore++;
}
else if (urtotal<=high&& comptotal>high)
{cout<<" you win"<<endl;
urscore++;
}
else
{cout<<"no win"<<endl;
draw++;
}
}
cout<<"wana play again(n/y?)"<<endl;
cin>>cond;
}while(cond=='y');
cout<<"I win : "<<compscore<<endl;
cout<<"you win : "<<urscore<<endl;
cout<<"we draw : "<<draw<<endl;
cout<<endl;
}
|
|
|
|
|
The problem is in the following initialization:
struct
{
char face;
unsigned int value;
}
card[13] =
{ {'2', 2},{'2', 3},{'2', 4},
{'5', 5},{'6', 6},{'7', 7},
{'8', 8},{'9', 9},{'10', 10},
{'J', 10},{'Q', 10},{'K', 10},
{'A', 1}
};
since you have declare the struct to hold a char plus
an unsigned int . This works fine for all elements but {'10',10} does not match the struct because '10' isn't a character constant, but a multicharacter constant (see MSDN, C++ Character Constants topic, i.e. a 16-bits number that does not fit inside the struct face member (the compiler warns about ). What occurs is a cast of the 16-bits value (i.e. a truncation) '10'<->0x3130 to the corrensponding character value '0'<->0x30.
To fix the bug you can either choose a (really) single character to represent 10 (e.g. 'X') or change the struct to hold strings, e.g.
struct
{
char * sFace;
unsigned int value;
}
card[13] =
{ {"2", 2},{"2", 3},{"2", 4},
{"5", 5},{"6", 6},{"7", 7},
{"8", 8},{"9", 9},{"10", 10},
{"J", 10},{"Q", 10},{"K", 10},
{"A", 1}
};
hope that helps.
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.
|
|
|
|
|
Just a quick question with a hopefully simple solution. Does anybody know how to detect if IE7 is running in 'protected mode'? Perhaps there is a registry setting somewhere I can read, but looking through the registry I'm not sure exactly which one it may be.
|
|
|
|
|
|
Hello everyone,
Im creating an MFC app ( an SDI one ) that uses an explorer style User Interface. There are 3 "panes" in the Child View. All 3 of these "panes" are sized programmatically and are laid horizontally inside the Child View of the Main Frame. The "panes" are literally CWnd objects and are not CDialogs.
What I want is to have a splitter functionality that is quite similar to Visual Studio 2005 where the cursor icon changes to a "splitter sizing icon" when the mouse pointer hovers above the edges of two adjacent panes. And once you click on the edge of one of these panes, it should let the user drag and size up the panes dynamically.... jus like what happens in Visual Studio 2005.
How do I achieve this functionality without using a CSplitterWindow ? Cos I heard from one of ma colleagues say that u dont always need a CSplitterWindow to implement a Splitter functionality. Is it possible ? Please do give me some hints or advice and I will follow up your suggestions on MSDN and the like...
thanx a lot..
wishing u all a happy new year with loads of fun coding !
Eraj
-- modified at 0:39 Sunday 31st December, 2006
|
|
|
|
|
technojay wrote: Cos I heard from one of ma colleagues say that u dont always need a CSplitterWindow to implement a Splitter functionality.
You don't need to use anyone else's code to implement any functionality.
If you want it to look like VS splitters then you'll need to handle drawing the bars,
responding when the mouse is over the bars, dragging the bars for resizing, etc...all the
things that CSplitterWnd does for you.
You could also just use regular sizeable windows and anytime they are resized by the user then
you'd resize the other windows appropriately. it wouldn't look like VS splitters though
What part are you having trouble with?
Mark
|
|
|
|
|
Hey Mark,
Im quite new to MFC and this is kinda my first serious app that I was asked to do to get myself acquainted with it. So right now, although I understand the technique that you are suggesting, I am pretty clueless as to how Im gonna implement it ( for example : how to draw bars between adjacent windows, enabling them to be user dragged etc ).
I am not askin for code snippets or anything like that... All I need is jus a brief description of what type of controls would be needed, what MFC classes Ill have to bring in and any specific events that I mite need to handle. If you could give me that I can reference the MSDN and try it out.
hopin to hear from you soon.
Eraj
|
|
|
|
|
What I did myself:
- implement a separate window class; do the following:
- decides if is a vertical or horizontal splitter bar, and depending on it, registers window class using LoadCursor with IDC_SIZEWE or IDC_SIZENS (I don't remember the exact names, but should be ok)
- manages the draw part similar with MFC splitter (use an erase/redraw new pos. technique - study splitter code)
- maintains the distance from a border (say left border if is a vert. splitter)
- collaborate with parent window (read: send and receive size messages)
- handles mouse messages for left button down and up, mouse move and perform the necessary painting code.
|
|
|
|
|
for (int i = length - 1; i > -1 ; i--)
{
}
for (int i = length - 1; i >= 0; i--)
{
}
I always used to think the bottom way was slower then the top because i saw "i >= 0" as being two different checks being done on i.
For this reason I thought doing "i > -1" was better cause it was just one comparison... but today i just noticed that -1 might be an additional operation being done in each iteration of the for-loop like "...is i greater then (what is the negative of 1)".
So which is the faster way? :P
EDIT: Hmm maybe it still is the first way that is faster cause the negative number might be evaluated at compile-time?
|
|
|
|
|
The difference between those two, if there is any, will never be noticeable by people. Write whichever way makes sense. Assuming that code is looping over an array or other collection, I would always write i >= 0 because i is the array index and 0 is the logical stopping point.
|
|
|
|
|