|
Take a look at TB_ADDBITMAP .
|
|
|
|
|
u know any book of WIN32....or any website?
|
|
|
|
|
The documentation has a small code snippet on how this can be done - http://msdn.microsoft.com/en-us/library/bb787289(VS.85).aspx
|
|
|
|
|
|
Is there any efficient way to share OpenGL resources in multithreaded programming?
|
|
|
|
|
Could you please elaborate ? What do you mean by resources exactly ? And how do you want to share them ?
|
|
|
|
|
Hello,everybody !
I want to set a 25 hours timer in the dialog based project.There will be plenty of database operation in the menber function.
I used this way:
1、SetTimer
when I used it ,the window interface always death after 10 minutes ago.
2、Multi-Threading
but it faild to ,when the function execute several times,it no longer to run anymore.
DWORD CTestDlg::ThreadProc(LPARAM lParam)
{
typedef BOOL (_stdcall *MYSWITCH)();
MYSWITCH MySwitchToThread;
HINSTANCE hInst = LoadLibrary("Kernel32.dll");
if (hInst != NULL)
MySwitchToThread = (MYSWITCH)GetProcAddress(hInst, "SwitchToThread");
if(!MySwitchToThread)
return -1;
CTestDlg *pDlg = (CTestDlg *)lParam;
TRACE( "Work thread pDlg --- %d\n ",pDlg);
UINT oldTickCount,newTickCount;
oldTickCount = GetTickCount();
while(TRUE)
{
while(TRUE)
{
newTickCount = GetTickCount();
if(newTickCount - oldTickCount >= 10000)
{
oldTickCount = newTickCount;
break;
}
else
MySwitchToThread();
}
CFile file("MyThread.txt",CFile::modeReadWrite|CFile::modeNoTruncate);
CTime time;
CString str="";
time = CTime::GetCurrentTime();
str.Format("%d-%02d-%02d %02d:%02d:%02d Thread Running...\r\n",
time.GetYear(),time.GetMonth(),time.GetDay(),
time.GetHour(),time.GetMinute(),time.GetSecond());
file.SeekToEnd();
file.Write(str,str.GetLength());
file.Flush();
file.Close();
Sleep(100);
pDlg->Fun1();
Sleep(100);
pDlg->Fun2();
return 0;
}
return 0;
}
then run the thread:
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
......
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ThreadProc,this,0,NULL);
}
There a better way ?
modified on Sunday, April 11, 2010 11:30 PM
|
|
|
|
|
You can use SetTimer like this -
SetTimer(hWnd 0, 25 * 60 * 60 * 1000);
|
|
|
|
|
|
Koma Wang wrote: I want to set a 25 hours timer...
Have you tried setting a 60000ms timer and when the timer has "fired" 1500 times, you know that it has been 25 hours?
Another option would be to create a scheduled task within Windows and let it handle when to run the program.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
thanks !
I used Windows Task Scheduler instead.
|
|
|
|
|
Hi,
I often hear or read about Parent/Child relationship with regards to Process
but is there any relationship with regards to threads
For instance if Thread A AFXbeginThread B and Thread B AFXBeginThread C
if thread A goes away do Thread B and C still live as long as the process is alive
thankx
|
|
|
|
|
ForNow wrote: if thread A goes away do Thread B and C still live as long as the process is alive
yes
|
|
|
|
|
If you are using Nested Threads like NT as main thread & T1 & T2 are as two sub thread under NT, then the answer will be YES.
But, other than called it as parent-child relation, I would rather like to call it as ordered relation, like threads will execute,in an order they are placed in the program.
As threads are mainly uses systems resources, so one can not delete a thread until that gets completed.
NOTE: though using various time slashing algorithm one can switch between threads if he/she wants.
--Rupam
System Analysts
|
|
|
|
|
There is no parent-child relationship that I'm aware of, but there's one caveat: if the main thread dies (the thread that calls WinMain ) dies so does the entire process.
Steve
|
|
|
|
|
Is a CWinAPP so special or does the process need at least one thread alive
|
|
|
|
|
Every process has one main thread of execution. On windows threads are getting scheduled, not processes.
|
|
|
|
|
It's not CWinApp that's special, the "specialness" is at a lower level. When a process starts its initial thread calls WinMain[^]. This thread can create as many threads as it likes and they in turn can do the same, but as soon as the the initial thread exits the process is history. MFC is built on top of Windows, and the initial thread is the one that's generally going to be executing CWinApp 's methods. So yes, a process does need at least one thread to be executing: the initial one.
Steve
|
|
|
|
|
I am a college student, looking to participate in an open source project. The only experience I have is class work, and I want to start participating in "real world" programming. I was wondering if anyone could point me in the right direction to find a project I might be able to help with. Thank you for any advice you can give.
Jason
|
|
|
|
|
well ... it's kind of easy no ? just think a little bit : one word.
Linux
From that simple world you will find thousands of opensource projects you can put you hands into.
Choose the application domain you feel you will like the most (or want to learn the most), for example don't do 3D stuff if you don't like it, or scientific software if you like music producing)
or you your favourite search engine with keywords like "open source project"
Good luck.
Watched code never compiles.
|
|
|
|
|
www.sourceforge.net
Biggest Collection of OpenSource projects
|
|
|
|
|
You should find a project which you would like to use but is not exactly what you need. This way you will have motivation as well as new features which you can add to the system.
-Saurabh
|
|
|
|
|
While working with ListView I started adding case WM_NOTIFY to the parent window message loop.
Although it was empty, but when I ran the app all the columns that used to be populated are now empty!
What kind of problem could I be looking at?
|
|
|
|
|
Take a look at where you added this case entry to make sure it is not falling through the loop. Also review the function/block where you fill your columns.
It's time for a new signature.
|
|
|
|
|
Function/block is fine, after removing WM_NOTIFY everything returned as normal.
How can it be falling through the loop?
|
|
|
|