|
Anu_Bala wrote: I dont know why it occurs.
Because Time is never greater than TtlTime .
"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
|
|
|
|
|
Hi,
Sleep() function makes application sleep for specified time, but it blocks
the thread from processing anything.
How can i make application sleep for some time but still process the
messages? (e.g. equivalent to DoEvents in Visual Basic 6)
-----
Don't look back... See your stomach...
|
|
|
|
|
The sleep() lets sleep the thread where it's inside.
If you let sleep the WinThread, so all the windows will sleep too.
You need to use workerthreads, there in you can let sleep the threads as long as you want and
the windows will not be affected ...
Good luck
|
|
|
|
|
This is for UI thread:
void Delay(DWORD dwMsecs, BOOL bBlocking)
{
static BOOL bInDelay = FALSE;
if (bInDelay)
return;
bInDelay = TRUE;
DWORD dwStrtmsecs, dwCurmsecs;
MSG msg;
dwStrtmsecs = dwCurmsecs = ::GetCurrentTime();
do
{
if (!bBlocking)
{
if (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
::PostMessage(NULL, WM_QUIT, 0, 0L);
break;
}
else
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
}
dwCurmsecs = ::GetCurrentTime();
if (dwCurmsecs < dwStrtmsecs)
dwStrtmsecs = dwCurmsecs;
} while ((dwCurmsecs < (dwMsecs + dwStrtmsecs)));
bInDelay = FALSE;
}
|
|
|
|
|
Wow, thanks a lot... there's lot to learn out there, i guess...
|
|
|
|
|
How to communicate UI thread from worker thread?
Thanks in advance.
-- modified at 2:32 Wednesday 11th July, 2007
Have A Nice Day!
Murali.M
|
|
|
|
|
In general, the way it is done is simply pass a pointer to a class or structure to your thread function (you can pass an argument to this function when you start the thread). Then, you can simply change variables of this class/structure. But beware that they need to be protected with critical sections (to avoid that both threads access the same variable at the same time).
|
|
|
|
|
I think in many ways we don't specially cosider UI thread and worker thread in communication,we just use thread-communicate,you can use any mechanism of thread-communicate to transfer message from one thread to another,such as postmessage,sendmessage and so on.Of course what I referred above are all in one process.
|
|
|
|
|
To be able to use PostMessage and SendMessage, you need to have a window that will receive the messages. If you have a worker thread, generally you don't have a window, so this is not really an option.
|
|
|
|
|
The UI thread of course has a window procedure which the worker thread can post or send message to.
|
|
|
|
|
Of course. But it is not possible the other way around.
|
|
|
|
|
You can use events for symchronization you can also use Other synchronization objects like Critcal section.
You cant pass messages to worker thread.
If you wanna communicate from worker thread ->UI thread you can pass messages.
i Hope it is useful.
Thanks,
SandipG.
|
|
|
|
|
Also, check out PostThreadMessage()
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
Hi,
what can be the possible solution if i want to run video on web page.
Regards
|
|
|
|
|
Using ActiveX control
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
use ActiveX control or DirectShow development on web.
|
|
|
|
|
I am getting the expected MIDI acknowledgement messages in release mode from the H/W but some MIDI messages are missing in debug mode( not coming to WindowProc() ). Is there any difference in behaviour of WindowProc() between debug and release mode?
Best Regards,
Suman
|
|
|
|
|
I don't think there's a difference between Debug and Release mode for WinProc(),please check your code and make sure.
|
|
|
|
|
I can't seem to do this, I've found some things here and there explaining how to do it, but all I end up doing is rendering my program unable to start up. I could go into the linker turn on ignore default libraries and and I get a 2kb program that pops a messagebox. When I try to bring up my actual interface though...
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
MessageBox(NULL, "Messagebox.", "Hi.", MB_OK);
return 0;
}
but replace messagebox with DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLG1), NULL, DialogProc); and I get an unusable program.
I'm still new to this C thing, but so far the program is entirely win32 api, and single digit kb files are more appealing than 40kb ones. I've seen a bunch of programs that show off stupidly low files sizes, one even being 1kb, but I can't seem to achieve this effect. I can guess what I'm doing wrong but I don't know how to correct it. The 1kb one comes with a readme explaining how it was done, last step which I don't get is...(which is where you actually drop the CRT)
- skip a standard WinMain-EntryPoint by defining a new EntryPoint
via the "ENTRY" linker command
Could somebody please explain how I can accomplish it? I don't really get how to create a new WinMain function.
|
|
|
|
|
choadvach wrote: int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
To the entry point of an application, i dont think any parameters are passed in to it. That means the HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow are all junk values.
May you can try like this
int WINAPI WinMain()
{
HINSTANCE hInstance = GetModuleHandle(NULL);
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLG1), NULL, DialogProc);
return 0;
}
And let me know the result.
|
|
|
|
|
Thanks a ton, this worked perfectly! All this time it was so simple and I was just blowing my mind over nothing.
|
|
|
|
|
Naveen.R wrote: That means the HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow are all junk values
What do you mean by this, these are junk values?
|
|
|
|
|
I mean kernel32.dll will not pass those parameters to the application entry point. Have you checked how an application entry point is? check the WinMainCRTStartup function. You can find how that function calls the winmain of an application.
|
|
|
|
|
Hi all,
How to use edit box.I want to enter some string in the edit box and pass it as an argument to some function.
|
|
|
|
|
You can use of SetWindowText for set text and for retrieve text use of GetWindowText .
|
|
|
|