|
Instead of using a TimerProc() you might consider using a thread. Look up CreateThread() (Windows CE 1.01 and later) in the MSDN Library.
Oooh! Do not forget to look at the totorials on threading.
Trust in the code Luke. Yea right!
|
|
|
|
|
You can do something like this:
Init fcn:
{
...
theApp.m_sAlertParamStruct.hThread = ::CreateThread(NULL,0,BackgroundAlertThread,(LPVOID)&theApp.m_sAlertParamStruct,0,&dwThreadID);
...
}
DWORD WINAPI BackgroundAlertThread(LPVOID pParams)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
BACKGROUNDPARAMSTRUCT *pParamStruct = (BACKGROUNDPARAMSTRUCT *)pParams;
char caBuf[21];
if (pParamStruct->pApplication->GetUserTagValue("AlertBackgroundThreadRunFrequency",caBuf))
iRunFrequency = atoi(caBuf);
// check not more frequent than every 30 seconds..
if (iRunFrequency < 30)
iRunFrequency = 30;
int iSeconds = 0;
while (!pParamStruct->bTerminateThread)
{
iSeconds++;
if (iSeconds >= iRunFrequency)
{
// do your thing here......
iSeconds = 0;
}
Sleep(1000);
}
if (!pParamStruct->bTerminateThread)
pParamStruct->hThread = NULL;
return 0;
}
|
|
|
|
|
Thank you so much for the suggestions.
I am leaning more towards not adding a background thread mainly becz I already have three threads in my module. So, I am thinking of modifying one of the threads that I have to wait for RETRANSMIT_TIME, do the job and again wait.
Ruchika
|
|
|
|
|
Exactly what I had in mind!
Trust in the code Luke. Yea right!
|
|
|
|
|
Hello,
I am working on a suite which needs to launch small file processing applications once a while. As my suite application spawns the small helper application, it losses the focus, and not regain it until the helper application complete and exit.
I wonder anyone knows how to launch an application (no UI) in background? I am using function ShellExecuteEx() right now.
Regards,
--jC
|
|
|
|
|
Search codeproject for ShellExecuteEx() and or CreateProcess(). There is an example around here some where, a similar example is out on the web [some where].
Also do the same search on the MSDN Library.
Sorry I could not be more helpful, but that is how I found imformation you are looking for last month.
Trust in the code Luke. Yea right!
|
|
|
|
|
Hello ,
Iam doing a MFC project.Iam displaying Animated GIFs with CDhtmlDialog class.This method works but the problem is that it works like a IE explorer.FOr example ,if i right click on the image a menu appears which is same as the IE right click menu .
Is there a way to get rid of this menu and similar such default IE message handlers??
|
|
|
|
|
I've never used VC++NET and I don't know if it is the same, but in a HTML Web page you can weite down this and the popup disappears...
<html><body oncontextmenu="return false"> ...
Hope this helps...
|
|
|
|
|
ACtually iam dispaling images here .ANyway i wil try ur suggestion .Thanks for it .
I solved it by getting the child window and disabling the user input to it !!!( Wnd->Enable Window(FALSE))
|
|
|
|
|
I'm having a little problem with trying to use one app to get two GDI+ windows up. I am using MFC.
I was origonally initializing GDI+ graphics as ::
Graphics graphics(::GetDC(m_hWnd));
And whenever two GDI+ screens overlapped, one would not reprint however, mouse movements on that window would still work). I changed the above to :::
CPaintDC dc(this);
Graphics graphics(dc.m_hDC);.
And right now, both screens are active, meaning if I move one over the next, both would reprint, however, they would not reprint on command, meaning that if I move my mouse over a button, it would internally change the variable to highlight, but the display would not get displayed.
Using method # 1, displays the graphics whenever possible, but using #2 only displays it on a window resize... I am putting the code inside the OnPaint function.
Any ideas? I have no idea why the behavior is different. Can one app have two GDI+ windows constantly repainting? I am using CS_OWNDC.
Thanks for the suggestions!
|
|
|
|
|
Hi All,
I need to integrate MapPoint software into my MFC database application. Basically what i want to acheive is to
get the data from the database and display it in the map. Application has to invoke the map and draw the route on it.
Any ideas will be appreciated.
Thanks,
John
|
|
|
|
|
Using the MFC AppWizard in Visual C++ 6.0 I created an SDI app with CRichEditView as the base class, and included the standard printing and print preview options. When printing or using the print preview, the text is always formatted for 8-1/2 x 11 paper oriented portrait, regardless of what is selected for these options in the print setup. For example, if landscape orientation is requested, the text is printed landscape, but it is formatted too narrow for the page, and it runs off the bottom of the page. What do I need to do so that the printable area is resized when the print setup options change?
|
|
|
|
|
Did you consider having a look in the wordpad example source?
I guess you may find it here. wordpad is yust a RichEditView.
G. Steudtel
|
|
|
|
|
I had looked at the code for the WordPad example, but I couldn't isolate the problem. I found that if I commented out the line
theApp.NotifyPrinterChanged();
from CWordPadView::OnPageSetup() it acted the same as what I have described. I can't seem to trace the cause of this behavior.
|
|
|
|
|
Hi,
the problem is not so hard to solve. You found all the footprint of the path to follow, except for the last.
If you have a close look at the source, you will find it sends a message m_nPrinterChangedMsg which will be intercepted eventually by the wordpadview class (CWordPadView).
In here a new device context for the printer is created and passed to the CRichEditView via OnPrinterChanged.
Having then a look at the help for CRichEditView::OnPrinterChanged reveals, that by default the printing will be on a paper of size 8.5" to 11".
So all you have to do, is create a printer device context, and send it to your CRichEditView.
You must destroy this printer device after printing. See CWinApp::CreatePrinterDevice .
You see, you found the place, where to start searching, and just stopped a millimeter before reaching the goal.
Never give up to early.
Regards
G. Steudtel
|
|
|
|
|
Thanks. I am new to Visual C++, so the MFC things are difficult for me to understand and trace through. I'll try to implement what you have described. Thanks again.
|
|
|
|
|
Hello,
how can I convert a CString to an int?
For char pointer strings this is easy (using the atoi function), but how to do it with CString?
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Hi, try this
Cstring str;
str="4711";
int number = atoi(str.GetBuffer(str.GetLength()));
|
|
|
|
|
Works perfectly. Thanks!!!
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Don't use GetBuffer() and GetLength(). just use atoi() and cast the cstring to const char * (optional)
#include <beer.h>
|
|
|
|
|
There's no need to use GetBuffer() or GetLength().
|
|
|
|
|
I normaly convert direkt too, but in a former case i had a problem with that so i thought this would be the save way
|
|
|
|
|
why not just int number = atoi(str); ?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
I'm trying to adapt the size of window so it can fit with different resolutions based on the monitor size?
|
|
|
|