|
What is the best way to set up a timer for a process that will take an hour or two?
_____________________
"So in the interests of survival, they trained themselves to be agreeing machines instead of thinking machines. All their minds had to do was to discover what other people were thinking, and then they thought that, too."
Breakfast of Champions, Kurt Vonnegut
|
|
|
|
|
By 'process' you mean Windows process which has some timeout period in your case? Or some general activity?
You have number of options - classic Window timers, waitable timers, WaitForXXX APIs.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
The user sets the timeout period.
_____________________
"So in the interests of survival, they trained themselves to be agreeing machines instead of thinking machines. All their minds had to do was to discover what other people were thinking, and then they thought that, too."
Breakfast of Champions, Kurt Vonnegut
|
|
|
|
|
The timeout of what? Do you create other process by spawning some executable, or are you performing some activity in your own app?
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
Tomasz Sowinski wrote:
The timeout of what?
When the videotape ends. A friend wants me to write him an app to stop his video capture program after a period of time so he can run the program overnight without filling his harddrive and crashing.
I know how to use SetTimer() for short delays, but I want to know if there is a better solution for long delays (like an hour or more).
_____________________
"So in the interests of survival, they trained themselves to be agreeing machines instead of thinking machines. All their minds had to do was to discover what other people were thinking, and then they thought that, too."
Breakfast of Champions, Kurt Vonnegut
|
|
|
|
|
I'd use WaitForSingleObject with timeout in this case.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
Thanks.
_____________________
"So in the interests of survival, they trained themselves to be agreeing machines instead of thinking machines. All their minds had to do was to discover what other people were thinking, and then they thought that, too."
Breakfast of Champions, Kurt Vonnegut
|
|
|
|
|
How can I disable WinKey and another system shortcuts ?
Thanx.
LB
|
|
|
|
|
rewrite the gina.dll
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
To disable WinKey i found but didnt tried it!
http://is-it-true.org/nt/registry/rtips92.shtml
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
change registry ? BTW: I havent following item in register
Hive: HKEY_CURRENT_USER
Key:Software\Microsoft\Windows\CurrentVersion\Policies\System
Name: DisableLockWorkstation
Type: REG_DWORD
Value: 1 disable
I found this but its not for Win2K and later :/
SystemParametersInfo(SPI_SCREENSAVERRUNNING, true, NULL, 0);
Thakx
Wiizi
|
|
|
|
|
if u do like the page says ull be creating this key
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
|
Heres the VC client calling the function in a DlL:
CButton * pBar = (CButton*)GetDlgItem(IDC_BUTTONRECV);
long hPbHandle = (long)pBar->GetSafeHwnd();
_CRemoteCall p;
p.CreateDispatch("DllwithForm.Class1");
p.CheckingPB(hPbHandle);
p.ReleaseDispatch();
In the dll, the message is being sent as:
SendMessage(PbarHandle, WM_COMMAND, 0, 0)
This is supposed to trigger of my (test) button handler. But it doesnt....What might be the problem here?
Thanks,
ns
|
|
|
|
|
The wParam (argument which goes right after WM_COMMAND) in the SendMessage call should contain identifier of your button (probably IDC_BUTTONRECV).
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
Its the API I am calling in my dll (its a VB dll).
LRESULT SendMessage(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
so I think my order is okay. MFC's sendmessage takes the command first...so I'm sorry I wasnt clear that I was using the raw API...
Thanks,
ns
|
|
|
|
|
In your case, hWnd should be the handle of button's parent window, Msg is WM_COMMAND, wParam is the button ID (IDC_SOMETHING), lParam is zero.
You don't send message to button itself. Instead, message is handled by parent (usually dialog). That's why you need to pass control ID as well.
MFC encapsulates HWNDs for you and CWnd::SendMessage has three arguments.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
The button is on a CFormView form. So what is the parent? (I need to know the exact objects name, which is the parent. If you just tell me its the CView form I am going to be lost ) Do I have to do the getactiveview stuff? Then I can do an HWnd on it....
REally appreciate your help.
Thanks,
ns
|
|
|
|
|
Yes, the parent window is CFormView. You can't use GetActiveView from within VB .dll, because it's MFC method, not the Windows API function.
Could you describe the relationships between the .dll and client app in more detailed fashion?
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
The client app is going to show a progressbar, (tried to put it in the status bar, but I'll use the article link you sent me instead). The VB dll is doing database processing. One operation is done in a for loop and is lengthy. I thought I could SendMEssage a progressbar in the VC client and STEP_IT for each pass through the loop. All I want from the dll is :either a value for the counter, or just a WM_COMMAND message that trigggers a CView button which then STEP_ITs the progressbar> SO for each pass thru, the progressbar advances. This is whats happening. SO far I tried using MAunders ProgressBAr in a Statusbar class to send the message to, directly from the dll. THe dll can send a PBM stepit to the VC client if the progressbar is on the form itself. (In a sample app it does anyways so it ought to work for me too). MY problem is that the progressbar isnt on the form. Its either in the status bar, or else it will be spawned by that class ( CWaitDialog)you linked me too.
I havent tried the latter yet,( it doesnt want to sendmessage to the statusbar progressbar, but will to the forms progress bar.) So I though I'd get a WM_COMMAND notification for each pass through the VB loop and step the progressbar from the handler locally.....want to try that - it might work....
Thanks,
ns
|
|
|
|
|
The problem is that CWaitDialog needs to process messages. You'd have to call CWaitDialog member functions (SetPercentComplete and Pump) periodically from .dll which is beyond VB capabilities.
I guess you should go with progress-on-status. Get the HWND of progress control, pass it to the .dll and send PBM_STEPIT messages. To ensure that progress control redraws itself, you may also call ::InvalidateRect and ::UpdateWindow.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
THe CWAitDialog wil be created on the VC side. the user presses a menu item: MAke DAtabase
THe handler creates a CWait object. All I get from the dll is the loop counter. IT does no UI generation. Unless I'm misunderstanding, if I can get my sendmessage to work, I think (optimist!) that CWait will work. Brcause then I can do stuff like:
void OnButtonREceivingMessage
{
FunctionCalledInButtonHandler;
}
void FunctionCalledInButtonHandler() each time the message is sent
{
BOOL bContinue = TRUE;
CWaitDialog dlg (&bContinue);
globalCounter +=1;
int nPercent = globalCounter something;
dlg.SetPercentComplete (nPercent);
dlg.Pump ();
}
}
Does that make sense?
Thanks,
ns
|
|
|
|
|
Yes, it should work. You may also get rid of this VB-style button-press method invocation. Why don't you use (WM_APP + n) as special message which CWaitDialog would handle and call its SetPercentComplete and Pump?
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
just wary of messing with message map entries, but I shall be brave!
Thanks,
ns
|
|
|
|
|
I've been trying to sendmessage to the status bar progress bar all day today. I can send it to the progressbar on the form ,but not to the one in the status bar...
Thanks,
ns
|
|
|
|