|
One solution is a timer queue timer.
Kuphryn
|
|
|
|
|
The ::SetTimer() function can be used to force a callback to a specified function rather than sending a message to a window. For example:
void CALLBACK MyTimerProc(HWND hWnd, UINT nMsg, UINT_PTR idEvent, DWORD dwTime)
{
// Do something
}
UINT nID = ::SetTimer( NULL, 0, 1000, MyTimerProc );
This will call MyTimerProc after 1000ms. The first parameter is NULL, meaning that no window is associated with this timer.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
hello @all,
i have to write a program which generates randomized letters, e.g. from A to D (variable letters and with a variable length). the string could look like:
CString str="AAACCDDDDDBBBBCDABBBDDDD....";
can anybody help me?
thank you very much!!!
sunny
|
|
|
|
|
char GetRandomLetter( void )
{
char cLetter;
cLetter = (rand() % 26) + 'A';
return cLetter;
}
CString str;
for (int x = 0; x < some_length; x++)
{
char c = GetRandomLetter();
str += c;
}
|
|
|
|
|
thanks for reply.
the program works, but i don't know why!
DavidCrow wrote:
cLetter = (rand() % 26) + 'A';
why does this works?
thank you very much!
sunny
|
|
|
|
|
rand() gives you a number between 0 and RAND_MAX. Modulo that with 26 gives you a number between 0 and 25. Add 'A' to that gives you one of the 26 letters of the alphabet. Make sense?
|
|
|
|
|
One solution is to generate a number and then convert it to a char.
string text;
unsigned int randNum = 0;
for (unsigned int i = 0; i < nTextSize; ++i)
{
randNum = static_cast<unsigned int="">((((static_cast<double>(rand())) / (static_cast<double>(RAND_MAX + 1))) * 94 + 33));
sName += static_cast<char>(randNum);
}
Kuphryn
|
|
|
|
|
Hi! I'm not exactly new to MFC but i haven't really dealt with internet programming. I was wondering how i could create an internet chat program. I found stuff on network chat programs but nothing on internet chat programs. Could i use a web server?
-- Steve
|
|
|
|
|
One solution is winsock.
Kuphryn
|
|
|
|
|
What's the scope of your quest?
Is this a "for fun" kinda "i want to talk to my friends" thing?
If you're doing a "for fun" programming, the easiest way to do this, is to create a peer-to-peer application. Where each client speaks directly to the other client via the net -- TCP or UDP (winsock). This involves writing one piece of software, the software is a UI, and a networking endpoint.
If you want to write a serious chat program, that ya gotta go the "client/server" route. Where you actually end up writing 2 different pieces of software: a client(UI and winsock connection to server) and a server which manages the chat, and makes sure text is routed to each connected client.
Client/Server is by far the better route. Peer-to-Peer seems simple until you want to do something fancy -- like create a chat room with more than one other person in it. Or for more advanced -- sending video to more than one other person....
Good luck in your chat adventure.
I've seen source code out there for simple peer-to-peer chat programs based in java....
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
i don't have the ability to do a client/server chat, so i'm going to try peer-to-peer. What i don't get is how to connect the 2 computers though the internet. i can't find anything on it.
-- Steve
|
|
|
|
|
In VC6 Have a look at the ChatSrvr and Chatter sample programs.
Alternatively you could look at an internet article on CodeProject [^]
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Hi Folks!
I want to write a program that should be able to determine how many instances of the (same) program are currently running and what are they doing. Based upon this, it should decide whether to work immediately or to pause until the other instances are finished and continue after that.
How would you do that?
Best Regards,
Christian Richardt
Those who know don't talk.
Those who talk don't know.
|
|
|
|
|
Maybe CSemaphore can be what you're looking for.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi! I am really confused!
I am using the DHTML edit control and it is making some kind of newline in the html code which I dont want because I want to put infront of and after each line some chars and with that mysterious newline it puts the chars to be placed at the end of the line after a newline ! Are there any other newlines than '\n' and '\r\n' ???
Thank you for your answers in advance!
|
|
|
|
|
Scolinks wrote:
Are there any other newlines than '\n' and '\r\n' ???
No, that's it.
|
|
|
|
|
<br> ?
|
|
|
|
|
Is there any good tutorial or some sample project with source codes?
|
|
|
|
|
Before we upgraded to Visual C/C++ 7.1, we used version 6.0 of the compiler.
To make it easier for us and our help desk to find problems, we linked our production (release) versions with /DEBUG and /PDB:NONE (but all sources were compiled with /Ox and no debug info).
That way information about the addresses of functions and methods were stored in the executable, ready for Dr.Watson to read them.
This also had the advantage that we could use SymGetSymFromAddr to get the symbol name (of a function) for a function address (handy if you e.g. want to report the stack at the moment of a memory leak).
Unfortunately Visual C/C++ does not have the option /PDB:NONE anymore, which means we cannot put this information int he executable anymore (and our nice feature of printing out the stack when a memory leak was found does not work anymore either).
AAAAAAAAAAAArgh.
Is there another way of storing the function addresses so this info can be read by Dr.Watson and still works with SymGetSymFromAddr (the first one is more urgent), using Visual C/C++ 7.1?
Otherwise we have to read stuff like this:
FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name<br />
0012F054 00549EBF 01BA91A8 00000001 006AE5E0 0012F0CC !<nosymbols><br />
0012F104 00508DCA 009DDDB0 00000000 00000001 0057A490 !<nosymbols><br />
0012F120 0057A43C 009DDDB0 00000001 0057A490 0012F148 !<nosymbols><br />
0012F1D0 0046F330 01570F58 02DB9118 00000000 00030018 !<nosymbols><br />
0012F29C 0048F9FC 02D88BD8 0012F70C 00000000 01C3C4C0 !<nosymbols>
and map each pointer (probably ReturnAddress) to something similar in the .map file (created with the /MAP option). This is horrible and time consuming.
Somebody who knows a solution?
Enjoy life, this is not a rehearsal !!!
My Articles:
- Implementing a Subject/Observer pattern with templates
- Different ways of writing class factories
- AutoRunner: a template class to automatically run start- and cleanup-code in code blocks
</
|
|
|
|
|
Wouldn't it be easier to just fix the app so that it doesn't crash anymore?
onwards and upwards...
|
|
|
|
|
That's pretty crass.
It sounds like you work in a world of software that lives in an extremely controlled environment.
Well, good for you.
The rest of us make do in a world of windows with spyware, third-party audio drivers, third-party video drivers, third-party camera drivers, different flavors of windows with different behaviors, and on and on -- things that cause the environment to become less than standard and less than well perfectly behaved.
Things do crash. And if you're not prepared to support your customers with crash support and diagnosis, then good luck.
This place is all about help and support -- sharing knowledge not attitude.
I don't know the answer to his question, but I do know that your response to him doesn't help (and for that matter, neither does mine). I, too, am interested in this topic, as this behavior affects our products as well
Thank you very much.
That's all I have to say.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
You have probably done this but MSDN suggests that instead of /PDB:NONE you use /Zi. From the description it sounds like they do the same thing.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
I want a button to diplay the red text sometime, so I create a class derived from CButton and override the OnCtlColor handler, as below:
HBRUSH CColorButton::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CButton::OnCtlColor(pDC, pWnd, nCtlColor);
if(m_iFlag == 1)
pDC->SetTextColor(0x000000ff);
return hbr;
}
but I found the handler didn't be executed even when the dialog initialized,
How can I do the work I want.
Thanx.
|
|
|
|
|
|
Thank you.
I saw the source code and found the way he accomplished the work seamed the same as mine.
I just wonder why my overrided message handler OnCtlColor didn't be executed, as I set a break point in the handler, no stoping occured when I debuged.
|
|
|
|