|
i found this and it works fine, there is no problem so far but i cant how to set the timer less time periods and the ms is accurate ms here?
#include <windows.h>
#include <process.h>
#include <stdio.h>
unsigned __stdcall TF(void* arg) {
HANDLE timer=(HANDLE) arg;
while (1) {
WaitForSingleObject(timer,INFINITE);
printf(".");
}
}
int main(int argc, char* argv[]) {
HANDLE timer = CreateWaitableTimer(
0,
false,
0);
LARGE_INTEGER li;
const int unitsPerSecond=10*1000*1000;
li.QuadPart=-(2*unitsPerSecond);
SetWaitableTimer(
timer,
&li,
750,
0,
0,
false);
_beginthreadex(0,0,TF,(void*) timer,0,0);
while (1) ;
return 0;
}
--always comes daylight after night-----
|
|
|
|
|
If you set the time interval to zero, you can use the waitable timer as a one-shot delay. It this case, the "due time" is in 100nSec intervals (0.1 microsecond). Maybe you could retrigger by calling SetWaitableTimer() again but I suspect that this call could take a microsecond which defeats the object (could be worth a try). If you need a periodic timer with sub-millisecond period then maybe this isnt the thing for you but I thought it would be worth mentioning it, because its better than using Sleep().
Tony
|
|
|
|
|
I would like to do something on a view based on right and left clicks on the status bar of CMainFrame. I was able to do it succesfully using SendMessage command in Pretranslate function, but I noticed that it was breaking standard windows shortcuts like CTRL +F4 and others... Is there a better way of sendng these messages without overriding :::PreTranslate function ?
Thanks
|
|
|
|
|
I'm not sure why you need to override PreTranslate() . Why not just add the SendMessage() or PostMessage() in the code that handles the mouse clicks? Also if you have message conflicts then use one of the values reserved for applications - WM_USER + x .
|
|
|
|
|
great, but why can't I seem to do the left and right click handlers in MainFrame ? It doesn't even hit those handler functions when Left and right clicked. I do have ON_WM_LBUTTONDOWN() defined for example in the Message map as well.
Any ideas what I could be missing there?
|
|
|
|
|
Well this is a totally different issue; your original question suggested that you were capturing the mouse clicks. The comments above imply this is MFC, which is something I haven't used for many years, so I'm afraid I cannot offer much more, apart from suggesting you check all the alternative events that MFC will send to you.
|
|
|
|
|
Thanks, yes it is MFC. Yes, I was able to capture clicks within the PreTranslate function, but OnLButtonDown(UINT nFlags,CPoint point); is whats not working, it isn't even going there.
|
|
|
|
|
Are you sure your PreTranslate() function is returning the correct value so the messages still get dispatched? If you tell the framework that you have already handled the message then they will never get to the relevant event handler elsewhere.
|
|
|
|
|
The following code works, but breaks some of the standard Windows shortcuts for some reason. How do I just implement ONLeftMouse and OnRightMouse handlers to do the equivalent? I tried doing void CMainFrame::OnLButtonDown(UINT Flags,CPoint point) & void CMainFrame::OnRButtonDown(UINT Flags,CPoint point), but It isn't going there. Any ideas?
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
POSITION FirstDoc =theApp.m_pMainDocTemplate->GetFirstDocPosition();
if(FirstDoc !=NULL){
CMYAppDoc* pDoc = (CMYAppDoc*)theApp.m_pMainDocTemplate->GetNextDoc(FirstDoc);
if(pDoc != NULL){
POSITION pos = pDoc->GetFirstViewPosition();
while (pos != NULL){
CView* pActiveView = pDoc->GetNextView(pos);
if(pActiveView->IsKindOf( RUNTIME_CLASS(CRealView)) ){
CRealView *pView = (CRealView*)pActiveView;
if (pMsg->message == WM_LBUTTONDOWN)
pView->SendMessage(WM_LBUTTONDOWN,(WPARAM)0, (LPARAM)0);
else if (pMsg->message == WM_RBUTTONDOWN)
pView->SendMessage(WM_RBUTTONDOWN,(WPARAM)0,(LPARAM)0);
}
}
}
}
return CFrameWnd::PreTranslateMessage(pMsg);
}
|
|
|
|
|
As I said earlier I haven't used MFC for a long time, and I have to admit I am not a great fan. However looking at the above code I am not sure that you should be calling SendMessage() within the PreTranslateMessage() function, as this tries to process the message in the relevant Window before returning. Maybe PostMessage would work as it merely puts the message into the queue for the specified Window. However, I am speculating here as I am not sure how the MFC framework treats this situation.
|
|
|
|
|
Hi,
With much appreciated help from this forum I have finally managed to display a 32 bit bitmap with graded transparency (using the alpha channel).
However, I have noticed that if the bitmap is re-drawn in the same location, the semi-transparent pixels become solid and so the image reverts to having a ragged edge.
Is this normal behavior or have I got a setting wrong?
Thanks
Tony
|
|
|
|
|
Are you clearing the background before redrawing the bitmap ?
|
|
|
|
|
Hi Cedric
Nope I am not and as you are suggesting, if I do this it works. The question then is how to clear the background?
The object containing the transparent bitmap only has access to a DC and not to a window so I cant easily use InvalidateRect().
Perhaps there is another way to clear the backgound. I even thought of copying the background into another bitmap and BitBlt it before drawing the transparent bitmap each time the object is repainted but is this getting a bit complicated?
Perhaps there is an easier way?
Tony
|
|
|
|
|
On which "surface" are you drawing your bitmap ?
|
|
|
|
|
Hi,
I have a window derrived from CWnd and the client area consist of a background bitmap with lots of animated bitmaps overlaid drawn in the Window's DC, mostly in response to WM_PAINT messages.
The background bitmap is redrawn in OnEraseBkgnd() and the OnPaint() handler creates a DC and tells all of the bitmaps to draw themselves.
Does that answer your question?
Thanks for your interest
Tony
|
|
|
|
|
softwaremonkey wrote: I even thought of copying the background into another bitmap and BitBlt it before drawing the transparent bitmap each time the object is repainted but is this getting a bit complicated
That's the right thing to do, because it will always deliver a correct result even if your background has a bitmap on it or is gradiented, and it is just a few lines of code more...
Note: I think you could use InvalidateRect() when could be garanteed that the window was repainted before you draw your bitmap on it. Maybe WaitForInputIdle() can help you with that. [modified] Why doing so difficult: if your background is a solid color why not paint it yourself?
Rozis
|
|
|
|
|
Hey Rozis, thanks for the reply.
You were right, it wasnt too difficult to store the background as a bitmap and redraw it each time and it has fixed the problem. As a side effect, I have been able to reduce the number of Invalidate() and InvalidateRect() calls I make elsewhere which reduces the flicker so its a win-win situation.
It is always good to have a sanity check though, to make sure that I'm not going off at a tangent!
Thanks again!
Tony 
|
|
|
|
|
Hi,
i have handle to the editControl (Hwnd) how can i check whether the edit control is Readonly or not....
Is there any Api...?
|
|
|
|
|
Form MSDN [^]:
To determine whether an edit control has the ES_READONLY style, use the GetWindowLong function with the GWL_STYLE flag.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
how to get a hidden file extensions?
thanks in advance
|
|
|
|
|
Sorry?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Im not sure do you need to GetFileAttributes ?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
there are no hidden file extensions when doing directory lookups within a program. If you are talking about seeing file extensions in things like Explorer Windows or File Open dialogs, you do that by going to Tools / Folder Options / View in any Explorer Folder and uncheck "Hide file extensions for known file types"
Steve
_________________
I C(++) therefore I am
|
|
|
|
|
Hi Experts,
Please help me with this issue.
How to hook the baloon tooltip window (which arrived when a device is connected to the pc showing "found new hardware") so that i can change the caption of it??
I have tried the hooking of WM_CREATE , but its not the right one..
Please help me.
Regards,
spk 521
|
|
|
|
|
can we write a program without main block in c++ please specify another way except using static block
|
|
|
|