|
How can I call a .exe file in a c/c++(not MFC) project?
thx,
L Zhang
|
|
|
|
|
ShellExecute
system
WinExec
CreateProcess
|
|
|
|
|
mwolf122 wrote: How can I call a .exe file
You mean launching an exe, no ? If yes, see the FAQ[^]
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
|
|
I want to use timers do some actions.
I read about
UINT SetTimer(HWND hWnd, UINT nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc );
versus the
CWnd::SetTimer, UINT nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc );
There is a nice document here explaining some facts. However, I still have some questions about who is handling the timers.
I want to create and handle the timers inside a CScrollView (by mapping and overwriting the inherited CWnd::OnTimer(UINT nIDEvent) and not via a TIMERPROC.
However, I am not sure which timer creation function to use and what value will be good for the nIDEvent on them.
i. How do I guarantee that the CScrollView which created the timer is the one that receives the WM_TIMER message (and subsequently process it). Is it possible that the
WM_TIMER expiration message ends up on another queue (I found that this is possible for mouse messages) or only the creating window can get it?
ii. Is the nIDEvent identifier a system unique one or a view unique one? How do I get a sufficiently unique nIDEvent value to make sure that I am processing the right timer?
iii. Is it possible that my CScrollView will receive time outs (i.e. WM_TIMER messages) by other views or even other threads or applications and under which conditions? If yes what should I do with those timers?
iv. Any idea why SetTimer may fail? Is this due to a system limit on running timers or due to a non unique nIDEvent? How can I know?
Dimitris
|
|
|
|
|
i. If you do "this->SetTimer(100, 2000, NULL)" inside your CScrollView class it will use the handle for your view.
ii. It is unique to your view. How many timers are you planning on using? If just one declare a constant.
iii. Yes if some sends the WM_TIMER message to that view. Really shouldn't happen though.
iv. How do you know it's failing?
|
|
|
|
|
Thanks a lot. It clarifies a lot of things.
Thus, I can be sure that my view and only this will handle the timers. My plans are to use one timer primarely but there are some rare cases that I may have two running similtaneously. However, if their ids are view unique ones I can use constants to guarantee uniquness and I am assuming that noone sends to my view a WM_TIMER message (according to what you said it sounds a reasonable assumption. Note that the thread will have more than one CScroll views of the same or different type).
According to my reading SetTimer indicates failure if it returns zero. Thus, I know that it is failed to create a timer. But it seems to me that this is due to system resources limits thus, nothing that I can do about it.
Well, was quite helpfull clarifying these points, hope now that they will work like these.
Dimitris...
|
|
|
|
|
Hello,
do you have:
ON_WM_TIMER()
in your Messagemap included??
than you have to call the function like this:
<br />
int SomeOtherFunc()<br />
{<br />
nIDEvent = SetTimer(iTimerIdentifier, iIntervalMiliSecond,0);
nIDEvent = SetTimer(2, 1000,0);<br />
}<br />
afx_msg void MyAppDlg::OnTimer(UINT nIDEvent)<br />
{<br />
switch(nIDEvent)<br />
{<br />
case 1:<br />
{<br />
...<br />
break;<br />
}<br />
case 2:<br />
{<br />
<br />
...<br />
break;<br />
}<br />
default:<br />
break;<br />
}<br />
}<br />
<br />
....<br />
give peace of code to see what you coding to set and start timer!
break;
-- modified at 11:13 Wednesday 19th July, 2006
|
|
|
|
|
hi all,
when i switch from one CFormView to Another CFormView, I am observing that my menu items for the second form are Disabled. I cant Understand why this is Happen when i switch from one view to another.
//---------Code -----------------------------------//
void CMainFrame::SwitchView()
{
CView *pOldView;
CView *pNewView;
pOldView = GetActiveView();
if (m_pCFirstView == NULL)
m_pCFirstView = pOldView;
if (m_pCSecondView == NULL)
{
CRuntimeClass *pCR = RUNTIME_CLASS(CSecondView);
m_pCSecondView = static_cast<cview*>(pCR->CreateObject());
m_pCSecondView->Create(NULL,NULL,AFX_WS_DEFAULT_VIEW,rectDefault,this,AFX_IDW_PANE_FIRST+1,NULL);
}
if (m_bFirstViewActive)
pNewView = m_pCSecondView;
else
pNewView = m_pCFirstView;
int nChildId = pNewView->GetDlgCtrlID();
pNewView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
pOldView->SetDlgCtrlID(nChildId);
CDocument *pDoc = pOldView->GetDocument();
pDoc->AddView(pNewView);
pDoc->RemoveView(pOldView);
SetActiveView(pNewView);
RecalcLayout();
pNewView->ShowWindow(SW_SHOW);
pOldView->ShowWindow(SW_HIDE);
m_bFirstViewActive = !m_bFirstViewActive;
}
//-----------------------------//------------------------------------//
Every thing is Ok but the Menu Items are Enabled when i transform from View to Another View. Please Provide me good Solution.
is there any Custom Command Routing for this.
please help me out.
uday.
-- modified at 7:36 Wednesday 19th July, 2006
|
|
|
|
|
Do you have UI updating defined only in one view, then?
Normally the view will get a crack at updating menu item states. If there's no handler, and no update handler, a menu item will get disabled.
Steve S
Developer for hire
|
|
|
|
|
hi steve,
Should i take Command Handlers in View or CFrameWnd, Shall i take in What order to this Problem.
Please help me out.
uday.
|
|
|
|
|
You can handle commands (and hence UI updating) in any of:
Frame - if you've derived your own frame window
Document - even though it isn't a window!
View - the active one
There is a series of articles in MSJ (now MSDN magazine) which you should still be able to find at the MSDN website, that explain how the routing works in some depth. Essentially, it's up to you as the app designer to determine where the appropriate/correct place for handlers is. For example, handling File/Print would generally be in the document class (since it applies irrespective of the view), whereas edit menu items tend to be managed by the view. If you have multiple views (either SDI switching or MDI) then it is perfectly possible that you have handlers in each view. However, only one of these handlers/UI updates will be called, and it will be the one in the object associated with the active view.
Steve S
Developer for hire
|
|
|
|
|
plz tell me answer for this
i want to know is this code work when i click tab1 on tab control
i try this but not do the work.
void CGouravDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CBrush brush;
CDC *pDC;
if(BN_CLICKED(IDC_TAB1))
{
brush.CreateSolidBrush(RGB(100,0,0));
pDC->SetBkColor(RGB(100,0,0));
// m_tab.SendMessage(WM_PAINT,0L,0L);
}
*pResult = 0;
}
Ashish Dogra
MCA
Noida
-- modified at 7:24 Wednesday 19th July, 2006
|
|
|
|
|
I dont know why you ask this question repeated I reply to you in previous thread and you can find your answer in this article(you can derived tabctrl and use from <ocde>WM_PAINT)
whitesky
|
|
|
|
|
Hi all,
I need to convert text from an edit control to double in an MFC application.
I also need to convert a double into a CString to display it in an edit box.
How can i do that ?
Thanx in advance,
Desmo16.
|
|
|
|
|
You can use
For Double to CString
CString Format function
CString to Double
double atof(const char *string );
See msdn once before posting a question
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
Its meCString to Double
double atof(const char *string )
If you want error handling use strtod and check return value, errno and end-pointer.
|
|
|
|
|
1.CString to double
use atof()
2. Double to CString.
use CString::Format() funtion.
nave
|
|
|
|
|
|
See
<code>
char *Char;
double Double;
Char = " -1234.56";
Double = atof( Char );
CString str;
str.Format("%lf",Double);
whitesky
|
|
|
|
|
If i've got a char vector ( example: char name[30]),
and i want to convert it into a CString,
is there a way to do that ?
|
|
|
|
|
char name[30] = "hello you";
CString str = name;
char name2[30];
strncpy(name2, str, sizeof(name2));
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-- modified at 11:12 Wednesday 19th July, 2006
|
|
|
|
|
toxcct wrote:
char name[30] = "hello you";
CString str = name;
char name2 = str;
char name[30] = "hello you";
CString str = name;
char name2 = str;
char name2 = str[0]; is fine, or char* name2 = str.GetBuffer() , but not the other.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|