|
I'm adding IRC chat to my game launcher, and am wanting to show the chat text in colors using a Rich Edit 2.0 control in a dialog. I'm doing the following to add a line of text (Tmp is a CString containing the chat line text):
<br />
CHARFORMAT cf;<br />
<br />
cf.cbSize = sizeof(cf);<br />
cf.dwMask = CFM_COLOR | CFM_FACE;<br />
strcpy(cf.szFaceName,"Subway");<br />
...<br />
cf.crTextColor = RGB(255,0,0);<br />
...<br />
ChatList.SetSel(-1,0);<br />
ChatList.SetDefaultCharFormat(cf);<br />
ChatList.ReplaceSel(Tmp);<br />
ChatList.LineScroll(ChatList.GetLineCount());<br />
Now, the text is correctly show using the "Subway" font, but it's still only black What am I doing wrong?
Thanks!
|
|
|
|
|
Hmm, the coloring works in release builds!
|
|
|
|
|
i love this site!
can Somebody tell me why ?
-=Ehsan-de-Burge=-
|
|
|
|
|
1) Easy to navigate and pleasant interface
2) Super fast message boards responses
3) Quality articles which seldomly require H scrolling
4) Emoticons are so damn cool
5) A real sense of community
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
+ + =
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Is there a way or another function that will work the same as STRTOK without removing the string after the token?
I want to find the first token and leave the string as it was.
Thanks,
Jim
|
|
|
|
|
if you just want to search for a sub-string, try "strstr".
-c
I'm not the droid you're looking for.
|
|
|
|
|
strstr would work, but I only know the string based on a delimiter.
strtok() works so well I was hoping I would have to save off the string first and then put it back in later.
Thanks...guess I'll keep searching....
|
|
|
|
|
substring by using strstr()?
~~~~Code the Dreams~~~~~
|
|
|
|
|
hi
i searched the MSDN but i findout out that the random() function in stdlib.h is not exist.
it seems that it's replaced with srand() and rand() . can anyone explain me how can i use these 2 function or any other to reach random numbers in requested range ? (for example 0 < x < 1000 )
thnx
|
|
|
|
|
|
thanks mr.nishant but it seems that in this example the Range of Figures are not important.
may be i should do something like this :
<br />
int r=1000;<br />
while(1){ r=rand(); if (r<999) break; }
thanks any way.
-=Fight with be Best Die like the Rest=-
|
|
|
|
|
*cough* modulus *cough*
Know that good little % operator?
I wonder what this would do:
min + (rand() % (max - min + 1))
|
|
|
|
|
HellShrimp4free wrote:
but it seems that in this example the Range of Figures are not important.
Correct, in the MSDN example the range isn't important, however you can do the following to limit your range to under 1000:
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#using <mscorlib.dll>
#include <tchar.h>
using namespace System;
int _tmain(void)
{
srand( (unsigned)time( NULL ) );
for( int i = 0; i < 10;i++ )
printf( " %6d\n", rand()%1000 );
Console::Read();
}
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
Hi
Those two functions have always been there. In fact I never used (saw ?) the function Random()
Here is how to use them:
// Seed Random-number Generator with Current Time
srand(( unsigned) time(NULL ));
int nRandomData = rand() % 4;
Replace 4 with the Maximum value accepted (1000 in your request)
The call to srand with current time allows the generation of different random sequences. If you start always with the same number, you always got the same sequence ( as far as I remember) ...
HTH
Thierry
|
|
|
|
|
I have a Windows NT service which maintains a pool of objects. The purpose of the pool is to improve performance because the objects being pooled require a signifigant amount of time for construction.
At any given time, there can be from 0-N requests for objects from the pool. There are times when the pool will have no requests at all for days. Other times, it will have 1000s of requests an hour/minute. I keep track of # of requests, avg time between requests, first request, last request, time to allocate, time to fill request, peak objects in pool, peak requests per sec/min, # of requests made when pool was exausted.
I am looking for an algorithm that will limit the number of requests that occur when the pool is exausted while not exceeding a maximum pool size or memory usage. There really is not MAX size, but I don't want to just allocate 1000s all the time. My goal would be to have 75-85% of requests filled by the pool with no waiting.
Currently, the algorithm I use is something like this:
(Pseudocode
long lDesiredPoolSize = lMinSize;
if (lRequestsLast5Minutes > (lRequestsLastHour / 12) && lRequestsLast5Minutes > lDesiredPoolSize)
lDesiredPoolSize = lRequestsLast5Minutes * 1.25;
if (lPoolExaustedRequests > lDesiredPoolSize)
lDesiredPoolSize = lPoolExaustedRequests * 1.25;
if (lRequestsLastHour >= lRequestsAtPeak)
lDesiredPoolSize = lRequestsLastHour * 1.25;
if (lDesiredPoolSize > lMaxPoolSize)
lDesiredPoolSize = lMaxPoolSize;
if (lRequestsLastHour == 0)
lDesiredPoolSize = 0;
I just made this up and tinkered with it, but I wonder if anyone in CPland has any more experience with this kind of thing?
|
|
|
|
|
I get the position of the slider and do a textOut with it. After the slider reaches a 100, and the text says 100, when I slide it back, a part of the last zero doesnt get cleaned off the screen and the textout looks like:
34 ) etc.
How do I make the remnants of the prev numbers go away? I thought of doing an Invalidate() after the textout but then the number totally vanishes (because its not being written out in OnDraw() but in OnHScroll. In HScroll I get the pointer to the scrollbar, so I can GetPos. How would I access this getPos in OnDraw(0 so that I could see the refreshed text?
Appreciate your help,
ns
|
|
|
|
|
Draw a couple spaces after the number? (ie "34 ")
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Wow!
I did
s.Format("%d ", position);
and that took care of it!
Thanks!!!
Appreciate your help,
ns
|
|
|
|
|
I've searched all over (CodeProject and the Internet at large) and I have not been able to find the answer to my problem, so here goes.
I have an MDI app where I would like to be able to open a document and immediately present the user with multiple views of the same document -- one will be the primary view, and I'd like to have two secondary views. I know that the CDocument class has a member function called AddView(), but I don't know where to add my secondary views. Where would I add my other views -- in MainFrm, ChildFrm, or elsewhere? And would using the AddView() member function be the appropriate way of accomplishing what I'm trying to do?
Thanks,
Dean
|
|
|
|
|
|
I know how to do a .Create() and make one, but what does one do after retrieving the address the
user enters? WHich control will accept this address and open the webpage it points to? Is there a sample that shows how the addressctrl communicates this info to the ctrl that actually opens the webpage (which also I need to know about)
Thanks
Appreciate your help,
ns
|
|
|
|
|
ARGH - this is killing me. All I am trying to do is take a dialog, bring it to the front, centered, and activated. And I CAN'T for the life of me figure out how to do all three! Here is some code I have tried, in the dialogs, OnInitDialog handler:
BOOL CongratsDlg::OnInitDialog()
{
...
CenterWindow();
ShowWindow(SW_RESTORE);
}
I have tried various parameters in ShowWindow , and I have tried it with the SetWindowPos stuff, and without it... and with it but not ShowWindow... etc.
So what is the magic combination to show and activate a window?
Some background: this is an MFC app. It has no main window - it launches some other app, waits for it to finish, and then pops up this dialog.
Muchas gracias.
Even a broken clock is right twice a day.
|
|
|
|
|
Hmm - I may have answered my own question. It seems like if I have the Start menu active at all - even if I activate it long before this dialog comes up, the window won't activate. It seems that in any other situation, the code I have above works.
Ah well.
Even a broken clock is right twice a day.
|
|
|
|
|