|
I had similar issue with editing in edit control.
It went away by using ShowWindow(SW_HIDE) before and ShowWindow(SW_SHOW) after the edit/ search / update.
Try that, it may help, but I feel that the "insert" item is the real isssue here.
|
|
|
|
|
first of all... not coding in OnDraw ();
code it in a separated function and in the OnDraw () do an evaluation of a flag. Something like:
if (bListRedraw)
UpdateListCtrl ();
in this UpdateListCtrl () funciont, the last line have to reset the flag (bListRedraw = FALSE).
in your methode of adding item, the last line have to set the flag (bListRedraw = TRUE).
I have sent you an email with some code that I used in one app. It deals with creation, initialitation and update of ListCtrl in a quite complex structure of Objcet derived elements and their datas.
Take a look, try to modify your code and ask if you dont understand something.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
I am dynamically loading a second process (via CreateProcess) and would like to automatically set breakpoints in that process. VS2005 doesn't automatically set the breakpoints even though the code I want to break on exists in both projects.
Is there an API I can call to set a breakpoint on a function in another process?
|
|
|
|
|
After it is started via the CreateProcess, fire up another instance of VS2005 and "attach" to the just launched process. You can set breakpoints now. If you need to debug the process's startup code, use DebugBreak and connect VS2005. I've always used a new instance of VS to debug each different process - don't know if you can do multiple processes all in one.
Judy
|
|
|
|
|
Ah, but that's the problem. By the time I can click on Attach To Process and then select the process and press Attach, the program I'm trying to trap has already run the function I want to trap.
I can't modify the source to the program I want to attach to.
I need to find a way to set breakpoints in the launched process via the application I am writing. Something like:
{
CreateProcess("newprogram.exe", ... CREATE_SUSPENDED, ... );
SetBreakpoint(newProcessHandle, "FunctionToDebug");
ResumeProcess(newProcessHandle);
}
|
|
|
|
|
Soundman32.2 wrote: By the time I can click on Attach To Process and then select the process and press Attach, the program I'm trying to trap has already run the function I want to trap.
In your processes code, call DebugBreak(), and the code execution will stop and you will be given the chance to attach a debugger.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
That's a tough one without being able to modify the source of the target. Just to make sure you haven't missed the obvious, have you tried to Attach after the process is created in the suspended state? I don't expect it to work, but I personally don't know what else to try. You're down to the point of having to do something to modify the target. If you can't touch the source, the only thing left is modifying the asm code in the .exe file. Can't help there.
Sorry,
Judy
|
|
|
|
|
Hi Experts,
Plz tell me how to check the registry for a prticular version of MS-Outlook?
and how to make changes in Registry.
|
|
|
|
|
Look at the HKLM\SOFTWARE\Microsoft\Office key.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
It's getting embarrassing watching you utilize documentation so frequently
|
|
|
|
|
following code is correct.
class MyInt
{
public:
int i0;
int i1;
int i2;
};
<br>
<br>
MyInt myData[]=
{
{1, 0, 2},
{5,},
{4,},
};
I hope default value of i1=100 and i2=200;
So I add construct to class MyInt:
class MyInt
{
public:
MyInt()
{
i1=100;
i2=200;
}
int i0;
int i1;
int i2;
};
<br>
<br>
MyInt myData[]=
{
{1, 0, 2},
{5,},
{4,},
};
This time, I got a compile error:
error C2440: 'initializing' : cannot convert from 'const int' to 'class MyInt'
which points to //error line.
The error looks like syntax error, how to solve the problem and set i1 and i2 to default values?
|
|
|
|
|
Strange, I'm not finding errors
have you tryed this constructor way?
MyInt()
: i1(100)
, i2(200)
, i3(0)
{
}
-- modified at 9:51 Monday 10th September, 2007
At the same time I'm not so sure that you can define a constructor and initialize the elements of the class as it is a struct. This sintax is forcing a little the flexibility of the C++ language. I mean that this time probally it is better if you spend some time writing ALL the initialization by hand.
Russell
|
|
|
|
|
You can't use the array initializer syntax on a struct that has a ctor. Do this instead:
MyInt myData[]=
{
MyInt(1,0,2),
MyInt(5),
MyInt(4)
}; And what's with all those extra commas?
|
|
|
|
|
Hello friends,
I am working on a project in which It is sending the packet on the Internet server at the interval of 3 sec. The packet is roughly of 1KB(kilo Bytes) size. And when I check the programme in the Taskbar it show the CPU Usage to 50%.
The project is a simple Dialog based WIN32 application. And it uses SOCKET and Timer to send and receive the data from Internet Server.
Is there any way I can reduce the memory usage.
Or please tell me what are the possible flaws that can lead to this type of proble.
|
|
|
|
|
Hi,
when you poll for new data, you have seriously a loop (while(!Stop) or something like this)
you should use a Sleep(10) or Sleep(100) into this loop, otherwise this thread is working nonstop.
Good luck
|
|
|
|
|
Thanx,
NOW I am using the Sleep(); in my function. and all working fine.
|
|
|
|
|
If the absence of Sleep() causes your program to not work, that usually indicates a design flaw.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Whatever works for you, I guess, but most would say that's a really bad design.
You're wasting CPU resources in a loop for something that can be made completely event
driven and work VERY efficiently.
By the way, if you're using a SOCKET and a timer, how is it possible that you're using any
noticeable CPU?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I've learned much from this article. But now I got some problem.
How to get client's IP address when it act as a server?
Thanks in advance.
----------
C++ Learner
|
|
|
|
|
Hi,
i made it this way :
SOCKADDR_IN ClientAddress;
int adrlen = sizeof(ClientAddress);
accept(ListenSocket,(LPSOCKADDR)&ClientAddress,&adrlen);
then you get the String of the Client's IP Adresse this way:
inet_ntoa(ClientAddress.sin_addr)
I hope this helps you
|
|
|
|
|
Thanks for your assistance.
I added those lines to my project.
But, when I build the project, there was an error :
error C2065: 'ListenSocket' : undeclared identifier
So I added this line :
SOCKET ListenSocket;
Then I build it again, although I got some warning :
warning C4700: uninitialized local variable 'ListenSocket' used
there was no error.
Then I debug, try to connect from other computer.
It was connected, could read the buffer, but my program shows "0.0.0.0" as client's IP address.
Any suggestion?
----------
C++ Learner
|
|
|
|
|
Ok,
so you have used the CodeProject offered classes "Java-like-Sockets" without
knowing how it works.
The ListenSocket is a part of the source code that you need to etablish a connection.
You need to look into the SourceCode of the "Java-like-Sockets" Classes and check where
the accept(...) is performed. There you can add the line inet_ntoa(...); to get the Clients-IP-Address
If you have questions: i'll look here
Good luck
|
|
|
|
|
|
In sock.cpp you have the following lines :
SOCKET theClient;
SOCKADDR_IN clientAddr;
int ssz = sizeof(struct sockaddr);
theClient = accept(m_socket,(LPSOCKADDR)&clientAddr,&ssz);
if (theClient == INVALID_SOCKET) {
int nret = WSAGetLastError();
throw CSocketException(nret, "Invalid client socket: Accept()");
}
CSocket *sockClient = new CSocket();
sockClient->SetSocket(theClient);
sockClient->SetClientAddr(clientAddr);
m_socket is the socket which listens on the given Port. So m_socket is a ListenSocket
theClient is also a Socket which will store an Incomming-Connection from a Client.
clientAddr is a structure which will be filled with information during the accept()-function.
After accept was executing, you have the IP and Port into this strucure.
At the end you see that clientAddr is stored inside the class, so you can access from out
your source code, to the CServerSocket class and get the Client-Information-Structure.
You get the IP in plain text with
char TheClientIP[16]="";
strcpy(TheClientIP,inet_ntoa(...->sin_addr));
Good luck
|
|
|
|
|
Your response is always so fast.
I really appreciated your explanation about the source.
It's really easy to understand.
I think I got what it mean now.
But still doesn't know what is inside (...->sin_addr).
because m_clientAddr is an private object,
so I can't access it.
----------
C++ Learner
|
|
|
|