|
To move an item up:
Call GetNextItem(-1, LVNI_SELECTED) to get the item's index.
Call GetItemText() to get the item's text.
Call InsertItem(nIndex - 1, text) to insert the item in the previous position.
Call DeleteItem(nIndex + 1) to delete the old item
You'll obviously need to massage this a bit to get it to work (e.g., make sure that you don't try and move item 0 up). Moving an item down is almost identical.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
SQL statment is
"SELECT COUNT(*) FROM [User]"
[User] is a table name, which contains handreds of records.
then I use CRecordset.Open(...) to execute the statment.
but CRecordset.GetRecordCount() function returns 1 always.
I think it is not a good way to go throught all records by CRecordset.MoveNext() - it is too slow.
how to get number of records in the table by SQL directly?
1) is CRecordset right class to execute the SQL?
2) is the SQL statment correct?
thanks for any help.
|
|
|
|
|
includeh10 wrote: but CRecordset.GetRecordCount() function returns 1 always.
That's obvious: your query asks for exactly 1 record, containing 1 field: the number of records.
The value you're searching maybe obtained using CRecordset::GetFieldValue method [^].
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]
|
|
|
|
|
includeh10 wrote: CRecordset.GetRecordCount()
For that function to give you the result you want, you'd have to use the SQL query "SELECT * FROM User". But don't do that - let the database engine do the maths and return the result as a single-field, single-row recordset, and read the result from that value, as CPallini said.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Have you thought of using IMAPI[^]?
There's a CP article[^] that details how to add lists of files and directories to the image. It's in C#, but really, how difficult could it be to convert that article to C++? To be honest, the IMAPI stuff is probably easier from C++ than C# - the article uses interop to access IMAPI...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello everybody,
im creating a picture control in a dialog box (win 32), i need to show an image in that control, but my bitmap is of 30 X 30 size, but the control is 100 X 100, i would like to stretch the image upto 80 X 80, so that picture control is filled with the same image.
Thanks in advance,
A. Gopinath.
|
|
|
|
|
You may use my DLL [^], if you need to stretch it without loosing too much quality.
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]
|
|
|
|
|
Thank you very much. this will be useful for me
|
|
|
|
|
I usually specify the required size in the LoadImage API in its cxDesired and cyDesired parameters.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
CStatic* pContol = (CStatic *) GetDlgItem(IDC_ST_PICTUREBOX);
pControl->ShowWindow(SW_MAXIMIZE);
|
|
|
|
|
is this possible?
I launch a process from my main process and when the second process attempts to use DLLs that the first is using, the second program crashes. However, when I click the icon for the second application while the first application is running, it accesses these DLLs just fine. I have used CreateProcess and ShellExecute to launch and both provide the same outcome. If CreateProcessAsUser is the solution, will it work for creating the process as the same user who launched the first process?
|
|
|
|
|
The answer is yes for your question.
But I geuss it is not the solution for your situation.
Is the platform vista? If is that so, some issues are around UAC...
Is it the fact the reason of crash that is origined from some of security context errors?
|
|
|
|
|
You should be able to give the new process a different security context by using lpProcessAttributes->lpSecurityDescriptor .
|
|
|
|
|
Consider the following code in C:
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
scanf("%s",n);
printf("%s");
getch();
}
Question: The above program amazingly reads a string and prints it but I don't know how/ Plz help me.
Plz specify the working of scanf and printf in the above program. n is not given as an address to the scanf function and printf contain only format strings.
Awaiting a good reply
|
|
|
|
|
In the scanf call, scanf will take n to be a char* value, so will store the string read in at the address given by n. You're just 'lucky' that n's value is equivalent to a writeable address.
The printf call? Well, as printf is a variadic funtion, it'll look up the stack from the pushed format string, looking for argument values. The next value on the stack above the format string is (you guessed it!) n, so printf will see n, interpret it as a char* value and print the string at that address.
The joys of a type-unsafe system programming language
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I am working on MFC Asynchronoussocket program, I could able to successfully send and receive messages between one to one client and server using accept, receive classes. But when i am trying to connect multiple client to server, my application crashes. And I also wonder, if I able to accept multiple client, how would I match the send and receive messages between different clients and server.
Could anyone please help me out!!!
Thanks
Reddy
|
|
|
|
|
reddy07 wrote: And I also wonder, if I able to accept multiple client, how would I match the send and receive messages between different clients and server.
I've only looked at the basics of this quite some time ago, but the structure that accept() populates on the server has a sin_addr member. Can you pass that to inet_ntoa() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks david, I solved it - now I could able to establish mulitple client with single server, but I am facing problem in receving messages from clients. Server couldnt receive the message that client is sending. On client side, client is sucessfully sending the message. Could you please throw some light.
Binding i will look into it later once server start receving messages
|
|
|
|
|
Hi.
I have a program which is creating a huge memory leak. Here is an example of my program. This is not an actual code but an example which references my program.
Class ABC
{
static int *B;
}
Class DEF{
int *MALLOC_C[20];
void Function1(int* ptr);
void Function2( );
}
ABC[10];
DEF[10];
void main()
{
int *sample=new sample();
*sample=1;
ABC* Object1[20];
DEF* Object2[20];
for(int i=0;i<20;i++) //Edited
{
Object1[i]=new ABC();
Object2[i]=new DEF();
}
for(int i=0;i<20;i++)
{
Object[i].Function1(sample);
}
for(int i=0;i<20;i++)
{
delete Object1[i];
delete Object2[i];
}
}
DEF::Function1(int *ptr)
{
ABC::B=ptr;
}
DEF::Function2()
{
for(int i=0;i<20;i++)
{MALLOC_C[i]=(int*) malloc(1000*sizeof(int) ); //Edited,Corrected
}
//DO processing on MALLOC_C
for(int i=0;i<20;i++)
free(MALLOC_c[i]);
}
This is what I am doing. What is wrong? Please help!
modified on Wednesday, June 3, 2009 10:08 PM
|
|
|
|
|
jobin007007 wrote: MALLOC_C=(int*) malloc(1000*sizeof(int) );
why is this line inside a for(i) loop and not using i?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
My mistake. Its been edited.
It should have been-
MALLOC_C[i]=(int*) malloc(1000*sizeof(int) );
Thanks
|
|
|
|
|
Leaks maybe in this
int *sample=new sample();
And below makes infinite loop
for(int i=0;i<20)
{
Object1[i]=new ABC();
Object2[i]=new DEF();
}
If you use VC, microsoft provides some helpfull debug runtime like _CrtCheckMemory.
If you do not, make memory management library or use some like those.
Happy debug!
|
|
|
|
|
It was a stupid variable issue.
I was not going through the whole array
Basically I was doing the below->
for(int i=0;i<20;i++)
{
MALLOC_C[i]=(int*) malloc(1000*sizeof(int) ); //Edited,Corrected
}
for(int i=0;i<10;i++) //Notice the 10. It should have been 20
free(MALLOC_c[i]);
|
|
|
|
|
Hallo in my SDI-Application i have the following problem: when i write something and click close or exit the application
does not ask me if i want to save the document /file or not(the prompt message does not appear???) please help.
|
|
|
|