|
What I want to do is, when I get this message, I want to create a timer for 60 secs and display a dialog to the user with the timer counting down. During this time, the application should not be doing anything, just wait till the timer expires and then continue from there on.
Am I being clear enough?
Thanks
Murali
|
|
|
|
|
He's one way to do it. Make a dialog and add a static text control to contain the countdown. In the OnInitDialog (I'm assuming MFC here) handler start a timer like this:
SetTimer(1, 1000);
Add a handler for the WM_TIMER message with ClassWizard. In the handler you would do something like this:
afx_msg void CCountdownDialog::OnTimer(UINT_PTR nIDEvent)
{
CString s;
s.Format(_T("Time remaining: %d"), --m_TimeRemaining);
CWnd *pStatic = GetDlgItem(IDC_COUNTDOWN);
pStatic->SetWindowText(s);
if ( m_TimeRemaining==0 )
{
KillTimer(1);
}
}
This should get you started.
Steve
|
|
|
|
|
What is AfxGetMainWnd() returning? My MFC is rusty but I don't think the app's main window is created yet in CWinApp::InitInstance() . That code would do better in CMainFrame::OnCreate() .
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi Mike,
The app's main window gets created like this:
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CNotifyTimerDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CNotifyTimerView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
After this I issue the following (I could have also used m_pMainWnd, but this just for testing):
//send the message to the main frame to display the notification.
AfxGetMainWnd()->SendMessage(WM_NOTIFY_POWER_ON_TIME, 0, 60);
What I want to do is, when I get this message, I want to create a timer for 60 secs and display a dialog to the user with the timer counting down. During this time, the application should not be doing anything, just wait till the timer expires and then continue from there on.
Am I being clear enough?
Thanks
Murali
|
|
|
|
|
Hey everyone:
I want to copy the way say window1 is currently displayed (in terms of what has been painted).
This is becauase I now need to call a command that will send window1 to all black.
Now I want to paste in the way window1 looked, which I have copied in step1.
Please tell me there's a nice & easy way to do this,
`Chase (membos AT yahoo DOT com)
|
|
|
|
|
I use the the ftprenamefile command to rename the file at the ftp server site to the new file I want.
The error that I get from the returned error code is 12003. Can anyone tell me what is this and how to solve this error?
Thank you.
|
|
|
|
|
ERROR_INTERNET_EXTENDED_ERROR
An extended error was returned from the server. This is typically a string or buffer containing a verbose error message. Call InternetGetLastResponseInfo to retrieve the error text.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
I am trying to create an event listener for a left mouse button event in c++. Does anyone have any idea how to create this so that I can register the listener at the beginning and then when the event happens it will call a function of what I want to happen. If this makes no sense let me know.
Thanks
|
|
|
|
|
If VC++ 6.0, use the ClassWizard and set up a member function for WM_LBUTTONDOWN.
If VC++ 7.1, don't use the Classwizard ('cause it 'taint there) and set a handler for WM_LBUTTONDOWN
If your using VC .NET, I haven't the clue. It's too safe for me anyway.;P
(In .NET it's probably in the System.Computer.Actions.Mouse.MouseActions.ButtonActions.PressedActions.LeftButton.Down namespace or something hideously long like that)
-- modified at 20:25 Wednesday 12th April, 2006
|
|
|
|
|
I need to get text from my Edit Controls, which are CString types, and convert them to char arrays which I later store in the header of my binary file. I can do this easily if I specify my character set to be Non Unicode and use strcpy . The problem when I do this is that all my dialogs and buttons revert back to the Windows 2000 style, rather than the WinXP style. It is not really a bid deal, but I would like the application to look as up to date as possible.
Can anyone tell me how to convert CStrings into char arrays, using Unicode, or how to get WinXP dialogs with a Non Unicode character set? What I am getting at may be a little vague so let me know if you need me to explain it in more detail.
Any help is appreciated. Thank you!
|
|
|
|
|
If all you need to do is copy the data from the CString and write it to a file, you do not need to copy the contents of the string to a non-const buffer. CString objects have a LPCTSTR operator, which means that you can use it in place of a const TCHAR * .
Since the CString class is TCHAR -based, it supports Unicode. You can convert the string to ANSI for writing it to a file using the ATL Conversion Macros (T2CA ) if the data is not too large, or calling WideCharToMultiByte(...) yourself with your own buffer(s).
Also, if you get into the habit of using the TCHAR -based string functions, you life may get easier (i.e. using _tcscpy(...) instead of strcpy(...) ).
Look up how to create (and optionally embed) a common control manifest file; that should help you with getting the XP-style controls back into the application when running it in ANSI mode.
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
|
hello Everyone,
I am a beginner in Visual Studio C++.
In all I have read till know I can't find an example of how to plot,
let say i have x=[1 3 7 ] and y=[7 9 10]
i want to build an application where i press the button PLOT and it plots y versus x in circle (or line) in and a given color
I would really appreciate your help.
thanks again
|
|
|
|
|
You have to research device contexts. All "plotting", or any graphical output for that matter, in Windows is accoplished through a device context.
CDC *pDC;<br />
<br />
pDC->MoveTo(x1, y1);
pDC->LineTo(x2,y2)
pDC->Ellipse();
pDC->Rectangle();
There are many more features to device contexts which should allow you to do what you want. Any good Visual C++ book should talk about DC and I know this web site has A LOT of useful examples.
Hope that helps.
Paul
|
|
|
|
|
ilda lapi wrote: I am a beginner in Visual Studio C++.
In all I have read till know I can't find an example of how to plot,
In addition to the post on DC, you can also change that context into either an OpenGL or Direct3D display, thus allowing you a full range of very low-level drawing functions.
and there are additional methods such as GDI+ depending on your needs. http://www.codeproject.com/miscctrl/pgllib.asp[^]
there are actually quite a few ways to do plotting through various frameworks to libraries.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I have to develop a device driver for windows NT that will add a virtual audio device to the system. i need to hook up and capture the audio stream coming from microphone and send it to two differnt application. one sugesstion i got from Kakan is to develop a filter driver.
Now can a filter driver be used to install a virtual device.
there are MSVAD sample drivers in DDK. are thay filter drivers?
can i use those sample codes for my work.
saad
|
|
|
|
|
Hi,
I have a line that I want to key as follows:
m_Query.Format("select Route_ID
Stage_ID,
Price,
valid_from,
valid_to,
Price_Key
from TicketPrice
where Ticket_Type = '%s'
FOR UPDATE", m_selected_id);
However I get C2001 newline in constant messages from the compiler. Anyone know the line continuation symbol?
Ger
|
|
|
|
|
Ger Hayden wrote: Anyone know the line continuation symbol?
You can either use the backslash character like:
m_Query.Format("select Route_ID \
Stage_ID, \
Price, \
valid_from, \
valid_to, \
Price_Key \
from TicketPrice \
where Ticket_Type = '%s' \
FOR UPDATE", m_selected_id); or enclose each string in quotes like:
m_Query.Format("select Route_ID "
"Stage_ID, "
"Price, "
"valid_from, "
"valid_to, "
"Price_Key "
"from TicketPrice "
"where Ticket_Type = '%s' "
"FOR UPDATE", m_selected_id);
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Thanks David,
Both forms work perfectly
GER
Ger
|
|
|
|
|
I've built a fairly simple MFC project, dialog based, that talks to a USB GPS device. The program uses a second thread to receive data at a 1-second rate and display the information in text form. When a data packet is received, the worker thread sends a message to the DlgWindow to tell it to get the new information. The call is:
if (pThis->m_hWndPost)<br />
::PostMessage (pThis->m_hWndPost, pThis->m_nMessageID, 0, 0);<br />
This works correctly in the Debug version of the project. However, when the Release version is built, the second call to ::PostMessage() crashes. I've isolated that code, and if I don't call the message post, no problem (of course, the DlgWnd never gets the new data). If I trap the message at the responding function in the DlgWnd, it crashes.
One work-around: if I set the compiler options to build using the debug libraries, either stand-alone or with shared MFC DLL, the problem goes away. I can't find that I have any corrupted libraries (and no reason to suspect).
Has anyone ever seen this problem before? Any ideas what I'm doing wrong? Turning off optimizations has no effect, either.
Thanks,
Mike
|
|
|
|
|
In debug mode, compiler takes care of things like initialization.
Check if all variables used are properly initialized.
Use NULL check before using pointers.
This is just a try. I'm not sure , why crash is happening.
|
|
|
|
|
Hi EveryOne!,
I will add code later, but I am having a problem with member variables. As you will see in the code the variables are being created and ClassWizard recognizes them. However, when I try to access them in the .CPP file they aren't working (I can add events from class wizard for them). I.E. I copy the variable from it's definition in the header file place it where I need it in the .CPP file and place a . (dot) after it, but it does not provide me a list of member functions that should be available. It does nothing. There is one exception and that is the m_CalUICCombo it works fine. The m_FySelected (also a ComboBox) does not work? Following is the Header file followed by the .cpp file. To keep this post down I've only inserted the relavant parts. Has anyone every run into this problem and if so what did you do to fix it?
Many Thanks in advance...
Charlie
<br />
class CECalAppendixIForm : public CFormView<br />
{<br />
protected:<br />
CECalAppendixIForm();
DECLARE_DYNCREATE(CECalAppendixIForm)<br />
<br />
public:<br />
enum { IDD = IDD_APPENDIXI_FORM_VIEW };<br />
CComboBox m_FySelected;<br />
CLabel m_SelectedItemsLabel;<br />
CLabel m_AppendixILabel;<br />
CComboBox m_CalUICCombo;<br />
<br />
public:<br />
SYSTEMTIME ct;<br />
<br />
<br />
CImgViewerDoc* GetDocument();<br />
CString csHdrLine;<br />
public:<br />
<br />
public:<br />
virtual void OnInitialUpdate();<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
virtual void OnDraw(CDC* pDC);<br />
<br />
protected:<br />
virtual ~CECalAppendixIForm();<br />
#ifdef _DEBUG<br />
virtual void AssertValid() const;<br />
virtual void Dump(CDumpContext& dc) const;<br />
#endif<br />
<br />
afx_msg void OnCloseupCalUIC();<br />
afx_msg void OnCloseupFySelected();<br />
DECLARE_MESSAGE_MAP()<br />
};<br />
<br />
<br />
<br />
IMPLEMENT_DYNCREATE(CECalAppendixIForm, CFormView)<br />
<br />
CECalAppendixIForm::CECalAppendixIForm()<br />
: CFormView(CECalAppendixIForm::IDD)<br />
{<br />
}<br />
<br />
CECalAppendixIForm::~CECalAppendixIForm()<br />
{<br />
}<br />
<br />
void CECalAppendixIForm::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CFormView::DoDataExchange(pDX);<br />
DDX_Control(pDX, IDC_FYSELECTED, m_FySelected);<br />
DDX_Control(pDX, IDC_SELECTITEMS, m_SelectedItemsLabel);<br />
DDX_Control(pDX, IDC_APPENDIXI, m_AppendixILabel);<br />
DDX_Control(pDX, IDC_CALUICOMBO, m_CalUICCombo);<br />
}<br />
<br />
<br />
BEGIN_MESSAGE_MAP(CECalAppendixIForm, CFormView)<br />
ON_CBN_CLOSEUP(IDC_CALUICOMBO, OnCloseupCalUIC)<br />
ON_CBN_CLOSEUP(IDC_FYSELECTED, OnCloseupFySelected)<br />
END_MESSAGE_MAP()<br />
<br />
#ifdef _DEBUG<br />
void CECalAppendixIForm::AssertValid() const<br />
{<br />
CFormView::AssertValid();<br />
}<br />
<br />
void CECalAppendixIForm::Dump(CDumpContext& dc) const<br />
{<br />
CFormView::Dump(dc);<br />
}<br />
#endif //_DEBUG<br />
<br />
CImgViewerDoc* CECalAppendixIForm::GetDocument()
{<br />
m_pDocument->IsKindOf(RUNTIME_CLASS(CImgViewerDoc));<br />
return (CImgViewerDoc*)m_pDocument;<br />
}<br />
<br />
void CECalAppendixIForm::OnDraw(CDC* pDC) <br />
{<br />
SetScrollSizes(MM_TEXT, CSize(1200,1200));
CImgViewerDoc* pDoc = GetDocument();<br />
pDoc->csHdrLine = "APPENDIX I";<br />
pDoc->UpdateAllViews(this);<br />
}<br />
<br />
void CECalAppendixIForm::OnCloseupCalUIC() <br />
{<br />
}<br />
<br />
void CECalAppendixIForm::OnInitialUpdate() <br />
{<br />
CFormView::OnInitialUpdate();<br />
<br />
CSize sizeTotal;<br />
<br />
sizeTotal.cx = 250;<br />
sizeTotal.cy = 100;<br />
SetScrollSizes(MM_TEXT, sizeTotal);<br />
<br />
m_SelectedItemsLabel.SetWindowText("There are No Input Item(s) required for this Appendix.");<br />
m_AppendixILabel.SetTextColor(RGB(0,100,130));<br />
m_AppendixILabel.SetFontName("Times New Roman");<br />
m_AppendixILabel.SetFontSize(14);<br />
m_AppendixILabel.SetFontBold(FALSE);<br />
m_AppendixILabel.SetFontUnderline(FALSE);<br />
m_AppendixILabel.ShowWindow(SW_SHOW);<br />
}<br />
<br />
void CECalAppendixIForm::OnCloseupFySelected() <br />
{<br />
<br />
}
Everything is Free... Until You Have to Pay for it...
Platforms Windows 2000/XP Professional using Visual C++ 6.0
|
|
|
|
|
Without having to wade through all of the code, are you having trouble with IntelliSense?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Let me see if I can make the problem a little more clear. When I go to my OnDraw function in the source file and put in m_CalUICCombo. I get a scrollable list box of the functions/variables I can access for that combobox. When I type m_FySelected. I do not receive the scrollable list box giving me those choices for that combobox. I hope this will make it a little more clear what I am having a problem with. So I am not sure if that would be a problem with intellisense? Any further advice would be appreciated.
Everything is Free... Until You Have to Pay for it...
Platforms Windows 2000/XP Professional using Visual C++ 6.0
|
|
|
|
|
Charlie Curtis wrote: So I am not sure if that would be a problem with intellisense?
It is. See if this helps.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|