|
I'm not sure but I think it is derived from CComboBox and you would do it the same. If it is there was mention of that not to long ago in this forum.
- Matt Newman / Anti-Linux Activist
-Sonork ID: 100.11179:BestSnowman
†
|
|
|
|
|
Change the style of the cell like this :
CGridCellCombo *pCell = (CGridCellCombo*) m_ListZone.GetCell( pItem->iRow + 1, 0 );
pCell->SetStyle(CBS_DROPDOWNLIST);
Hope this help
|
|
|
|
|
Hi, I have a stupid question.
How to make a timer? For example, I want to check the waiting time. If my program has been waiting for 1000 millisecond already, terminate the program.
Thanks
|
|
|
|
|
Anonymous wrote:
If my program has been waiting for 1000 millisecond already, terminate the program.
What du you mean by waiting?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
For example, due to some reasons I want to "force" my program to pause for 1000 millisecond.......how can i count this 1000ms, and let it go again after 1000ms.
e.g.
if (x=10)
{
pause for 1000ms
continue to do stuff here....
}
thanks!!!!
|
|
|
|
|
with Sleep() you can pause the timer.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
with SetTimer() you can create timer.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I think i describe my question wrongly.
I need a timer to count how long the program has been waiting:
e.g.
if (x=10)
{
pause indefinitely
if (timer = 1000ms) //function pause for 1000 ms already
continue to do stuff here....
}
How can i implement this timer??? Any example!????
Thanks!!!!
|
|
|
|
|
oh,yes
For doing this I think you can't use timer.You have to create thread.I don't know how
but you can look into CMutex and other thread class in MSDN for its information.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
If you are just interested in the SDK, use:
SetTimer(hWnd, nID, 1000, NULL);
hWnd will be the handle to where you would like the timer event sent, and nID is the id code for this timer event. The 1000 is the timeout interval between each timer event. You can ignore the last parameter for now, this is for a timerProc callback function.
Then Create a WM_TIMER handler to catch the message, you should check the wParam value to make sure that it is the timer that you are interested in. This becomes important when you create more than one timer.
When you want to get rid of your timer call:
KillTimer(hWnd, nID);
|
|
|
|
|
Hi there,
I wrote a help by Html Help Workshop,
I maked Index and Content for the Help.
I wanna call the HTML help pages in my program,
I know, i must use HtmlHelp function.
In one of parameters of the function i must enter Keyword !
But i didn't make any Keyword in my HTML help,
How can i make a Keyword in my HTML helps ???
In my HTML help project i saw [MAP] part !
What is it ?
Please help me !
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I have a CString array called abc[10000]. This array is initialized in a OnOK() with value "none". However, when I begin a thread, and this thread called another function "testing()".......the array becomes empty.....so i got error message when I access this array in testing().
I've tried to declared this array in stdAfx.h and .cpp, and also its own .h file....but doesn't work too.........
Please help.....
p.s.: I got the similar problem when i use vector array (that's why i choose to declare abc array to abc[10000].)
|
|
|
|
|
I figure out myself....just a stupid mistake. I should declare the array in StdAfx.h/cpp.
|
|
|
|
|
Hi,
I have an application which I open a dialog box. The dialog box has a button IDC_ANALYSIS with the message handler onOpenanalysis which when pressed opens another dialog box using:
void CEpgActive::OnOpenanalysis()
{
CEpgAnalysis dlgEpgAnalysis(this);
int nRetCode = dlgEpgAnalysis.DoModal();
}
How can I modify this code (if this is the code i should modify!) can I get it so that the 1st dialog is cleared from the screen and only the second dialog is displayed?
Thanks a lot in advance,
Joe
|
|
|
|
|
void CEpgActive::OnOpenanalysis()
{
ShowWindow(SW_HIDE);
CEpgAnalysis dlgEpgAnalysis(this);
int nRetCode = dlgEpgAnalysis.DoModal();
ShowWindow(SW_SHOW);
}
Nish
Oh, I don't know why she's
leaving, or where she's gonna go
I guess she's got her reasons but I just don't wanna know
'Cos for 24 years I've been living next door to Alice
24 years just waitin' for a chance
To tell her how I feel and maybe get a second glance
Now I gotta get used to not living next door to Alice
|
|
|
|
|
Please help me . . .
I have a very simple Question. I want to use MSFlexGrid from Windows API, C++. I can not use VC++ and also VC editor.
From where I am find sample on that.
Thanx in advance.
|
|
|
|
|
I have a time-consuming thread about mathmatics processing.
I do not want to just wait for its ending.
I created a user-interface thread.
CWinThread *pProcThread = AfxBeginThread(RUNTIME_CLASS(CProcThread));
After I started the thread, I found the thread almost took all CPU's time.
I can't do anything, except closing it.
Can anyone guide me a right way?
Thanks.
Windows2000 SP2, VC++ 6.0 SP5
|
|
|
|
|
It sounds like you've got a tight loop in the theaad somewhere, such as:
while(TRUE)
{
// Nothing happens here to give up the cpu
// spins back to top of loop
}
Take a look at any looping you're doing in the thread, and throw in a Sleep() call before you come back aournd to the top of the loop to give up the cup to the next thread.
Sleep(0) will allow the next thread to get some action without a detrimental effect on your performance in the loop. That will probably suffice if this is your problem. If you sleep for an actual amount of milliseconds, keep in mind that in 9x, your minimum granularity (quanta) is 55 milliseconds (I may be off by a couple of milliseconds on the 9x number, been a while) and under NT it's 10 milliseconds, so even if you call Sleep(1), what you'll get will be these minimum slices depending on the platform.
Chistopher Duncan
Author - The Career Programmer: Guerilla Tactics for an Imperfect World (Apress)
|
|
|
|
|
The mathmaics process program is from a dll call.
I can't put any sleep() call into it.
It costs about 2-3 seconds per call(depending on the performance of the
computer). My program has to call 100-400 times.
What shall I do?
Windows98 SE, VC++ 6.0 SP5
|
|
|
|
|
If you want to gain some more responsiveness from your UI thread, at the cost of increasing the time taken by the worker thread, lower the priority of the latter by using SetThreadPriority . For best results, create the thread in suspended mode, set its priority and then resume it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Well, it's a little unclear from your previous post exactly what/where the problem is, so more details would be helpful. If what you're saying is that the cpu shoots to 100% utilization for 2-3 seconds each time you make a call to your math library dll (assuming it's not your code but a third party add on), then you're screwed - call their tech support and see if maybe there's something incorrect in how you're calling it. Yeah, I know, not the answer any of us ever want to hear, but if that's the case then you have to talk to the people who wrote that code.
If the dll you're calling is your own code, then of course you can look for tight looping in the dll function that you're calling.
If the problem is not 100% cpu utilization for 2-3 seconds every time you make that dll call, could you please be more specific about what you're experiencing?
Chistopher Duncan
Author - The Career Programmer: Guerilla Tactics for an Imperfect World (Apress)
|
|
|
|
|
Thank you.
I have some simple questions:
1. How to change a tight loop into a loose one?
My codes:
for (int i = 0; i < nTimes; i++)
{
Mathmatics call(); // 100% CPU utilization for 2-3 seconds per call. It's from a third party.
}
2. What I want to do is just lowering this thread's CPU utilization or making it run background. What shall I do?
3. Can suspended mode thread work?
4. If all of above failed, any further suggestion for me or the 3rd party?
|
|
|
|
|
RichardWdy wrote:
1. How to change a tight loop into a loose one?
My codes:
for (int i = 0; i < nTimes; i++)
{
Mathmatics call(); // 100% CPU utilization for 2-3 seconds per call. It's from a third party.
}
Try this:
for (int i = 0; i < nTimes; i++)
{
// you're screwed for 2-3 seconds, but...
Mathmatics call();
// this will give the other threads a fighting chance
Sleep(0);
// if you're using overlapped i/o and want your
// thread to be alertable, you'd use SleepEx(0, TRUE);
}
RichardWdy wrote:
2. What I want to do is just lowering this thread's CPU utilization or making it run background. What shall I do?
Use AfxBeginThread instead of beginthread to kick off your thread - one of the parameters is the priority, which defaults to THREAD_PRIORITY_NORMAL.
RichardWdy wrote:
3. Can suspended mode thread work?
I'm not really sure what you mean by this, but you can start the thread in the paused state by using the CREATE_SUSPENDED flag, and then call ResumeThread() when you're ready to let it go. Use the thread handle in the CWinThread* that you get back in the call to ResumeThread() or any other thread API, e.g. ResumeThread(pThread->m_hThread).
RichardWdy wrote:
4. If all of above failed, any further suggestion for me or the 3rd party?
From the looks of that for loop, there's at least the possiblity that the problem is not in the math call. A loop like that is going to redline the cpu all on its own. Try putting that sleep in there first and see if that solves the problem. If the math call truly is causing 100% cpu utilization for 2-3 seconds, it's a tech support issue. However, if it's a small enough company that you can talk to the developers, you might suggest that they too implement some Sleep(0) calls to give up the cpu periodicially. By the way, Sleep(0) seems like it wouldn't pause at all, and it doesn't. What it does, however, is tells Windows that you're thread is ready to give up the rest of its time slice to the next waiting thread, kinda like Yield() in the old 16 bit Windows days.
Hope this helps!
Chistopher Duncan
Author - The Career Programmer: Guerilla Tactics for an Imperfect World (Apress)
|
|
|
|
|
Like Chris said, just set the threads priority low. IMHO, there is little point in playing games with Sleep. Just set the priority of the thread low and let the OS do it's job. If nothing else requires CPU, the math thread will get 100% of CPU which is exactly what you want. There is no point sleeping the thread when nothing else needs the CPU. However, since the thread has a lower priority, if pratically any other thread requires the CPU, they will get it.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I remember I have seen some really indepth articles on DLLs, all the types and also when to auto load and when to load it explicitly. However, I searched Codeproject and did not find too much. I want to make my FIRST attempt. I want to include a class and ALL its resources in a DLL. Can anyone point me to ALL the articles?
I also read that when you change or add to a DLL then you have to recompile everything and relink. Is this also true if you are only changing an internal functions but not its calling method. I mean f(x,y,z)... This stays the same. Only now it is x-y+z instead of maybe x+y+z. Will this tpye of situation require the not only redistributing the DLL but also a new exe?
Thanks in advance.
|
|
|
|
|